use of org.mycore.common.events.MCREvent in project mycore by MyCoRe-Org.
the class MCRPersistentIdentifierEventHandler method handleObjectRepaired.
@Override
protected void handleObjectRepaired(MCREvent evt, MCRObject obj) {
/* Add PIs to DB if they are not there */
MCRPersistentIdentifierManager.getInstance().getRegistered(obj).forEach(pi -> MCRPersistentIdentifierManager.getInstance().delete(pi.getMycoreID(), pi.getAdditional(), pi.getType(), pi.getService()));
Gson gson = new Gson();
obj.getService().getFlags(MCRPIRegistrationService.PI_FLAG).stream().map(piFlag -> gson.fromJson(piFlag, MCRPI.class)).filter(entry -> !MCRPersistentIdentifierManager.getInstance().exist(entry)).forEach(entry -> {
// TODO: disabled for MCR-1393
// entry.setMcrRevision(MCRCoreVersion.getRevision());
entry.setMcrVersion(MCRCoreVersion.getVersion());
entry.setMycoreID(obj.getId().toString());
LOGGER.info("Add PI : {} with service {} to database!", entry.getIdentifier(), entry.getService());
MCRHIBConnection.instance().getSession().save(entry);
});
handleObjectUpdated(evt, obj);
}
use of org.mycore.common.events.MCREvent in project mycore by MyCoRe-Org.
the class MCRFile method delete.
/**
* Deletes this file and its content stored in the system. Note that after
* calling this method, the file object is deleted and invalid and can not
* be used any more.
*/
@Override
public void delete() throws MCRPersistenceException {
ensureNotDeleted();
if (storageID.length() != 0) {
BasicFileAttributes attrs;
try {
attrs = getBasicFileAttributes();
} catch (IOException e) {
attrs = MCRFileAttributes.file(getID(), getSize(), getMD5(), FileTime.from(getLastModified().toInstant()));
}
getContentStore().deleteContent(storageID);
// Call event handlers to update indexed content
MCREvent event = new MCREvent(MCREvent.PATH_TYPE, MCREvent.DELETE_EVENT);
// to support old events
event.put(MCRFileEventHandlerBase.FILE_TYPE, this);
event.put(MCREvent.PATH_KEY, toPath());
event.put(MCREvent.FILEATTR_KEY, attrs);
MCREventManager.instance().handleEvent(event);
if (hasParent()) {
getParent().sizeOfChildChanged(-size);
}
}
super.delete();
contentTypeID = null;
md5 = null;
storageID = null;
storeID = null;
avExtender = null;
}
use of org.mycore.common.events.MCREvent in project mycore by MyCoRe-Org.
the class MCRFilesystemNode method fireUpdateEvent.
protected void fireUpdateEvent() {
MCREvent event = new MCREvent(MCREvent.PATH_TYPE, MCREvent.UPDATE_EVENT);
// to support old events
event.put(MCRFileEventHandlerBase.FILE_TYPE, this);
event.put(MCREvent.PATH_KEY, toPath());
try {
event.put(MCREvent.FILEATTR_KEY, getBasicFileAttributes());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
MCREventManager.instance().handleEvent(event);
}
use of org.mycore.common.events.MCREvent in project mycore by MyCoRe-Org.
the class MCRMODSLinksEventHandler method handleObjectUpdated.
/* (non-Javadoc)
* @see org.mycore.common.events.MCREventHandlerBase#handleObjectUpdated(org.mycore.common.events.MCREvent, org.mycore.datamodel.metadata.MCRObject)
*/
@Override
protected void handleObjectUpdated(final MCREvent evt, final MCRObject obj) {
if (!MCRMODSWrapper.isSupported(obj)) {
return;
}
handleObjectCreated(evt, obj);
// may have to reindex children, if they inherit any information
for (MCRMetaLinkID childLinkID : obj.getStructure().getChildren()) {
MCRObjectID childID = childLinkID.getXLinkHrefID();
if (MCRMetadataManager.exists(childID)) {
MCREvent childEvent = new MCREvent(childID.getTypeId(), MCREvent.INDEX_EVENT);
childEvent.put("object", MCRMetadataManager.retrieve(childID));
MCREventManager.instance().handleEvent(childEvent);
}
}
}
Aggregations