use of org.mycore.datamodel.ifs2.MCRStoredMetadata in project mycore by MyCoRe-Org.
the class MCRXMLMetadataManager method retrieveObjectDates.
/**
* returns an enhanced list of object ids and their last modified date
* @param ids MCRObject ids
* @throws IOException thrown by {@link MCRObjectIDFileSystemDate}
*/
public List<MCRObjectIDDate> retrieveObjectDates(List<String> ids) throws IOException {
List<MCRObjectIDDate> objidlist = new ArrayList<>(ids.size());
for (String id : ids) {
MCRStoredMetadata sm = this.retrieveStoredMetadata(MCRObjectID.getInstance(id));
objidlist.add(new MCRObjectIDFileSystemDate(sm, id));
}
return objidlist;
}
use of org.mycore.datamodel.ifs2.MCRStoredMetadata in project mycore by MyCoRe-Org.
the class MCRXMLMetadataManager method retrieveContent.
public MCRContent retrieveContent(MCRObjectID mcrid) throws IOException {
MCRContent metadata;
MCRStoredMetadata storedMetadata = retrieveStoredMetadata(mcrid);
if (storedMetadata == null || storedMetadata.isDeleted()) {
return null;
}
metadata = storedMetadata.getMetadata();
return metadata;
}
use of org.mycore.datamodel.ifs2.MCRStoredMetadata in project mycore by MyCoRe-Org.
the class MCRXMLMetadataManager method update.
/**
* Updates metadata of existing MCRObject in the persistent store.
*
* @param mcrid the MCRObjectID
* @param xml the xml metadata of the MCRObject
* @param lastModified the date of last modification to set
* @return the stored metadata as IFS2 object
*/
public MCRStoredMetadata update(MCRObjectID mcrid, MCRContent xml, Date lastModified) throws IOException {
if (!exists(mcrid)) {
String msg = "Object to update does not exist: " + mcrid;
throw new MCRPersistenceException(msg);
}
MCRStoredMetadata sm = getStore(mcrid).retrieve(mcrid.getNumberAsInteger());
try {
sm.update(xml);
} catch (JDOMException e) {
throw new MCRPersistenceException("Error while updating object: " + mcrid, e);
}
sm.setLastModified(lastModified);
MCRConfiguration.instance().systemModified();
return sm;
}
use of org.mycore.datamodel.ifs2.MCRStoredMetadata 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.MCRStoredMetadata in project mycore by MyCoRe-Org.
the class MCRXMLMetadataManagerTest method delete.
@Test
public void delete() throws IOException {
MCRStoredMetadata metadata = getStore().create(MyCoRe_document_00000001.id, MyCoRe_document_00000001.blob, MyCoRe_document_00000001.lastModified);
assertFalse(MyCoRe_document_00000001.id + " should not have been deleted", metadata.isDeleted());
assertTrue(MyCoRe_document_00000001.id + " should exist", getStore().exists(MyCoRe_document_00000001.id));
try {
getStore().delete(MCR_document_00000001.id);
} catch (IOException e) {
// is expected as MCR_document_00000001 does not exist
}
assertTrue(MyCoRe_document_00000001.id + " should not have been deleted", getStore().exists(MyCoRe_document_00000001.id));
}
Aggregations