]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5129: Cleaned up repository session managment and transaction management when...
authorRichard Millet <remillet@berkeley.edu>
Wed, 20 Jun 2012 01:30:45 +0000 (18:30 -0700)
committerRichard Millet <remillet@berkeley.edu>
Wed, 20 Jun 2012 01:30:45 +0000 (18:30 -0700)
19 files changed:
3rdparty/nuxeo/build.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/Hierarchy.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/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java
services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java
services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java
services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java
services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java
services/relation/service/src/main/java/org/collectionspace/services/relation/RelationResource.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

index 9c65cb2bb1dcf71ea7130b8fbb4d3641e752aeb4..e29826f698d52b8d043793577637d183459750d0 100644 (file)
             <fileset dir="${basedir}/nuxeo-server/${nuxeo.release}/config"/>\r
             <filterset>\r
                 <filter token="DB" value="${db}" />\r
-                               <filter token="DB_URL" value="jdbc:${db}://localhost:${db.port}/nuxeo${db.url.suffix}" />\r
+                               <filter token="DB_URL" value="jdbc:${db}://localhost:${db.port}/nuxeo"/>\r
                                <filter token="XA_DATASOURCE" value="${db.xaDataSource}" />\r
                 <filter token="NUXEO_USER" value="${db.nuxeo.user}" />\r
                 <filter token="NUXEO_PW" value="${db.nuxeo.user.password}" />\r
index 4da271f926ab5a28015c2b5748c9d817b87a8484..5f166ffaeed4afe78d12fbf9435148450d12d7a8 100644 (file)
          File below this line have been ported. -->\r
     <!-- ============================================= -->\r
     \r
+<!--     \r
     <run controlFile="./security.xml" testGroup="deleteBug" />\r
     <run controlFile="objectexit/object-exit.xml" testGroup="makeone" />\r
     <run controlFile="objectexit/object-exit.xml" testGroup="checkList" />\r
     <run controlFile="objectexit/object-exit-display.xml" testGroup="refNameDisplayNameOnly" />\r
-<!--     \r
  -->\r
  \r
+<!--\r
     <run controlFile="collectionobject/collectionobject-adv-search.xml" testGroup="advSearchCommonSchema" />\r
     <run controlFile="collectionobject/collectionobject-adv-search.xml" testGroup="advSearchExtensionSchema" />\r
     <run controlFile="acquisitions/acquisitions.xml" testGroup="makeone" />\r
     <run controlFile="acquisitions/acquisitions.xml" testGroup="testList" />\r
     <run controlFile="relation/relation.xml" testGroup="makeRelations" />\r
-<!--\r
 -->\r
 \r
 <!-- No - this test is broken\r
        <run controlFile="relation/relation.xml" testGroup="r2only" />\r
 -->\r
 \r
+<!-- \r
     <run controlFile="person/person.xml" testGroup="postPerson" />\r
     <run controlFile="person/person.xml" testGroup="updatePerson" />\r
+ -->    \r
     <run controlFile="person/person.xml" testGroup="PersonAddRelsDeleteRels" />\r
 \r
+<!-- \r
     <run controlFile="location/location-hierarchy.xml" testGroup="HierarchicLocation" />\r
     <run controlFile="organization/organization-hierarchy.xml" testGroup="HierarchicOrganization" />\r
  \r
@@ -66,6 +69,7 @@
     <run controlFile="authrefs/authrefsSimple.xml" testGroup="AuthRefsSimple" />\r
     <run controlFile="authrefs/authrefsComplex.xml" testGroup="AuthRefsComplex" />\r
     <run controlFile="imports/imports.xml" testGroup="importsTestGroup" />\r
-    \r
+ -->\r
+     \r
 </xmlReplayMaster>\r
 \r
index 058f67a64860e6c490cc5cfe4cf8becfcf49c998..fcee903af552707dda5f8850e9c5507fb84fd880 100644 (file)
@@ -59,6 +59,7 @@ import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.collectionspace.services.workflow.WorkflowCommon;
 import org.jboss.resteasy.util.HttpResponseCodes;
 import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,7 +72,6 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MultivaluedMap;
@@ -80,9 +80,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 
-import java.util.ArrayList;
 import java.util.List;
-import org.collectionspace.services.client.*;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 
 /**
@@ -205,7 +203,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
      * 
      * @throws Exception the exception
      */
-    protected DocumentHandler createItemDocumentHandler(
+    protected DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> createItemDocumentHandler(
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
             String inAuthority, String parentShortIdentifier)
             throws Exception {
@@ -288,7 +286,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         } else {
             parentShortIdentifier = parentSpec.value;
             String whereClause = buildWhereForAuthByName(parentSpec.value);
-            ServiceContext ctx = createServiceContext(getServiceName(), queryParams);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getServiceName(), queryParams);
             parentcsid = getRepositoryClient(ctx).findDocCSID(null, ctx, whereClause); //FIXME: REM - If the parent has been soft-deleted, should we be looking for the item?
         }
         result.CSID = parentcsid;
@@ -296,7 +294,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         return result;
     }
 
-    public String lookupItemCSID(String itemspecifier, String parentcsid, String method, String op, ServiceContext ctx)
+    public String lookupItemCSID(String itemspecifier, String parentcsid, String method, String op, ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx)
             throws DocumentException {
         String itemcsid;
         Specifier itemSpec = getSpecifier(itemspecifier, method, op);
@@ -322,7 +320,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
        }
         String whereClause = buildWhereForAuthByName(item.getParentShortIdentifier());
         // Ensure we have the right context.
-        ServiceContext ctx = createServiceContext(item.inAuthority.resource);
+        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(item.inAuthority.resource);
         
         // HACK - this really must be moved to the doc handler, not here. No Nuxeo specific stuff here!
         RepositoryJavaClientImpl client = (RepositoryJavaClientImpl)getRepositoryClient(ctx);
@@ -341,7 +339,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         try {
             PoxPayloadIn input = new PoxPayloadIn(xmlPayload);
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input);
-            DocumentHandler handler = createDocumentHandler(ctx);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
             String csid = getRepositoryClient(ctx).create(ctx, handler);
             UriBuilder path = UriBuilder.fromResource(resourceClass);
             path.path("" + csid);
@@ -383,7 +381,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         PoxPayloadOut result = null;
         try {
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
-            DocumentHandler handler = createDocumentHandler(ctx);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
 
             Specifier spec = getSpecifier(specifier, "getAuthority", "GET");
             if (spec.form == SpecifierForm.CSID) {
@@ -426,7 +424,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         try {
             MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
-            DocumentHandler handler = createDocumentHandler(ctx);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
             DocumentFilter myFilter = handler.getDocumentFilter();
             // Need to make the default sort order for authority items
             // be on the displayName field
@@ -441,7 +439,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                 myFilter.setWhereClause(authorityCommonSchemaName + ":refName='" + nameQ + "'");
             }
             getRepositoryClient(ctx).getFiltered(ctx, handler);
-            return (AbstractCommonList) handler.getCommonPartList();
+            return handler.getCommonPartList();
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.GET_FAILED);
         }
