From 89af1a53cb81c3e05301dfb81d8c83e61764d7bd Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Tue, 30 Jun 2009 20:04:39 +0000 Subject: [PATCH] CSPACE-109: Adding prototype method for call Nuxeo's Java API --- .../CollectionObjectServiceNuxeoImpl.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/CollectionObjectServiceNuxeoImpl.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/CollectionObjectServiceNuxeoImpl.java index 086dd2e4a..fe863707f 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/CollectionObjectServiceNuxeoImpl.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/CollectionObjectServiceNuxeoImpl.java @@ -15,12 +15,20 @@ import org.collectionspace.services.nuxeo.NuxeoRESTClient; import org.collectionspace.services.nuxeo.CollectionSpaceServiceNuxeoImpl; import org.collectionspace.services.collectionobject.CollectionObject; import org.collectionspace.services.CollectionObjectJAXBSchema; +import org.collectionspace.services.nuxeo.NuxeoUtils; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; import org.restlet.resource.Representation; +import org.nuxeo.ecm.core.api.IdRef; +import org.nuxeo.ecm.core.api.repository.RepositoryInstance; +import org.nuxeo.ecm.core.api.DocumentModel; +import org.nuxeo.ecm.core.api.DocumentRef; + + + /** * @author remillet * @@ -54,6 +62,11 @@ public class CollectionObjectServiceNuxeoImpl extends public Document getCollectionObject(String csid) throws DocumentException, IOException { + + // Calling via Nuxeo Java API + //getCollectionObjectViaJavaAPI(csid); + + // Return to normal Nuxeo REST call List pathParams = new ArrayList(); Map queryParams = new HashMap(); @@ -70,6 +83,35 @@ public class CollectionObjectServiceNuxeoImpl extends return document; } + + /* + * Prototype method for calling the Nuxeo Java API + */ + private Document getCollectionObjectViaJavaAPI(String csid) + throws DocumentException, IOException { + Document result = null; + RepositoryInstance repoSession = null; + + try { + repoSession = getRepositorySession(); + DocumentRef documentRef = new IdRef(csid); + DocumentModel documentModel = repoSession.getDocument(documentRef); + result = NuxeoUtils.getDocument(repoSession, documentModel); + } catch (Exception e) { + if (logger.isDebugEnabled()) { + e.printStackTrace(); + } + } finally { + if (repoSession != null) { + releaseRepositorySession(repoSession); + } + } + + // Dump out the contents of the result to stdout + System.out.println(result.asXML()); + + return result; + } public Document getCollectionObjectList() throws DocumentException, IOException { -- 2.47.3