]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-109: Adding prototype method for call Nuxeo's Java API
authorRichard Millet <richard.millet@berkeley.edu>
Tue, 30 Jun 2009 20:04:39 +0000 (20:04 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Tue, 30 Jun 2009 20:04:39 +0000 (20:04 +0000)
services/collectionobject/service/src/main/java/org/collectionspace/services/CollectionObjectServiceNuxeoImpl.java

index 086dd2e4a159c5de22e75ffcffbfb51ab6c14215..fe863707f5c9cc84422400989c7031abb7c9b718 100644 (file)
@@ -15,12 +15,20 @@ import org.collectionspace.services.nuxeo.NuxeoRESTClient;
 import org.collectionspace.services.nuxeo.CollectionSpaceServiceNuxeoImpl;\r
 import org.collectionspace.services.collectionobject.CollectionObject;\r
 import org.collectionspace.services.CollectionObjectJAXBSchema;\r
+import org.collectionspace.services.nuxeo.NuxeoUtils;\r
 \r
 import org.dom4j.Document;\r
 import org.dom4j.DocumentException;\r
 import org.dom4j.io.SAXReader;\r
 import org.restlet.resource.Representation;\r
 \r
+import org.nuxeo.ecm.core.api.IdRef;\r
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
+import org.nuxeo.ecm.core.api.DocumentModel;\r
+import org.nuxeo.ecm.core.api.DocumentRef;\r
+\r
+\r
+\r
 /**\r
  * @author remillet\r
  * \r
@@ -54,6 +62,11 @@ public class CollectionObjectServiceNuxeoImpl extends
 \r
        public Document getCollectionObject(String csid) throws DocumentException,\r
                        IOException {\r
+               \r
+               // Calling via Nuxeo Java API\r
+               //getCollectionObjectViaJavaAPI(csid);\r
+               \r
+               // Return to normal Nuxeo REST call\r
                List<String> pathParams = new ArrayList<String>();\r
                Map<String, String> queryParams = new HashMap<String, String>();\r
 \r
@@ -70,6 +83,35 @@ public class CollectionObjectServiceNuxeoImpl extends
 \r
                return document;\r
        }\r
+       \r
+       /*\r
+        * Prototype method for calling the Nuxeo Java API\r
+        */\r
+       private Document getCollectionObjectViaJavaAPI(String csid)\r
+                       throws DocumentException, IOException {\r
+               Document result = null;\r
+               RepositoryInstance repoSession = null;\r
+               \r
+               try {\r
+                       repoSession = getRepositorySession();\r
+                       DocumentRef documentRef = new IdRef(csid);\r
+                       DocumentModel documentModel = repoSession.getDocument(documentRef);\r
+                       result = NuxeoUtils.getDocument(repoSession, documentModel);\r
+               } catch (Exception e) {\r
+                       if (logger.isDebugEnabled()) {\r
+                               e.printStackTrace();\r
+                       }\r
+               } finally {\r
+                       if (repoSession != null) {\r
+                               releaseRepositorySession(repoSession);\r
+                       }\r
+               }\r
+               \r
+               // Dump out the contents of the result to stdout\r
+               System.out.println(result.asXML());\r
+               \r
+               return result;\r
+       }\r
 \r
        public Document getCollectionObjectList() throws DocumentException,\r
                        IOException {\r