use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.
the class MCRFileNodeServlet method sendDirectory.
/**
* Sends the contents of an MCRDirectory as XML data to the client
* @throws SAXException
* @throws TransformerException
*/
private MCRContent sendDirectory(HttpServletRequest request, HttpServletResponse response, MCRPath mcrPath) throws IOException, TransformerException, SAXException {
Document directoryXML = MCRPathXML.getDirectoryXML(mcrPath);
MCRJDOMContent source = new MCRJDOMContent(directoryXML);
source.setLastModified(Files.getLastModifiedTime(mcrPath).toMillis());
String fileName = mcrPath.getNameCount() == 0 ? mcrPath.getOwner() : mcrPath.getFileName().toString();
source.setName(fileName);
return getLayoutService().getTransformedContent(request, response, source);
}
use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.
the class MCRFileCollection method saveAdditionalData.
protected void saveAdditionalData() throws IOException {
FileObject target = VFS.getManager().resolveFile(fo, dataFile);
new MCRJDOMContent(data.getDocument()).sendTo(target);
}
use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.
the class MCRMetadataStoreTest method getNextFreeID.
@Test
public void getNextFreeID() throws Exception {
int id1 = getMetaDataStore().getNextFreeID();
assertTrue(id1 >= 0);
assertFalse(getMetaDataStore().exists(id1));
Document xml1 = new Document(new Element("root"));
int id2 = getMetaDataStore().create(new MCRJDOMContent(xml1)).getID();
assertTrue(id2 > id1);
assertTrue(getMetaDataStore().getNextFreeID() > id2);
}
use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.
the class MCRMetadataStoreTest method retrieve.
@Test
public void retrieve() throws Exception {
Document xml1 = new Document(new Element("root"));
int id = getMetaDataStore().create(new MCRJDOMContent(xml1)).getID();
MCRStoredMetadata sm1 = getMetaDataStore().retrieve(id);
MCRContent xml2 = sm1.getMetadata();
assertEquals(new MCRJDOMContent(xml1).asString(), xml2.asString());
}
use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.
the class MCRMetadataStoreTest method createDocumentInt.
@Test
public void createDocumentInt() throws Exception {
Document xml1 = new Document(new Element("root"));
try {
getMetaDataStore().create(new MCRJDOMContent(xml1), 0);
fail("metadata store allows to save with id \"0\".");
} catch (Exception e) {
// test passed
}
int id = getMetaDataStore().getNextFreeID();
assertTrue(id > 0);
MCRStoredMetadata sm1 = getMetaDataStore().create(new MCRJDOMContent(xml1), id);
assertNotNull(sm1);
MCRContent xml2 = getMetaDataStore().retrieve(id).getMetadata();
assertEquals(new MCRJDOMContent(xml1).asString(), xml2.asString());
getMetaDataStore().create(new MCRJDOMContent(xml1), id + 1);
MCRContent xml3 = getMetaDataStore().retrieve(id + 1).getMetadata();
assertEquals(new MCRJDOMContent(xml1).asString(), xml3.asString());
}
Aggregations