use of org.mycore.datamodel.ifs2.MCRMetadataStore in project mycore by MyCoRe-Org.
the class MCRXMLMetadataManager method getStore.
/**
* Returns IFS2 MCRMetadataStore for the given project and object type
*
* @param project the project, e.g. DocPortal
* @param type the object type, e.g. document
*/
public MCRMetadataStore getStore(String project, String type) {
String projectType = getStoryKey(project, type);
String prefix = "MCR.IFS2.Store." + projectType + ".";
String forceXML = MCRConfiguration.instance().getString(prefix + "ForceXML", null);
if (forceXML == null) {
synchronized (this) {
forceXML = MCRConfiguration.instance().getString(prefix + "ForceXML", null);
if (forceXML == null) {
try {
setupStore(project, type, prefix);
} catch (ReflectiveOperationException e) {
throw new MCRPersistenceException(MessageFormat.format("Could not instantiate store for project {0} and object type {1}.", project, type), e);
}
}
}
}
MCRMetadataStore store = MCRStoreManager.getStore(projectType, MCRMetadataStore.class);
if (store == null) {
throw new MCRPersistenceException(MessageFormat.format("Metadata store for project {0} and object type {1} is unconfigured.", project, type));
}
return store;
}
use of org.mycore.datamodel.ifs2.MCRMetadataStore in project mycore by MyCoRe-Org.
the class MCRXMLMetadataManager method getLastModified.
/**
* Returns the time when the xml data of a MCRObject was last modified.
* @return output of {@link MCRStoredMetadata#getLastModified()}
* @throws IOException thrown by {@link MCRMetadataStore#retrieve(int)}
*/
public long getLastModified(MCRObjectID id) throws IOException {
MCRMetadataStore store = getStore(id);
MCRStoredMetadata metadata = store.retrieve(id.getNumberAsInteger());
if (metadata != null) {
return metadata.getLastModified().getTime();
}
return -1;
}
use of org.mycore.datamodel.ifs2.MCRMetadataStore in project mycore by MyCoRe-Org.
the class MCRMetadataHistoryCommands method buildDerivateHistory.
private static Stream<MCRMetaHistoryItem> buildDerivateHistory(MCRObjectID derId) {
try {
List<MCRMetadataVersion> versions = Collections.emptyList();
MCRMetadataStore store = MCRXMLMetadataManager.instance().getStore(derId);
if (store instanceof MCRVersioningMetadataStore) {
MCRVersionedMetadata versionedMetadata = ((MCRVersioningMetadataStore) store).retrieve(derId.getNumberAsInteger());
versions = versionedMetadata.listVersions();
}
if (versions.isEmpty()) {
return buildSimpleDerivateHistory(derId);
} else {
return buildDerivateHistory(derId, versions);
}
} catch (IOException e) {
LogManager.getLogger().error("Error while getting history of {}", derId);
return Stream.empty();
}
}
use of org.mycore.datamodel.ifs2.MCRMetadataStore in project mycore by MyCoRe-Org.
the class MCRMODSLinkedMetadataTest method tearDown.
@After
public void tearDown() throws Exception {
MCRMetadataManager.deleteMCRObject(bookID);
MCRMetadataManager.deleteMCRObject(seriesID);
MCRMetadataStore metadataStore = MCRXMLMetadataManager.instance().getStore(seriesID);
MCRStoreManager.removeStore(metadataStore.getID());
super.tearDown();
}
use of org.mycore.datamodel.ifs2.MCRMetadataStore in project mycore by MyCoRe-Org.
the class MCRObjectServlet method requestVersionedObject.
private MCRContent requestVersionedObject(final MCRObjectID mcrid, final HttpServletResponse resp, final long rev) throws IOException {
MCRXMLMetadataManager xmlMetadataManager = MCRXMLMetadataManager.instance();
MCRMetadataStore metadataStore = xmlMetadataManager.getStore(mcrid);
if (metadataStore instanceof MCRVersioningMetadataStore) {
MCRContent content = xmlMetadataManager.retrieveContent(mcrid, rev);
if (content != null) {
return content;
}
resp.sendError(HttpServletResponse.SC_NOT_FOUND, getErrorI18N(I18N_ERROR_PREFIX, "revisionNotFound", rev, mcrid));
return null;
}
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, getErrorI18N(I18N_ERROR_PREFIX, "noVersions", mcrid));
return null;
}
Aggregations