use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRIFSCommands method checkDerivatesWithProjectIDInMCRFSNODES.
@MCRCommand(syntax = "check mcrfsnodes of derivates with project id {0}", help = "check the entries of MCRFSNODES with project ID {0} that the derivate exists")
public static void checkDerivatesWithProjectIDInMCRFSNODES(String project_id) {
LOGGER.info("Start check of MCRFSNODES for derivates with project ID {}", project_id);
if (project_id == null || project_id.length() == 0) {
LOGGER.error("Project ID missed for check MCRFSNODES entries of derivates with project ID {0}");
return;
}
MCRXMLMetadataManager mgr = MCRXMLMetadataManager.instance();
EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> query = cb.createQuery(String.class);
Root<MCRFSNODES> nodes = query.from(MCRFSNODES.class);
AtomicInteger counter = new AtomicInteger();
em.createQuery(query.distinct(true).select(nodes.get(MCRFSNODES_.owner)).where(cb.like(nodes.get(MCRFSNODES_.owner), project_id + "\\_%"))).getResultList().stream().peek(ignore -> counter.incrementAndGet()).map(MCRObjectID::getInstance).filter(derID -> {
try {
return !mgr.exists(derID);
} catch (IOException e) {
LOGGER.error("Error while checking existence of {}", derID, e);
return true;
}
}).forEach(missingDerivate -> LOGGER.error(" !!!! Can't find MCRFSNODES entry {} as existing derivate", missingDerivate));
LOGGER.info("Check done for {} entries", counter.get());
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRIFSCommands method writeMissingFileReport.
@MCRCommand(syntax = "generate missing file report in directory {0}", help = "generates XML a report over all content stores about missing files and write it in directory {0}")
public static void writeMissingFileReport(String targetDirectory) throws IOException, SAXException, TransformerConfigurationException {
File targetDir = getDirectory(targetDirectory);
FSNodeChecker checker = new LocalFileExistChecker();
writeReport(targetDir, checker);
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRIFSCommands method fixDirectorysOfDerivate.
@MCRCommand(syntax = "repair directory sizes of derivate {0}", help = "Fixes the directory sizes of a derivate.")
public static void fixDirectorysOfDerivate(String id) {
MCRDirectory mcrDirectory = (MCRDirectory) MCRFilesystemNode.getRootNode(id);
if (mcrDirectory == null) {
throw new IllegalArgumentException(MessageFormat.format("Could not get root node for {0}", id));
}
fixDirectorySize(mcrDirectory);
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRTransferPackageCommands method _untar.
@MCRCommand(syntax = "_import transfer package untar {0}")
public static void _untar(String pathToTar) throws Exception {
Path tar = Paths.get(pathToTar);
Path targetDirectory = MCRTransferPackageUtil.getTargetDirectory(tar);
LOGGER.info("Untar {} to {}...", pathToTar, targetDirectory);
MCRUtils.untar(tar, targetDirectory);
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRTransferPackageCommands method _importDerivate.
@MCRCommand(syntax = "_import transfer package derivate {0} from {1}")
public static void _importDerivate(String derivateId, String targetDirectoryPath) throws Exception {
Path targetDirectory = Paths.get(targetDirectoryPath);
MCRTransferPackageUtil.importDerivate(targetDirectory, derivateId);
}
Aggregations