use of org.mycore.datamodel.common.MCRMarkManager in project mycore by MyCoRe-Org.
the class MCRTransferPackageCommands method _cleanUp.
@MCRCommand(syntax = "_import transfer package clean up {0}")
public static void _cleanUp(String targetDirectoryPath) throws Exception {
Path targetDirectory = Paths.get(targetDirectoryPath);
// delete mark of imported object
List<String> mcrObjects = MCRTransferPackageUtil.getMCRObjects(targetDirectory);
MCRMarkManager markManager = MCRMarkManager.instance();
for (String id : mcrObjects) {
markManager.remove(MCRObjectID.getInstance(id));
}
// index all objects
MCRSolrIndexer.rebuildMetadataIndex(mcrObjects);
// deleting expanded directory
LOGGER.info("Deleting expanded tar in {}...", targetDirectoryPath);
Files.walkFileTree(Paths.get(targetDirectoryPath), MCRRecursiveDeleter.instance());
}
use of org.mycore.datamodel.common.MCRMarkManager in project mycore by MyCoRe-Org.
the class MCRTransferPackageCommands method _fromDirectory.
@MCRCommand(syntax = "_import transfer package from directory {0}")
public static List<String> _fromDirectory(String targetDirectoryPath) throws Exception {
LOGGER.info("Import transfer package from {}...", targetDirectoryPath);
Path targetDirectory = Paths.get(targetDirectoryPath);
List<String> commands = new ArrayList<>();
// load classifications
List<Path> classificationPaths = MCRTransferPackageUtil.getClassifications(targetDirectory);
for (Path pathToClassification : classificationPaths) {
commands.add("_import transfer package classification from " + pathToClassification.toAbsolutePath());
}
// import objects
List<String> mcrObjects = MCRTransferPackageUtil.getMCRObjects(targetDirectory);
MCRMarkManager markManager = MCRMarkManager.instance();
for (String id : mcrObjects) {
markManager.mark(MCRObjectID.getInstance(id), Operation.IMPORT);
commands.add("_import transfer package object " + id + " from " + targetDirectoryPath);
}
return commands;
}
Aggregations