@@ -465,7 +463,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload);
             Specifier spec = getSpecifier(specifier, "updateAuthority", "UPDATE");
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(theUpdate);
-            DocumentHandler handler = createDocumentHandler(ctx);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
             String csid;
             if (spec.form == SpecifierForm.CSID) {
                 csid = spec.value;
@@ -497,7 +495,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         try {
             ensureCSID(csid, ServiceMessages.DELETE_FAILED, "Authority.csid");
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
-            DocumentHandler handler = createDocumentHandler(ctx);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
             getRepositoryClient(ctx).delete(ctx, csid, handler);
             return Response.status(HttpResponseCodes.SC_OK).build();
         } catch (Exception e) {
@@ -516,13 +514,13 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                @PathParam("csid") String specifier, String xmlPayload) {
         try {
             PoxPayloadIn input = new PoxPayloadIn(xmlPayload);
-            ServiceContext ctx = createServiceContext(getItemServiceName(), input);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), input);
             ctx.setResourceMap(resourceMap);
             ctx.setUriInfo(ui);    //Laramie
 
             // Note: must have the parentShortId, to do the create.
             CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(specifier, "createAuthorityItem", "CREATE_ITEM", null);
-            DocumentHandler handler = createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier);
             String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
             UriBuilder path = UriBuilder.fromResource(resourceClass);
             path.path(parent.CSID + "/items/" + itemcsid);
@@ -574,7 +572,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
 
             // Create a service context and document handler for the parent resource.
             ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext(getItemServiceName());
-            DocumentHandler parentDocHandler = this.createDocumentHandler(parentCtx);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> parentDocHandler = this.createDocumentHandler(parentCtx);
             ctx.setProperty(WorkflowClient.PARENT_DOCHANDLER, parentDocHandler); //added as a context param for the workflow document handler -it will call the parent's dochandler "prepareForWorkflowTranstion" method
 
             // When looking for the document, we need to use the parent's workspace name -not the "workflow" workspace name
@@ -617,13 +615,13 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItem(parent)", "GET_ITEM", queryParams);
 
             RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
-            ctx = (RemoteServiceContext) createServiceContext(getItemServiceName(), queryParams);
+            ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(getItemServiceName(), queryParams);
             ctx.setJaxRsContext(jaxRsContext);
 
             ctx.setUriInfo(ui); //ARG!   must pass this or subsequent calls will not have a ui.
 
             // We omit the parentShortId, only needed when doing a create...
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, null);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
 
             Specifier itemSpec = getSpecifier(itemspecifier, "getAuthorityItem(item)", "GET_ITEM");
             if (itemSpec.form == SpecifierForm.CSID) {
@@ -706,7 +704,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
 
             // For the wildcard case, parentcsid is null, but docHandler will deal with this.
             // We omit the parentShortId, only needed when doing a create...
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, null);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
             
             DocumentFilter myFilter = handler.getDocumentFilter();
             // Need to make the default sort order for authority items
@@ -753,7 +751,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                         + " and ORDER BY clause: " + myFilter.getOrderByClause());
             }
             getRepositoryClient(ctx).getFiltered(ctx, handler);
-            return (AbstractCommonList) handler.getCommonPartList();
+            return handler.getCommonPartList();
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.LIST_FAILED);
         }
@@ -845,8 +843,8 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
 
             ctx = createServiceContext(getItemServiceName(), queryParams);
             // We omit the parentShortId, only needed when doing a create...
-            DocumentModelHandler handler =
-                    (DocumentModelHandler)createItemDocumentHandler(ctx, parentcsid, null);
+            DocumentModelHandler<?, AbstractCommonList> handler =
+                    (DocumentModelHandler<?, AbstractCommonList>)createItemDocumentHandler(ctx, parentcsid, null);
 
             String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getAuthorityItemAuthRefs(item)", "GET_ITEM_AUTH_REFS", ctx);
 
@@ -886,7 +884,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM", ctx);
 
             // We omit the parentShortId, only needed when doing a create...
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, null);
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
             ctx.setUriInfo(ui);
             getRepositoryClient(ctx).update(ctx, itemcsid, handler);
             result = ctx.getOutput();
@@ -923,8 +921,8 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             // }
             // try {
             // Note that we have to create the service context for the Items, not the main service
