Search in sources :

Example 1 with MCRMarkManager

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());
}
Also used : Path(java.nio.file.Path) MCRMarkManager(org.mycore.datamodel.common.MCRMarkManager) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Example 2 with MCRMarkManager

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;
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) MCRMarkManager(org.mycore.datamodel.common.MCRMarkManager) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Aggregations

Path (java.nio.file.Path)2 MCRMarkManager (org.mycore.datamodel.common.MCRMarkManager)2 MCRCommand (org.mycore.frontend.cli.annotation.MCRCommand)2 ArrayList (java.util.ArrayList)1