]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1079. Work towards supporting search for documents by a field value. Some...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 10 Mar 2010 01:01:13 +0000 (01:01 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 10 Mar 2010 01:01:13 +0000 (01:01 +0000)
13 files changed:
services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java
services/common/src/main/config/services/tenant-bindings.xml
services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClient.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java [new file with mode: 0644]
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/common/src/main/resources/service.xsd
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java
services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java

index 910b733f29fd553d24fe4e57f97c9137208b463c..68cfb54eba7f2154c731d73353af98fa8a006329 100644 (file)
@@ -53,6 +53,7 @@ import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.query.IQueryManager;
 import org.collectionspace.services.common.query.QueryManager;
 import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
@@ -330,9 +331,8 @@ public class AcquisitionResource
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues("authRef");
-            String prefix = ctx.getCommonPartLabel()+":";
-            authRefList = handler.getAuthorityRefs(docWrapper, prefix, authRefFields);
+            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
                     Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
index ac027467a5099561b08cce6734363b158634f8a6..dad878dc131fc801eb8db210b835f5a22b82f367 100644 (file)
@@ -57,6 +57,7 @@ import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.query.IQueryManager;
 import org.collectionspace.services.common.query.QueryManager;
 import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
 import org.collectionspace.services.intake.IntakeResource;
 import org.collectionspace.services.intake.IntakesCommonList;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
@@ -405,9 +406,8 @@ public class CollectionObjectResource
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues("authRef");
-            String prefix = ctx.getCommonPartLabel()+":";
-            authRefList = handler.getAuthorityRefs(docWrapper, prefix, authRefFields);
+            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
                     Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
index fd6177686be349f7cd5ecc169c40a330c286f856..294577b9b4b4bb2df9a8ae78e631c6f43fe413c9 100644 (file)
@@ -13,7 +13,7 @@
     <!-- begin movingimages.us tenant meta-data -->
     <tenant:tenantBinding
         id="1" name="movingimages.us" displayName="Museum of Moving Images" version="0.1" repositoryDomain="default-domain">
-        <tenant:serviceBindings name="CollectionObjects" version="0.1">
+        <tenant:serviceBindings name="CollectionObjects" type="object" version="0.1">
             <!-- begin collectionobject service meta-data -->
             <service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
                 nuxeo-java
@@ -66,7 +66,7 @@
         </tenant:serviceBindings>
         <!--end collectionobject service meta-data -->
         <!-- begin intake service meta-data -->
-        <tenant:serviceBindings name="Intakes" version="0.1">
+        <tenant:serviceBindings name="Intakes" type="procedure" version="0.1">
             <service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
                 nuxeo-java
             </service:repositoryClient>
         </tenant:serviceBindings>
         <!-- end person service meta-data -->
         <!-- begin acquisition service meta-data -->
-        <tenant:serviceBindings name="Acquisitions" version="0.1">
+        <tenant:serviceBindings name="Acquisitions" type="procedure" version="0.1">
             <service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
                 nuxeo-java
             </service:repositoryClient>
index f2131416fb5bad27a9e5b8d5d3baef1acbfb8604..347bbf1009da6aef334569a63e8633c85f985aca 100644 (file)
 package org.collectionspace.services.common.config;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
+
 import org.collectionspace.services.common.ClientType;
 import org.collectionspace.services.common.RepositoryClientConfigType;
 import org.collectionspace.services.common.ServiceMain;
@@ -215,6 +218,28 @@ public class TenantBindingConfigReaderImpl
         return serviceBindings.get(key);
     }
 
