]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-90: Adding support for getting list and full payload for an item given a csid.
authorremillet <remillet@yahoo.com>
Thu, 23 Feb 2017 23:16:25 +0000 (15:16 -0800)
committerremillet <remillet@yahoo.com>
Thu, 23 Feb 2017 23:16:25 +0000 (15:16 -0800)
services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java
services/client/src/main/java/org/collectionspace/services/client/IRelationsManager.java
services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java
services/common/src/main/java/org/collectionspace/services/common/query/QueryManager.java
services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java

index ea8bb775fb281e8f454e88eba800e3c2d74db7d9..9095fb9547a5251db8cf6230bfda613fd9621ca7 100644 (file)
@@ -43,6 +43,7 @@ public interface IQueryManager {
        final static String SEARCH_QUALIFIER_AND = SEARCH_TERM_SEPARATOR + "AND" + SEARCH_TERM_SEPARATOR;
        final static String SEARCH_QUALIFIER_OR = SEARCH_TERM_SEPARATOR + "OR" + SEARCH_TERM_SEPARATOR;
     final static String DEFAULT_SELECT_CLAUSE = "SELECT * FROM ";
+    final static String CSID_QUERY_PARAM = "csid";
        
 
        //
@@ -163,5 +164,10 @@ public interface IQueryManager {
         * @return the string
         */
        public String createWhereClauseForInvocableByMode(String schema, String mode);
+
+       /*
+        * 
+        */
+       public String createWhereClauseFromCsid(String csid);
        
 }
index 408198cca7958d451c991709b7bb463c353397cb..9160ad1107d1ea3fdc14e3573784969e87654ff5 100644 (file)
@@ -22,7 +22,7 @@ public interface IRelationsManager {
     static public final String SUBJECT = "subjectCsid";
     static public final String SUBJECT_REFNAME = "subjectRefName";    
     static public final String SUBJECT_QP = "sbj";
-    static public final String SUBJECT_TYPE = "subjectType";
+//    static public final String SUBJECT_TYPE = "subjectType";
     static public final String SUBJECT_TYPE_QP = SUBJECT_QP + "Type";
     
     /** The Constant PREDICATE. */
@@ -33,6 +33,6 @@ public interface IRelationsManager {
     static public final String OBJECT = "objectCsid";
     static public final String OBJECT_REFNAME = "objectRefName";
     static public final String OBJECT_QP = "obj";
-    static public final String OBJECT_TYPE = "objectType";
+//    static public final String OBJECT_TYPE = "objectType";
     static public final String OBJECT_TYPE_QP = OBJECT_QP + "Type";
 }
index 3d2afa09d6c49295af8b3f5a128dadbe8ad043c8..0cba4b901337700cbe01c460c1373d6c62f0105f 100644 (file)
@@ -8,6 +8,7 @@ import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
 import org.collectionspace.services.common.config.PropertyItemUtils;
+import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
 import org.collectionspace.services.config.service.ObjectPartType;
 import org.collectionspace.services.config.service.ServiceBindingType;
 import org.collectionspace.services.config.service.ServiceObjectType;
@@ -16,7 +17,9 @@ import org.collectionspace.services.config.types.PropertyType;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
+
 import java.lang.IndexOutOfBoundsException;
+
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.document.DocumentUtils;
 import org.slf4j.Logger;
@@ -167,7 +170,7 @@ public class ServiceBindingUtils {
                                propName, value, onlyIfNotSet);
     }
     
-    public static String getMappedFieldInDoc( ServiceBindingType sb,
+    public static String getMappedFieldInDoc(ServiceBindingType sb,
                String logicalFieldName, DocumentModel docModel ) {
        // Now we have to get the number, which is configured as some field
        // on each docType
@@ -214,6 +217,21 @@ public class ServiceBindingUtils {
     } 
     
     private static ArrayList<String> commonProcedureServiceTypes = null;
+    
+    /**
+     * Get the service name (service resource path) from the object name (Nuxeo document type)
+     * @param serviceName
+     * @param sb
+     * @return
+     */
+    public static String getServiceNameFromObjectName(TenantBindingConfigReaderImpl bindingReader, String tenantId, String docType) {
+       String result = null;
+       
+       ServiceBindingType bindingType = bindingReader.getServiceBindingForDocType(tenantId, docType);
+       result = bindingType.getName().toLowerCase();
+       
+       return result;
+    }
    
     public static ArrayList<String> getCommonServiceTypes(boolean includeAuthorities) {
         ArrayList<String> commonServiceTypes = new ArrayList<String>();
index fb46ff2ce4da79501a3268535bb68ac7fad17225..5790575c6d63d984970c23631e36bdb5d94e91f5 100644 (file)
@@ -52,6 +52,10 @@ public class QueryManager {
                return queryManager.createWhereClauseFromAdvancedSearch(keywords);
        }
        
+       static public String createWhereClauseFromCsid(String csid) {
+               return queryManager.createWhereClauseFromCsid(csid);
+       }       
+       
        /**
         * Creates the where clause for partial term match.
         * 
index 54d42f903d9155a7275efda61ece49a503e68c57..c947fedfc57540e8c80d40300a3dd92245f9b672 100644 (file)
@@ -35,10 +35,13 @@ import java.util.regex.Pattern;
 //import org.nuxeo.ecm.core.client.NuxeoClient;
 
 
+
+
 import org.collectionspace.services.jaxb.InvocableJAXBSchema;
 //import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;
 //import org.collectionspace.services.nuxeo.client.java.NxConnect;
 
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.common.invocable.InvocableUtils;
 import org.collectionspace.services.common.storage.DatabaseProductType;
@@ -358,4 +361,14 @@ public class QueryManagerNuxeoImpl implements IQueryManager {
        return filterClause.toString();
        }
 
+       @Override
+       public String createWhereClauseFromCsid(String csid) {
+               String trimmed = (csid == null) ? "" : csid.trim();
+               if (trimmed.isEmpty()) {
+                       throw new RuntimeException("No CSID specified.");
+               }
+
+               return NuxeoUtils.getByNameWhereClause(csid);
+       }
+
 }
index cddb62fd08568fa4d6a32f041d0b5c414d9c8c85..c13df907db2fc351254bc5e5b8510b23c43e9f29 100644 (file)
@@ -31,6 +31,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
+import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
@@ -54,19 +55,19 @@ import org.collectionspace.services.lifecycle.TransitionDefList;
 import org.collectionspace.services.lifecycle.TransitionList;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentException;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
+
 import org.dom4j.Document;
 import org.dom4j.io.SAXReader;
 import org.nuxeo.ecm.core.NXCore;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.Blob;
 import org.nuxeo.ecm.core.api.CoreSession;
 import org.nuxeo.ecm.core.api.DocumentRef;
 import org.nuxeo.ecm.core.api.IdRef;
 import org.nuxeo.ecm.core.api.NuxeoException;
 import org.nuxeo.ecm.core.api.PathRef;
-import org.nuxeo.ecm.core.api.model.PropertyException;
+import org.nuxeo.ecm.core.api.PropertyException;
 import org.nuxeo.ecm.core.io.DocumentPipe;
 import org.nuxeo.ecm.core.io.DocumentReader;
 import org.nuxeo.ecm.core.io.DocumentWriter;
@@ -305,7 +306,7 @@ public class NuxeoUtils {
        } catch (Exception e) {
                logger.error("Could not remove facet from DocumentModel instance: " + docModel.getId(), e);
        }
-       
+
        return result;
     }
     
@@ -400,9 +401,9 @@ public class NuxeoUtils {
             bais = new ByteArrayInputStream(baos.toByteArray());
             SAXReader saxReader = new SAXReader();
             doc = saxReader.read(bais);
-        } catch (ClientException ce) {
-               throw new NuxeoDocumentException(ce);
-        } catch (Exception e) {
+        } catch (org.dom4j.DocumentException ce) {
+               throw new DocumentException(ce);
+        } catch (IOException e) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Caught exception while processing document ", e);
             }
@@ -464,7 +465,7 @@ public class NuxeoUtils {
      */
     public static DocumentModel getWorkspaceModel(
                CoreSessionInterface repoSession, String workspaceName)
-            throws DocumentException, IOException, ClientException {
+            throws DocumentException, IOException {
         DocumentModel result = null;
         //FIXME: commented out as this does not work without tenant qualification
         String workspaceUUID = null;
@@ -494,13 +495,9 @@ public class NuxeoUtils {
             throws DocumentException {
         DocumentModel result = null;
 
-        try {
-            DocumentRef documentRef = new IdRef(nuxeoId);
-            result = repoSession.getDocument(documentRef);
-        } catch (ClientException e) {
-            throw new NuxeoDocumentException(e);
-        }
-
+        DocumentRef documentRef = new IdRef(nuxeoId);
+        result = repoSession.getDocument(documentRef);
+        
         return result;
     }
     
@@ -722,6 +719,10 @@ public class NuxeoUtils {
         return result;
     }
     
+    static public NuxeoBasedResource getDocumentResource(String csid) {
+       return null;
+    }
+    
     static public DocumentModel getDocFromSpecifier(
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
                CoreSessionInterface repoSession,
@@ -873,7 +874,7 @@ public class NuxeoUtils {
     }
     
     public static boolean documentExists(CoreSessionInterface repoSession,
-               String csid) throws ClientException {
+               String csid) {
                boolean result = false;
                
                String statement = String.format(
@@ -933,14 +934,10 @@ public class NuxeoUtils {
     public static String getTenantQualifiedDocType(QueryContext queryCtx, String docType) throws Exception {
        String result = docType;
        
-       try {
-               String tenantQualifiedDocType = queryCtx.getTenantQualifiedDoctype();
-                       if (docTypeExists(tenantQualifiedDocType) == true) {
-                               result = tenantQualifiedDocType;
-                       }
-       } catch (ClientException ce) {
-               throw new NuxeoDocumentException(ce);
-       }
+       String tenantQualifiedDocType = queryCtx.getTenantQualifiedDoctype();
+               if (docTypeExists(tenantQualifiedDocType) == true) {
+                       result = tenantQualifiedDocType;
+               }
                
        return result;
     }
@@ -952,22 +949,12 @@ public class NuxeoUtils {
     static private boolean docTypeExists(String docType) throws Exception {
        boolean result = false;
        
-        SchemaManager schemaManager = null;
-       try {
-                       schemaManager = Framework.getService(org.nuxeo.ecm.core.schema.SchemaManager.class);
-       } catch (ClientException ce) {
-               throw new NuxeoDocumentException(ce);
-               } catch (Exception e1) {
-                       // TODO Auto-generated catch block
-                       logger.error("Could not get Nuxeo SchemaManager instance.", e1);
-                       throw e1;
-               }
-       
+        SchemaManager schemaManager = Framework.getService(org.nuxeo.ecm.core.schema.SchemaManager.class);
                Set<String> docTypes = schemaManager.getDocumentTypeNamesExtending(docType);
                if (docTypes != null && docTypes.contains(docType)) {
                        result = true;
                }
-               
+
        return result;
     }
     
@@ -979,7 +966,7 @@ public class NuxeoUtils {
      * the DocumentModel.getPropertyValue method.  This method catches that NPE and instead returns null.
      */
     public static Object getProperyValue(DocumentModel docModel,
-               String propertyName) throws ClientException, PropertyException {
+               String propertyName) {
        Object result = null;
        
        try {
index 5bc7924c0cfe859756cd440b5917093527334df2..72e2a552b639127436da20d0307cbf9dabe47c12 100644 (file)
@@ -36,6 +36,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.NuxeoBasedResource;
+import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.ServiceMessages;
 import org.collectionspace.services.common.UriInfoWrapper;
@@ -47,9 +48,13 @@ import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.context.ServiceContextFactory;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.query.QueryManager;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm;
 import org.collectionspace.services.config.service.ServiceBindingType;
 import org.collectionspace.services.config.service.ServiceObjectType;
 import org.collectionspace.services.nuxeo.client.java.CommonList;
+import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentFilter;
 import org.collectionspace.services.servicegroup.nuxeo.ServiceGroupDocumentModelHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -200,10 +205,9 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<Po
         return result.getBytes();
     }
 
-
     @GET
     @Path("{csid}/items")
-    public AbstractCommonList getItems(
+    public AbstractCommonList getItemList(
             @Context UriInfo uriInfo,
             @PathParam("csid") String serviceGroupName) {
        UriInfoWrapper ui = new UriInfoWrapper(uriInfo);
@@ -220,14 +224,15 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<Po
                        groupsList = new ArrayList<String>();
                        groupsList.add(serviceGroupName);
                }
-               // set up a keyword search
+               
+               // check first for a csid query parameter
             MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
-            String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
-               if (keywords != null && !keywords.isEmpty()) {
-                   String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
-                   if(Tools.isEmpty(whereClause)) {
+               String csid = queryParams.getFirst(IQueryManager.CSID_QUERY_PARAM);
+               if (csid != null && !csid.isEmpty()) {
+                   String whereClause = QueryManager.createWhereClauseFromCsid(csid);
+                   if (Tools.isEmpty(whereClause)) {
                        if (logger.isDebugEnabled()) {
-                               logger.debug("The WHERE clause is empty for keywords: ["+keywords+"]");
+                               logger.debug("The WHERE clause is empty for csid: ["+csid+"]");
                        }
                    } else {
                            DocumentFilter documentFilter = handler.getDocumentFilter();
@@ -236,8 +241,27 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<Po
                                logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
                            }
                    }
+               } else {
+                       // check to see if we have to set up a keyword search
+                   String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
+                       if (keywords != null && !keywords.isEmpty()) {
+                           String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
+                           if(Tools.isEmpty(whereClause)) {
+                               if (logger.isDebugEnabled()) {
+                                       logger.debug("The WHERE clause is empty for keywords: ["+keywords+"]");
+                               }
+                           } else {
+                                   DocumentFilter documentFilter = handler.getDocumentFilter();
+                                   documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
+                                   if (logger.isDebugEnabled()) {
+                                       logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
+                                   }
+                           }
+                       }                       
                }
-            list = handler.getItemsForGroup(ctx, groupsList);
+               
+               // make the query
+            list = handler.getItemListForGroup(ctx, groupsList);
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.READ_FAILED, serviceGroupName);
         }
@@ -245,5 +269,39 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<Po
         return list;
     }
 
+    @GET
+    @Path("{csid}/items/{specifier}")
+    public byte[] getItem(
+               @Context ResourceMap resourceMap,
+            @Context UriInfo uriInfo,
+            @PathParam("csid") String serviceGroupName,
+            @PathParam("specifier") String specifier) {
+       UriInfoWrapper ui = new UriInfoWrapper(uriInfo);
+        ensureCSID(serviceGroupName, NuxeoBasedResource.READ);
+        PoxPayloadOut result = null;
+        
+        try {
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
+               ServiceGroupDocumentModelHandler handler = (ServiceGroupDocumentModelHandler)
+                                               createDocumentHandler(ctx);
+               ArrayList<String> groupsList = null;  
+               if("common".equalsIgnoreCase(serviceGroupName)) {
+                       groupsList = ServiceBindingUtils.getCommonServiceTypes(INCLUDE_AUTHORITIES);
+               } else {
+                       groupsList = new ArrayList<String>();
+                       groupsList.add(serviceGroupName);
+               }
+               
+            String whereClause = QueryManager.createWhereClauseFromCsid(specifier);
+            DocumentFilter myFilter = new NuxeoDocumentFilter(whereClause, 0, 1);
+            handler.setDocumentFilter(myFilter);    
+               
+            result = handler.getItemForCsid(ctx, groupsList, specifier);
+        } catch (Exception e) {
+            throw bigReThrow(e, ServiceMessages.READ_FAILED, serviceGroupName);
+        }
+
+        return result.getBytes();
 
+    }
 }
index 214f9218d184f684a6956bc67139c8a46b33007d..58febc704fe3d4b3ee128bbcfbe6234cac72714b 100644 (file)
@@ -41,6 +41,7 @@ import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 
+import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.ServiceMessages;
@@ -77,11 +78,10 @@ public class ServiceGroupDocumentModelHandler
     protected static final String DOC_NUMBER_FIELD = "docNumber";
     protected static final String DOC_NAME_FIELD = "docName";
 
-    public AbstractCommonList getItemsForGroup(
-               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-               List<String> serviceGroupNames) throws Exception {
-        CommonList commonList = new CommonList();
-        AbstractCommonList list = (AbstractCommonList)commonList;
+    public PoxPayloadOut getItemForCsid(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+               List<String> serviceGroupNames,
+               String csid) throws DocumentException {
+       PoxPayloadOut result = null;
         CoreSessionInterface repoSession = null;
        boolean releaseRepoSession = false;
         
@@ -92,49 +92,113 @@ public class ServiceGroupDocumentModelHandler
                        repoSession = repoClient.getRepositorySession(ctx);
                        releaseRepoSession = true;
                }
-               
+               try {
+               Map<String, ServiceBindingType> queriedServiceBindings = new HashMap<String, ServiceBindingType>();
+               DocumentModelList docList = this.getDocListForGroup(ctx, serviceGroupNames, queriedServiceBindings,
+                               repoSession, repoClient);
+               if (docList == null) { // found no authRef fields - nothing to process
+                   //return list;
+               }
+               DocumentModel docModel = docList.get(0);
+                TenantBindingConfigReaderImpl bindingReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+                String serviceName = ServiceBindingUtils.getServiceNameFromObjectName(bindingReader, ctx.getTenantId(),
+                               docModel.getDocumentType().getName());
+                NuxeoBasedResource resource = (NuxeoBasedResource) ctx.getResourceMap().get(serviceName);
+                resource.hashCode();
+
+               } catch (DocumentException de) {
+                       throw de;
+               } catch (Exception e) {
+                       if (logger.isDebugEnabled()) {
+                               logger.debug("Caught exception ", e);
+                       }
+                       throw new DocumentException(e);
+               } finally {
+                       if (releaseRepoSession && repoSession != null) {
+                               repoClient.releaseRepositorySession(ctx, repoSession);
+                       }
+               }
+       } catch (Exception e) {
+               if (logger.isDebugEnabled()) {
+                       logger.debug("Caught exception ", e);
+               }
+               throw new DocumentException(e);
+       }
+       
+        return result;
+    }
+    
+    private DocumentModelList getDocListForGroup(
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+               List<String> serviceGroupNames,
+               Map<String, ServiceBindingType> queriedServiceBindings,
+               CoreSessionInterface repoSession,
+               RepositoryClientImpl repoClient) throws Exception {
+        
+        RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)repoClient;
+        // Get the service bindings for this tenant
+        TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+        // We need to get all the procedures, authorities, and objects.
+        List<ServiceBindingType> servicebindings = 
+                       tReader.getServiceBindingsByType(ctx.getTenantId(), serviceGroupNames);
+        if (servicebindings == null || servicebindings.isEmpty()) {
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    ServiceMessages.READ_FAILED + 
+                    ServiceMessages.resourceNotFoundMsg(implode(serviceGroupNames, ","))).type("text/plain").build();
+            throw new CSWebApplicationException(response);
+        }
+        
+        servicebindings = SecurityUtils.getReadableServiceBindingsForCurrentUser(servicebindings);
+        // Build the list of docTypes for allowed serviceBindings
+        ArrayList<String> docTypes = new ArrayList<String>();
+       for(ServiceBindingType binding:servicebindings) {
+               ServiceObjectType serviceObj = binding.getObject();
+               if(serviceObj!=null) {
+                String docType = serviceObj.getName();
+                       docTypes.add(docType);
+                queriedServiceBindings.put(docType, binding);
+               }
+       }
+       
+       // This should be type "Document" but CMIS is gagging on that right now.
+       ctx.getQueryParams().add(IQueryManager.SELECT_DOC_TYPE_FIELD, QueryManagerNuxeoImpl.COLLECTIONSPACE_DOCUMENT_TYPE);
+        
+        // Now we have to issue the search
+       // The findDocs() method will build a QueryContext, which wants to see a docType for our context
+       ctx.setDocumentType(QueryManagerNuxeoImpl.NUXEO_DOCUMENT_TYPE);
+        DocumentWrapper<DocumentModelList> docListWrapper = 
+                       nuxeoRepoClient.findDocs(ctx, this, repoSession, docTypes );
+        // Now we gather the info for each document into the list and return
+        DocumentModelList docList = docListWrapper.getWrappedObject();
+       
+        return docList;
+    }
+    
+    public AbstractCommonList getItemListForGroup(
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+               List<String> serviceGroupNames) throws Exception {
+        CommonList commonList = new CommonList();
+        AbstractCommonList list = (AbstractCommonList)commonList;
+        CoreSessionInterface repoSession = null;
+       boolean releaseRepoSession = false;
+        
+       try { 
             DocumentFilter myFilter = getDocumentFilter();
                int pageSize = myFilter.getPageSize();
                int pageNum = myFilter.getStartPage();
                list.setPageNum(pageNum);
                list.setPageSize(pageSize);
+
+               RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
+               repoSession = this.getRepositorySession();
+               if (repoSession == null) {
+                       repoSession = repoClient.getRepositorySession(ctx);
+                       releaseRepoSession = true;
+               }
                try {
                Map<String, ServiceBindingType> queriedServiceBindings = new HashMap<String, ServiceBindingType>();
-               RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)repoClient;
-               // Get the service bindings for this tenant
-               TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
-               // We need to get all the procedures, authorities, and objects.
-               List<ServiceBindingType> servicebindings = 
-                               tReader.getServiceBindingsByType(ctx.getTenantId(), serviceGroupNames);
-               if (servicebindings == null || servicebindings.isEmpty()) {
-                    Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                            ServiceMessages.READ_FAILED + 
-                            ServiceMessages.resourceNotFoundMsg(implode(serviceGroupNames, ","))).type("text/plain").build();
-                    throw new CSWebApplicationException(response);
-               }
-               
-               servicebindings = SecurityUtils.getReadableServiceBindingsForCurrentUser(servicebindings);
-               // Build the list of docTypes for allowed serviceBindings
-               ArrayList<String> docTypes = new ArrayList<String>();
-               for(ServiceBindingType binding:servicebindings) {
-                       ServiceObjectType serviceObj = binding.getObject();
-                       if(serviceObj!=null) {
-                       String docType = serviceObj.getName();
-                               docTypes.add(docType);
-                        queriedServiceBindings.put(docType, binding);
-                       }
-               }
-               
-               // This should be type "Document" but CMIS is gagging on that right now.
-               ctx.getQueryParams().add(IQueryManager.SELECT_DOC_TYPE_FIELD, QueryManagerNuxeoImpl.COLLECTIONSPACE_DOCUMENT_TYPE);
-               
-               // Now we have to issue the search
-               // The findDocs() method will build a QueryContext, which wants to see a docType for our context
-               ctx.setDocumentType(QueryManagerNuxeoImpl.NUXEO_DOCUMENT_TYPE);
-               DocumentWrapper<DocumentModelList> docListWrapper = 
-                               nuxeoRepoClient.findDocs(ctx, this, repoSession, docTypes );
-               // Now we gather the info for each document into the list and return
-               DocumentModelList docList = docListWrapper.getWrappedObject();
+               DocumentModelList docList = this.getDocListForGroup(ctx, serviceGroupNames, queriedServiceBindings,
+                               repoSession, repoClient);
                if (docList == null) { // found no authRef fields - nothing to process
                    return list;
                }