use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRMetadataHistoryManager method getHighestStoredID.
public static Optional<MCRObjectID> getHighestStoredID(String project, String type) {
String looksLike = Objects.requireNonNull(project) + "\\_" + Objects.requireNonNull(type) + "%";
EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
TypedQuery<MCRObjectID> query = em.createNamedQuery("MCRMetaHistory.getHighestID", MCRObjectID.class);
query.setParameter("looksLike", looksLike);
return Optional.ofNullable(query.getSingleResult());
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRBasketPersistence method updateBasket.
/**
* Updates the basket's data in the persistent store by saving its XML representation
* to a file in a derivate. The ID of the derivate is given in the basket's properties.
*/
public static void updateBasket(MCRBasket basket) throws Exception {
String derivateID = basket.getDerivateID();
MCRObjectID derivateOID = MCRObjectID.getInstance(derivateID);
MCRDerivate derivate = MCRMetadataManager.retrieveMCRDerivate(derivateOID);
MCRPath file = getBasketFile(derivateID);
writeBasketToFile(basket, derivate, file);
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRBasketPersistence method createDerivateWithBasket.
/**
* Creates a new derivate including a file basket.xml which stores the persistent
* data of the given basket.
*
* @param basket the basket to store in a new file in a new derivate
* @param ownerID the ID of the MCRObject owning the new derivate
* @throws MCRAccessException see {@link MCRMetadataManager#create(MCRDerivate)}
* @throws MCRPersistenceException
*/
public static void createDerivateWithBasket(MCRBasket basket, MCRObjectID ownerID) throws IOException, MCRPersistenceException, MCRAccessException {
String base = ownerID.getProjectId() + "_derivate";
MCRObjectID derivateOID = MCRObjectID.getNextFreeId(base);
String derivateID = derivateOID.toString();
MCRDerivate derivate = createNewDerivate(ownerID, derivateOID);
basket.setDerivateID(derivateID);
writeBasketToFile(basket, derivate, getBasketFile(derivateID));
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRDefaultMetadataShareAgent method receiveMetadata.
/* (non-Javadoc)
* @see org.mycore.datamodel.metadata.share.MCRMetadataShareAgent#inheritMetadata(org.mycore.datamodel.metadata.MCRObject, org.mycore.datamodel.metadata.MCRObject)
*/
@Override
public void receiveMetadata(MCRObject child) {
MCRObjectID parentID = child.getStructure().getParentID();
if (parentID == null) {
return;
}
LOGGER.debug("Parent ID = {}", parentID);
MCRObject parent = MCRMetadataManager.retrieveMCRObject(parentID);
// remove already embedded inherited tags
child.getMetadata().removeInheritedMetadata();
// insert heritable tags
child.getMetadata().appendMetadata(parent.getMetadata().getHeritableMetadata());
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRViewerResource method getContent.
protected MCRContent getContent(final HttpServletRequest req) throws Exception {
// get derivate id from request object
String derivate = MCRViewerConfiguration.getDerivate(req);
if (derivate == null) {
MCRJerseyUtil.throwException(Status.BAD_REQUEST, "Could not locate derivate identifer in path.");
}
// get mycore object id
final MCRObjectID derivateID = MCRObjectID.getInstance(derivate);
if (!MCRMetadataManager.exists(derivateID)) {
String errorMessage = MCRTranslation.translate("component.viewer.MCRIViewClientServlet.object.not.found", derivateID);
MCRJerseyUtil.throwException(Status.NOT_FOUND, errorMessage);
}
// check permission
if (IVIEW_ACL_PROVDER != null && !IVIEW_ACL_PROVDER.checkAccess(req.getSession(), derivateID)) {
String errorMessage = MCRTranslation.translate("component.viewer.MCRIViewClientServlet.noRights", derivateID);
MCRJerseyUtil.throwException(Status.UNAUTHORIZED, errorMessage);
}
// build configuration object
MCRViewerConfigurationStrategy configurationStrategy = MCRConfiguration.instance().getInstanceOf("MCR.Viewer.configuration.strategy", new MCRViewerDefaultConfigurationStrategy());
MCRJDOMContent source = new MCRJDOMContent(buildResponseDocument(configurationStrategy.get(req)));
MCRParameterCollector parameter = new MCRParameterCollector(req);
MCRContentTransformer transformer = getContentTransformer(source.getDocType(), parameter);
return transformer.transform(source);
}
Aggregations