-            ServiceContext ctx = createServiceContext(getItemServiceName());
-            DocumentHandler handler = createDocumentHandler(ctx);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName());
+            DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
             getRepositoryClient(ctx).delete(ctx, itemcsid, handler);
             return Response.status(HttpResponseCodes.SC_OK).build();
         } catch (Exception e) {
@@ -943,7 +941,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             // All items in dive can look at their child uri's to get uri.  So we calculate the very first one.  We could also do a GET and look at the common part uri field, but why...?
             String calledUri = ui.getPath();
             String uri = "/" + calledUri.substring(0, (calledUri.length() - ("/" + hierarchy).length()));
-            ServiceContext ctx = createServiceContext(getItemServiceName());
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName());
             ctx.setUriInfo(ui);
             String direction = ui.getQueryParameters().getFirst(Hierarchy.directionQP);
             if (Tools.notBlank(direction) && Hierarchy.direction_parents.equals(direction)) {
index 8da76472200544adb33ae667ab7bfbd2eb2ed903..ef862a46a4643200ef3d2d60332b393f6a3e5e62 100644 (file)
@@ -24,6 +24,8 @@
 
 package org.collectionspace.services.common.vocabulary;
 
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.XmlTools;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.context.ServiceContext;
@@ -49,25 +51,28 @@ public class Hierarchy {
      * @param uri informational, optional - if not known, pass an empty String.
      * @return String of XML document, including xml processing instruction, root node is "&lt;hierarchy&gt;".
      */
-    public static String dive(ServiceContext ctx, String itemcsid, String uri) {
+    public static String dive(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String itemcsid, String uri) {
         String result = dive(ctx, itemcsid, uri, true);
         result =  "<?xml version='1.0' ?><hierarchy>"+result+"</hierarchy>";
         try {
             result = XmlTools.prettyPrint(result);
         } catch (Exception e){
+               // Do nothing
         }
         return result;
     }
 
-    private static String dive(ServiceContext ctx, String itemcsid, String uri, boolean lookupFirstName) {
-        MultivaluedMap queryParams = ctx.getUriInfo().getQueryParameters();
+    private static String dive(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String itemcsid, String uri, boolean lookupFirstName) {
+        MultivaluedMap<String, String> queryParams = ctx.getUriInfo().getQueryParameters();
         //Run getList() once as sent to get childListOuter:
         queryParams.putSingle(IRelationsManager.PREDICATE_QP, RelationshipType.HAS_BROADER.value());
         queryParams.putSingle(IRelationsManager.SUBJECT_QP, null);
         queryParams.putSingle(IRelationsManager.SUBJECT_TYPE_QP, null);
         queryParams.putSingle(IRelationsManager.OBJECT_QP, itemcsid);
         queryParams.putSingle(IRelationsManager.OBJECT_TYPE_QP, null);
-        RelationsCommonList childListOuter = (new RelationResource()).getList(ctx.getUriInfo());    //magically knows all query params because they are in the context.
+        
+        RelationResource relationResource = new RelationResource();
+        RelationsCommonList childListOuter = relationResource.getList(ctx);    // Knows all query params because they are in the context.
         List<RelationsCommonList.RelationListItem> childList = childListOuter.getRelationListItem();
 
         StringBuffer sb = new StringBuffer();
@@ -80,8 +85,10 @@ public class Hierarchy {
         } else {
             sb.append("<uri>" + uri + "</uri>\r\n");
         }
+        
         sb.append("<csid>" + itemcsid + "</csid>\r\n");
         sb.append("<children>\r\n");
+        
         for (RelationsCommonList.RelationListItem item : childList) {
             RelationsDocListItem parent = item.getObject();
             RelationsDocListItem child = item.getSubject();
@@ -98,28 +105,33 @@ public class Hierarchy {
         return sb.toString();
     }
 
-    public static String surface(ServiceContext ctx, String itemcsid, String uri) {
+    public static String surface(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String itemcsid, String uri) {
         String result = surface(ctx, itemcsid, uri, true).resultBuffer.toString();
         result =  "<?xml version='1.0' ?><hierarchy direction='"+direction_parents+"'>"+result+"</hierarchy>";
         try {
             result = XmlTools.prettyPrint(result);
         } catch (Exception e){
+               // Do nothing
         }
         return result;
     }
+    
     private static class SurfaceResultStruct {
         public StringBuffer resultBuffer;
         public boolean noParents = false;
     }
-    private static SurfaceResultStruct surface(ServiceContext ctx, String itemcsid, String uri, boolean first) {
-        MultivaluedMap queryParams = ctx.getUriInfo().getQueryParameters();
+    
+    private static SurfaceResultStruct surface(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String itemcsid, String uri, boolean first) {
+        MultivaluedMap<String, String> queryParams = ctx.getUriInfo().getQueryParameters();
         //Run getList() once as sent to get parentListOuter:
         queryParams.putSingle(IRelationsManager.PREDICATE_QP, RelationshipType.HAS_BROADER.value());
         queryParams.putSingle(IRelationsManager.SUBJECT_QP, itemcsid);
         queryParams.putSingle(IRelationsManager.SUBJECT_TYPE_QP, null);
         queryParams.putSingle(IRelationsManager.OBJECT_QP, null);
         queryParams.putSingle(IRelationsManager.OBJECT_TYPE_QP, null);
-        RelationsCommonList parentListOuter = (new RelationResource()).getList(ctx.getUriInfo());    //magically knows all query params because they are in the context.
+        
+        RelationResource relationResource = new RelationResource();
+        RelationsCommonList parentListOuter = relationResource.getList(ctx);    // Knows all query params because they are in the context.
         List<RelationsCommonList.RelationListItem> parentList = parentListOuter.getRelationListItem();
 
         StringBuffer sbOuter = new StringBuffer();
@@ -141,6 +153,7 @@ public class Hierarchy {
         if (parentList.size()==0){
             resultStruct.noParents = true;
         }
+        
         for (RelationsCommonList.RelationListItem item : parentList) {
             resultStruct.noParents = false;
             RelationsDocListItem parent = item.getObject();
@@ -188,5 +201,4 @@ public class Hierarchy {
 
         return resultStruct;
     }
-
 }
index e2b22a664784fa8e2a373da7a59a6fe4becaaa71..28953ba353466190e089b3962bbe7dae47469409 100644 (file)
@@ -130,7 +130,7 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
        RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
         try {
-               repoSession = nuxeoRepoClient.getRepositorySession();
+               repoSession = nuxeoRepoClient.getRepositorySession(ctx);
             DocumentWrapper<DocumentModel> wrapDoc = nuxeoRepoClient.getDocFromCsid(ctx, repoSession, authCSID);
             DocumentModel docModel = wrapDoc.getWrappedObject();
             shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER);
@@ -138,7 +138,7 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
             throw new RuntimeException("AuthorityDocHandler Internal Error: cannot get shortId!", ce);
         } finally {
                if (repoSession != null) {
-                       nuxeoRepoClient.releaseRepositorySession(repoSession);
+                       nuxeoRepoClient.releaseRepositorySession(ctx, repoSession);
                }
         }
         
index 369db347c5597047db85c34a8914629e428c2b90..56dff860ef2ec8295c280360f6c5f2962acf30cd 100644 (file)
@@ -30,6 +30,7 @@ import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.RelationClient;
+
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.api.CommonAPI;
 import org.collectionspace.services.common.api.RefName;
@@ -46,24 +47,24 @@ import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
 import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+
 import org.collectionspace.services.config.service.ListResultField;
 import org.collectionspace.services.config.service.ObjectPartType;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.nuxeo.client.java.CommonList; //FIXME: REM - 5/15/2012 - CommonList should be moved out of this package and into a more "common" package
+
 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+
 import org.collectionspace.services.relation.RelationResource;
 import org.collectionspace.services.relation.RelationsCommon;
 import org.collectionspace.services.relation.RelationsCommonList;
 import org.collectionspace.services.relation.RelationsDocListItem;
 import org.collectionspace.services.relation.RelationshipType;
+
 import org.collectionspace.services.vocabulary.VocabularyItemJAXBSchema;
 
 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.model.Property;
 import org.nuxeo.ecm.core.api.model.PropertyException;
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
 
@@ -71,6 +72,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import java.util.ArrayList;
@@ -441,11 +443,11 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
        RepositoryInstance repoSession = null;
        boolean releaseRepoSession = false;
         
-       try { 
+       try {
                RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
-                       repoSession = repoClient.getRepositorySession();
+                       repoSession = repoClient.getRepositorySession(ctx);
                        releaseRepoSession = true;
                }
             DocumentFilter myFilter = getDocumentFilter();
@@ -470,8 +472,9 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
                        }
                        throw new DocumentException(e);
                } finally {
+                       // If we got/aquired a new seesion then we're responsible for releasing it.
                        if (releaseRepoSession && repoSession != null) {
-                               repoClient.releaseRepositorySession(repoSession);
+                               repoClient.releaseRepositorySession(ctx, repoSession);
                        }
                }
        } catch (Exception e) {
@@ -479,7 +482,8 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
                        logger.debug("Caught exception ", e);
                }
                throw new DocumentException(e);
-       }               
+       }
+       
         return authRefDocList;
     }
 
@@ -818,13 +822,13 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         DocumentModel docModel = wrapDoc.getWrappedObject();
                String itemRefName = (String) docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME);
 
-        ServiceContext ctx = getServiceContext();
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
         //Do magic replacement of ${itemCSID} and fix URI's.
         fixupInboundListItems(ctx, inboundList, docModel, itemCSID);
 
         String HAS_BROADER = RelationshipType.HAS_BROADER.value();
         UriInfo uriInfo = ctx.getUriInfo();
-        MultivaluedMap queryParams = uriInfo.getQueryParameters();
+        MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
 
         if (fUpdate) {
             //Run getList() once as sent to get childListOuter:
@@ -834,13 +838,15 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
             queryParams.putSingle(IRelationsManager.SUBJECT_TYPE_QP, null);
             queryParams.putSingle(IRelationsManager.OBJECT_QP, itemCSID);
             queryParams.putSingle(IRelationsManager.OBJECT_TYPE_QP, null);
-            RelationsCommonList childListOuter = (new RelationResource()).getList(ctx.getUriInfo());    //magically knows all query params because they are in the context.
+            
+            RelationResource relationResource = new RelationResource();
+            RelationsCommonList childListOuter = relationResource.getList(ctx);    // Knows all query params because they are in the context.
 
             //Now run getList() again, leaving predicate, swapping subject and object, to get parentListOuter.
             queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate);
             queryParams.putSingle(IRelationsManager.SUBJECT_QP, itemCSID);
             queryParams.putSingle(IRelationsManager.OBJECT_QP, null);
-            RelationsCommonList parentListOuter = (new RelationResource()).getList(ctx.getUriInfo());
+            RelationsCommonList parentListOuter = relationResource.getList(ctx);
 
 
             childList = childListOuter.getRelationListItem();
@@ -855,7 +861,6 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
             }
         }
 
-
         for (RelationsCommonList.RelationListItem inboundItem : inboundList) {
             // Note that the relations may specify the other (non-item) bit with a refName, not a CSID,
             // and so the CSID for those may be null
@@ -939,12 +944,15 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         return relationsCommonListBody;
     }
 
-    private void ensureChildHasNoOtherParents(ServiceContext ctx, MultivaluedMap queryParams, String childCSID) {
+    private void ensureChildHasNoOtherParents(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+               MultivaluedMap<String, String> queryParams, String childCSID) {
         logger.trace("ensureChildHasNoOtherParents for: " + childCSID );
         queryParams.putSingle(IRelationsManager.SUBJECT_QP, childCSID);
         queryParams.putSingle(IRelationsManager.PREDICATE_QP, RelationshipType.HAS_BROADER.value());
         queryParams.putSingle(IRelationsManager.OBJECT_QP, null);  //null means ANY
-        RelationsCommonList parentListOuter = (new RelationResource()).getList(ctx.getUriInfo());
+        
+        RelationResource relationResource = new RelationResource();
+        RelationsCommonList parentListOuter = relationResource.getList(ctx);
         List<RelationsCommonList.RelationListItem> parentList = parentListOuter.getRelationListItem();
         //logger.warn("ensureChildHasNoOtherParents preparing to delete relations on "+childCSID+"\'s parent list: \r\n"+dumpList(parentList, "duplicate parent list"));
         deleteRelations(parentList, ctx, "parentList-delete");
@@ -981,7 +989,6 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         return sb.toString();
     }
     private final static String CR = "\r\n";
-    private final static String T = " ";
 
     private String dumpList(List<RelationsCommonList.RelationListItem> list, String label) {
         StringBuilder sb = new StringBuilder();
@@ -1045,7 +1052,8 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     }
 
     // this method calls the RelationResource to have it create the relations and persist them.
-    private void createRelations(List<RelationsCommonList.RelationListItem> inboundList, ServiceContext ctx) throws Exception {
+    private void createRelations(List<RelationsCommonList.RelationListItem> inboundList,
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) throws Exception {
         for (RelationsCommonList.RelationListItem item : inboundList) {
             RelationsCommon rc = new RelationsCommon();
             //rc.setCsid(item.getCsid());
@@ -1083,12 +1091,14 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
             PayloadOutputPart outputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMONPART_NAME, rc);
             payloadOut.addPart(outputPart);
             RelationResource relationResource = new RelationResource();
-            Object res = relationResource.create(ctx.getResourceMap(),
+            Response res = relationResource.create(ctx, ctx.getResourceMap(),
                     ctx.getUriInfo(), payloadOut.toXML());    //NOTE ui recycled from above to pass in unknown query params.
         }
     }
 
-    private void deleteRelations(List<RelationsCommonList.RelationListItem> list, ServiceContext ctx, String listName) {
+    private void deleteRelations(List<RelationsCommonList.RelationListItem> list,
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+               String listName) {
         try {
             for (RelationsCommonList.RelationListItem item : list) {
                 RelationResource relationResource = new RelationResource();
@@ -1097,7 +1107,10 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
                        itemToString(sb, "==== TO DELETE: ", item);
                        logger.trace(sb.toString());
                 }
-                Object res = relationResource.delete(item.getCsid());
+                Response res = relationResource.deleteWithParentCtx(ctx, item.getCsid());
+                if (logger.isDebugEnabled()) {
+                       logger.debug("Status of authority item deleteRelations method call was: " + res.getStatus());
+                }
             }
         } catch (Throwable t) {
             String msg = "Unable to deleteRelations: " + Tools.errorToString(t, true);
@@ -1206,14 +1219,14 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
 
     //================= TODO: move this to common, refactoring this and  CollectionObjectResource.java
     public RelationsCommonList getRelations(String subjectCSID, String objectCSID, String predicate) throws Exception {
-        ServiceContext ctx = getServiceContext();
-        MultivaluedMap queryParams = ctx.getQueryParams();
+        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
+        MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
         queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate);
         queryParams.putSingle(IRelationsManager.SUBJECT_QP, subjectCSID);
         queryParams.putSingle(IRelationsManager.OBJECT_QP, objectCSID);
 
         RelationResource relationResource = new RelationResource(); //is this still acting like a singleton as it should be?
-        RelationsCommonList relationsCommonList = relationResource.getList(ctx.getUriInfo());
+        RelationsCommonList relationsCommonList = relationResource.getList(ctx);
         return relationsCommonList;
     }
     //============================= END TODO refactor ==========================
index 4777d291f5b9b1073350c45797c2f1d16b10029b..4b2f2608d25d70b37ef313ed7ad75efebf9af73f 100644 (file)
@@ -91,7 +91,7 @@ public class BatchDocumentModelHandler
                RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
-                       repoSession = repoClient.getRepositorySession();
+                       repoSession = repoClient.getRepositorySession(ctx);
                        releaseRepoSession = true;
                }
 
@@ -133,7 +133,7 @@ public class BatchDocumentModelHandler
                        throw new DocumentException(e);
                } finally {
                        if (releaseRepoSession && repoSession != null) {
-                               repoClient.releaseRepositorySession(repoSession);
+                               repoClient.releaseRepositorySession(ctx, repoSession);
                        }
                }
                className = className.trim();
index 9334399d1822f987e0ffcc6072579a736de69e89..95f067c37ffdba62160ffcd63fd1affd2f9e796d 100644 (file)
@@ -29,20 +29,15 @@ package org.collectionspace.services.common;
 import java.util.Iterator;\r
 import java.util.List;\r
 \r
-import javax.ws.rs.Consumes;\r
 import javax.ws.rs.GET;\r
 import javax.ws.rs.PUT;\r
 import javax.ws.rs.Path;\r
 import javax.ws.rs.PathParam;\r
-import javax.ws.rs.Produces;\r
-import javax.ws.rs.WebApplicationException;\r
-import javax.ws.rs.core.Response;\r
 \r
 import org.collectionspace.services.client.PayloadOutputPart;\r
 import org.collectionspace.services.client.PoxPayloadIn;\r
 import org.collectionspace.services.client.PoxPayloadOut;\r
 import org.collectionspace.services.client.workflow.WorkflowClient;\r
-import org.collectionspace.services.common.api.Tools;\r
 import org.collectionspace.services.common.context.MultipartServiceContext;\r
 import org.collectionspace.services.common.context.MultipartServiceContextFactory;\r
 import org.collectionspace.services.common.context.ServiceContext;\r
@@ -51,10 +46,8 @@ import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler;\r
 import org.collectionspace.services.lifecycle.Lifecycle;\r
 import org.collectionspace.services.lifecycle.TransitionDef;\r
-import org.collectionspace.services.lifecycle.TransitionDefList;\r
 import org.collectionspace.services.workflow.WorkflowCommon;\r
 import org.dom4j.DocumentException;\r
-import org.jboss.resteasy.client.ClientResponse;\r
 \r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
index 38f34669a74a15e2902e6648538b259b19c1c5ac..7d8a55683244468cc2bbae3b31d7f6131d1a1ee2 100644 (file)
@@ -42,6 +42,7 @@ import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
 import org.jboss.resteasy.util.HttpResponseCodes;\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
 \r
 import javax.ws.rs.*;\r
@@ -52,7 +53,7 @@ import java.util.List;
 /**\r
  * $LastChangedRevision:  $\r
  * $LastChangedDate:  $\r
- * Author: laramie\r
+ * Author: Laramie Crocker\r
  */\r
 public abstract class ResourceBase\r
         extends AbstractMultiPartCollectionSpaceResourceImpl {\r
@@ -84,22 +85,36 @@ public abstract class ResourceBase
     //======================= CREATE ====================================================\r
     \r
     @POST\r
-    public Response create(@Context ResourceMap resourceMap, @Context UriInfo ui,\r
+    public Response create(@Context ResourceMap resourceMap,\r
+               @Context UriInfo ui,\r
             String xmlPayload) {\r
+        return this.create(null, resourceMap, ui, xmlPayload);\r
+    }\r
+    \r
+    public Response create(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,\r
+               @Context ResourceMap resourceMap,\r
+               @Context UriInfo ui,\r
+            String xmlPayload) {\r
+       Response result = null;\r
+       \r
         try {\r
             PoxPayloadIn input = new PoxPayloadIn(xmlPayload);\r
-            //System.out.println("\r\n\r\n==============================\r\nxmlPayload:\r\n"+xmlPayload);\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input);\r
             ctx.setResourceMap(resourceMap);\r
-            return create(input, ctx);\r
+            if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) {\r
+               ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists\r
+            }            \r
+            result = create(input, ctx);\r
         } catch (Exception e) {\r
             throw bigReThrow(e, ServiceMessages.CREATE_FAILED);\r
         }\r
-    }\r
-\r
+        \r
+        return result;\r
+    }    \r
+    \r
     protected Response create(PoxPayloadIn input, ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {\r
         try {\r
-            DocumentHandler handler = createDocumentHandler(ctx);\r
+            DocumentHandler<PoxPayloadIn, PoxPayloadOut, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);\r
             UriBuilder path = UriBuilder.fromResource(this.getClass());\r
             return create(input, ctx, handler, path); //==> CALL implementation method, which subclasses may override.\r
         } catch (Exception e) {\r
@@ -110,7 +125,7 @@ public abstract class ResourceBase
     /** Subclasses may override this overload, which gets called from @see #create(MultipartInput)   */\r
     protected Response create(PoxPayloadIn input,\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
-            DocumentHandler handler,\r
+            DocumentHandler<PoxPayloadIn, PoxPayloadOut, DocumentModel, DocumentModelList> handler,\r
             UriBuilder path)\r
             throws Exception {\r
         String csid = getRepositoryClient(ctx).create(ctx, handler);\r
@@ -163,7 +178,7 @@ public abstract class ResourceBase
         ensureCSID(csid, DELETE);\r
         try {\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();\r
-            return delete(csid, ctx);  //==> CALL implementation method, which subclasses may override.\r
+            return delete(ctx, csid);  //==> CALL implementation method, which subclasses may override.\r
         } catch (Exception e) {\r
             throw bigReThrow(e, ServiceMessages.DELETE_FAILED, csid);\r
         }\r
@@ -171,12 +186,27 @@ public abstract class ResourceBase
 \r
     /** subclasses may override this method, which is called from #delete(String)\r
      *  which handles setup of ServiceContext, and does Exception handling.  */\r
-    protected Response delete(String csid, ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx)\r
+    protected Response delete(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String csid)\r
             throws Exception {\r
-       DocumentHandler handler = createDocumentHandler(ctx);\r
+       DocumentHandler<PoxPayloadIn, PoxPayloadOut, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);\r
         getRepositoryClient(ctx).delete(ctx, csid, handler);\r
         return Response.status(HttpResponseCodes.SC_OK).build();\r
     }\r
+    \r
+    public Response deleteWithParentCtx(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,\r
+               String csid)\r
+            throws Exception {\r
+        ensureCSID(csid, DELETE);\r
+        try {\r
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();\r
+            if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) {\r
+               ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession()); // reuse the repo session if one exists\r
+            }\r
+            return delete(ctx, csid);  //==> CALL implementation method, which subclasses may override.\r
+        } catch (Exception e) {\r
+            throw bigReThrow(e, ServiceMessages.DELETE_FAILED, csid);\r
+        }\r
+    }    \r
 \r
     //======================= GET ====================================================\r
     @GET\r
@@ -244,7 +274,7 @@ public abstract class ResourceBase
         }\r
         return list;\r
     }\r
