]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-1351: API For Supporting Create Page Update (#433)
authorMichael Ritter <mikejritter@users.noreply.github.com>
Sat, 23 Nov 2024 00:02:36 +0000 (17:02 -0700)
committerGitHub <noreply@github.com>
Sat, 23 Nov 2024 00:02:36 +0000 (17:02 -0700)
* Add new endpoint /servicegroups/:group/tags
* Add servicetag query parameter to /servicegroups/:group
* Apply spotless

services/servicegroup/jaxb/src/main/resources/servicegroup_common.xsd
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 fc2f45a744bb34ff44e81618136c435387bf2039..42a66955141f55f2a2c525446a79885f908a7151 100644 (file)
     $LastChangedDate: 2010-06-02 16:03:51 -0700 (Wed, 02 Jun 2010) $
 -->
 
-<xs:schema 
+<xs:schema
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
   jaxb:version="1.0" elementFormDefault="unqualified"
-  xmlns:ns="http://collectionspace.org/services/servicegroup"
   xmlns="http://collectionspace.org/services/servicegroup"
   targetNamespace="http://collectionspace.org/services/servicegroup"
   version="0.1"
 >
 
-    <!-- servicegroup -->
-    <xs:element name="servicegroups_common">
-        <xs:complexType>
+  <!-- servicegroup -->
+  <xs:element name="servicegroups_common">
+    <xs:complexType>
+      <xs:sequence>
+        <!--  ServiceGroup Information Group -->
+        <xs:element name="name" type="xs:string" />
+        <xs:element name="uri" type="xs:string" />
+        <xs:element name="hasDocTypes">
+          <xs:complexType>
             <xs:sequence>
-                <!--  ServiceGroup Information Group -->
-                <xs:element name="name" type="xs:string"/>
-                <xs:element name="uri" type="xs:string"/>
-                               <xs:element name="hasDocTypes">
-                                       <xs:complexType>
-                                               <xs:sequence>
-                                                       <xs:element name="hasDocType" type="xs:string"
-                                                               minOccurs="1" maxOccurs="unbounded" />
-                                               </xs:sequence>
-                                       </xs:complexType>
-                               </xs:element>
+              <xs:element name="hasDocType" type="xs:string" minOccurs="1" maxOccurs="unbounded" />
             </xs:sequence>
-        </xs:complexType>
-    </xs:element>
-    
+          </xs:complexType>
+        </xs:element>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
 </xs:schema>
 
index e18cc3ce72a95edc7b7167f10f1ba55b86b7f0cf..728cc9e9121fbee886bfb34c9e9c052fa53a2f13 100644 (file)
@@ -2,19 +2,19 @@
  *  This document is a part of the source code and related artifacts
  *  for CollectionSpace, an open source collections management system
  *  for museums and related institutions:
-
+ *
  *  http://www.collectionspace.org
  *  http://wiki.collectionspace.org
-
+ *
  *  Copyright 2009 University of California at Berkeley
-
+ *
  *  Licensed under the Educational Community License (ECL), Version 2.0.
  *  You may not use this file except in compliance with this License.
-
+ *
  *  You may obtain a copy of the ECL 2.0 License at
-
+ *
  *  https://source.collectionspace.org/collection-space/LICENSE.txt
-
+ *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,14 +25,24 @@ package org.collectionspace.services.servicegroup;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
-
+import java.util.Set;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.xml.parsers.ParserConfigurationException;
 import org.collectionspace.services.ServiceGroupListItemJAXBSchema;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.ServiceGroupClient;
-import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.NuxeoBasedResource;
@@ -48,58 +58,45 @@ 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.jaxb.AbstractCommonList;
 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;
 
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
 @Path(ServiceGroupClient.SERVICE_PATH)
 @Produces({"application/xml"})
 @Consumes({"application/xml"})
 public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<PoxPayloadIn, PoxPayloadOut> {
 
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
-    
-    private final static boolean EXCLUDE_AUTHORITIES = false;
-    private final static boolean INCLUDE_AUTHORITIES = true;
-    
+
+    private static final boolean EXCLUDE_AUTHORITIES = false;
+    private static final boolean INCLUDE_AUTHORITIES = true;
+
     @Override
-    public String getServiceName(){
+    public String getServiceName() {
         return ServiceGroupClient.SERVICE_NAME;
     }
 
-    public String getServicePathComponent(){
+    public String getServicePathComponent() {
         return ServiceGroupClient.SERVICE_NAME.toLowerCase();
     }
 
     @Override
     protected String getVersionString() {
-       final String lastChangeRevision = "$LastChangedRevision: 2108 $";
-       return lastChangeRevision;
+        final String lastChangeRevision = "$LastChangedRevision: 2108 $";
+        return lastChangeRevision;
     }
 
     @Override
-    //public Class<ServicegroupsCommon> getCommonPartClass() {
     public Class<?> getCommonPartClass() {
-       try {
-            return Class.forName("org.collectionspace.services.servicegroup.ServicegroupsCommon");//.class;
-        } catch (ClassNotFoundException e){
+        try {
+            return Class.forName("org.collectionspace.services.servicegroup.ServicegroupsCommon");
+        } catch (ClassNotFoundException e) {
             return null;
         }
     }
@@ -109,95 +106,94 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<Po
         return MultipartServiceContextFactory.get();
     }
 
-
-    //======================= GET without specifier: List  =====================================
+    // ======================= GET without specifier: List  =====================================
     @GET
     public AbstractCommonList getList(@Context UriInfo ui) {
         try {
             CommonList commonList = new CommonList();
-            AbstractCommonList list = (AbstractCommonList)commonList;
-               ArrayList<String> svcGroups = new ArrayList<String>();
-               svcGroups.add("procedure");
-               svcGroups.add("object");
-               svcGroups.add("authority");
-               // Fetch the list of groups from the tenant-bindings config, and prepare a list item
-               // for each one.
-               // We always declare this a full list, of the size that we are returning. 
-               // Not quite in the spirit of what paging means, but tells callers not to ask for more.
-               list.setPageNum(0);
-               list.setPageSize(svcGroups.size());
-               list.setItemsInPage(svcGroups.size());
-               list.setTotalItems(svcGroups.size());
-               String fields[] = new String[2];
-               fields[0] = ServiceGroupListItemJAXBSchema.NAME;
-               fields[1] = ServiceGroupListItemJAXBSchema.URI;
-               commonList.setFieldsReturned(fields);
-                       HashMap<String, Object> item = new HashMap<String, Object>();
-               for(String groupName:svcGroups){
-                   item.put(ServiceGroupListItemJAXBSchema.NAME, groupName);
-                   String uri = "/" + getServiceName().toLowerCase() + "/" + groupName;
-                   item.put(ServiceGroupListItemJAXBSchema.URI, uri);
-                   commonList.addItem(item);
-                   item.clear();
-               }
-               return list;
+            AbstractCommonList list = (AbstractCommonList) commonList;
+            ArrayList<String> svcGroups = new ArrayList<String>();
+            svcGroups.add("procedure");
+            svcGroups.add("object");
+            svcGroups.add("authority");
+            // Fetch the list of groups from the tenant-bindings config, and prepare a list item
+            // for each one.
+            // We always declare this a full list, of the size that we are returning.
+            // Not quite in the spirit of what paging means, but tells callers not to ask for more.
+            list.setPageNum(0);
+            list.setPageSize(svcGroups.size());
+            list.setItemsInPage(svcGroups.size());
+            list.setTotalItems(svcGroups.size());
+            String fields[] = new String[2];
+            fields[0] = ServiceGroupListItemJAXBSchema.NAME;
+            fields[1] = ServiceGroupListItemJAXBSchema.URI;
+            commonList.setFieldsReturned(fields);
+            HashMap<String, Object> item = new HashMap<String, Object>();
+            for (String groupName : svcGroups) {
+                item.put(ServiceGroupListItemJAXBSchema.NAME, groupName);
+                String uri = "/" + getServiceName().toLowerCase() + "/" + groupName;
+                item.put(ServiceGroupListItemJAXBSchema.URI, uri);
+                commonList.addItem(item);
+                item.clear();
+            }
+            return list;
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.LIST_FAILED);
         }
-        
     }
 
-    
-    //======================= GET ====================================================
-    // NOTE that csid is not a good name for the specifier, but if we name it anything else, 
-    // our AuthZ gets confused!!!
+    // ======================= GET ====================================================
+    // NOTE that csid is not a good name for the specifier, but if we name it anything else our AuthZ gets confused!!!
     @GET
     @Path("{csid}")
-    public byte[] get(
-            @Context UriInfo ui,
-            @PathParam("csid") String groupname) {
+    public byte[] get(@Context UriInfo ui, @PathParam("csid") String groupname) {
         PoxPayloadOut result = null;
         ensureCSID(groupname, NuxeoBasedResource.READ);
         try {
-               ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
-            TenantBindingConfigReaderImpl tReader =
-                    ServiceMain.getInstance().getTenantBindingConfigReader();
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
+            ServiceGroupDocumentModelHandler handler = (ServiceGroupDocumentModelHandler) createDocumentHandler(ctx);
+            TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
             // We need to get all the procedures, authorities, and objects.
-               ArrayList<String> groupsList = null;  
-               if("common".equalsIgnoreCase(groupname)) {
-                       groupsList = ServiceBindingUtils.getCommonServiceTypes(INCLUDE_AUTHORITIES);
-               } else {
-                       groupsList = new ArrayList<String>();
-                       groupsList.add(groupname);
-               }
-            List<ServiceBindingType> servicebindings = tReader.getServiceBindingsByType(ctx.getTenantId(), groupsList);
-            if (servicebindings == null || servicebindings.isEmpty()) {
-               // 404 if there are no mappings.
-                Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                        ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(groupname)).type("text/plain").build();
+            ArrayList<String> groupsList = null;
+            if ("common".equalsIgnoreCase(groupname)) {
+                groupsList = ServiceBindingUtils.getCommonServiceTypes(INCLUDE_AUTHORITIES);
+            } else {
+                groupsList = new ArrayList<String>();
+                groupsList.add(groupname);
+            }
+            List<ServiceBindingType> bindings = tReader.getServiceBindingsByType(ctx.getTenantId(), groupsList);
+            if (bindings == null || bindings.isEmpty()) {
+                // 404 if there are no mappings.
+                Response response = Response.status(Response.Status.NOT_FOUND)
+                        .entity(ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(groupname))
+                        .type("text/plain")
+                        .build();
                 throw new CSWebApplicationException(response);
             }
-               //Otherwise, build the response with a list
+            // Otherwise, build the response with a list
             ServicegroupsCommon common = new ServicegroupsCommon();
             common.setName(groupname);
             String uri = "/" + getServicePathComponent() + "/" + groupname;
             common.setUri(uri);
             result = new PoxPayloadOut(getServicePathComponent());
             result.addPart("ServicegroupsCommon", common);
-            
-               ServicegroupsCommon.HasDocTypes wrapper = common.getHasDocTypes();
-               if(wrapper==null) {
-                       wrapper = new ServicegroupsCommon.HasDocTypes();
-                       common.setHasDocTypes(wrapper);
-               }
-               List<String> hasDocTypes = wrapper.getHasDocType();
-               for(ServiceBindingType binding:servicebindings) {
-                       ServiceObjectType serviceObj = binding.getObject();
-                       if(serviceObj!=null) {
-                       String docType = serviceObj.getName();
-                       hasDocTypes.add(docType);
-                       }
-               }
+
+            String queryTag = ctx.getQueryParams().getFirst(IQueryManager.TAG_QUERY_PARAM);
+            ServicegroupsCommon.HasDocTypes wrapper = common.getHasDocTypes();
+            if (wrapper == null) {
+                wrapper = new ServicegroupsCommon.HasDocTypes();
+                common.setHasDocTypes(wrapper);
+            }
+            List<String> hasDocTypes = wrapper.getHasDocType();
+            for (ServiceBindingType binding : bindings) {
+                boolean includeDocType = handler.acceptServiceBinding(binding, queryTag);
+
+                ServiceObjectType serviceObj = binding.getObject();
+                if (includeDocType && serviceObj != null) {
+                    String docType = serviceObj.getName();
+                    hasDocTypes.add(docType);
+                }
+            }
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.READ_FAILED, groupname);
         }
@@ -205,72 +201,131 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<Po
         return result.getBytes();
     }
 
+    /**
+     * Get a list of the existing service tags for a give service type
+     * e.g. the procedure services might have nagpra and legacy
+     *
+     * @param ui the uri info
+     * @param serviceType the service type to retrieve the set of tags for
+     * @return the set of service tags, as an abstract-common-list
+     */
+    @GET
+    @Path("{csid}/tags")
+    public AbstractCommonList getTagsForType(@Context UriInfo ui, @PathParam("csid") String serviceType) {
+        Set<String> serviceObjects = new HashSet<>();
+        ensureCSID(serviceType, NuxeoBasedResource.READ);
+        try {
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
+            TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+
+            List<ServiceBindingType> bindings = tReader.getServiceBindingsByType(ctx.getTenantId(), serviceType);
+            if (bindings == null || bindings.isEmpty()) {
+                // 404 if there are no mappings.
+                Response response = Response.status(Response.Status.NOT_FOUND)
+                        .entity(ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(serviceType))
+                        .type("text/plain")
+                        .build();
+                throw new CSWebApplicationException(response);
+            }
+
+            for (ServiceBindingType binding : bindings) {
+                ServiceObjectType serviceObj = binding.getObject();
+                if (serviceObj != null) {
+                    if (binding.getTags() != null) {
+                        serviceObjects.addAll(binding.getTags().getTag());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw bigReThrow(e, ServiceMessages.READ_FAILED, serviceType);
+        }
+
+        try {
+            CommonList commonList = new CommonList();
+            commonList.setPageNum(0);
+            commonList.setPageSize(serviceObjects.size());
+            commonList.setItemsInPage(serviceObjects.size());
+            commonList.setTotalItems(serviceObjects.size());
+
+            String[] fields = new String[1];
+            fields[0] = ServiceGroupListItemJAXBSchema.NAME;
+            commonList.setFieldsReturned(fields);
+            HashMap<String, Object> item = new HashMap<String, Object>();
+            for (String service : serviceObjects) {
+                item.put(ServiceGroupListItemJAXBSchema.NAME, service);
+                commonList.addItem(item);
+                item.clear();
+            }
+            return commonList;
+        } catch (ParserConfigurationException e) {
+            throw bigReThrow(e, ServiceMessages.UNKNOWN_ERROR_MSG, serviceType);
+        }
+    }
+
     @GET
     @Path("{csid}/items")
     public AbstractCommonList getResourceItemList(
-            @Context UriInfo uriInfo,
-            @PathParam("csid") String serviceGroupName) {
-       UriInfoWrapper ui = new UriInfoWrapper(uriInfo);
+            @Context UriInfo uriInfo, @PathParam("csid") String serviceGroupName) {
+        UriInfoWrapper ui = new UriInfoWrapper(uriInfo);
         ensureCSID(serviceGroupName, NuxeoBasedResource.READ);
         AbstractCommonList list = 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);
-               }
-               
-               // check first for a csid query parameter
+            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);
+            }
+
+            // check first for a csid query parameter
             MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
-               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 csid: ["+csid+"]");
-                       }
-                   } else {
-                           DocumentFilter documentFilter = handler.getDocumentFilter();
-                           documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
-                           if (logger.isDebugEnabled()) {
-                               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());
-                                   }
-                           }
-                       }                       
-               }
-               
+            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 csid: [" + csid + "]");
+                    }
+                } else {
+                    DocumentFilter documentFilter = handler.getDocumentFilter();
+                    documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
+                    if (logger.isDebugEnabled()) {
+                        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());
+                        }
+                    }
+                }
+            }
+
             String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS);
