]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
PAHMA-963-REM-A: Added an Spring AOP wrapper for the Nuxeo repository instance class.
authorRichard Millet <remillet@berkeley.edu>
Mon, 24 Feb 2014 17:34:07 +0000 (09:34 -0800)
committerRichard Millet <remillet@berkeley.edu>
Mon, 24 Feb 2014 17:34:07 +0000 (09:34 -0800)
45 files changed:
3rdparty/nuxeo/nuxeo-platform-thumbnail/.gitignore [new file with mode: 0644]
pom.xml
services/JaxRsServiceProvider/src/main/resources/log4j.properties
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml
services/authentication/jaxb/.gitignore [new file with mode: 0644]
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/authorization/jaxb/.gitignore [new file with mode: 0644]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchDocumentModelHandler.java
services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java
services/common-api/.gitignore [new file with mode: 0644]
services/common/.gitignore [new file with mode: 0644]
services/common/pom.xml
services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java
services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java
services/common/src/main/java/org/collectionspace/services/common/relation/RelationUtils.java
services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClient.java
services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryInstanceWrapperAdvice.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnector.java [deleted file]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorRemote.java [deleted file]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceInterface.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceWrapper.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java
services/config/.gitignore [new file with mode: 0644]
services/hyperjaxb/.gitignore [new file with mode: 0644]
services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java
services/jaxb/.gitignore [new file with mode: 0644]
services/movement/jaxb/.gitignore [new file with mode: 0644]
services/objectexit/jaxb/.gitignore [new file with mode: 0644]
services/organization/jaxb/.gitignore [new file with mode: 0644]
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java
services/taxonomy/jaxb/.gitignore [new file with mode: 0644]
services/vocabulary/jaxb/.gitignore [new file with mode: 0644]

diff --git a/3rdparty/nuxeo/nuxeo-platform-thumbnail/.gitignore b/3rdparty/nuxeo/nuxeo-platform-thumbnail/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
diff --git a/pom.xml b/pom.xml
index d98d4aac967e9bdc66aeedf9c21e8cc6f730af11..a1b41338724fad693f2b880f5f550f16faa934a0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -24,8 +24,8 @@
 -->\r
                <cspace.services.version>4.1-SNAPSHOT</cspace.services.version>\r
                <cspace.services.client.version>4.1-SNAPSHOT</cspace.services.client.version>\r
-               <spring.version>3.0.0.RELEASE</spring.version>\r
-        <spring.security.version>3.0.2.RELEASE</spring.security.version>\r
+               <spring.version>3.0.5.RELEASE</spring.version>\r
+        <spring.security.version>3.0.5.RELEASE</spring.security.version>\r
        </properties>\r
 \r
        <distributionManagement>\r
index 3677268c945655f162a7df801fc8d99e20ac6266..ba0b6ce4fb94fe308b01b33a625ef9bf82cf34bd 100644 (file)
@@ -53,9 +53,9 @@ log4j.additivity.perf.collectionspace=false
 # CollectionSpace loggers and default levels - all loggers using the rootLogger if not otherwise specified\r
 #\r
 log4j.logger.org.collectionspace=INFO\r
-log4j.logger.org.collectionspace.services.nuxeo.client.java=TRACE\r
+log4j.logger.org.collectionspace.services.nuxeo.client.java=ERROR\r
 log4j.logger.org.collectionspace.services.common.storage.JDBCTools=ERROR\r
-log4j.logger.org.collectionspace.services.common.profile.CSpaceFilter=DEBUG\r
+log4j.logger.org.collectionspace.services.common.profile.CSpaceFilter=ERROR\r
 \r
 #log4j.logger.org.collectionspace.services.common.vocabulary.nuxeo=TRACE\r
 \r
index a6750477b1dd46df05f59651cca776aebaad0efc..ca6e361835f70a12f61dcedb6a714aae1e70df9a 100644 (file)
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:sec="http://www.springframework.org/schema/security"
        xmlns:util="http://www.springframework.org/schema/util"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
-       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+       http://www.springframework.org/schema/security  http://www.springframework.org/schema/security/spring-security.xsd
+       http://www.springframework.org/schema/util              http://www.springframework.org/schema/util/spring-util.xsd">
 
     <!--
         debugging tips : enable following categories in
@@ -81,7 +83,7 @@
             <value>cspace</value> <!-- value should be same as in application-policy in JBoss login-config.xml -->
         </property>
         <property name="loginConfig">
-            <value>/WEB-INF/login.conf</value> <!-- filler, not used at runtime -->
+            <value>/WEB-INF/login.conf</value>
         </property>
         <property name="callbackHandlers">
             <list>
index 529f90b599597e14e83510245b90226bff9dbc48..28714fd3b18cc0979504323ccfdb11f80763767e 100644 (file)
@@ -36,7 +36,7 @@
 \r
     <!--\r
       - Location of the XML file that defines the root application context\r
-      - Applied by ContextLoaderListener.\r
+      - Applied by Spring's ContextLoaderListener.\r
       -->\r
     <context-param>\r
         <param-name>contextConfigLocation</param-name>\r
@@ -65,6 +65,7 @@
        -               delayBetweenAttemptsMillis - How long to wait between retries.\r
        -\r
        -->\r
+       <!-- \r
        <filter>\r
                <filter-name>networkErrorRetryFilter</filter-name>\r
                <filter-class>org.collectionspace.services.common.NetworkErrorRetryFilter</filter-class>\r
@@ -82,7 +83,8 @@
                <filter-name>networkErrorRetryFilter</filter-name>\r
                <url-pattern>/*</url-pattern>\r
        </filter-mapping>\r
-    \r
+     -->\r
+     \r
        <!--\r
                A filter that logs profiling information.\r
         -->\r
diff --git a/services/authentication/jaxb/.gitignore b/services/authentication/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
index 95693d7382c25ee6c30857248e227702f1e392bc..d7354748fc9b49c64d3413a3da38b493e53996a4 100644 (file)
@@ -79,6 +79,7 @@ import org.collectionspace.services.config.ClientType;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.lifecycle.TransitionDef;
 import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.workflow.WorkflowCommon;
@@ -326,7 +327,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
      * Resource. They then call this method on that resource.
      */
     @Override
