Search in sources :

Example 1 with MCRJAXBContent

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

the class MCRSolrInputDocumentGenerator method getSolrInputDocument.

public static List<SolrInputDocument> getSolrInputDocument(MCRContent source) throws JAXBException, IOException {
    if (source instanceof MCRJAXBContent) {
        @SuppressWarnings("unchecked") MCRJAXBContent<MCRSolrInputDocumentList> jaxbContent = (MCRJAXBContent<MCRSolrInputDocumentList>) source;
        return getSolrInputDocuments(jaxbContent.getObject().getDoc());
    }
    Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
    MCRSolrInputDocumentList solrDocuments = (MCRSolrInputDocumentList) unmarshaller.unmarshal(source.getSource());
    return getSolrInputDocuments(solrDocuments.getDoc());
}
Also used : MCRJAXBContent(org.mycore.common.content.MCRJAXBContent) MCRSolrInputDocumentList(org.mycore.solr.index.document.jaxb.MCRSolrInputDocumentList) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 2 with MCRJAXBContent

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

the class MCRUserTransformer method getDocument.

private static Document getDocument(MCRUser user) {
    MCRJAXBContent<MCRUser> content = new MCRJAXBContent<>(JAXB_CONTEXT, user);
    try {
        Document userXML = content.asXML();
        sortAttributes(userXML);
        return userXML;
    } catch (SAXParseException | JDOMException | IOException e) {
        throw new MCRException("Exception while transforming MCRUser " + user.getUserID() + " to JDOM document.", e);
    }
}
Also used : MCRJAXBContent(org.mycore.common.content.MCRJAXBContent) MCRException(org.mycore.common.MCRException) SAXParseException(org.xml.sax.SAXParseException) MCRUser(org.mycore.user2.MCRUser) IOException(java.io.IOException) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException)

Aggregations

MCRJAXBContent (org.mycore.common.content.MCRJAXBContent)2 IOException (java.io.IOException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Document (org.jdom2.Document)1 JDOMException (org.jdom2.JDOMException)1 MCRException (org.mycore.common.MCRException)1 MCRSolrInputDocumentList (org.mycore.solr.index.document.jaxb.MCRSolrInputDocumentList)1 MCRUser (org.mycore.user2.MCRUser)1 SAXParseException (org.xml.sax.SAXParseException)1