+    /**
+     * getServiceBinding gets service binding for given tenant for a given service
+     * @param tenantId
+     * @param serviceName
+     * @return
+     */
+    public List<ServiceBindingType> getServiceBindingsByType(
+            String tenantId, String serviceType) {
+       ArrayList<ServiceBindingType> list = null;
+       TenantBindingType tenant = tenantBindings.get(tenantId);
+       if(tenant!=null) {
+               for(ServiceBindingType sb:tenant.getServiceBindings()) {
+                       if(sb.getType().equals(serviceType)) {
+                               if(list==null)
+                               list = new ArrayList<ServiceBindingType>();
+                               list.add(sb);
+                       }
+               }
+       }
+        return list;
+    }
+
     /**
      * getWorkspaceId retrieves workspace id for given tenant for given service
      * @param tenantId
index b0746f57efd3dc4062c02b4f75b5798a5a0145ac..448a0cf19fddb69db32b03ba09ce2d50995d93f6 100644 (file)
@@ -121,12 +121,7 @@ public abstract class AbstractServiceContextImpl<IT, OT>
         if (objectPartMap.size() != 0) {
             return objectPartMap;
         }
-        ServiceBindingType serviceBinding = getServiceBinding();
-        ServiceObjectType objectType = serviceBinding.getObject();
-        List<ObjectPartType> objectPartTypes = objectType.getPart();
-        for (ObjectPartType objectPartType : objectPartTypes) {
-            objectPartMap.put(objectPartType.getLabel(), objectPartType);
-        }
+        ServiceBindingUtils.getPartsMetadata(getServiceBinding(), objectPartMap);
         return objectPartMap;
     }
     
@@ -141,21 +136,13 @@ public abstract class AbstractServiceContextImpl<IT, OT>
 
     public List<String> getPropertyValuesForPart(String partLabel, String propName) {
        List<PropertyType> allProps = getPropertiesForPart(partLabel);
-       List<String> values = new ArrayList<String>();
-       if(allProps.size()>0) {
-               List<PropertyItemType> propItems = allProps.get(0).getItem();
-               for(PropertyItemType propItem:propItems) {
-                       if(propName.equals(propItem.getKey())) {
-                               String value = propItem.getValue();
-                               if(value!=null) {
-                                       values.add(value);
-                               }
-                       }
-               }
-       }
-       return values;
+       return ServiceBindingUtils.getPropertyValuesByName(allProps, propName);
     }
 
+    public List<String> getPropertyValues(String propName) {
+        return ServiceBindingUtils.getPropertyValues(getServiceBinding(), propName);
+    }
+    
     public List<PropertyType> getCommonPartProperties() {
        return getPropertiesForPart(getCommonPartLabel());
     }
diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java
new file mode 100644 (file)
index 0000000..f9c39ef
--- /dev/null
@@ -0,0 +1,81 @@
+package org.collectionspace.services.common.context;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.collectionspace.services.common.service.ObjectPartType;\r
+import org.collectionspace.services.common.service.ServiceBindingType;\r
+import org.collectionspace.services.common.service.ServiceObjectType;\r
+import org.collectionspace.services.common.types.PropertyItemType;\r
+import org.collectionspace.services.common.types.PropertyType;\r
+\r
+public class ServiceBindingUtils {\r
+\r
+    public static void getPartsMetadata(ServiceBindingType serviceBinding, \r
+               Map<String, ObjectPartType> objectPartMap) {\r
+        ServiceObjectType objectType = serviceBinding.getObject();\r
+        List<ObjectPartType> objectPartTypes = objectType.getPart();\r
+        for (ObjectPartType objectPartType : objectPartTypes) {\r
+            objectPartMap.put(objectPartType.getLabel(), objectPartType);\r
+        }\r
+    }\r
+    \r
+    public static List<PropertyType> getPropertiesForPart(ServiceBindingType serviceBinding,\r
+               String partLabel) {\r
+        ServiceObjectType objectType = serviceBinding.getObject();\r
+        List<ObjectPartType> objectPartTypes = objectType.getPart();\r
+        for (ObjectPartType objectPartType : objectPartTypes) {\r
+            if(partLabel.equals(objectPartType.getLabel())) {\r
+               return objectPartType.getProperties();\r
+            }\r
+        }\r
+               throw new RuntimeException("No such part found: "+partLabel);\r
+    }\r
+\r
+    public static List<String> getPropertyValuesForPart(ServiceBindingType serviceBinding,\r
+               String partLabel, String propName) {\r
+       List<PropertyType> partProps = getPropertiesForPart(serviceBinding, partLabel);\r
+       return getPropertyValuesByName(partProps, propName);\r
+    }\r
+\r
+    public static List<String> getPropertyValuesByName(List<PropertyType> partProps, String propName) {\r
+       List<String> values = new ArrayList<String>();\r
+       if(partProps.size()>0) {\r
+               List<PropertyItemType> propItems = partProps.get(0).getItem();\r
+               for(PropertyItemType propItem:propItems) {\r
+                       if(propName.equals(propItem.getKey())) {\r
+                               String value = propItem.getValue();\r
+                               if(value!=null) {\r
+                                       values.add(value);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       return values;\r
+    }\r
+\r
+       public static List<String> getPropertyValues(ServiceBindingType serviceBinding,\r
+               String propName) {\r
+       List<String> values = new ArrayList<String>();\r
+        ServiceObjectType objectType = serviceBinding.getObject();\r
+        List<ObjectPartType> objectPartTypes = objectType.getPart();\r
+        for (ObjectPartType objectPartType : objectPartTypes) {\r
+               List<PropertyType> partProps = objectPartType.getProperties();\r
+               if(partProps.size()>0) {\r
+               List<PropertyItemType> propItems = partProps.get(0).getItem();\r
+               for(PropertyItemType propItem:propItems) {\r
+                       if(propName.equals(propItem.getKey())) {\r
+                               String value = propItem.getValue();\r
+                               if(value!=null) {\r
+                                       values.add(value);\r
+                               }\r
+                       }\r
+               }\r
+               }\r
+        }\r
+       return values;\r
+    }\r
+\r
+\r
+}\r
index 892fb70ba5c64c962954d5cde88c6187b63b7fe3..c6078f4794c5703eb4102cea56ffcfec75735d5d 100644 (file)
  */
 package org.collectionspace.services.common.repository;
 
