Search in sources :

Example 31 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRFileTest method contentXML.

@Test
public void contentXML() throws Exception {
    MCRFile file = col.createFile("foo.xml");
    Document xml = new Document(new Element("root"));
    file.setContent(new MCRJDOMContent(xml));
    assertFalse(MCRFile.MD5_OF_EMPTY_FILE.equals(file.getMD5()));
    Document xml2 = file.getContent().asXML();
    assertEquals("root", xml2.getRootElement().getName());
}
Also used : Element(org.jdom2.Element) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) Document(org.jdom2.Document) Test(org.junit.Test)

Example 32 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRMetadataStoreTest method delete.

@Test
public void delete() throws Exception {
    Document xml1 = new Document(new Element("root"));
    int id = getMetaDataStore().create(new MCRJDOMContent(xml1)).getID();
    assertTrue(getMetaDataStore().exists(id));
    getMetaDataStore().delete(id);
    assertFalse(getMetaDataStore().exists(id));
    assertNull(getMetaDataStore().retrieve(id));
}
Also used : Element(org.jdom2.Element) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) Document(org.jdom2.Document) Test(org.junit.Test)

Example 33 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRMailEventHandler method handleCategoryEvent.

private void handleCategoryEvent(MCREvent evt, MCRCategory obj) {
    MCRContent xml = new MCRJDOMContent(MCRCategoryTransformer.getMetaDataDocument(obj, false));
    handleEvent(evt, xml, obj.toString());
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRContent(org.mycore.common.content.MCRContent)

Example 34 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRClassificationBrowser2 method renderToHTML.

/**
 * Sends output to client browser
 * @throws SAXException
 * @throws TransformerException
 */
private void renderToHTML(MCRServletJob job, HttpServletRequest req, Element xml) throws IOException, TransformerException, SAXException {
    // XSL.Style, optional
    String style = req.getParameter("style");
    if ((style != null) && (style.length() > 0)) {
        req.setAttribute("XSL.Style", style);
    }
    MCRServlet.getLayoutService().doLayout(req, job.getResponse(), new MCRJDOMContent(xml));
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent)

Example 35 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRMetadataStoreTest method update.

@Test
public void update() throws Exception {
    Document xml1 = new Document(new Element("root"));
    MCRStoredMetadata sm = getMetaDataStore().create(new MCRJDOMContent(xml1));
    Document xml2 = new Document(new Element("update"));
    sm.update(new MCRJDOMContent(xml2));
    MCRContent xml3 = getMetaDataStore().retrieve(sm.getID()).getMetadata();
    assertEquals(new MCRJDOMContent(xml2).asString(), xml3.asString());
}
Also used : Element(org.jdom2.Element) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) Document(org.jdom2.Document) MCRContent(org.mycore.common.content.MCRContent) Test(org.junit.Test)

Aggregations

MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)54 Document (org.jdom2.Document)33 Element (org.jdom2.Element)28 Test (org.junit.Test)21 MCRContent (org.mycore.common.content.MCRContent)20 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)6 IOException (java.io.IOException)5 File (java.io.File)4 MCRParameterCollector (org.mycore.common.xsl.MCRParameterCollector)4 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)4 MCRObject (org.mycore.datamodel.metadata.MCRObject)4 Date (java.util.Date)3 JDOMException (org.jdom2.JDOMException)3 MCRContentTransformer (org.mycore.common.content.transformer.MCRContentTransformer)3 MCRPath (org.mycore.datamodel.niofs.MCRPath)3 FileObject (org.apache.commons.vfs2.FileObject)2 XMLOutputter (org.jdom2.output.XMLOutputter)2 MCRException (org.mycore.common.MCRException)2 MCRPersistenceException (org.mycore.common.MCRPersistenceException)2 MCRFileContent (org.mycore.common.content.MCRFileContent)2