use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRDerivateServlet method setMainFile.
/**
* The method set the main file of a derivate object that is stored in the
* server. The method use the input parameter: <b>type</b>,<b>step</b>
* <b>se_mcrid</b> and <b>re_mcrid</b>. Access rights must be 'writedb'.
*/
private void setMainFile(String derivateId, String file, HttpServletResponse response) throws IOException {
if (MCRAccessManager.checkPermission(derivateId, PERMISSION_WRITE)) {
MCRObjectID mcrid = MCRObjectID.getInstance(derivateId);
MCRDerivate der = MCRMetadataManager.retrieveMCRDerivate(mcrid);
der.getDerivate().getInternals().setMainDoc(file);
MCRMetadataManager.updateMCRDerivateXML(der);
} else {
response.sendError(HttpServletResponse.SC_FORBIDDEN, MessageFormat.format("User has not the \"" + PERMISSION_WRITE + "\" permission on object {0}.", derivateId));
}
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRMETSHierarchyGenerator method setup.
/**
* Initializes the derivate and the root object.
*
* @param derivateId the derivate id to setup
*/
protected void setup(String derivateId) {
// get derivate
MCRObjectID derId = MCRObjectID.getInstance(derivateId);
this.mcrDer = MCRMetadataManager.retrieveMCRDerivate(derId);
// get mycore object
MCRObjectID objId = this.mcrDer.getDerivate().getMetaLink().getXLinkHrefID();
this.rootObj = MCRMetadataManager.retrieveMCRObject(objId);
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRMETSHierarchyGenerator method newLogicalStructMap.
protected LogicalStructMap newLogicalStructMap() {
LogicalStructMap lstr = new LogicalStructMap();
MCRObjectID objId = this.rootObj.getId();
// create main div
String amdId = this.amdSection.getId();
String dmdId = this.dmdSection.getId();
LogicalDiv logicalDiv = new LogicalDiv(objId.toString(), getType(this.rootObj), getLabel(this.rootObj), amdId, dmdId);
lstr.setDivContainer(logicalDiv);
// run through all children
newLogicalStructMap(this.rootObj, logicalDiv);
// remove not linked logical divs
logicalDiv.getChildren().removeIf(child -> !validateLogicalStruct(child));
return lstr;
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRMetsResolver method resolve.
@Override
public Source resolve(String href, String base) throws TransformerException {
String id = href.substring(href.indexOf(":") + 1);
LOGGER.debug("Reading METS for ID {}", id);
MCRObjectID objId = MCRObjectID.getInstance(id);
if (!objId.getTypeId().equals("derivate")) {
String derivateID = getDerivateFromObject(id);
if (derivateID == null) {
return new JDOMSource(new Element("mets", Namespace.getNamespace("mets", "http://www.loc.gov/METS/")));
}
id = derivateID;
}
MCRPath metsPath = MCRPath.getPath(id, "/mets.xml");
try {
if (Files.exists(metsPath)) {
// ignoreNodes.add(metsFile);
return new MCRPathContent(metsPath).getSource();
}
Document mets = MCRMETSGeneratorFactory.create(MCRPath.getPath(id, "/")).generate().asDocument();
return new JDOMSource(mets);
} catch (Exception e) {
throw new TransformerException(e);
}
}
use of org.mycore.datamodel.metadata.MCRObjectID in project mycore by MyCoRe-Org.
the class MCRMetsSave method updateMetsOnFileAdd.
/**
* Updates the mets.xml belonging to the given derivate. Adds the file to
* the mets document (updates file sections and stuff within the mets.xml)
*
* @param file
* a handle for the file to add to the mets.xml
*/
public static void updateMetsOnFileAdd(MCRPath file) throws Exception {
MCRObjectID derivateID = MCRObjectID.getInstance(file.getOwner());
Document mets = getCurrentMets(derivateID.toString());
if (mets == null) {
LOGGER.info("Derivate with id \"{}\" has no mets file. Nothing to do", derivateID);
return;
}
mets = MCRMetsSave.updateOnFileAdd(mets, file);
if (mets != null) {
MCRMetsSave.saveMets(mets, derivateID);
}
}
Aggregations