+import java.util.List;
+
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.storage.StorageClient;
 import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
 
 /**
  * RepositoryClient is a generic Document Repository client
@@ -51,7 +54,7 @@ public interface RepositoryClient extends StorageClient {
      */
     public String createWorkspace(String tenantDomain, String workspaceName) throws Exception;
 
-        /**
+    /**
      * getWorkspaceId gets an id of given workspace in default repository under given domain
      * @param tenantDomain domain representing tenant
      * @param workspaceName name of the workspace
@@ -72,7 +75,7 @@ public interface RepositoryClient extends StorageClient {
             throws DocumentNotFoundException, DocumentException;
 
     /**
-     * find wrapped documentModel from the Nuxeo repository
+     * Find wrapped documentModel from the Nuxeo repository
      * @param ctx service context under which this method is invoked
      * @param specifies docType. If null, uses ctx.getDocumentType()
      * @param where NXQL where clause to get the document
@@ -83,7 +86,7 @@ public interface RepositoryClient extends StorageClient {
             throws DocumentNotFoundException, DocumentException;
 
     /**
-     * find doc and return CSID from the Nuxeo repository
+     * Find doc and return CSID from the Nuxeo repository
      * @param ctx service context under which this method is invoked
      * @param specifies docType. If null, uses ctx.getDocumentType()
      * @param where NXQL where clause to get the document
@@ -93,4 +96,15 @@ public interface RepositoryClient extends StorageClient {
                ServiceContext ctx, String where)
             throws DocumentNotFoundException, DocumentException;
 
+    /**
+     * Find a list of documentModels from the Nuxeo repository
+     * @param docTypes a list of DocType names to match
+     * @param where the clause to qualify on
+     * @param domain the domain for the associated services
+     * @return
+     */
+    public DocumentWrapper<DocumentModelList> findDocs(
+               List<String> docTypes, String where, String domain,
+               int pageSize, int pageNum, boolean computeTotal )
+            throws DocumentNotFoundException, DocumentException;
 }
diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
new file mode 100644 (file)
index 0000000..83c0ec1
--- /dev/null
@@ -0,0 +1,87 @@
+/**\r
+ *  This document is a part of the source code and related artifacts\r
+ *  for CollectionSpace, an open source collections management system\r
+ *  for museums and related institutions:\r
+\r
+ *  http://www.collectionspace.org\r
+ *  http://wiki.collectionspace.org\r
+\r
+ *  Copyright 2009 University of California at Berkeley\r
+\r
+ *  Licensed under the Educational Community License (ECL), Version 2.0.\r
+ *  You may not use this file except in compliance with this License.\r
+\r
+ *  You may obtain a copy of the ECL 2.0 License at\r
+\r
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt\r
+\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+package org.collectionspace.services.common.vocabulary;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.nuxeo.ecm.core.api.DocumentModelList;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.collectionspace.services.common.ServiceMain;\r
+import org.collectionspace.services.common.authorityref.AuthorityRefDocList;\r
+import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
+import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;\r
+import org.collectionspace.services.common.context.ServiceBindingUtils;\r
+import org.collectionspace.services.common.document.DocumentException;\r
+import org.collectionspace.services.common.document.DocumentNotFoundException;\r
+import org.collectionspace.services.common.document.DocumentWrapper;\r
+import org.collectionspace.services.common.repository.RepositoryClient;\r
+import org.collectionspace.services.common.service.ServiceBindingType;\r
+\r
+/**\r
+ * RefNameServiceUtils is a collection of services utilities related to refName usage.\r
+ *\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ */\r
+public class RefNameServiceUtils {\r
+       \r
+       public static final String AUTH_REF_PROP = "authRef";\r
+\r
+    private final Logger logger = LoggerFactory.getLogger(RefNameServiceUtils.class);\r
+    \r
+    public AuthorityRefDocList getAuthorityRefDocs(RepositoryClient repoClient, \r
+               String tenantId, String serviceType, String refName,\r
+               int pageSize, int pageNum, boolean computeTotal )\r
+               throws DocumentException, DocumentNotFoundException {\r
+       AuthorityRefDocList wrapperList = new AuthorityRefDocList();\r
+        List<AuthorityRefDocList.AuthorityRefDocItem> list = \r
+               wrapperList.getAuthorityRefDocItem();\r
+       TenantBindingConfigReaderImpl tReader =\r
+            ServiceMain.getInstance().getTenantBindingConfigReader();\r
+       List<ServiceBindingType> servicebindings = tReader.getServiceBindingsByType(tenantId, serviceType);\r
+       if(servicebindings==null || servicebindings.size()>0)\r
+               return null;\r
+       String domain = tReader.getTenantBinding(tenantId).getRepositoryDomain();\r
+       ArrayList<String> docTypes = new ArrayList<String>(); \r
+       StringBuilder whereClause = new StringBuilder();\r
+       for(ServiceBindingType sb:servicebindings) {\r
+               List<String> authRefFields = ServiceBindingUtils.getPropertyValues(sb, AUTH_REF_PROP);\r
+               String docType = sb.getObject().getName();\r
+               docTypes.add(docType);\r
+               for(String field:authRefFields) {\r
+                       // Build up the where clause for each authRef field\r
+                       throw new UnsupportedOperationException();\r
+               }\r
+       }\r
+               // Now we have to issue the search\r
+               DocumentWrapper<DocumentModelList> docListWrapper = repoClient.findDocs(\r
+                       docTypes, whereClause.toString(), domain, pageSize, pageNum, computeTotal );\r
+       return null;\r
+    }\r
+\r
+               \r
+}\r
+\r
index 6efb988a71f3add81493c72a1332235b478d1cef..435e2ae1d2f02e5f848bc995d60090fce4e75b1a 100644 (file)
@@ -191,7 +191,6 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
     
     public AuthorityRefList getAuthorityRefs(
                DocumentWrapper<DocumentModel> docWrapper,
-               String pathPrefix,
                List<String> authRefFields) {
        AuthorityRefList authRefList = new AuthorityRefList();
         try {
@@ -200,7 +199,7 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
                authRefList.getAuthorityRefItem();
 
             for(String field:authRefFields){
-                       String refName = (String)docModel.getPropertyValue(pathPrefix+field);
+                       String refName = (String)docModel.getPropertyValue(field);
                        if(refName==null)
                                continue;
                try{
index 98ca8e7aa4a812b8efc69ce127f0f2ff2da41ddc..9ce6d6d7795ba4a1197a77560e9dd8c06027b769 100644 (file)
@@ -378,6 +378,53 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
                return csid;
     }
 
+    /**
+     * Find a list of documentModels from the Nuxeo repository
+     * @param docTypes a list of DocType names to match
+     * @param where the clause to qualify on
+     * @param domain the domain for the associated services
+     * @return
+     */
+    @Override
+    public DocumentWrapper<DocumentModelList> findDocs(
+               List<String> docTypes, String where, String domain,
+               int pageSize, int pageNum, boolean computeTotal )
+            throws DocumentNotFoundException, DocumentException {
+        RepositoryInstance repoSession = null;
+        DocumentWrapper<DocumentModelList> wrapDoc = null;
+
+        try {
+            if (docTypes == null || docTypes.size()<1) {
+                throw new DocumentNotFoundException(
+                       "findDocs must specify at least one DocumentType.");
+            }
+            if (domain == null) {
+                throw new DocumentNotFoundException("findDocs must specify Domain.");
+            }
+            repoSession = getRepositorySession();
+            DocumentModelList docList = null;
+            // force limit to 1, and ignore totalSize
+            String query = buildNXQLQuery(docTypes, where, domain ); 
+            docList = repoSession.query( query, null, pageSize, pageNum, computeTotal);
+            wrapDoc = new DocumentWrapperImpl<DocumentModelList>(docList);
+        } catch (IllegalArgumentException iae) {
+            throw iae;
+        } catch (DocumentException de) {
+            throw de;
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception ", e);
+            }
+            throw new DocumentException(e);
+        } finally {
+            if (repoSession != null) {
+                releaseRepositorySession(repoSession);
+            }
+        }
+        return wrapDoc;
+    }
+
+    
     @Override
     public void get(ServiceContext ctx, List<String> csidList, DocumentHandler handler)
                throws DocumentNotFoundException, DocumentException {
@@ -693,9 +740,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
         return workspaceId;
     }
     
-    private final String buildNXQLQuery(String docType, String where, String domain ) {
-        StringBuilder query = new StringBuilder("SELECT * FROM ");
-        query.append(docType);
+    private final void appendNXQLWhere(StringBuilder query, String where, String domain ) {
         // TODO This is a slow method for tenant-filter
         // We should make this a property that is indexed.
         query.append(" WHERE ecm:path STARTSWITH '/" + domain + "'");
@@ -704,6 +749,26 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
                // into SQL, we need to parenthesize our 'where' clause
             query.append(" AND " + "(" + where +")" + "AND ecm:isProxy = 0");
         }
+    }
+
+    private final String buildNXQLQuery(String docType, String where, String domain ) {
+        StringBuilder query = new StringBuilder("SELECT * FROM ");
+        query.append(docType);
+        appendNXQLWhere(query, where, domain );
+        return query.toString();
+    }
+
+    private final String buildNXQLQuery(List<String> docTypes, String where, String domain ) {
+        StringBuilder query = new StringBuilder("SELECT * FROM ");
+        boolean fFirst = true;
+        for(String docType:docTypes) {
+               if(fFirst) {
+                query.append(",");
+                fFirst = false;
+               }
+            query.append(docType);
+        }
+        appendNXQLWhere(query, where, domain );
         return query.toString();
     }
 
index 78e85f2fed52ec5e258d6fedc09e0f1eb52ca4a8..c6d97a40c279a2817b11d160b2cbc06189783632 100644 (file)
@@ -46,6 +46,7 @@
             <xs:element name="repositoryWorkspaceId" type="xs:string" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
         <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="type" type="xs:string" use="optional"/>
         <xs:attribute name="version" type="types:VersionType" use="required"/>
     </xs:complexType>
 
index 3693342d2e9e2a218a17c7dc713bbe2c6d766039..6efbcc25dfe0417eee082bebf11e3e4d451b7f85 100644 (file)
@@ -268,7 +268,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest {
      * at any point during testing, even if some of those resources
      * may be expected to be deleted by certain tests.
      */
-    // @AfterClass(alwaysRun=true)
+    @AfterClass(alwaysRun=true)
     public void cleanUp() {
         if (logger.isDebugEnabled()) {
             logger.debug("Cleaning up temporary resources created for testing ...");
index 159d79696f964d7980de0ebe1642ef221e743340..718b520bfdb7c0317682693cb288cf79f1005340 100644 (file)
@@ -55,6 +55,7 @@ import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.query.IQueryManager;
 import org.collectionspace.services.common.query.QueryManager;
 import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
@@ -212,9 +213,8 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl {
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues("authRef");
-            String prefix = ctx.getCommonPartLabel()+":";
-            authRefList = handler.getAuthorityRefs(docWrapper, prefix, authRefFields);
+            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
                     Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();