-\r
+    \r
     protected AbstractCommonList getList(MultivaluedMap<String, String> queryParams) {\r
         try {\r
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);\r
index d3fa9f3a72a7ab601c9d63023811ef429393a821..1b03aa47323fb2a4306a92e16f34bc2e3ce6a001 100644 (file)
@@ -93,8 +93,12 @@ public abstract class AbstractServiceContextImpl<IT, OT>
     private DocumentHandler docHandler = null;
     /** security context */
     private SecurityContext securityContext;
-
+    /** The sessions JAX-RS URI information */
     private UriInfo uriInfo;
+    /** The current repository session */
+    private Object currentRepositorySession;
+    /** A reference count for the current repository session */
+    private int currentRepoSesssionRefCount = 0;
 
     /**
      * Instantiates a new abstract service context impl.
@@ -626,8 +630,47 @@ public abstract class AbstractServiceContextImpl<IT, OT>
         this.uriInfo = ui;
     }
 
-   @Override
-   public UriInfo getUriInfo(){
-        return this.uriInfo;
-    }
+       @Override
+       public UriInfo getUriInfo() {
+               return this.uriInfo;
+       }
+       
+       /*
+        * We expect the 'currentRepositorySession' member to be set only once per instance.  Also, we expect only one open repository session
+        * per HTTP request.  We'll log an error if we see more than one attempt to set a service context's current repo session.
+        * (non-Javadoc)
+        * @see org.collectionspace.services.common.context.ServiceContext#setCurrentRepositorySession(java.lang.Object)
+        */
+       @Override
+       public void setCurrentRepositorySession(Object repoSession) throws Exception {
+               if (repoSession == null) {
+                       String errMsg = "Setting a service context's repository session to null is not allowed.";
+                       logger.error(errMsg);
+                       throw new Exception(errMsg);
+               } else if (currentRepositorySession != null && currentRepositorySession != repoSession) {
+                       String errMsg = "The current service context's repository session was replaced.  This may cause unexpected behavior and/or data loss.";
+                       logger.error(errMsg);
+                       throw new Exception(errMsg);
+               }
+               
+               currentRepositorySession = repoSession;
+               this.currentRepoSesssionRefCount++;
+       }
+       
+       @Override
+       public void clearCurrentRepositorySession() {
+               if (this.currentRepoSesssionRefCount > 0) {
+                       currentRepoSesssionRefCount--;
+               }
+               
+               if (currentRepoSesssionRefCount == 0) {
+                       this.currentRepositorySession = null;
+               }
+       }
+       
+       @Override
+       public Object getCurrentRepositorySession() {
+               // TODO Auto-generated method stub
+               return currentRepositorySession;
+       }       
 }