-       public DocumentModel getDocModelForAuthorityItem(RepositoryInstance repoSession, RefName.AuthorityItem item) 
+       public DocumentModel getDocModelForAuthorityItem(RepositoryInstanceInterface repoSession, RefName.AuthorityItem item) 
                        throws Exception, DocumentNotFoundException {
        if(item == null) {
                return null;
index d00d923d0f7206f17df17e3b04bc62a74e16e585..3fbac6ae1af79d1e303b10bc8ca643d039a3f13e 100644 (file)
@@ -8,7 +8,7 @@ import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
 import org.nuxeo.ecm.core.client.NuxeoClient;\r
 \r
-import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;\r
+//import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;\r
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
 //import org.collectionspace.services.common.query.IQueryManager;\r
 \r
index 87aca5fdd7877ef7b33274c20df098d3790336d2..0887cf267c766c85aabf0afb431a91238f1deddc 100644 (file)
@@ -38,8 +38,8 @@ import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
 import org.collectionspace.services.config.service.ObjectPartType;
-
 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -159,7 +159,7 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
     
     public String getShortIdentifier(String authCSID, String schemaName) throws Exception {
         String shortIdentifier = null;
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
 
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
        RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
index 133572b33c1a3d1de60375e952e5c37a86aa2afa..8f75f91ac25db406ba430e82b9b416f580bf1e36 100644 (file)
@@ -45,6 +45,7 @@ import org.collectionspace.services.config.service.ListResultField;
 import org.collectionspace.services.config.service.ObjectPartType;
 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentException;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.relation.RelationsCommonList;
@@ -355,7 +356,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
             }
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
             RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = getRepositoryClient(ctx);
-            RepositoryInstance repoSession = this.getRepositorySession();
+            RepositoryInstanceInterface repoSession = this.getRepositorySession();
             
             // Update all the existing records that have a field with the old refName in it
             int nUpdated = RefNameServiceUtils.updateAuthorityRefDocs(ctx, repoClient, repoSession,
@@ -470,7 +471,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
                String propertyName,
             String itemcsid) throws Exception {
         AuthorityRefDocList authRefDocList = null;
-       RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
        boolean releaseRepoSession = false;
         
        try {
diff --git a/services/authorization/jaxb/.gitignore b/services/authorization/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..19f2e00
--- /dev/null
@@ -0,0 +1,2 @@
+/target
+/target
index 4b2f2608d25d70b37ef313ed7ad75efebf9af73f..3aa4b552d2d4480d0814c96f53bfcc399e989d0f 100644 (file)
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Response;
 import org.collectionspace.services.BatchJAXBSchema;
 import org.collectionspace.services.jaxb.InvocableJAXBSchema;
 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.collectionspace.services.batch.BatchCommon;
 import org.collectionspace.services.batch.BatchInvocable;
@@ -68,7 +69,7 @@ public class BatchDocumentModelHandler
                        ResourceMap resourceMap, 
                        InvocationContext invContext) throws Exception {
 
-               RepositoryInstance repoSession = null;
+               RepositoryInstanceInterface repoSession = null;
                boolean releaseRepoSession = false;
 
                String invocationMode = invContext.getMode();
index 9345ab91e2a852679e6ac2866ac4b1074aab5209..8c0d3a85383d33d09f991ce383d2cb75d9cc006a 100644 (file)
@@ -42,11 +42,11 @@ import org.collectionspace.services.jaxb.BlobJAXBSchema;
 import org.collectionspace.services.nuxeo.client.java.CommonList;
 
 
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.IdRef;
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -115,7 +115,7 @@ extends DocHandlerBase<BlobsCommon> {
         ObjectPartType partMeta = partsMetaMap.get(metadataLabel);
 
         if (partMeta != null) {
-                       RepositoryInstance repoSession = this.getRepositorySession();
+               RepositoryInstanceInterface repoSession = this.getRepositorySession();
                        if (nuxeoImageID != null && nuxeoImageID.isEmpty() == false) try {
                                IdRef documentRef = new IdRef(nuxeoImageID);
                                DocumentModel docModel = repoSession.getDocument(documentRef);
@@ -139,7 +139,7 @@ extends DocHandlerBase<BlobsCommon> {
                        throws Exception {
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
                BlobInput blobInput = BlobUtil.getBlobInput(ctx); // the blobInput was set by the Blob JAX-RS resource code and put into the service context
-               RepositoryInstance repoSession = this.getRepositorySession();
+               RepositoryInstanceInterface repoSession = this.getRepositorySession();
                DocumentModel docModel = wrapDoc.getWrappedObject();
                BlobsCommon blobsCommon = this.getCommonPartProperties(docModel);               
                String blobRepositoryId = blobsCommon.getRepositoryId(); //cache the value to pass to the blob retriever
@@ -220,7 +220,7 @@ extends DocHandlerBase<BlobsCommon> {
                        // If blobInput has a file then we just received a multipart/form-data file post or a URI query parameter
                        //
                        DocumentModel documentModel = wrapDoc.getWrappedObject();
-                       RepositoryInstance repoSession = this.getRepositorySession();
+                       RepositoryInstanceInterface repoSession = this.getRepositorySession();
                
                        BlobsCommon blobsCommon = NuxeoBlobUtils.createBlobInRepository(ctx, repoSession, blobInput, purgeOriginal, true);
                        blobInput.setBlobCsid(documentModel.getName()); //Assumption here is that the documentModel "name" field is storing a CSID
diff --git a/services/common-api/.gitignore b/services/common-api/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
diff --git a/services/common/.gitignore b/services/common/.gitignore
new file mode 100644 (file)
index 0000000..19f2e00
--- /dev/null
@@ -0,0 +1,2 @@
+/target
+/target
index bc02b04a103f17569a6d38688ba8d347e701f93c..38b714cb55af86a3db9a2bcd6e77348db74aa5af 100644 (file)
             <version>${spring.security.version}</version>\r
             <scope>provided</scope>\r
         </dependency>\r
+               <dependency>\r
+                       <groupId>org.springframework</groupId>\r
+                       <artifactId>spring-aop</artifactId>\r
+                       <version>${spring.version}</version>\r
+               </dependency>        \r
     </dependencies>\r
 \r
     <repositories>\r
index 58117049fac9a6d1e0865717fef396d5e8e73466..92bb9d8160dc1e54cc227a6e00fed7243c038fb9 100644 (file)
@@ -26,6 +26,7 @@ package org.collectionspace.services.common;
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
+\r
 import javax.ws.rs.*;\r
 import javax.ws.rs.core.*;\r
 \r
@@ -33,7 +34,6 @@ import org.collectionspace.services.client.IClientQueryParams;
 import org.collectionspace.services.client.IQueryManager;\r
 import org.collectionspace.services.client.PoxPayloadIn;\r
 import org.collectionspace.services.client.PoxPayloadOut;\r
-\r
 import org.collectionspace.services.common.api.RefName;\r
 import org.collectionspace.services.common.api.Tools;\r
 import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
@@ -47,19 +47,16 @@ import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.query.QueryManager;\r
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;\r
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo;\r
-\r
 import org.collectionspace.services.config.ClientType;\r
 import org.collectionspace.services.config.service.DocHandlerParams;\r
 import org.collectionspace.services.config.service.ListResultField;\r
 import org.collectionspace.services.config.service.ServiceBindingType;\r
-\r
 import org.collectionspace.services.jaxb.AbstractCommonList;\r
 import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
-\r
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
 import org.jboss.resteasy.util.HttpResponseCodes;\r
-\r
 import org.nuxeo.ecm.core.api.DocumentModel;\r
 import org.nuxeo.ecm.core.api.DocumentModelList;\r
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
@@ -506,7 +503,7 @@ public abstract class ResourceBase
      * for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get\r
      * the map, and pass it in.\r
      */\r
-    public static DocumentModel getDocModelForRefName(RepositoryInstance repoSession, String refName, ResourceMap resourceMap) \r
+    public static DocumentModel getDocModelForRefName(RepositoryInstanceInterface repoSession, String refName, ResourceMap resourceMap) \r
                        throws Exception, DocumentNotFoundException {\r
        RefName.AuthorityItem item = RefName.AuthorityItem.parse(refName);\r
        if(item != null) {\r
@@ -529,13 +526,13 @@ public abstract class ResourceBase
 \r
     // THis is ugly, but prevents us parsing the refName twice. Once we make refName a little more\r
     // general, and less Authority(Item) specific, this will look better.\r
-       public DocumentModel getDocModelForAuthorityItem(RepositoryInstance repoSession, RefName.AuthorityItem item) \r
+       public DocumentModel getDocModelForAuthorityItem(RepositoryInstanceInterface repoSession, RefName.AuthorityItem item) \r
                        throws Exception, DocumentNotFoundException {\r
                logger.warn("Default (ResourceBase) getDocModelForAuthorityItem called - should not happen!");\r
                return null;\r
        }\r
 \r
-    public DocumentModel getDocModelForRefName(RepositoryInstance repoSession, String refName) \r
+    public DocumentModel getDocModelForRefName(RepositoryInstanceInterface repoSession, String refName) \r
                        throws Exception, DocumentNotFoundException {\r
        return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName));\r
     }\r
index d592abab168f6b9fabc3c30487bee7b9beb48fb7..a6e5143013705e02031162a668c18274fe0e3edd 100644 (file)
@@ -118,6 +118,7 @@ import org.collectionspace.services.blob.MeasuredPartGroup;
 import org.collectionspace.services.blob.MeasuredPartGroupList;\r
 import org.collectionspace.services.jaxb.BlobJAXBSchema;\r
 import org.collectionspace.services.nuxeo.client.java.CommonList;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
 import org.collectionspace.services.nuxeo.extension.thumbnail.ThumbnailConstants;\r
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
@@ -297,7 +298,7 @@ public class NuxeoBlobUtils {
                return result;\r
        }\r
 \r
-       static public CommonList getBlobDerivatives(RepositoryInstance repoSession,\r
+       static public CommonList getBlobDerivatives(RepositoryInstanceInterface repoSession,\r
                        String repositoryId, List<ListResultField> resultsFields, String uri)\r
                        throws Exception {\r
                CommonList commonList = new CommonList();\r
@@ -501,7 +502,7 @@ public class NuxeoBlobUtils {
         * This is a prototype method that is not currently used as of 1/1/2012.  However,\r
         * it may be useful now that we've transitioned to using an embedded Nuxeo server.\r
         */\r
-       static private File getBlobFile(RepositoryInstance ri,\r
+       static private File getBlobFile(RepositoryInstanceInterface ri,\r
                        DocumentModel documentModel, Blob blob) {\r
                DefaultBinaryManager binaryManager = null;\r
                RepositoryDescriptor descriptor = null;\r
@@ -576,11 +577,11 @@ public class NuxeoBlobUtils {
         *            the id\r
         * @return the blob\r
         */\r
-       static private Blob getBlob(RepositoryInstance nuxeoSession, String id) {\r
+       static private Blob getBlob(RepositoryInstanceInterface repoSession, String id) {\r
                Blob result = null;\r
 \r
                try {\r
-                       Repository repository = nuxeoSession.getRepository();\r
+                       Repository repository = repoSession.getRepositoryInstance().getRepository();\r
                        // binaryManager.initialize(new RepositoryDescriptor());\r
                        // binaryManager.getBinary("a4cac052ae0281979f2dcf5ab2e61a6c");\r
                        // DocumentResolver.resolveReference(nuxeoSession, documentRef);\r
@@ -876,8 +877,8 @@ public class NuxeoBlobUtils {
                return result;\r
        }\r
        \r
-       static private RepositoryInstance getRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient) {\r
-               RepositoryInstance result = null;               \r
+       static private RepositoryInstanceInterface getRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient) {\r
+               RepositoryInstanceInterface result = null;              \r
                RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;\r
                \r
                try {\r
@@ -889,7 +890,7 @@ public class NuxeoBlobUtils {
                return result;\r
        }\r
        \r
-       static private void releaseRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient, RepositoryInstance repoSession) throws TransactionException {\r
+       static private void releaseRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient, RepositoryInstanceInterface repoSession) throws TransactionException {\r
                RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;\r
                nuxeoClient.releaseRepositorySession(ctx, repoSession);\r
        }\r
@@ -907,7 +908,7 @@ public class NuxeoBlobUtils {
     }\r
        \r
        private static DocumentModel createDocumentFromBlob(\r
-                       RepositoryInstance repoSession,\r
+                       RepositoryInstanceInterface repoSession,\r
             Blob inputStreamBlob, \r
             String blobLocation, \r
             boolean overwrite, \r
@@ -922,7 +923,7 @@ public class NuxeoBlobUtils {
                        // image derivatives.\r
                        //\r
                        result = getFileManager().createDocumentFromBlob(\r
-                                       repoSession, inputStreamBlob, blobLocation, true, blobName);\r
+                                       repoSession.getRepositoryInstance(), inputStreamBlob, blobLocation, true, blobName);\r
                } else {\r
                        //\r
                        // User Nuxeo's default file importer/adapter explicitly.  This avoids specialized functionality from happening like\r
@@ -936,7 +937,7 @@ public class NuxeoBlobUtils {
 \r
                        FileImporter defaultFileImporter = fileManagerService.getPluginByName("DefaultFileImporter");\r
                        result = defaultFileImporter.create(\r
-                                       repoSession, inputStreamBlob, blobLocation, true, blobName, getTypeService());                  \r
+                                       repoSession.getRepositoryInstance(), inputStreamBlob, blobLocation, true, blobName, getTypeService());                  \r
                }\r
                \r
                return result;\r
@@ -951,7 +952,7 @@ public class NuxeoBlobUtils {
                BlobsCommon result = null;\r
 \r
                boolean repoSessionCleanup = false;\r
-               RepositoryInstance repoSession = (RepositoryInstance)ctx.getCurrentRepositorySession();\r
+               RepositoryInstanceInterface repoSession = (RepositoryInstanceInterface)ctx.getCurrentRepositorySession();\r
                if (repoSession == null) {\r
                        repoSession = getRepositorySession(ctx, repositoryClient);\r
                        repoSessionCleanup = true;\r
@@ -998,7 +999,7 @@ public class NuxeoBlobUtils {
         */\r
        public static BlobsCommon createBlobInRepository(\r
                        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
-                       RepositoryInstance repoSession,\r
+                       RepositoryInstanceInterface repoSession,\r
                        BlobInput blobInput,\r
                        boolean purgeOriginal,\r
                        boolean useNuxeoAdaptors) throws Exception {\r
@@ -1084,7 +1085,7 @@ public class NuxeoBlobUtils {
         *            the mime type\r
         * @return the string\r
         */\r
-       static private BlobsCommon createBlobInRepository(RepositoryInstance nuxeoSession,\r
+       static private BlobsCommon createBlobInRepository(RepositoryInstanceInterface nuxeoSession,\r
                        DocumentModel blobLocation,\r
                        boolean purgeOriginal,\r
                        File file,\r
@@ -1178,7 +1179,7 @@ public class NuxeoBlobUtils {
                BlobOutput result = null;\r
                \r
                boolean repoSessionCleanup = false;\r
-               RepositoryInstance repoSession = (RepositoryInstance)ctx.getCurrentRepositorySession();\r
+               RepositoryInstanceInterface repoSession = (RepositoryInstanceInterface)ctx.getCurrentRepositorySession();\r
                if (repoSession == null) {\r
                        repoSession = getRepositorySession(ctx, repositoryClient);\r
                        repoSessionCleanup = true;\r
@@ -1244,7 +1245,7 @@ public class NuxeoBlobUtils {
         * @return the image\r
         */\r
        static public BlobOutput getBlobOutput(ServiceContext ctx,\r
-                       RepositoryInstance repoSession,\r
+                       RepositoryInstanceInterface repoSession,\r
                        String repositoryId,\r
                        String derivativeTerm,\r
                        Boolean getContentFlag,\r
index 846b589f67043e17c75c7cc89e3aa69094e074c1..d52778a203f777f426beebdc5b8a89dac2d8d3ac 100644 (file)
@@ -9,6 +9,7 @@ import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.repository.RepositoryClient;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -28,7 +29,7 @@ public class RelationUtils {
      */
     private static DocumentModelList findRelationsWithRefName(
             ServiceContext ctx,
-            RepositoryInstance repoSession,
+            RepositoryInstanceInterface repoSession,
             String refName,
             String targetField,
             String orderByField,
@@ -73,7 +74,7 @@ public class RelationUtils {
     public static void updateRefNamesInRelations(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
             RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
-            RepositoryInstance repoSession,
+            RepositoryInstanceInterface repoSession,
             String targetField,
             String oldRefName,
             String newRefName) {
index c9967c00f5971ad20dbe9cca71ec8e9f4236b424..35502c21011cb92fdf1fff45b2539871a26963ec 100644 (file)
@@ -32,10 +32,15 @@ import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.storage.StorageClient;
 import org.collectionspace.services.config.tenant.RepositoryDomainType;
+
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
+//
+// All of these Nuxeo specific classes should not be here.  This is supposed to be
+// a repository-neutral interface.
+//
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
 
 /**
  * RepositoryClient is a generic Document Repository client
@@ -127,7 +132,7 @@ public interface RepositoryClient<IT, OT> extends StorageClient {
      * @param where NXQL where clause to get the document
      * @throws DocumentException
      */
-    public String findDocCSID(RepositoryInstance repoSession, 
+    public String findDocCSID(RepositoryInstanceInterface repoSession, 
             ServiceContext<IT, OT> ctx, String where)
             throws DocumentNotFoundException, DocumentException;
 
diff --git a/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryInstanceWrapperAdvice.java b/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryInstanceWrapperAdvice.java
new file mode 100644 (file)
index 0000000..f8e40cf
--- /dev/null
@@ -0,0 +1,23 @@
+package org.collectionspace.services.common.repository;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+
+
+public class RepositoryInstanceWrapperAdvice implements MethodInterceptor {
+
+       public RepositoryInstanceWrapperAdvice() {
+               // TODO Auto-generated constructor stub
+       }
+
+       //@Override
+       public Object invoke(MethodInvocation methodInvocation) throws Throwable {
+               try {
+                       // proceed to original method call
+                       Object result = methodInvocation.proceed(); 
+                       return result;
+               } catch (IllegalArgumentException e) {
+                       throw e;
+               }
+       }
+}
index 96a50c23ecf9251c8878bce3580c9f3d36cc379a..13f47fe5d15809fff159d4b37d91ecad1d69145c 100644 (file)
@@ -38,7 +38,6 @@ import org.nuxeo.ecm.core.api.model.impl.primitives.StringProperty;
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
-\r
 import org.collectionspace.services.client.CollectionSpaceClient;\r
 import org.collectionspace.services.client.IRelationsManager;\r
 import org.collectionspace.services.client.PoxPayloadIn;\r
@@ -65,6 +64,7 @@ import org.collectionspace.services.common.query.QueryManager;
 import org.collectionspace.services.common.relation.RelationUtils;\r
 import org.collectionspace.services.common.repository.RepositoryClient;\r
 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
 import org.collectionspace.services.common.security.SecurityUtils;\r
 import org.collectionspace.services.config.service.ServiceBindingType;\r
@@ -213,7 +213,7 @@ public class RefNameServiceUtils {
     public static void updateRefNamesInRelations(\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
             RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
-            RepositoryInstance repoSession,\r
+            RepositoryInstanceInterface repoSession,\r
             String oldRefName,\r
             String newRefName) {\r
        //\r
@@ -240,7 +240,7 @@ public class RefNameServiceUtils {
     }\r
 \r
     public static AuthorityRefDocList getAuthorityRefDocs(\r
-            RepositoryInstance repoSession,\r
+               RepositoryInstanceInterface repoSession,\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
             UriTemplateRegistry uriTemplateRegistry,\r
             RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
@@ -395,7 +395,7 @@ public class RefNameServiceUtils {
     public static int updateAuthorityRefDocs(\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
             RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
-            RepositoryInstance repoSession,\r
+            RepositoryInstanceInterface repoSession,\r
             String oldRefName,\r
             String newRefName,\r
             String refPropName) throws Exception {\r
@@ -468,7 +468,7 @@ public class RefNameServiceUtils {
     private static DocumentModelList findAuthorityRefDocs(\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
             RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
-            RepositoryInstance repoSession, List<String> serviceTypes,\r
+            RepositoryInstanceInterface repoSession, List<String> serviceTypes,\r
             String refName,\r
             String refPropName,\r
             Map<String, ServiceBindingType> queriedServiceBindings,\r
index 175c209b32e7bf1dff1fff8792c3efd244c3cbc0..e60f1ee6a4c37f9502c5f8038417c8695f76be30 100644 (file)
@@ -177,7 +177,7 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
     public AbstractCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
        CommonList commonList = new CommonList();\r
         String markRtSbj = null;\r
-       RepositoryInstance repoSession = null;\r
+        RepositoryInstanceInterface repoSession = null;\r
        RepositoryJavaClientImpl repoClient = null;\r
        RepositoryJavaClientImpl nuxeoRepoClient = null;\r
        boolean releaseRepoSession = false;\r
index 41fb0966437bb93920dd3970435ed8eeb4f38808..7559b24ab256cba943d2fca2fef73492c77610ac 100644 (file)
@@ -77,7 +77,7 @@ public abstract class DocumentModelHandler<T, TL>
         extends AbstractMultipartDocumentHandlerImpl<T, TL, DocumentModel, DocumentModelList> {
 
     private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
-    private RepositoryInstance repositorySession;
+    private RepositoryInstanceInterface repositorySession;
 
     protected String oldRefNameOnUpdate = null;  // FIXME: REM - We should have setters and getters for these
     protected String newRefNameOnUpdate = null;  // FIXME: two fields.
@@ -211,7 +211,7 @@ public abstract class DocumentModelHandler<T, TL>
      * getRepositorySession returns Nuxeo Repository Session
      * @return
      */
-    public RepositoryInstance getRepositorySession() {
+    public RepositoryInstanceInterface getRepositorySession() {
        
         return repositorySession;
     }
@@ -220,7 +220,7 @@ public abstract class DocumentModelHandler<T, TL>
      * setRepositorySession sets repository session
      * @param repoSession
      */
-    public void setRepositorySession(RepositoryInstance repoSession) {
+    public void setRepositorySession(RepositoryInstanceInterface repoSession) {
         this.repositorySession = repoSession;
     }
 
index f7aeb66ef053d23eec2fb4e46df596be3ffbcc9d..144450c81712c4fffd23c8163ea5ceee09c296e4 100644 (file)
@@ -24,10 +24,7 @@ import java.util.HashMap;
 import java.util.Iterator;\r
 import java.util.Map.Entry;\r
 \r
-import javax.transaction.TransactionManager;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
+import org.collectionspace.services.common.repository.RepositoryInstanceWrapperAdvice;\r
 import org.collectionspace.services.config.tenant.RepositoryDomainType;\r
 import org.jboss.remoting.InvokerLocator;\r
 import org.nuxeo.ecm.core.api.repository.Repository;\r
@@ -36,11 +33,14 @@ import org.nuxeo.ecm.core.api.repository.RepositoryInstanceHandler;
 import org.nuxeo.ecm.core.api.repository.RepositoryManager;\r
 import org.nuxeo.ecm.core.client.DefaultLoginHandler;\r
 import org.nuxeo.ecm.core.client.LoginHandler;\r
-//import org.nuxeo.ecm.core.repository.RepositoryDescriptor;\r
 import org.nuxeo.runtime.api.Framework;\r
 import org.nuxeo.runtime.transaction.TransactionHelper;\r
+\r
+import javax.transaction.TransactionManager;\r
+\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
+import org.springframework.aop.framework.ProxyFactory;\r
 \r
 /**\r
  * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>\r
@@ -52,26 +52,24 @@ public final class NuxeoClientEmbedded {
        \r
     private LoginHandler loginHandler;\r
 \r
-    private final HashMap<String, RepositoryInstance> repositoryInstances;\r
+    private final HashMap<String, RepositoryInstanceInterface> repositoryInstances;\r
 \r
     private InvokerLocator locator;\r
 \r
     private RepositoryManager repositoryMgr;\r
 \r
     private static final NuxeoClientEmbedded instance = new NuxeoClientEmbedded();\r
-\r
-    private static final Log log = LogFactory.getLog(NuxeoClientEmbedded.class);\r
-\r
+        \r
     /**\r
      * Constructs a new NuxeoClient. NOTE: Using {@link #getInstance()} instead\r
      * of this constructor is recommended.\r
      */\r
-    public NuxeoClientEmbedded() {\r
+    private NuxeoClientEmbedded() {\r
         loginHandler = loginHandler == null ? new DefaultLoginHandler()\r
                 : loginHandler;\r
-        repositoryInstances = new HashMap<String, RepositoryInstance>();\r
+        repositoryInstances = new HashMap<String, RepositoryInstanceInterface>();\r
     }\r
-\r
+    \r
     public static NuxeoClientEmbedded getInstance() {\r
         return instance;\r
     }\r
@@ -86,13 +84,13 @@ public final class NuxeoClientEmbedded {
     private void doDisconnect() throws Exception {\r
         locator = null;\r
         // close repository sessions if any\r
-        Iterator<Entry<String, RepositoryInstance>> it = repositoryInstances.entrySet().iterator();\r
+        Iterator<Entry<String, RepositoryInstanceInterface>> it = repositoryInstances.entrySet().iterator();\r
         while (it.hasNext()) {\r
-            Entry<String, RepositoryInstance> repo = it.next();\r
+            Entry<String, RepositoryInstanceInterface> repo = it.next();\r
             try {\r
                 repo.getValue().close();\r
             } catch (Exception e) {\r
-                log.debug("Error while trying to close " + repo, e);\r
+                logger.debug("Error while trying to close " + repo, e);\r
             }\r
             it.remove();\r
         }\r
@@ -144,20 +142,23 @@ public final class NuxeoClientEmbedded {
     /*\r
      * Open a Nuxeo repo session using the passed in repoDomain and use the default tx timeout period\r
      */\r
-    public RepositoryInstance openRepository(RepositoryDomainType repoDomain) throws Exception {\r
+    public RepositoryInstanceInterface openRepository(RepositoryDomainType repoDomain) throws Exception {\r
         return openRepository(repoDomain.getRepositoryName(), -1);\r
     }\r
     \r
     /*\r
      * Open a Nuxeo repo session using the passed in repoDomain and use the default tx timeout period\r
      */\r
-    public RepositoryInstance openRepository(String repoName) throws Exception {\r
+    public RepositoryInstanceInterface openRepository(String repoName) throws Exception {\r
         return openRepository(repoName, -1);\r
     }    \r
 \r
-    public RepositoryInstance openRepository(String repoName, int timeoutSeconds) throws Exception {\r
-       RepositoryInstance result = null;\r
+    public RepositoryInstanceInterface openRepository(String repoName, int timeoutSeconds) throws Exception {\r
+       RepositoryInstanceInterface result = null;\r
        \r
+       //\r
+       // If the called passed in a custom timeout setting, use it to configure Nuxeo's transaction manager.\r
+       //\r
        if (timeoutSeconds > 0) {\r
                TransactionManager transactionMgr = TransactionHelper.lookupTransactionManager();\r
                transactionMgr.setTransactionTimeout(timeoutSeconds);\r
@@ -167,6 +168,9 @@ public final class NuxeoClientEmbedded {
                }\r
        }\r
        \r
+       //\r
+       // Start a new Nuxeo transaction\r
+       //\r
        boolean startedTransaction = false;\r
        if (TransactionHelper.isTransactionActive() == false) {\r
                startedTransaction = TransactionHelper.startTransaction();\r
@@ -179,7 +183,11 @@ public final class NuxeoClientEmbedded {
                logger.warn("A request to start a new transaction was made, but a transaction is already open.");\r
        }\r
        \r
-        Repository repository = null;\r
+       //\r
+       // From the repository name that the caller passed in, get an instance of Nuxeo's Repository class.\r
+       // The Repository class is just a metadata description of the repository.\r
+       //\r
+        Repository repository;\r
         if (repoName != null) {\r
                repository = getRepositoryManager().getRepository(repoName);\r
         } else {\r
@@ -187,32 +195,77 @@ public final class NuxeoClientEmbedded {
                logger.warn(String.format("Using default repository '%s' because no name was specified.", repository.getName()));\r
         }\r
         \r
+        //\r
+        // Using the Repository class, get a Spring AOP proxied instance.  We use Spring AOP to "wrap" all calls to the\r
+        // Nuxeo repository so we can check for network related failures and perform a series of retries.\r
+        //\r
         if (repository != null) {\r
-               result = newRepositoryInstance(repository);\r
-               if (result != null) {\r
+            result = getRepositoryInstanceWrapper(repository);\r
+               logger.trace(String.format("A new transaction was started on thread '%d' : %s.",\r
+                               Thread.currentThread().getId(), startedTransaction ? "true" : "false"));\r
+               logger.trace(String.format("Added a new repository instance to our repo list.  Current count is now: %d",\r
+                               repositoryInstances.size()));\r
+        } else {\r
+               String errMsg = String.format("Could not open a session to the Nuxeo repository='%s'", repoName);\r
+               logger.error(errMsg);\r
+               throw new Exception(errMsg);\r
+        }      \r
+       \r
+        \r
+        return result;\r
+    }\r
+    \r
+    //\r
+    // Returns a proxied interface to a Nuxeo repository instance.  Our proxy uses Spring AOP to\r
+    // wrap each call to the Nuxeo repo with code that catches network related errors/exceptions and\r
+    // re-attempts the calls to see if it recovers.\r
+    //\r
+    private RepositoryInstanceInterface getAOPProxy(RepositoryInstance repositoryInstance) {\r
+       RepositoryInstanceInterface result = null;\r
+       \r
+       try {\r
+                       ProxyFactory factory = new ProxyFactory(new RepositoryInstanceWrapper(repositoryInstance));\r
+                       factory.addAdvice(new RepositoryInstanceWrapperAdvice());\r
+                       factory.setExposeProxy(true);\r
+                       result = (RepositoryInstanceInterface)factory.getProxy();\r
+       } catch (Exception e) {\r
+               logger.error("Could not create AOP proxy for: " + RepositoryInstanceWrapper.class.getName(), e);\r
+       }\r
+       \r
+       return result;\r
+    }\r
+    \r
+    /*\r
+     * From the Repository object (a description of the repository), get repository instance wrapper.  Our wrapper\r
+     * will using the Spring AOP mechanism to intercept all calls to the repository.  We will wrap all the calls to the\r
+     * Nuxeo repository and check for network related failures.  We will retry all calls to the Nuxeo repo that fail because\r
+     * of network erros.\r
+     */\r
+    private RepositoryInstanceInterface getRepositoryInstanceWrapper(Repository repository) throws Exception {\r
+       RepositoryInstanceInterface result = null;\r
+               \r
+       RepositoryInstance repositoryInstance = new RepositoryInstanceHandler(repository).getProxy();  // A Nuxeo repo instance handler proxy\r
+        if (repositoryInstance != null) {\r
+               result = this.getAOPProxy(repositoryInstance);  // This is our AOP proxy\r
+               if (result != null) {\r
                        String key = result.getSessionId();\r
                        repositoryInstances.put(key, result);\r
-                       if (logger.isTraceEnabled()) {\r
-                               logger.trace(String.format("A new transaction was started on thread '%d' : %s.",\r
-                                               Thread.currentThread().getId(), startedTransaction ? "true" : "false"));\r
-                               logger.trace(String.format("Added a new repository instance to our repo list.  Current count is now: %d",\r
-                                               repositoryInstances.size()));\r
-                       }\r
-               } else {\r
-                       String errMsg = String.format("Could not create a new repository instance for '%s' repository.", repository.getName());\r
-                       logger.error(errMsg);\r
-                       throw new Exception(errMsg);\r
-               }\r
+               } else {\r
+                       String errMsg = String.format("Could not instantiate a Spring AOP proxy for class '%s'.",\r
+                                       RepositoryInstanceWrapper.class.getName());\r
+                       logger.error(errMsg);\r
+                       throw new Exception(errMsg);\r
+               }\r
         } else {\r
-               String errMsg = String.format("Could not open a session to the Nuxeo repository='%s'", repoName);\r
+               String errMsg = String.format("Could not create a new repository instance for '%s' repository.", repository.getName());\r
                logger.error(errMsg);\r
                throw new Exception(errMsg);\r
         }\r
-\r
-        return result;\r
+       \r
+       return result;\r
     }\r
 \r
-    public void releaseRepository(RepositoryInstance repo) throws Exception {\r
+    public void releaseRepository(RepositoryInstanceInterface repo) throws Exception {\r
        String key = repo.getSessionId();\r
 \r
         try {\r
@@ -222,7 +275,7 @@ public final class NuxeoClientEmbedded {
                logger.error("Possible data loss.  Could not save and/or release the repository.", e);\r
                throw e;\r
         } finally {\r
-            RepositoryInstance wasRemoved = repositoryInstances.remove(key);\r
+            RepositoryInstanceInterface wasRemoved = repositoryInstances.remove(key);\r
             if (logger.isTraceEnabled()) {\r
                if (wasRemoved != null) {\r
                        logger.trace("Removed a repository instance from our repo list.  Current count is now: "\r
@@ -237,10 +290,5 @@ public final class NuxeoClientEmbedded {
                logger.trace(String.format("Transaction closed on thread '%d'", Thread.currentThread().getId()));\r
             }\r
         }\r
-    }\r
-\r
-    public static RepositoryInstance newRepositoryInstance(Repository repository) {\r
-        return new RepositoryInstanceHandler(repository).getProxy(); // Why a proxy here?\r
-    }\r
-\r
+    }    \r
 }\r
diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnector.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnector.java
deleted file mode 100644 (file)
index fbb14e6..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/**
- *  This document is a part of the source code and related artifacts
- *  for CollectionSpace, an open source collections management system
- *  for museums and related institutions:
-
- *  http://www.collectionspace.org
- *  http://wiki.collectionspace.org
-
- *  Copyright 2009 University of California at Berkeley
-
- *  Licensed under the Educational Community License (ECL), Version 2.0.
- *  You may not use this file except in compliance with this License.
-
- *  You may obtain a copy of the ECL 2.0 License at
-
- *  https://source.collectionspace.org/collection-space/LICENSE.txt
-
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.collectionspace.services.nuxeo.client.java;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.collectionspace.services.config.RepositoryClientConfigType;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
-import org.nuxeo.ecm.core.client.DefaultLoginHandler;
-import org.nuxeo.ecm.core.client.NuxeoApp;
-import org.nuxeo.ecm.core.client.NuxeoClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * NuxeoConnector creates Nuxeo remoting runtime and provides access to Nuxeo client.
- * @author 
- */
-public class NuxeoConnector {
-
-    public final static String NUXEO_CLIENT_DIR = "nuxeo-client";
-    private Logger logger = LoggerFactory.getLogger(NuxeoConnector.class);
-    private static final NuxeoConnector self = new NuxeoConnector();
-       private static final String NUXEO_CLIENT_USERNAME = "NUXEO_CLIENT_USERNAME";
-       private static final String NUXEO_CLIENT_PASSWORD = "NUXEO_CLIENT_PASSWORD";
-    private NuxeoApp app;
-    private NuxeoClient client;
-    private volatile boolean initialized = false; //use volatile for lazy initialization in singleton
-    private RepositoryClientConfigType repositoryClientConfig;
-
-    private NuxeoConnector() {
-    }
-
-    public final static NuxeoConnector getInstance() {
-        return self;
-    }
-
-    private String getClientUserName(RepositoryClientConfigType repositoryClientConfig) {
-       String username = System.getenv(NUXEO_CLIENT_USERNAME);
-       if (username == null) {
-               username = repositoryClientConfig.getUser();
-       }
-       return username;
-    }
-    
-    private String getClientPassword(RepositoryClientConfigType repositoryClientConfig) {
-       String password = System.getenv(NUXEO_CLIENT_PASSWORD);
-       if (password == null) {
-               password = repositoryClientConfig.getPassword();
-       }
-       return password;
-    }
-    
-    /**
-     * initialize initialize the Nuxeo connector. It makes sure that the connector
-     * is initialized in a thread-safe manner and not initialized more than once.
-     * Initialization involves starting Nuxeo runtime, loading Nuxeo APIs jars
-     * in OSGI container as well as establishing initial connection.
-     * @param repositoryClientConfig
-     * @throws java.lang.Exception
-     */
-    public void initialize(RepositoryClientConfigType repositoryClientConfig) throws Exception {
-
-        if(initialized == false){
-            synchronized(this){
-                if(initialized == false){
-                    try{
-                        this.repositoryClientConfig = repositoryClientConfig;
-                        setProperties(repositoryClientConfig);
-                        app = new NuxeoApp();
-                        app.start();
-                        if(logger.isDebugEnabled()){
-                            logger.debug("initialize() NuxeoApp started");
-                        }
-                        loadBundles();
-                        client = NuxeoClient.getInstance();
-                        String username = getClientUserName(repositoryClientConfig);
-                        String password = getClientPassword(repositoryClientConfig);
-//                        DefaultLoginHandler loginHandler = new DefaultLoginHandler(
-//                                repositoryClientConfig.getUser(), repositoryClientConfig.getPassword());
-                        DefaultLoginHandler loginHandler = new DefaultLoginHandler(username, password);
-                        client.setLoginHandler(loginHandler);
-                        client.connect(repositoryClientConfig.getHost(),
-                                repositoryClientConfig.getPort());
-                        if(logger.isDebugEnabled()){
-                            logger.debug("initialize(): connection successful port=" +
-                                    repositoryClientConfig.getPort());
-                        }
-                        initialized = true;
-                    }catch(Exception e){
-                        if(logger.isDebugEnabled()){
-                            logger.debug("Caught exception while initializing", e);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * release releases resources occupied by Nuxeo remoting client runtime
-     * @throws java.lang.Exception
-     */
-    public void release() throws Exception {
-        if(initialized == true){
-            client.disconnect();
-            app.shutdown();
-        }
-    }
-
-    private void loadBundles() throws Exception {
-        String bundles = "nuxeo-client/lib/nuxeo-runtime-*:nuxeo-client/lib/nuxeo-*";
-//        String serverRootDir = ServiceMain.getInstance().getServerRootDir();
-        //can't call ServiceMain here because loadBundles is called within
-        //the iniitialization context of ServiceMain, recrusion problem
-        String serverRootDir = System.getProperty("jboss.server.home.dir");
-        if(serverRootDir == null){
-            serverRootDir = "."; //assume server is started from server root, e.g. server/cspace
-        }
-        File clientLibDir = new File(serverRootDir);
-        if(!clientLibDir.exists()){
-            String msg = "Library bundles requried to deploy Nuxeo client not found: " +
-                    " directory named nuxeo-client with bundles does not exist in " + serverRootDir;
-            logger.error(msg);
-            throw new IllegalStateException(msg);
-        }
-        Collection<File> files = null;
-        if(bundles != null){
-            files = NuxeoApp.getBundleFiles(new File(serverRootDir), bundles, ":");
-        }
-        if(logger.isDebugEnabled()){
-            logger.debug("loadBundles(): deploying bundles: " + files);
-        }
-        if(files != null){
-            app.deployBundles(files);
-        }
-    }
-
-    private void setProperties(RepositoryClientConfigType repositoryClientConfig) {
-        System.setProperty("nuxeo.client.on.jboss", Boolean.TRUE.toString());
-        System.setProperty("org.nuxeo.runtime.server.enabled", Boolean.FALSE.toString());
-        System.setProperty("org.nuxeo.runtime.server.port", "" + repositoryClientConfig.getPort());
-        System.setProperty("org.nuxeo.runtime.server.host", repositoryClientConfig.getHost());
-        //System.setProperty("org.nuxeo.runtime.1.3.3.streaming.port", "3233");
-        System.setProperty("org.nuxeo.runtime.streaming.serverLocator", "socket://" + repositoryClientConfig.getHost() + ":3233");
-        System.setProperty("org.nuxeo.runtime.streaming.isServer", Boolean.FALSE.toString());
-        //org.nuxeo.client.remote is part of the fix to Nuxeo Runtime to use Java Remote APIs
-        //from JBoss
-        System.setProperty("org.nuxeo.client.remote", Boolean.TRUE.toString());
-    }
-
-    /**
-     * getClient get Nuxeo client for accessing Nuxeo services remotely using
-     * Nuxeo Java (EJB) Remote APIS
-     * @return NuxeoClient
-     * @throws java.lang.Exception
-     */
-    public NuxeoClient getClient() throws Exception {
-        if(initialized == true){
-            if(client.isConnected()){
-                client.login();
-                return client;
-            }else{
-                client.forceConnect(repositoryClientConfig.getHost(), repositoryClientConfig.getPort());
-                if(logger.isDebugEnabled()){
-                    logger.debug("getClient(): connection successful port=" +
-                            repositoryClientConfig.getPort());
-                }
-                return client;
-            }
-        }
-        String msg = "NuxeoConnector is not initialized!";
-        logger.error(msg);
-        throw new IllegalStateException(msg);
-    }
-
-    /**
-     * getRepositorySession get session to default repository
-     * @return RepositoryInstance
-     * @throws java.lang.Exception
-     */
-    public RepositoryInstance getRepositorySession() throws Exception {
-        RepositoryInstance repoSession = getClient().openRepository();
-        if(logger.isDebugEnabled()){
-            logger.debug("getRepositorySession() opened repository session");
-        }
-        return repoSession;
-    }
-
-    /**
-     * releaseRepositorySession releases given repository session
-     * @param repoSession
-     * @throws java.lang.Exception
-     */
-    public void releaseRepositorySession(RepositoryInstance repoSession) throws Exception {
-        if(repoSession != null){
-            getClient().releaseRepository(repoSession);
-
-            if(logger.isDebugEnabled()){
-                logger.debug("releaseRepositorySession() released repository session");
-            }
-        }
-    }
-
-    /**
-     * retrieveWorkspaceIds retrieves all workspace ids from default repository
-     * @param tenantDomain domain representing tenant
-     * @return
-     * @throws java.lang.Exception
-     */
-    public Hashtable<String, String> retrieveWorkspaceIds(String tenantDomain) throws Exception {
-        RepositoryInstance repoSession = null;
-        Hashtable<String, String> workspaceIds = new Hashtable<String, String>();
-        try{
-            repoSession = getRepositorySession();
-            DocumentModel rootDoc = repoSession.getRootDocument();
-            DocumentModelList rootChildrenList = repoSession.getChildren(rootDoc.getRef());
-            Iterator<DocumentModel> diter = rootChildrenList.iterator();
-            while(diter.hasNext()){
-                DocumentModel domain = diter.next();
-                String domainPath = "/" + tenantDomain;
-                if(!domain.getPathAsString().equalsIgnoreCase(domainPath)){
-                    continue;
-}
-                if(logger.isDebugEnabled()){
-                    logger.debug("domain=" + domain.toString());
-                }
-                DocumentModelList domainChildrenList = repoSession.getChildren(domain.getRef());
-                Iterator<DocumentModel> witer = domainChildrenList.iterator();
-                while(witer.hasNext()){
-                    DocumentModel childNode = witer.next();
-                    if("Workspaces".equalsIgnoreCase(childNode.getName())){
-                        DocumentModelList workspaceList = repoSession.getChildren(childNode.getRef());
-                        Iterator<DocumentModel> wsiter = workspaceList.iterator();
-                        while(wsiter.hasNext()){
-                            DocumentModel workspace = wsiter.next();
-                            if(logger.isDebugEnabled()){
-                                logger.debug("workspace name=" + workspace.getName() +
-                                        " id=" + workspace.getId());
-                            }
-                            workspaceIds.put(workspace.getName().toLowerCase(), workspace.getId());
-                        }
-                    }
-                }
-            }
-        }catch(Exception e){
-            if(logger.isDebugEnabled()){
-                logger.debug("retrieveWorkspaceIds() caught exception ", e);
-            }
-            throw e;
-        }finally{
-            if(repoSession != null){
-                releaseRepositorySession(repoSession);
-            }
-        }
-        return workspaceIds;
-    }
-}
index 3da583a9b589931344100a25e8da8b4ce32cbf7e..e1f509b1a6bbfc41e7dc949e647408af9b2c62fc 100644 (file)
@@ -13,10 +13,10 @@ import org.collectionspace.services.common.api.JEEServerDeployment;
 import org.collectionspace.services.config.RepositoryClientConfigType;\r
 import org.collectionspace.services.config.tenant.RepositoryDomainType;\r
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
+\r
 import org.nuxeo.ecm.core.NXCore;\r
 import org.nuxeo.ecm.core.api.DocumentModel;\r
 import org.nuxeo.ecm.core.api.DocumentModelList;\r
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
 import org.nuxeo.ecm.core.model.Repository;\r
 import org.nuxeo.osgi.application.FrameworkBootstrap;\r
 import org.nuxeo.ecm.core.repository.RepositoryDescriptor;\r
@@ -145,7 +145,7 @@ public class NuxeoConnectorEmbedded {
                                        this.servletContext = servletContext;\r
                                        this.repositoryClientConfig = repositoryClientConfig;\r
                                        startNuxeoEP(serverRootPath);\r
-                                       client = new NuxeoClientEmbedded();\r
+                                       client = NuxeoClientEmbedded.getInstance();\r
                                        initialized = true;\r
                                }\r
                        }\r
@@ -183,7 +183,7 @@ public class NuxeoConnectorEmbedded {
         * @param repoSession\r
         * @throws java.lang.Exception\r
         */\r
-       public void releaseRepositorySession(RepositoryInstance repoSession)\r
+       public void releaseRepositorySession(RepositoryInstanceInterface repoSession)\r
                        throws Exception {\r
                if (repoSession != null) {\r
                        getClient().releaseRepository(repoSession);\r
@@ -200,8 +200,8 @@ public class NuxeoConnectorEmbedded {
         * @return RepositoryInstance\r
         * @throws java.lang.Exception\r
         */\r
-       public RepositoryInstance getRepositorySession(RepositoryDomainType repoDomain) throws Exception {\r
-               RepositoryInstance repoSession = getClient().openRepository(repoDomain);\r
+       public RepositoryInstanceInterface getRepositorySession(RepositoryDomainType repoDomain) throws Exception {\r
+               RepositoryInstanceInterface repoSession = getClient().openRepository(repoDomain);\r
                \r
                if (logger.isDebugEnabled() && repoSession != null) {\r
                        logger.debug("getRepositorySession() opened repository session");\r
@@ -288,7 +288,7 @@ public class NuxeoConnectorEmbedded {
         */\r
        public Hashtable<String, String> retrieveWorkspaceIds(RepositoryDomainType repoDomain)\r
                        throws Exception {\r
-               RepositoryInstance repoSession = null;\r
+               RepositoryInstanceInterface repoSession = null;\r
                Hashtable<String, String> workspaceIds = new Hashtable<String, String>();\r
                try {\r
                        repoSession = getRepositorySession(repoDomain);\r
diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorRemote.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorRemote.java
deleted file mode 100644 (file)
index bada25b..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-package org.collectionspace.services.nuxeo.client.java;\r
-\r
-import java.io.File;\r
-import java.util.Collection;\r
-import java.util.Hashtable;\r
-import java.util.Iterator;\r
-\r
-import org.collectionspace.services.config.RepositoryClientConfigType;\r
-import org.nuxeo.ecm.core.api.CoreInstance;\r
-import org.nuxeo.ecm.core.api.DocumentModel;\r
-import org.nuxeo.ecm.core.api.DocumentModelList;\r
-import org.nuxeo.ecm.core.api.repository.Repository;\r
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
-import org.nuxeo.ecm.core.api.repository.RepositoryManager;\r
-import org.nuxeo.ecm.core.client.DefaultLoginHandler;\r
-import org.nuxeo.ecm.core.client.NuxeoApp;\r
-import org.nuxeo.ecm.core.client.NuxeoClient;\r
-import org.nuxeo.osgi.application.FrameworkBootstrap;\r
-import org.nuxeo.runtime.api.Framework;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class NuxeoConnectorRemote {\r
-       public FrameworkBootstrap fb;\r
-       public final static String NUXEO_CLIENT_DIR = "nuxeo-client";\r
-       private Logger logger = LoggerFactory.getLogger(NuxeoConnectorRemote.class);\r
-       private static final NuxeoConnectorRemote self = new NuxeoConnectorRemote();\r
-       private static final String NUXEO_CLIENT_USERNAME = "NUXEO_CLIENT_USERNAME";\r
-       private static final String NUXEO_CLIENT_PASSWORD = "NUXEO_CLIENT_PASSWORD";\r
-       private NuxeoClient client;\r
-       private volatile boolean initialized = false; // use volatile for lazy\r
-                                                                                                       // initialization in\r
-                                                                                                       // singleton\r
-       private RepositoryClientConfigType repositoryClientConfig;\r
-\r
-       private NuxeoConnectorRemote() {\r
-       }\r
-\r
-       public final static NuxeoConnectorRemote getInstance() {\r
-               return self;\r
-       }\r
-\r
-       private String getClientUserName(\r
-                       RepositoryClientConfigType repositoryClientConfig) {\r
-               String username = System.getenv(NUXEO_CLIENT_USERNAME);\r
-               if (username == null) {\r
-                       username = repositoryClientConfig.getUser();\r
-               }\r
-               return username;\r
-       }\r
-\r
-       private String getClientPassword(\r
-                       RepositoryClientConfigType repositoryClientConfig) {\r
-               String password = System.getenv(NUXEO_CLIENT_PASSWORD);\r
-               if (password == null) {\r
-                       password = repositoryClientConfig.getPassword();\r
-               }\r
-               return password;\r
-       }\r
-\r
-       private void startNuxeoEP() throws Exception {\r
-               String nuxeoHome = "nuxeo-client/";\r
-               String serverRootDir = System.getProperty("jboss.server.home.dir");\r
-               if (serverRootDir == null) {\r
-                       serverRootDir = "."; // assume server is started from server root,\r
-                                                                       // e.g. server/cspace\r
-               }\r
-               File nuxeoHomeDir = new File(serverRootDir + File.separator + nuxeoHome);\r
-               logger.info("Loading Nuxeo configuration from: "\r
-                               + nuxeoHomeDir.getAbsolutePath());\r
-               if (nuxeoHomeDir.exists() == false) {\r
-                       String msg = "Library bundles requried to deploy Nuxeo client not found: "\r
-                                       + " directory named nuxeo-client with bundles does not exist in "\r
-                                       + serverRootDir;\r
-                       logger.error(msg);\r
-                       throw new IllegalStateException(msg);\r
-               }\r
-               fb = new FrameworkBootstrap(NuxeoConnectorRemote.class.getClassLoader(),\r
-                               nuxeoHomeDir);\r
-               fb.initialize();\r
-               fb.start();\r
-       }\r
-\r
-       /**\r
-        * release releases resources occupied by Nuxeo remoting client runtime\r
-        * \r
-        * @throws java.lang.Exception\r
-        */\r
-       public void release() throws Exception {\r
-               if (initialized == true) {\r
-                       try {\r
-                               client.tryDisconnect();\r
-                       } catch (Exception e) {\r
-                               logger.error("Failed to disconnect Nuxeo connection.", e);\r
-                               throw e;\r
-                       }\r
-               }\r
-       }\r
-\r
-       public void initialize(RepositoryClientConfigType repositoryClientConfig)\r
-                       throws Exception {\r
-               if (initialized == false) {\r
-                       synchronized (this) {\r
-                               if (initialized == false) {\r
-                                       try {\r
-                                               this.repositoryClientConfig = repositoryClientConfig;\r
-                                               startNuxeoEP();\r
-                                               // client = NuxeoClient.getInstance();\r
-                                               client = new NuxeoClient();\r
-                                               String username = getClientUserName(repositoryClientConfig);\r
-                                               String password = getClientPassword(repositoryClientConfig);\r
-                                               DefaultLoginHandler loginHandler = new DefaultLoginHandler(\r
-                                                               username, password);\r
-                                               client.setLoginHandler(loginHandler);\r
-                                               client.tryConnect(repositoryClientConfig.getHost(),\r
-                                                               repositoryClientConfig.getPort());\r
-                                               if (logger.isDebugEnabled()) {\r
-                                                       logger.debug("initialize(): connection successful port="\r
-                                                                       + repositoryClientConfig.getPort());\r
-                                               }\r
-                                               initialized = true;\r
-                                       } catch (Exception e) {\r
-                                               if (logger.isDebugEnabled()) {\r
-                                                       logger.debug("Caught exception while initializing",\r
-                                                                       e);\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       /**\r
-        * releaseRepositorySession releases given repository session\r
-        * \r
-        * @param repoSession\r
-        * @throws java.lang.Exception\r
-        */\r
-       public void releaseRepositorySession(RepositoryInstance repoSession)\r
-                       throws Exception {\r
-               if (repoSession != null) {\r
-                       getClient().releaseRepository(repoSession);\r
-\r
-                       if (logger.isDebugEnabled()) {\r
-                               logger.debug("releaseRepositorySession() released repository session");\r
-                       }\r
-               }\r
-       }\r
-\r
-       /**\r
-        * getRepositorySession get session to default repository\r
-        * \r
-        * @return RepositoryInstance\r
-        * @throws java.lang.Exception\r
-        */\r
-       public RepositoryInstance getRepositorySession() throws Exception {\r
-               RepositoryInstance repoSession = getClient().openRepository();\r
-               if (logger.isDebugEnabled()) {\r
-                       logger.debug("getRepositorySession() opened repository session");\r
-               }\r
-               return repoSession;\r
-\r
-               // Repository repository =\r
-               // Framework.getService(RepositoryManager.class).getDefaultRepository();\r
-               // session = repository.open();\r
-\r
-       }\r
-\r
-       /**\r
-        * getClient get Nuxeo client for accessing Nuxeo services remotely using\r
-        * Nuxeo Java (EJB) Remote APIS\r
-        * \r
-        * @return NuxeoClient\r
-        * @throws java.lang.Exception\r
-        */\r
-       public NuxeoClient getClient() throws Exception {\r
-               if (initialized == true) {\r
-                       if (client.isConnected()) {\r
-                               client.login();\r
-                               return client;\r
-                       } else {\r
-                               client.forceConnect(repositoryClientConfig.getHost(),\r
-                                               repositoryClientConfig.getPort());\r
-                               if (logger.isDebugEnabled()) {\r
-                                       logger.debug("getClient(): connection successful port="\r
-                                                       + repositoryClientConfig.getPort());\r
-                               }\r
-                               return client;\r
-                       }\r
-               }\r
-               String msg = "NuxeoConnector is not initialized!";\r
-               logger.error(msg);\r
-               throw new IllegalStateException(msg);\r
-       }\r
-\r
-       /**\r
-        * retrieveWorkspaceIds retrieves all workspace ids from default repository\r
-        * \r
-        * @param tenantDomain\r
-        *            domain representing tenant\r
-        * @return\r
-        * @throws java.lang.Exception\r
-        */\r
-       public Hashtable<String, String> retrieveWorkspaceIds(String tenantDomain)\r
-                       throws Exception {\r
-               RepositoryInstance repoSession = null;\r
-               Hashtable<String, String> workspaceIds = new Hashtable<String, String>();\r
-               try {\r
-                       repoSession = getRepositorySession();\r
-                       DocumentModel rootDoc = repoSession.getRootDocument();\r
-                       DocumentModelList rootChildrenList = repoSession\r
-                                       .getChildren(rootDoc.getRef());\r
-                       Iterator<DocumentModel> diter = rootChildrenList.iterator();\r
-                       while (diter.hasNext()) {\r
-                               DocumentModel domain = diter.next();\r
-                               String domainPath = "/" + tenantDomain;\r
-                               if (!domain.getPathAsString().equalsIgnoreCase(domainPath)) {\r
-                                       continue;\r
-                               }\r
-                               if (logger.isDebugEnabled()) {\r
-                                       logger.debug("domain=" + domain.toString());\r
-                               }\r
-                               DocumentModelList domainChildrenList = repoSession\r
-                                               .getChildren(domain.getRef());\r
-                               Iterator<DocumentModel> witer = domainChildrenList.iterator();\r
-                               while (witer.hasNext()) {\r
-                                       DocumentModel childNode = witer.next();\r
-                                       if ("Workspaces".equalsIgnoreCase(childNode.getName())) {\r
-                                               DocumentModelList workspaceList = repoSession\r
-                                                               .getChildren(childNode.getRef());\r
-                                               Iterator<DocumentModel> wsiter = workspaceList\r
-                                                               .iterator();\r
-                                               while (wsiter.hasNext()) {\r
-                                                       DocumentModel workspace = wsiter.next();\r
-                                                       if (logger.isDebugEnabled()) {\r
-                                                               logger.debug("workspace name="\r
-                                                                               + workspace.getName() + " id="\r
-                                                                               + workspace.getId());\r
-                                                       }\r
-                                                       workspaceIds.put(workspace.getName().toLowerCase(),\r
-                                                                       workspace.getId());\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
-               } catch (Exception e) {\r
-                       if (logger.isDebugEnabled()) {\r
-                               logger.debug("retrieveWorkspaceIds() caught exception ", e);\r
-                       }\r
-                       throw e;\r
-               } finally {\r
-                       if (repoSession != null) {\r
-                               releaseRepositorySession(repoSession);\r
-                       }\r
-               }\r
-               return workspaceIds;\r
-       }\r
-       \r
-       @Deprecated\r
-    private void loadBundles() throws Exception {\r
-    }\r
-       \r
-}\r
index 1cbbb33c2a2d69b4b784446bcd3014c40b583805..6cc3b95a0b60f6ed457b49d6174ba472741955c5 100644 (file)
@@ -619,7 +619,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                boolean releaseRepoSession = false;
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
                RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
-               RepositoryInstance repoSession = this.getRepositorySession();
+               RepositoryInstanceInterface repoSession = this.getRepositorySession();
                if (repoSession == null) {
                        repoSession = repoClient.getRepositorySession(ctx);
                        releaseRepoSession = true;
@@ -1431,7 +1431,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         if (hasRefNameUpdate() == true) {
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
             RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = getRepositoryClient(ctx);
-            RepositoryInstance repoSession = this.getRepositorySession();
+            RepositoryInstanceInterface repoSession = this.getRepositorySession();
             
             // Update all the relationship records that referred to the old refName
             RefNameServiceUtils.updateRefNamesInRelations(ctx, repoClient, repoSession,
diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceInterface.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceInterface.java
new file mode 100644 (file)
index 0000000..2537811
--- /dev/null
@@ -0,0 +1,152 @@
+package org.collectionspace.services.nuxeo.client.java;
+
+import java.security.Principal;
+
+import org.nuxeo.ecm.core.api.ClientException;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.nuxeo.ecm.core.api.DocumentRef;
+import org.nuxeo.ecm.core.api.Filter;
+import org.nuxeo.ecm.core.api.IterableQueryResult;
+import org.nuxeo.ecm.core.api.event.DocumentEventTypes;
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
+
+public interface RepositoryInstanceInterface {
+
+       public RepositoryInstance getRepositoryInstance();
+       
+    /**
+     * Gets the root document of this repository.
+     *
+     * @return the root document. cannot be null
+     * @throws ClientException
+     * @throws SecurityException
+     */
+    public DocumentModel getRootDocument() throws ClientException;
+    
+    /**
+     * Gets the current session id.
+     * <p>
+     * If the client is not connected returns null.
+     *
+     * @return the session id or null if not connected
+     */
+    public String getSessionId();
+
+    /**
+     * 
+     * @throws Exception
+     */
+    public void close() throws Exception;
+    
+    /**
+     * Returns the repository name against which this core session is bound.
+     *
+     * @return the repository name used currently used as an identifier
+     */
+    public String getRepositoryName();
+    
+    /**
+     * Gets the principal that created the client session.
+     *
+     * @return the principal
+     */
+    public Principal getPrincipal();
+
+    public IterableQueryResult queryAndFetch(String query, String queryType,
+            Object... params) throws ClientException;
+
+    public DocumentModelList query(String query, Filter filter, long limit,
+            long offset, boolean countTotal) throws ClientException;
+
+    public DocumentModelList query(String query) throws ClientException;
+
+    /**
+     * Executes the given NXQL query an returns the result.
+     *
+     * @param query the query to execute
+     * @param max number of document to retrieve
+     * @return the query result
+     * @throws ClientException
+     */
+    public DocumentModelList query(String query, int max) throws ClientException;
+
+    /**
+     * Gets a document model given its reference.
+     * <p>
+     * The default schemas are used to populate the returned document model.
+     * Default schemas are configured via the document type manager.
+     * <p>
+     * Any other data model not part of the default schemas will be lazily
+     * loaded as needed.
+     *
+     * @param docRef the document reference
+     * @return the document
+     * @throws ClientException
+     * @throws SecurityException
+     */
+    public DocumentModel getDocument(DocumentRef docRef) throws ClientException;
+
+    public DocumentModel saveDocument(DocumentModel docModel) throws ClientException;
+
+    public void save() throws ClientException;
+
+    /**
+     * Bulk document saving.
+     *
+     * @param docModels the document models that needs to be saved
+     * @throws ClientException
+     */
+    public void saveDocuments(DocumentModel[] docModels) throws ClientException;
+
+    /**
+     * Removes this document and all its children, if any.
+     *
+     * @param docRef the reference to the document to remove
+     * @throws ClientException
+     */
+    public void removeDocument(DocumentRef docRef) throws ClientException;
+
+    /**
+     * Creates a document model using required information.
+     * <p>
+     * Used to fetch initial datamodels from the type definition.
+     * <p>
+     * DocumentModel creation notifies a
+     * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
+     * listener can initialize its content with computed properties.
+     *
+     * @param parentPath
+     * @param id
+     * @param typeName
+     * @return the initial document model
+     * @throws ClientException
+     */
+    public DocumentModel createDocumentModel(String parentPath, String id,
+            String typeName) throws ClientException;
+    
+    /**
+     * Creates a document using given document model for initialization.
+     * <p>
+     * The model contains path of the new document, its type and optionally the
+     * initial data models of the document.
+     * <p>
+     *
+     * @param model the document model to use for initialization
+     * @return the created document
+     * @throws ClientException
+     */
+    public DocumentModel createDocument(DocumentModel model) throws ClientException;
+    
+    /**
+     * Gets the children of the given parent.
+     *
+     * @param parent the parent reference
+     * @return the children if any, an empty list if no children or null if the
+     *         specified parent document is not a folder
+     * @throws ClientException
+     */
+    public DocumentModelList getChildren(DocumentRef parent) throws ClientException;
+
+    
+}
diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceWrapper.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceWrapper.java
new file mode 100644 (file)
index 0000000..797805a
--- /dev/null
@@ -0,0 +1,197 @@
+package org.collectionspace.services.nuxeo.client.java;
+
+import java.security.Principal;
+
+import org.nuxeo.ecm.core.api.ClientException;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.nuxeo.ecm.core.api.DocumentRef;
+import org.nuxeo.ecm.core.api.Filter;
+import org.nuxeo.ecm.core.api.IterableQueryResult;
+import org.nuxeo.ecm.core.api.NoRollbackOnException;
+import org.nuxeo.ecm.core.api.event.DocumentEventTypes;
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
+
+public class RepositoryInstanceWrapper implements RepositoryInstanceInterface {
+
+       private RepositoryInstance repoSession;
+       
+       public RepositoryInstanceWrapper(RepositoryInstance repoSession) {
+               this.repoSession = repoSession;
+       }
+
+       @Override
+       public  RepositoryInstance getRepositoryInstance() {
+               return repoSession;
+       }
+       
+       @Override
+    public String getSessionId() {
+       return repoSession.getSessionId();
+    }
+    
+    @Override
+    public void close() throws Exception {
+       repoSession.close();
+    }
+
+    /**
+     * Gets the root document of this repository.
+     *
+     * @return the root document. cannot be null
+     * @throws ClientException
+     * @throws SecurityException
+     */
+       @Override
+    public DocumentModel getRootDocument() throws ClientException {
+       return repoSession.getRootDocument();
+    }
+    
+    /**
+     * Returns the repository name against which this core session is bound.
+     *
+     * @return the repository name used currently used as an identifier
+     */
+       @Override
+    public String getRepositoryName() {
+               return repoSession.getRepositoryName();
+       }
+    
+    /**
+     * Gets the principal that created the client session.
+     *
+     * @return the principal
+     */
+       @Override
+       public Principal getPrincipal() {
+               return repoSession.getPrincipal();
+       }
+
+       @Override
+       public IterableQueryResult queryAndFetch(String query, String queryType,
+            Object... params) throws ClientException {
+               return repoSession.queryAndFetch(query, queryType, params);
+       }
+
+       @Override
+       public DocumentModelList query(String query, Filter filter, long limit,
+            long offset, boolean countTotal) throws ClientException {
+               return repoSession.query(query, filter, limit, offset, countTotal);
+       }
+
+       @Override
+    public DocumentModelList query(String query, int max) throws ClientException {
+       return repoSession.query(query, max);
+    }
+    
+       @Override
+       public DocumentModelList query(String query) throws ClientException {
+               return repoSession.query(query);
+       }
+
+    /**
+     * Gets a document model given its reference.
+     * <p>
+     * The default schemas are used to populate the returned document model.
+     * Default schemas are configured via the document type manager.
+     * <p>
+     * Any other data model not part of the default schemas will be lazily
+     * loaded as needed.
+     *
+     * @param docRef the document reference
+     * @return the document
+     * @throws ClientException
+     * @throws SecurityException
+     */
+    @NoRollbackOnException
+    @Override
+    public DocumentModel getDocument(DocumentRef docRef) throws ClientException {
+           return repoSession.getDocument(docRef);
+    }
+
+    @Override
+    public DocumentModel saveDocument(DocumentModel docModel) throws ClientException {
+       return repoSession.saveDocument(docModel);
+    }
+
+    @Override
+    public void save() throws ClientException {
+       repoSession.save();
+    }
+
+    /**
+     * Bulk document saving.
+     *
+     * @param docModels the document models that needs to be saved
+     * @throws ClientException
+     */
+    @Override
+    public void saveDocuments(DocumentModel[] docModels) throws ClientException {
+       repoSession.saveDocuments(docModels);
+    }
+
+    /**
+     * Removes this document and all its children, if any.
+     *
+     * @param docRef the reference to the document to remove
+     * @throws ClientException
+     */
+    @Override
+    public void removeDocument(DocumentRef docRef) throws ClientException {
+       repoSession.removeDocument(docRef);
+    }
+
+    /**
+     * Creates a document model using required information.
+     * <p>
+     * Used to fetch initial datamodels from the type definition.
+     * <p>
+     * DocumentModel creation notifies a
+     * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
+     * listener can initialize its content with computed properties.
+     *
+     * @param parentPath
+     * @param id
+     * @param typeName
+     * @return the initial document model
+     * @throws ClientException
+     */
+    @Override
+    public DocumentModel createDocumentModel(String parentPath, String id,
+            String typeName) throws ClientException {
+       return repoSession.createDocumentModel(parentPath, id, typeName);
+    }
+    
+    /**
+     * Creates a document using given document model for initialization.
+     * <p>
+     * The model contains path of the new document, its type and optionally the
+     * initial data models of the document.
+     * <p>
+     *
+     * @param model the document model to use for initialization
+     * @return the created document
+     * @throws ClientException
+     */
+    @Override
+    public DocumentModel createDocument(DocumentModel model) throws ClientException {
+       return repoSession.createDocument(model);
+    }
+    
+    /**
+     * Gets the children of the given parent.
+     *
+     * @param parent the parent reference
+     * @return the children if any, an empty list if no children or null if the
+     *         specified parent document is not a folder
+     * @throws ClientException
+     */
+    @NoRollbackOnException
+    @Override
+    public DocumentModelList getChildren(DocumentRef parent) throws ClientException {
+       return repoSession.getChildren(parent);
+    }
+
+    
+       
+}
index 86bcd01f7609d1bedae1c519d302676fe14491bb..4af1eeca5b5d7bd209d81e40f2912e32f9952280 100644 (file)
@@ -55,6 +55,7 @@ import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.document.DocumentWrapperImpl;
 import org.collectionspace.services.common.document.TransactionException;
 import org.collectionspace.services.config.tenant.RepositoryDomainType;
+
 import org.nuxeo.common.utils.IdUtils;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -65,7 +66,6 @@ import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl;
 import org.nuxeo.ecm.core.api.DocumentRef;
 import org.nuxeo.ecm.core.api.IdRef;
 import org.nuxeo.ecm.core.api.PathRef;
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
 import org.nuxeo.runtime.transaction.TransactionRuntimeException;
 
 //
@@ -95,7 +95,7 @@ import org.slf4j.LoggerFactory;
  * $LastChangedRevision: $ $LastChangedDate: $
  */
 public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn, PoxPayloadOut> {
-
+       
     /**
      * The logger.
      */
@@ -174,7 +174,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                     + " check if the workspace exists in the Nuxeo repository");
         }
 
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             handler.prepare(Action.CREATE);
             repoSession = getRepositorySession(ctx);
@@ -236,7 +236,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                     "RepositoryJavaClient.get: handler is missing");
         }
 
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             handler.prepare(Action.GET);
             repoSession = getRepositorySession(ctx);
@@ -287,7 +287,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     public void get(ServiceContext ctx, DocumentHandler handler)
             throws DocumentNotFoundException, TransactionException, DocumentException {
         QueryContext queryContext = new QueryContext(ctx, handler);
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
 
         try {
             handler.prepare(Action.GET);
@@ -328,7 +328,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     }
 
     public DocumentWrapper<DocumentModel> getDoc(
-            RepositoryInstance repoSession,
+               RepositoryInstanceInterface repoSession,
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
             String csid) throws DocumentNotFoundException, DocumentException {
         DocumentWrapper<DocumentModel> wrapDoc = null;
@@ -367,7 +367,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     public DocumentWrapper<DocumentModel> getDoc(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
             String csid) throws DocumentNotFoundException, TransactionException, DocumentException {
-        RepositoryInstance repoSession = null;
+       RepositoryInstanceInterface repoSession = null;
         DocumentWrapper<DocumentModel> wrapDoc = null;
 
         try {
@@ -396,7 +396,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     }
 
     public DocumentWrapper<DocumentModel> findDoc(
-            RepositoryInstance repoSession,
+               RepositoryInstanceInterface repoSession,
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
             String whereClause)
             throws DocumentNotFoundException, DocumentException {
@@ -450,7 +450,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
             String whereClause)
             throws DocumentNotFoundException, TransactionException, DocumentException {
-        RepositoryInstance repoSession = null;
+       RepositoryInstanceInterface repoSession = null;
         DocumentWrapper<DocumentModel> wrapDoc = null;
 
         try {
@@ -483,7 +483,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      * @return the CollectionSpace ID (CSID) of the requested document
      */
     @Override
-    public String findDocCSID(RepositoryInstance repoSession,
+    public String findDocCSID(RepositoryInstanceInterface repoSession,
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String whereClause)
             throws DocumentNotFoundException, TransactionException, DocumentException {
         String csid = null;
@@ -517,7 +517,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
 
     public DocumentWrapper<DocumentModelList> findDocs(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-            RepositoryInstance repoSession,
+            RepositoryInstanceInterface repoSession,
             List<String> docTypes,
             String whereClause,
             String orderByClause,
@@ -573,7 +573,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     public DocumentWrapper<DocumentModelList> findDocs(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
             DocumentHandler handler,
-            RepositoryInstance repoSession,
+            RepositoryInstanceInterface repoSession,
             List<String> docTypes)
             throws DocumentNotFoundException, DocumentException {
         DocumentWrapper<DocumentModelList> wrapDoc = null;
@@ -632,7 +632,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             String whereClause,
             int pageSize, int pageNum, boolean computeTotal)
             throws DocumentNotFoundException, TransactionException, DocumentException {
-        RepositoryInstance repoSession = null;
+       RepositoryInstanceInterface repoSession = null;
         DocumentWrapper<DocumentModelList> wrapDoc = null;
 
         try {
@@ -670,7 +670,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                     "RepositoryJavaClient.getAll: handler is missing");
         }
 
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             handler.prepare(Action.GET_ALL);
             repoSession = getRepositorySession(ctx);
@@ -727,7 +727,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                     + " check if the workspace exists in the Nuxeo repository.");
         }
 
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             handler.prepare(Action.GET_ALL);
             repoSession = getRepositorySession(ctx);
@@ -762,7 +762,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
 
     public DocumentWrapper<DocumentModel> getDocFromCsid(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-            RepositoryInstance repoSession,
+            RepositoryInstanceInterface repoSession,
             String csid)
             throws Exception {
         DocumentWrapper<DocumentModel> result = null;
@@ -784,7 +784,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             String csid)
             throws Exception {
         DocumentWrapper<DocumentModel> result = null;
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             repoSession = getRepositorySession(ctx);
             result = getDocFromCsid(ctx, repoSession, csid);
@@ -819,7 +819,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     /*
      * See CSPACE-5036 - How to make CMISQL queries from Nuxeo
      */
-    private IterableQueryResult makeCMISQLQuery(RepositoryInstance repoSession, String query, QueryContext queryContext) throws DocumentException {
+    private IterableQueryResult makeCMISQLQuery(RepositoryInstanceInterface repoSession, String query, QueryContext queryContext) throws DocumentException {
         IterableQueryResult result = null;
 
         // the NuxeoRepository should be constructed only once, then cached
@@ -836,7 +836,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             callContext.put(CallContext.USERNAME, repoSession.getPrincipal()
                     .getName());
             NuxeoCmisService cmisService = new NuxeoCmisService(repo,
-                    callContext, repoSession);
+                    callContext, repoSession.getRepositoryInstance());
 
             result = repoSession.queryAndFetch(query, "CMISQL", cmisService);
         } catch (ClientException e) {
@@ -870,7 +870,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         }
         QueryContext queryContext = new QueryContext(ctx, handler);
 
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             handler.prepare(Action.GET_ALL);
             repoSession = getRepositorySession(ctx); //Keeps a refcount here for the repository session so you need to release this when finished
@@ -934,7 +934,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      * @return a list of document models matching the search criteria.
      * @throws Exception 
      */
-    private DocumentModelList getFilteredJDBC(RepositoryInstance repoSession, ServiceContext ctx, 
+    private DocumentModelList getFilteredJDBC(RepositoryInstanceInterface repoSession, ServiceContext ctx, 
             DocumentHandler handler) throws Exception {
         DocumentModelList result = new DocumentModelListImpl();
 
@@ -1200,7 +1200,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     }
     
 
-    private DocumentModelList getFilteredCMIS(RepositoryInstance repoSession, ServiceContext ctx, DocumentHandler handler, QueryContext queryContext)
+    private DocumentModelList getFilteredCMIS(RepositoryInstanceInterface repoSession, ServiceContext ctx, DocumentHandler handler, QueryContext queryContext)
             throws DocumentNotFoundException, DocumentException {
 
         DocumentModelList result = new DocumentModelListImpl();
@@ -1312,7 +1312,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                     "RepositoryJavaClient.update: document handler is missing.");
         }
 
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             handler.prepare(Action.UPDATE);
             repoSession = getRepositorySession(ctx);
@@ -1385,7 +1385,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      */
     public void saveDocWithoutHandlerProcessing(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-            RepositoryInstance repoSession,
+            RepositoryInstanceInterface repoSession,
             DocumentModel docModel,
             boolean fSaveSession)
             throws ClientException, DocumentException {
@@ -1418,7 +1418,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      */
     public void saveDocListWithoutHandlerProcessing(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-            RepositoryInstance repoSession,
+            RepositoryInstanceInterface repoSession,
             DocumentModelList docList,
             boolean fSaveSession)
             throws ClientException, DocumentException {
@@ -1457,7 +1457,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         if (logger.isDebugEnabled()) {
             logger.debug("Deleting document with CSID=" + id);
         }
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             handler.prepare(Action.DELETE);
             repoSession = getRepositorySession(ctx);
@@ -1506,7 +1506,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
 
     @Override
     public String createDomain(RepositoryDomainType repositoryDomain) throws Exception {
-        RepositoryInstance repoSession = null;
+       RepositoryInstanceInterface repoSession = null;
         String domainId = null;
         try {
             //
@@ -1564,7 +1564,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     @Override
     public String getDomainId(RepositoryDomainType repositoryDomain) throws Exception {
         String domainId = null;
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
 
         String repoName = repositoryDomain.getRepositoryName();
         String domainStorageName = repositoryDomain.getStorageName();
@@ -1594,7 +1594,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     /*
      * Returns the workspaces root directory for a given domain.
      */
-    private DocumentModel getWorkspacesRoot(RepositoryInstance repoSession,
+    private DocumentModel getWorkspacesRoot(RepositoryInstanceInterface repoSession,
             String domainName) throws Exception {
         DocumentModel result = null;
 
@@ -1625,7 +1625,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      */
     @Override
     public String createWorkspace(RepositoryDomainType repositoryDomain, String workspaceName) throws Exception {
-        RepositoryInstance repoSession = null;
+       RepositoryInstanceInterface repoSession = null;
         String workspaceId = null;
         try {
             String repoName = repositoryDomain.getRepositoryName();
@@ -1672,7 +1672,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     public String getWorkspaceId(String tenantDomain, String workspaceName) throws Exception {
         String workspaceId = null;
 
-        RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
         try {
             repoSession = getRepositorySession((ServiceContext) null);
             DocumentRef docRef = new PathRef(
@@ -1697,11 +1697,11 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         return workspaceId;
     }
 
-    public RepositoryInstance getRepositorySession(ServiceContext ctx) throws Exception {
+    public RepositoryInstanceInterface getRepositorySession(ServiceContext ctx) throws Exception {
         return getRepositorySession(ctx, ctx.getRepositoryName());
     }
 
-    public RepositoryInstance getRepositorySession(String repoName) throws Exception {
+    public RepositoryInstanceInterface getRepositorySession(String repoName) throws Exception {
         return getRepositorySession(null, repoName);
     }
 
@@ -1712,8 +1712,8 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      * @return the repository session
      * @throws Exception the exception
      */
-    public RepositoryInstance getRepositorySession(ServiceContext ctx, String repoName) throws Exception {
-        RepositoryInstance repoSession = null;
+    public RepositoryInstanceInterface getRepositorySession(ServiceContext ctx, String repoName) throws Exception {
+       RepositoryInstanceInterface repoSession = null;
 
         Profiler profiler = new Profiler("getRepositorySession():", 2);
         profiler.start();
@@ -1722,7 +1722,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         //
         if (ctx != null) {
             repoName = ctx.getRepositoryName(); // Notice we are overriding the passed in 'repoName' since we have a valid service context passed in to us
-            repoSession = (RepositoryInstance) ctx.getCurrentRepositorySession(); // Look to see if one exists in the context before creating one
+            repoSession = (RepositoryInstanceInterface) ctx.getCurrentRepositorySession(); // Look to see if one exists in the context before creating one
         } else if (repoName == null || repoName.trim().isEmpty()) {
             String errMsg = String.format("We can't get a connection to the Nuxeo repo because the service context passed in was null and no repository name was passed in either.");
             logger.error(errMsg);
@@ -1763,7 +1763,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      *
      * @param repoSession the repo session
      */
-    public void releaseRepositorySession(ServiceContext ctx, RepositoryInstance repoSession) throws TransactionException {
+    public void releaseRepositorySession(ServiceContext ctx, RepositoryInstanceInterface repoSession) throws TransactionException {
         try {
             NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();
             // release session
index 761a77c124a4f1a2e706f936c2c8af74aa4b9a3b..b7c5127522c4061927527d1f55975a9510d953f5 100644 (file)
@@ -41,10 +41,9 @@ import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentUtils;
 import org.collectionspace.services.common.query.QueryContext;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentException;
-
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.dom4j.Document;
 import org.dom4j.io.SAXReader;
-
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.ClientException;
@@ -67,7 +66,6 @@ import org.nuxeo.ecm.core.search.api.client.querymodel.descriptor.QueryModelDesc
 import org.nuxeo.ecm.core.storage.sql.Binary;
 import org.nuxeo.ecm.core.storage.sql.coremodel.SQLBlob;
 import org.nuxeo.runtime.api.Framework;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -222,7 +220,7 @@ public class NuxeoUtils {
      * @return
      * @throws DocumentException
      */
-    public static Document getDocument(RepositoryInstance repoSession, DocumentModel nuxeoDoc)
+    public static Document getDocument(RepositoryInstanceInterface repoSession, DocumentModel nuxeoDoc)
             throws DocumentException {
         Document doc = null;
         DocumentWriter writer = null;
@@ -232,7 +230,7 @@ public class NuxeoUtils {
         try {
             baos = new ByteArrayOutputStream();
             //nuxeo io.impl begin
-            reader = new SingleDocumentReader(repoSession, nuxeoDoc);
+            reader = new SingleDocumentReader(repoSession.getRepositoryInstance(), nuxeoDoc);
             writer = new XMLDocumentWriter(baos);
             DocumentPipe pipe = new DocumentPipeImpl();
             //nuxeo io.impl end
@@ -282,7 +280,7 @@ public class NuxeoUtils {
      *
      * @throws DocumentException the document exception
      */
-    public static Document getDocument(RepositoryInstance repoSession, String csid)
+    public static Document getDocument(RepositoryInstanceInterface repoSession, String csid)
             throws DocumentException {
         Document result = null;
 
@@ -305,7 +303,7 @@ public class NuxeoUtils {
      * @throws ClientException the client exception
      */
     public static DocumentModel getWorkspaceModel(
-            RepositoryInstance repoSession, String workspaceName)
+               RepositoryInstanceInterface repoSession, String workspaceName)
             throws DocumentException, IOException, ClientException {
         DocumentModel result = null;
         //FIXME: commented out as this does not work without tenant qualification
@@ -332,7 +330,7 @@ public class NuxeoUtils {
      * @throws DocumentException the document exception
      */
     public static DocumentModel getDocumentModel(
-            RepositoryInstance repoSession, String nuxeoId)
+               RepositoryInstanceInterface repoSession, String nuxeoId)
             throws DocumentException {
         DocumentModel result = null;
 
@@ -538,7 +536,7 @@ public class NuxeoUtils {
     
     static public DocumentModel getDocFromCsid(
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-               RepositoryInstance repoSession,
+               RepositoryInstanceInterface repoSession,
                String csid) throws Exception {
            DocumentModel result = null;
        
@@ -623,7 +621,7 @@ public class NuxeoUtils {
         return id;
     }
     
-    public static boolean documentExists(RepositoryInstance repoSession,
+    public static boolean documentExists(RepositoryInstanceInterface repoSession,
                String csid) throws ClientException {
                boolean result = false;
                
diff --git a/services/config/.gitignore b/services/config/.gitignore
new file mode 100644 (file)
index 0000000..19f2e00
--- /dev/null
@@ -0,0 +1,2 @@
+/target
+/target
diff --git a/services/hyperjaxb/.gitignore b/services/hyperjaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
index 53d39f0f93e947ffc4eebf0114767289d1e9f85a..32d6dc5c3e3d57af47fa05e47e5b566c9c829b6f 100644 (file)
@@ -5,9 +5,11 @@ import java.util.Calendar;
 import java.util.HashMap;\r
 import java.util.Map;\r
 import java.util.TreeSet;\r
+\r
 import org.collectionspace.services.common.api.Tools;\r
 import org.collectionspace.services.nuxeo.client.java.NuxeoClientEmbedded;\r
 import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
 import org.nuxeo.ecm.core.api.DocumentModel;\r
 import org.nuxeo.ecm.core.api.DocumentRef;\r
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
@@ -30,7 +32,7 @@ public class ImportCommand {
         File file = new File(src);\r
         ///cspace way of configuring client and auth:\r
         NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();\r
-        RepositoryInstance repoSession = null;\r
+        RepositoryInstanceInterface repoSession = null;\r
         try {\r
             repoSession = client.openRepository(repoName, timeOut);\r
             if (logger.isDebugEnabled()) {\r
@@ -49,7 +51,7 @@ public class ImportCommand {
         }\r
     }\r
 \r
-    String importTree(RepositoryInstance repoSession, File file, String toPath) throws Exception {\r
+    String importTree(RepositoryInstanceInterface repoSession, File file, String toPath) throws Exception {\r
         Exception failed = null;\r
         DocumentReader reader = null;\r
         DocumentWriter writer = null;\r
@@ -65,7 +67,7 @@ public class ImportCommand {
                 logger.info("importTree reading file: " + file + (file != null ? " exists? " + file.exists() : " file param is null"));\r
             }\r
             reader = new LoggedXMLDirectoryReader(file);  //our overload of XMLDirectoryReader.\r
-            writer = new DocumentModelWriter(repoSession, toPath, 10);\r
+            writer = new DocumentModelWriter(repoSession.getRepositoryInstance(), toPath, 10);\r
             DocumentPipe pipe = new DocumentPipeImpl(10);\r
             // pipe.addTransformer(transformer);\r
             pipe.setReader(reader);\r
diff --git a/services/jaxb/.gitignore b/services/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
diff --git a/services/movement/jaxb/.gitignore b/services/movement/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
diff --git a/services/objectexit/jaxb/.gitignore b/services/objectexit/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
diff --git a/services/organization/jaxb/.gitignore b/services/organization/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
index 8f82b6e0a00fa9f26c8e6eb682a64b3d04f4a62f..2d34e46baa42891e3e37e051440adc6a22240eab 100644 (file)
@@ -60,9 +60,9 @@ import org.collectionspace.services.client.PlaceAuthorityClient;
 import org.collectionspace.services.client.WorkAuthorityClient;
 import org.collectionspace.services.client.ConceptAuthorityClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
-
 import org.collectionspace.services.config.service.ServiceBindingType;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -101,7 +101,7 @@ public class RelationDocumentModelHandler
        DocumentModel relationDocModel = wrapDoc.getWrappedObject();
        String errMsg = ERROR_TERMS_IN_WORKFLOWSTATE + workflowState;
                        
-        RepositoryInstance repoSession = this.getRepositorySession();
+       RepositoryInstanceInterface repoSession = this.getRepositorySession();
         try {
                        DocumentModel subjectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, SUBJ_DOC_MODEL);
                        DocumentModel objectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, OBJ_DOC_MODEL);
@@ -178,7 +178,7 @@ public class RelationDocumentModelHandler
         // Note that this introduces another caching problem... 
         DocumentModel relationDocModel = wrapDoc.getWrappedObject();
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
-        RepositoryInstance repoSession = this.getRepositorySession();
+        RepositoryInstanceInterface repoSession = this.getRepositorySession();
         
         DocumentModel subjectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, SUBJ_DOC_MODEL);
         DocumentModel objectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, OBJ_DOC_MODEL);
@@ -376,7 +376,7 @@ public class RelationDocumentModelHandler
     private final boolean OBJ_DOC_MODEL = false;
     
     private DocumentModel getSubjectOrObjectDocModel(
-               RepositoryInstance repoSession,
+               RepositoryInstanceInterface repoSession,
                DocumentModel relationDocModel,
                boolean fSubject) throws Exception {
        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
index 104f33d685669f435414fac2c908ab89c68d9214..ecd7764db177ce38f39e43559ef5e2801eb0ed2a 100644 (file)
@@ -78,6 +78,7 @@ import org.collectionspace.services.common.invocable.InvocationContext;
 import org.collectionspace.services.common.storage.JDBCTools;
 import org.collectionspace.services.jaxb.InvocableJAXBSchema;
 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.jfree.util.Log;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -108,7 +109,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
                        InvocationContext invContext,
                        StringBuffer outMimeType,
                        StringBuffer outReportFileName) throws Exception {
-               RepositoryInstance repoSession = null;
+               RepositoryInstanceInterface repoSession = null;
                boolean releaseRepoSession = false;
 
                String invocationMode = invContext.getMode();
index 874ad09952265ab60025df9ade27f0b18b98a72f..257dc729ab789dbf8feea877b3c10ad9a9c61936 100644 (file)
@@ -35,6 +35,7 @@ import javax.ws.rs.core.Response;
 import org.collectionspace.services.ServiceGroupListItemJAXBSchema;
 import org.collectionspace.services.nuxeo.client.java.CommonList;
 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
@@ -84,7 +85,7 @@ public class ServiceGroupDocumentModelHandler
                List<String> serviceGroupNames) throws Exception {
         CommonList commonList = new CommonList();
         AbstractCommonList list = (AbstractCommonList)commonList;
-       RepositoryInstance repoSession = null;
+        RepositoryInstanceInterface repoSession = null;
        boolean releaseRepoSession = false;
         
        try { 
diff --git a/services/taxonomy/jaxb/.gitignore b/services/taxonomy/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target
diff --git a/services/vocabulary/jaxb/.gitignore b/services/vocabulary/jaxb/.gitignore
new file mode 100644 (file)
index 0000000..ea8c4bf
--- /dev/null
@@ -0,0 +1 @@
+/target