use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRIView2Commands method deleteDerivateTiles.
/**
* Deletes all image tiles of this derivate.
* @param derivateID a derivate ID
*/
@MCRCommand(syntax = DEL_DERIVATE_TILES_COMMAND_SYNTAX, help = "removes tiles of a specific file identified by its derivate ID {0}", order = 100)
public static void deleteDerivateTiles(String derivateID) throws IOException {
Path derivateDir = MCRImage.getTiledFile(MCRIView2Tools.getTileDir(), derivateID, null);
Files.walkFileTree(derivateDir, MCRRecursiveDeleter.instance());
MCRTilingQueue.getInstance().remove(derivateID);
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRIView2Commands method tileImage.
/**
* Tiles this image.
* @param derivate derivate ID
* @param absoluteImagePath absolute path to image file
*/
@MCRCommand(syntax = TILE_IMAGE_COMMAND_SYNTAX, help = "tiles a specific file identified by its derivate {0} and absolute path {1}", order = 70)
public static void tileImage(String derivate, String absoluteImagePath) {
MCRTileJob job = new MCRTileJob();
job.setDerivate(derivate);
job.setPath(absoluteImagePath);
MCRTilingQueue.getInstance().offer(job);
startMasterTilingThread();
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRIView2Commands method fixDeadEntries.
@MCRCommand(syntax = "fix dead tile jobs", help = "Deletes entries for files which dont exist anymore!")
public static void fixDeadEntries() {
EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
TypedQuery<MCRTileJob> allTileJobQuery = em.createNamedQuery("MCRTileJob.all", MCRTileJob.class);
List<MCRTileJob> tiles = allTileJobQuery.getResultList();
tiles.stream().filter(tj -> {
MCRPath path = MCRPath.getPath(tj.getDerivate(), tj.getPath());
return !Files.exists(path);
}).peek(tj -> LOGGER.info("Delete TileJob {}:{}", tj.getDerivate(), tj.getPath())).forEach(em::remove);
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRMetsCommands method validateSelectedMets.
@MCRCommand(syntax = "validate selected mets", help = "validates all mets.xml of selected derivates", order = 10)
public static void validateSelectedMets() {
List<String> selectedObjectIDs = MCRObjectCommands.getSelectedObjectIDs();
for (String objectID : selectedObjectIDs) {
LOGGER.info("Validate mets.xml of {}", objectID);
MCRPath metsFile = MCRPath.getPath(objectID, "/mets.xml");
if (Files.exists(metsFile)) {
try {
MCRContent content = new MCRPathContent(metsFile);
InputStream metsIS = content.getInputStream();
METSValidator mv = new METSValidator(metsIS);
List<ValidationException> validationExceptionList = mv.validate();
if (validationExceptionList.size() > 0) {
invalidMetsQueue.add(objectID);
}
for (ValidationException validationException : validationExceptionList) {
LOGGER.error(validationException.getMessage());
}
} catch (IOException e) {
LOGGER.error("Error while reading mets.xml of {}", objectID, e);
} catch (JDOMException e) {
LOGGER.error("Error while parsing mets.xml of {}", objectID, e);
}
}
}
}
use of org.mycore.frontend.cli.annotation.MCRCommand in project mycore by MyCoRe-Org.
the class MCRMetsCommands method addMetsFileForProjectID.
@MCRCommand(syntax = "add mets files for project id {0}", order = 30)
public static void addMetsFileForProjectID(String projectID) {
MCRXMLMetadataManager manager = MCRXMLMetadataManager.instance();
List<String> dervate_list = manager.listIDsForBase(projectID + "_derivate");
for (String derivateID : dervate_list) {
addMetsFileForDerivate(derivateID);
}
}
Aggregations