Package org.mycore.impex
Class MCRTransferPackageUtil
java.lang.Object
org.mycore.impex.MCRTransferPackageUtil
Contains utility methods for handling transfer packages.
- Author:
- Silvio Hermann, Matthias Eichner
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default lookup path appendix (the subdirectory in the tar where the metadata resides). -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetClassifications
(Path targetDirectory) Returns a list containing all paths to the classifications which should be imported.getMCRObjects
(Path targetDirectory) Gets the list of mycore object identifiers from the given directory.static Path
getTargetDirectory
(Path pathToTar) Returns the path where the *.tar will be unzipped.static void
importDerivate
(Path targetDirectory, String derivateId) Imports a derivate from the given target directory path.static void
importFromDirectory
(Path targetDirectory) Imports from an unpacked *.tar archive directory.static void
importObject
(Path targetDirectory, String objectId, String parentId) Imports a object from the targetDirectory path.importObjectCLI
(Path targetDirectory, String objectId, String parentId) Same asimportObject(Path, String, String)
but returns a list of derivates which should be imported afterwards.static void
Imports a *.tar transport package from the given path.
-
Field Details
-
CONTENT_DIRECTORY
The default lookup path appendix (the subdirectory in the tar where the metadata resides). With leading and trailingFile.separator
- See Also:
-
-
Constructor Details
-
MCRTransferPackageUtil
public MCRTransferPackageUtil()
-
-
Method Details
-
importTar
public static void importTar(Path pathToTar) throws IOException, MCRAccessException, JDOMException, SAXParseException, URISyntaxException Imports a *.tar transport package from the given path.- Parameters:
pathToTar
- path to the *.tar archive- Throws:
IOException
- some file system stuff went wrongMCRAccessException
- if write permission is missing or seeMCRMetadataManager.create(MCRObject)
JDOMException
- some jdom parsing went wrongURISyntaxException
- unable to transform the xmlSAXParseException
- xml parsing went wrong
-
getTargetDirectory
Returns the path where the *.tar will be unzipped.- Parameters:
pathToTar
- the path to the tar.- Returns:
- path to the directory
-
importFromDirectory
public static void importFromDirectory(Path targetDirectory) throws JDOMException, IOException, MCRAccessException, SAXParseException, URISyntaxException Imports from an unpacked *.tar archive directory.- Parameters:
targetDirectory
- the directory where the *.tar was unpacked- Throws:
JDOMException
- some jdom parsing went wrongIOException
- something went wrong while reading from the file systemMCRAccessException
- if write permission is missing or seeMCRMetadataManager.create(MCRObject)
URISyntaxException
- unable to transform the xmlSAXParseException
- xml parsing went wrong
-
getClassifications
Returns a list containing all paths to the classifications which should be imported.- Parameters:
targetDirectory
- the directory where the *.tar was unpacked- Returns:
- list of paths
- Throws:
IOException
- if an I/O error is thrown when accessing one of the files
-
importObject
public static void importObject(Path targetDirectory, String objectId, String parentId) throws JDOMException, IOException, MCRAccessException Imports a object from the targetDirectory path.- Parameters:
targetDirectory
- the directory where the *.tar was unpackedobjectId
- object id to importparentId
- The new parent. Should be null if the original parent remains the same.- Throws:
JDOMException
- coulnd't parse the import order xmlIOException
- when an I/O error prevents a document from being fully parsedMCRAccessException
- if write permission is missing or seeMCRMetadataManager.create(MCRObject)
-
importObjectCLI
public static List<String> importObjectCLI(Path targetDirectory, String objectId, String parentId) throws JDOMException, IOException, MCRAccessException Same asimportObject(Path, String, String)
but returns a list of derivates which should be imported afterwards.- Parameters:
targetDirectory
- the directory where the *.tar was unpackedobjectId
- object id to importparentId
- The new parent. Should be null if the original parent remains the same.- Throws:
JDOMException
- coulnd't parse the import order xmlIOException
- when an I/O error prevents a document from being fully parsedMCRAccessException
- if write permission is missing or seeMCRMetadataManager.create(MCRObject)
-
importDerivate
public static void importDerivate(Path targetDirectory, String derivateId) throws JDOMException, IOException, MCRAccessException Imports a derivate from the given target directory path.- Parameters:
targetDirectory
- path to the extracted *.tar archivederivateId
- the derivate to import- Throws:
JDOMException
- derivate xml couldn't be readIOException
- some file system stuff went wrongMCRAccessException
- you do not have the permissions to do the import
-
getMCRObjects
Gets the list of mycore object identifiers from the given directory.- Parameters:
targetDirectory
- directory where the *.tar was unpacked- Returns:
- list of object which lies within the directory
- Throws:
JDOMException
IOException
-