use of org.mycore.datamodel.niofs.ifs1.MCRIFSFileSystem in project mycore by MyCoRe-Org.
the class MCRFileEventHandlerBase method toMCRFileEvent.
private MCREvent toMCRFileEvent(MCREvent source, Path path, BasicFileAttributes attrs) {
if (!(path.getFileSystem() instanceof MCRIFSFileSystem)) {
LOGGER.error("Cannot transform path from {} to MCRFile.", path.getFileSystem());
return null;
}
if (attrs != null && !attrs.isDirectory()) {
MCREvent target = new MCREvent(FILE_TYPE, source.getEventType());
// includes probably "file";
target.putAll(source);
if (!target.contains(FILE_TYPE)) {
if (target.getEventType().equals(MCREvent.DELETE_EVENT)) {
LOGGER.warn("Could not restore MCRFile for Path event: {}", path);
return null;
} else {
// fileKey is always internal id;
MCRFile file = MCRFile.getFile(attrs.fileKey().toString());
if (file == null) {
LOGGER.warn("Could not restore MCRFile with id {} for Path event: {}", attrs.fileKey(), path);
return null;
}
target.put(MCRFILE_EVENT_KEY, file);
}
}
LOGGER.info("Transformed {} -> {}", source, target);
return target;
}
return null;
}
Aggregations