-               if (advancedSearch != null && !advancedSearch.isEmpty()) {
-                   DocumentFilter documentFilter = handler.getDocumentFilter();
-                   String whereClause = QueryManager.createWhereClauseFromAdvancedSearch(advancedSearch);
-                   documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
-                   if (logger.isDebugEnabled()) {
-                       logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
-                   }
-               }
-               
-               // make the query
+            if (advancedSearch != null && !advancedSearch.isEmpty()) {
+                DocumentFilter documentFilter = handler.getDocumentFilter();
+                String whereClause = QueryManager.createWhereClauseFromAdvancedSearch(advancedSearch);
+                documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
+                if (logger.isDebugEnabled()) {
+                    logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
+                }
+            }
+
+            // make the query
             list = handler.getItemListForGroup(ctx, groupsList);
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.READ_FAILED, serviceGroupName);
@@ -282,30 +337,29 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<Po
     @GET
     @Path("{csid}/items/{specifier}")
     public byte[] getResourceItem(
-               @Context ResourceMap resourceMap,
+            @Context ResourceMap resourceMap,
             @Context UriInfo uriInfo,
             @PathParam("csid") String serviceGroupName,
             @PathParam("specifier") String specifier) {
-       UriInfoWrapper ui = new UriInfoWrapper(uriInfo);
+        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);
-               }
-               
+            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);    
-               
+            handler.setDocumentFilter(myFilter);
+
             result = handler.getResourceItemForCsid(ctx, groupsList, specifier);
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.READ_FAILED, serviceGroupName);
index e0bf42c97ab8c879aa8daab0c4040eb1cfcc679d..77171ac0c54e5acdef99bf6ddfcc92c044025c32 100644 (file)
@@ -268,6 +268,10 @@ public class ServiceGroupDocumentModelHandler
         * @return true if the ServiceBinding contains all query parameters, false otherwise
         */
        public boolean acceptServiceBinding(ServiceBindingType binding, String queryTag) {
+               if (queryTag == null || queryTag.isEmpty()) {
+                       return true;
+               }
+
                final Tags tags = binding.getTags();
                final List<String> tagList = tags == null ? Collections.<String>emptyList() : tags.getTag();