index 1c5f5c422087c65c52e38451b3298ce9f22ec183..23eee0bfc8c02a5b8d73de19db05bc62ea24bd00 100644 (file)
@@ -163,7 +163,7 @@ public class RemoteServiceContextImpl<IT, OT>
     @Override
     public ServiceContext getLocalContext(String localContextClassName) throws Exception {
         ClassLoader cloader = Thread.currentThread().getContextClassLoader();
-        Class ctxClass = cloader.loadClass(localContextClassName);
+        Class<?> ctxClass = cloader.loadClass(localContextClassName);
         if (!ServiceContext.class.isAssignableFrom(ctxClass)) {
             throw new IllegalArgumentException("getLocalContext requires "
                     + " implementation of " + ServiceContext.class.getName());
@@ -172,5 +172,5 @@ public class RemoteServiceContextImpl<IT, OT>
         Constructor ctor = ctxClass.getConstructor(java.lang.String.class);
         ServiceContext ctx = (ServiceContext) ctor.newInstance(getServiceName());
         return ctx;
-    }    
+    }
 }
index fee621f1b5c31ff8ea5aed61c8ca7b1481a5a887..dea896e93987e1ba0915bce0f9564f2fb210cb96 100644 (file)
@@ -60,6 +60,21 @@ public interface ServiceContext<IT, OT> {
     /** Used to qualify document types **/
        public static final String TENANT_SUFFIX = "Tenant";    
 
+       /* 
+        * Sets the current/open repository session
+        */
+       public void setCurrentRepositorySession(Object repoSession) throws Exception;
+       
+       /*
+        * Decrements the context's repo session ref count and nulls it if the count becomes 0.
+        */
+       public void clearCurrentRepositorySession();
+       
+       /*
+        * If a current repository session exists, returns it.
+        */
+       public Object getCurrentRepositorySession();
+       
     /**
      * getSecurityContext is contains security info. for the service layer
      */
index 7c944507011fb4be0aae43e6b2342ba97832c3b5..1f5c3a4b4dbffa5dd30ddfe2e47311f72f220df9 100644 (file)
@@ -727,7 +727,7 @@ public class NuxeoImageUtils {
                                        .getDigestAlgorithm(); // Need some way on initializing the\r
                                                                                        // FileManager with a call.\r
                        \r
-                       logger.debug("Start --> Calling Nuxeo to create an image blob.");\r
+                       logger.debug("Start --> Calling Nuxeo to create an image blob."); // See Nuxeo's DefaultPictureAdapter class for details\r
                        DocumentModel documentModel = getFileManagerService()\r
                                        .createDocumentFromBlob(nuxeoSession, fileBlob,\r
                                                        blobLocation.getPathAsString(), true,\r
index 68b3a6e0dde926622ac861cd716526850281ef27..623a86dc647ff34fd43a9f9eacd523f2adcd906b 100644 (file)
@@ -484,7 +484,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
                RepositoryInstance repoSession = this.getRepositorySession();
                if (repoSession == null) {
-                       repoSession = repoClient.getRepositorySession();
+                       repoSession = repoClient.getRepositorySession(ctx);
                        releaseRepoSession = true;
                }
                
@@ -504,7 +504,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                        }
                } finally {
                        if (releaseRepoSession == true) {
-                               repoClient.releaseRepositorySession(repoSession);
+                               repoClient.releaseRepositorySession(ctx, repoSession);
                        }
                }
                
index 7bf98618544fe7d535643b722001e852a43cbd58..9992e6f9882cf618cd5477cbec69235b7eb5ff2d 100644 (file)
@@ -154,7 +154,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         try {
             handler.prepare(Action.CREATE);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             DocumentRef nuxeoWspace = new IdRef(nuxeoWspaceId);
             DocumentModel wspaceDoc = repoSession.getDocument(nuxeoWspace);
             String wspacePath = wspaceDoc.getPathAsString();
@@ -179,7 +179,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
 
@@ -207,7 +207,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         try {
             handler.prepare(Action.GET);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             DocumentRef docRef = NuxeoUtils.createPathRef(ctx, id);
             DocumentModel docModel = null;
             try {
@@ -235,7 +235,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
     }
@@ -256,7 +256,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
 
         try {
             handler.prepare(Action.GET);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
 
             DocumentModelList docList = null;
             // force limit to 1, and ignore totalSize
@@ -287,7 +287,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
     }
@@ -335,7 +335,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
 
         try {
                // Open a new repository session
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             wrapDoc = getDoc(repoSession, ctx, csid);
         } catch (IllegalArgumentException iae) {
             throw iae;
@@ -348,7 +348,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
         
@@ -413,13 +413,13 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         DocumentWrapper<DocumentModel> wrapDoc = null;
 
         try {
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             wrapDoc = findDoc(repoSession, ctx, whereClause);
         } catch (Exception e) {
                        throw new DocumentException("Unable to create a Nuxeo repository session.", e);
                } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
         
@@ -443,8 +443,8 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         String csid = null;
         boolean releaseSession = false;
         try {
-               if(repoSession== null) {
-                       repoSession = this.getRepositorySession();
+               if (repoSession == null) {
+                       repoSession = this.getRepositorySession(ctx);
                        releaseSession = true;
                }
             DocumentWrapper<DocumentModel> wrapDoc = findDoc(repoSession, ctx, whereClause);
@@ -463,7 +463,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
                if(releaseSession && (repoSession != null)) {
-                       this.releaseRepositorySession(repoSession);
+                       this.releaseRepositorySession(ctx, repoSession);
                }
         }
         return csid;
@@ -520,7 +520,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         DocumentWrapper<DocumentModelList> wrapDoc = null;
 
         try {
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             wrapDoc = findDocs(ctx, repoSession, docTypes, whereClause,
                        pageSize, pageNum, computeTotal);
         } catch (IllegalArgumentException iae) {
@@ -532,7 +532,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
         
@@ -557,7 +557,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         try {
             handler.prepare(Action.GET_ALL);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             DocumentModelList docModelList = new DocumentModelListImpl();
             //FIXME: Should be using NuxeoUtils.createPathRef for security reasons
             for (String csid : csidList) {
@@ -580,7 +580,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
     }
@@ -613,7 +613,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         try {
             handler.prepare(Action.GET_ALL);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             DocumentRef wsDocRef = new IdRef(nuxeoWspaceId);
             DocumentModelList docList = repoSession.getChildren(wsDocRef);
             //set reposession to handle the document
@@ -630,7 +630,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
     }
@@ -669,11 +669,11 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         DocumentWrapper<DocumentModel> result = null;
         RepositoryInstance repoSession = null;
         try {
-               repoSession = getRepositorySession();
+               repoSession = getRepositorySession(ctx);
                result = getDocFromCsid(ctx, repoSession, csid);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
         
@@ -751,7 +751,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         try {
             handler.prepare(Action.GET_ALL);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx); //Need a refcount here for the repository session?
             
             DocumentModelList docList = null;
             String query = NuxeoUtils.buildNXQLQuery(ctx, queryContext);
@@ -789,7 +789,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
     }
@@ -893,7 +893,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         try {
             handler.prepare(Action.UPDATE);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             DocumentRef docRef = NuxeoUtils.createPathRef(ctx, csid);
             DocumentModel doc = null;
             try {
@@ -924,7 +924,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
     }
@@ -974,7 +974,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             boolean fSaveSession)
             throws ClientException, DocumentException {
         try {
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             DocumentModel[] docModelArray = new DocumentModel[docList.size()];
             repoSession.saveDocuments(docList.toArray(docModelArray));
             if (fSaveSession) {
@@ -1012,7 +1012,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         try {
                handler.prepare(Action.DELETE);
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(ctx);
             DocumentWrapper<DocumentModel> wrapDoc = null;
             try {
                DocumentRef docRef = NuxeoUtils.createPathRef(ctx, id);
@@ -1035,7 +1035,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(ctx, repoSession);
             }
         }
     }
@@ -1064,7 +1064,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                //
                // First create the top-level domain directory
                //
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(null);
             DocumentRef parentDocRef = new PathRef("/");
             DocumentModel parentDoc = repoSession.getDocument(parentDocRef);
             DocumentModel domainDoc = repoSession.createDocumentModel(parentDoc.getPathAsString(),
@@ -1101,7 +1101,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw e;
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(null, repoSession);
             }
         }
         
@@ -1115,7 +1115,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         
         if (domainName != null && !domainName.isEmpty()) {
                try {
-                   repoSession = getRepositorySession();
+                   repoSession = getRepositorySession(null);
                    DocumentRef docRef = new PathRef(
                            "/" + domainName);
                    DocumentModel domain = repoSession.getDocument(docRef);
@@ -1129,7 +1129,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                    return null;
                } finally {
                    if (repoSession != null) {
-                       releaseRepositorySession(repoSession);
+                       releaseRepositorySession(null, repoSession);
                    }
                }
         }
@@ -1174,7 +1174,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         RepositoryInstance repoSession = null;
         String workspaceId = null;
         try {
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(null);
             DocumentModel parentDoc = getWorkspacesRoot(repoSession, domainName);            
             DocumentModel doc = repoSession.createDocumentModel(parentDoc.getPathAsString(),
                     workspaceName, NuxeoUtils.WORKSPACE_DOCUMENT_TYPE);
@@ -1195,7 +1195,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw e;
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(null, repoSession);
             }
         }
         return workspaceId;
@@ -1210,7 +1210,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         
         RepositoryInstance repoSession = null;
         try {
-            repoSession = getRepositorySession();
+            repoSession = getRepositorySession(null);
             DocumentRef docRef = new PathRef(
                     "/" + tenantDomain
                     + "/" + NuxeoUtils.Workspaces
@@ -1226,7 +1226,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         } finally {
             if (repoSession != null) {
-                releaseRepositorySession(repoSession);
+                releaseRepositorySession(null, repoSession);
             }
         }
         
@@ -1240,19 +1240,37 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      * @return the repository session
      * @throws Exception the exception
      */
-    public RepositoryInstance getRepositorySession() throws Exception {
-        // FIXME: is it possible to reuse repository session?
-        // Authentication failures happen while trying to reuse the session
+    public RepositoryInstance getRepositorySession(ServiceContext ctx) throws Exception {
+       RepositoryInstance repoSession = null;
+       
        Profiler profiler = new Profiler("getRepositorySession():", 2);
        profiler.start();
-       
-        NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();
-        RepositoryInstance repoSession = client.openRepository();
+               
+        if (ctx != null) {
+               repoSession = (RepositoryInstance)ctx.getCurrentRepositorySession();
+            if (logger.isDebugEnabled() == true) {
+               if (repoSession != null) {
+                       logger.warn("Reusing the current context's repository session.");
+               }
+            }          
+        }
+        
+        // If we couldn't find a repoSession from the service context then we need to create a new one
+        if (repoSession == null) {
+               NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();
+               repoSession = client.openRepository();
+        }
+        
         if (logger.isTraceEnabled()) {
             logger.trace("Testing call to getRepository() repository root: " + repoSession.getRootDocument());
         }
         
         profiler.stop();
+        
+        if (ctx != null) {
+               ctx.setCurrentRepositorySession(repoSession); // For reusing, save the repository session in the current service context
+        }
+        
         return repoSession;
     }
 
@@ -1261,11 +1279,18 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
      *
      * @param repoSession the repo session
      */
-    public void releaseRepositorySession(RepositoryInstance repoSession) {
+    public void releaseRepositorySession(ServiceContext ctx, RepositoryInstance repoSession) {
         try {
             NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();
             // release session
-            client.releaseRepository(repoSession);
+            if (ctx != null) {
+               ctx.clearCurrentRepositorySession(); //clear the current context of the now closed repo session
+               if (ctx.getCurrentRepositorySession() == null) {
+                    client.releaseRepository(repoSession); //release the repo session if the service context's ref count is zeo.
+               }
+            } else {
+                client.releaseRepository(repoSession); //repo session was acquired without a service context
+            }
         } catch (Exception e) {
             logger.error("Could not close the repository session", e);
             // no need to throw this service specific exception
index 2b67aee62e2a39a6ce763358463e475a3a447773..4f16a9f3d8bbed4611cb3df19a5299d2cdfbe235 100644 (file)
@@ -299,7 +299,7 @@ public class MediaResource extends ResourceBase {
                //
                // Now that we've handled the related Blob record, delete the Media record
                //
-            return super.delete(csid, ctx);
+            return super.delete(ctx, csid);
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.DELETE_FAILED, csid);
         }
index 05c60e2c36158ac5049944336a936b441786d764..0095039c8b71027437a257831779c4b29532d126 100644 (file)
@@ -54,6 +54,7 @@ import javax.ws.rs.core.UriInfo;
 public class RelationResource extends ResourceBase {
        public final static String serviceName = "relations";
        final Logger logger = LoggerFactory.getLogger(RelationResource.class);
+       
        @Override
        protected String getVersionString() {
                final String lastChangeRevision = "$LastChangedRevision$";
@@ -67,12 +68,23 @@ public class RelationResource extends ResourceBase {
     public Class<RelationsCommon> getCommonPartClass() {
        return RelationsCommon.class;
     }
-
+       
        @Override
        @GET
        @Produces("application/xml")
-       public RelationsCommonList getList(@Context UriInfo ui) {
-               MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+       public RelationsCommonList getList(@Context UriInfo uriInfo) {
+               return this.getList(null, uriInfo);
+       }
+
+       public RelationsCommonList getList(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx) {
+               return this.getList(parentCtx, parentCtx.getUriInfo());
+       }
+       
+       private RelationsCommonList getList(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx, UriInfo uriInfo) {
+               if (parentCtx != null) {
+                       uriInfo = parentCtx.getUriInfo(); //Override the input param and use the parent context's UriInfo
+               }
+               MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
 
                String subjectCsid = queryParams.getFirst(IRelationsManager.SUBJECT_QP);
                String subjectType = queryParams.getFirst(IRelationsManager.SUBJECT_TYPE_QP);
@@ -80,13 +92,21 @@ public class RelationResource extends ResourceBase {
                String objectCsid = queryParams.getFirst(IRelationsManager.OBJECT_QP);
                String objectType = queryParams.getFirst(IRelationsManager.OBJECT_TYPE_QP);
 
-               return this.getRelationList(queryParams, subjectCsid, subjectType, predicate, objectCsid, objectType);
+               return this.getRelationList(parentCtx, queryParams, subjectCsid, subjectType, predicate, objectCsid, objectType);
        }
 
-    private RelationsCommonList getRelationList(MultivaluedMap<String, String> queryParams, String subjectCsid, String subjectType,
-                                                                         String predicate, String objectCsid, String objectType) throws WebApplicationException {
+    private RelationsCommonList getRelationList(
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,
+               MultivaluedMap<String, String> queryParams,
+               String subjectCsid, String subjectType,
+               String predicate,
+               String objectCsid,
+               String objectType) throws WebApplicationException {
         try {
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
+            if (parentCtx != null) { // If the parent context has an open repository session then use it
+               ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession());
+            }
             DocumentHandler handler = createDocumentHandler(ctx);
 
             String relationClause = RelationsUtils.buildWhereClause(subjectCsid, subjectType, predicate, objectCsid, objectType);
index 6e6dbf030bcffadc38d5bde77ae254612ff81945..b381395b2bc67514432c0699bc373a8a93927a2d 100644 (file)
@@ -129,7 +129,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
                RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
-                       repoSession = repoClient.getRepositorySession();
+                       repoSession = repoClient.getRepositorySession(ctx);
                        releaseRepoSession = true;
                }
 
@@ -172,7 +172,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
                        throw new DocumentException(e);
                } finally {
                        if (releaseRepoSession && repoSession != null) {
-                               repoClient.releaseRepositorySession(repoSession);
+                               repoClient.releaseRepositorySession(ctx, repoSession);
                        }
                }
                return buildReportResponse(csid, params, reportFileName);
index 444e439e58abeab27f436a048d871820b0e21447..28e9fc6c71a7dbe3be69f1fcde0583ab32ebb76f 100644 (file)
@@ -87,7 +87,7 @@ public class ServiceGroupDocumentModelHandler
                RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
-                       repoSession = repoClient.getRepositorySession();
+                       repoSession = repoClient.getRepositorySession(ctx);
                        releaseRepoSession = true;
                }
             DocumentFilter myFilter = getDocumentFilter();
@@ -163,7 +163,7 @@ public class ServiceGroupDocumentModelHandler
                        throw new DocumentException(e);
                } finally {
                        if (releaseRepoSession && repoSession != null) {
-                               repoClient.releaseRepositorySession(repoSession);
+                               repoClient.releaseRepositorySession(ctx, repoSession);
                        }
                }
        } catch (Exception e) {