]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1079 Search for documents that refer to a given Person item. Added support...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 21 Apr 2010 06:15:30 +0000 (06:15 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 21 Apr 2010 06:15:30 +0000 (06:15 +0000)
24 files changed:
services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/src/main/resources/OSGI-INF/core-types-contrib.xml
services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/src/main/resources/OSGI-INF/layouts-contrib.xml
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/PropertyItemUtils.java
services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java
services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingUtils.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
services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.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/intake/client/pom.xml
services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java [new file with mode: 0644]
services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java
services/jaxb/src/main/resources/authorityrefdocs.xsd [new file with mode: 0644]
services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java
services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java
services/person/client/pom.xml
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java
services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java

index e3b2a71d9a2c5c0174d3e69ac06be6aca547fa28..e2b0c7c7392757d222abcec9e0b243448a40f481 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <component name="org.collectionspace.acquisition.coreTypes">
   <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
-    <schema name="acquisitions_common" prefix="acq" src="schemas/acquisitions_common.xsd"/>
+    <schema name="acquisitions_common" prefix="acquisitions_common" src="schemas/acquisitions_common.xsd"/>
   </extension>
   <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
     <doctype name="Acquisition" extends="Document">
index 1e0da7c206e0e5a4af7daba1302dc30a2606e286..54a1f0c5f1c5acf59d3a5f5d1c9d237b5c4b9c3e 100644 (file)
       <rows>
         <row><widget>accessionDate</widget></row>
         <row><widget>acquisitionAuthorizer</widget></row>
-        <row><widget>AcquisitionAuthorizerDate</widget></row>
-        <row><widget>AcquisitionDate</widget></row>
-        <row><widget>AcquisitionFundingDenomination</widget></row>
-        <row><widget>AcquisitionFundingSource</widget></row>
-        <row><widget>AcquisitionFundingSourceProvisos</widget></row>
-        <row><widget>AcquisitionMethod</widget></row>
-        <row><widget>AcquisitionNote</widget></row>
-        <row><widget>AcquisitionProvisos</widget></row>
-        <row><widget>AcquisitionReason</widget></row>
-        <row><widget>AcquisitionReferenceNumber</widget></row>
-        <row><widget>AcquisitionSource</widget></row>
-        <row><widget>GroupPurchasePriceDenomination</widget></row>
-        <row><widget>GroupPurchasePriceValue</widget></row>
-        <row><widget>ObjectOfferPriceDenomination</widget></row>
-        <row><widget>ObjectOfferPriceValue</widget></row>
-        <row><widget>ObjectPurchaseOfferPriceDenomination</widget></row>
-        <row><widget>ObjectPurchaseOfferPriceValue</widget></row>
-        <row><widget>ObjectPurchasePriceDenomination</widget></row>
-        <row><widget>ObjectPurchasePriceValue</widget></row>
-        <row><widget>OriginalObjectPurchasePriceDenomination</widget></row>
-        <row><widget>OriginalObjectPurchasePriceValue</widget></row>
-        <row><widget>TransferOfTitleNumber</widget></row>
+        <row><widget>acquisitionAuthorizerDate</widget></row>
+        <row><widget>acquisitionDate</widget></row>
+        <row><widget>acquisitionFundingDenomination</widget></row>
+        <row><widget>acquisitionFundingValue</widget></row>
+        <row><widget>acquisitionFundingSource</widget></row>
+        <row><widget>acquisitionFundingSourceProvisos</widget></row>
+        <row><widget>acquisitionMethod</widget></row>
+        <row><widget>acquisitionNote</widget></row>
+        <row><widget>acquisitionProvisos</widget></row>
+        <row><widget>acquisitionReason</widget></row>
+        <row><widget>acquisitionReferenceNumber</widget></row>
+        <row><widget>acquisitionSource</widget></row>
+        <row><widget>groupPurchasePriceDenomination</widget></row>
+        <row><widget>groupPurchasePriceValue</widget></row>
+        <row><widget>objectOfferPriceDenomination</widget></row>
+        <row><widget>objectOfferPriceValue</widget></row>
+        <row><widget>objectPurchaseOfferPriceDenomination</widget></row>
+        <row><widget>objectPurchaseOfferPriceValue</widget></row>
+        <row><widget>objectPurchasePriceDenomination</widget></row>
+        <row><widget>objectPurchasePriceValue</widget></row>
+        <row><widget>originalObjectPurchasePriceDenomination</widget></row>
+        <row><widget>originalObjectPurchasePriceValue</widget></row>
+        <row><widget>transferOfTitleNumber</widget></row>
         <row><widget>fieldCollectionDate</widget></row>
         <row><widget>fieldCollectionEventName</widget></row>
         <row><widget>fieldCollectionNumber</widget></row>
@@ -46,7 +47,7 @@
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:accessionDate</field>
+          <field>acquisitions_common:accessionDate</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:acquisitionAuthorizer</field>
+          <field>acquisitions_common:acquisitionAuthorizer</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionAuthorizerDate" type="text">
+      <widget name="acquisitionAuthorizerDate" type="text">
         <labels>
-          <label mode="any">AcquisitionAuthorizerDate</label>
+          <label mode="any">acquisitionAuthorizerDate</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:acquisitionAuthorizerDate</field>
+          <field>acquisitions_common:acquisitionAuthorizerDate</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionDate" type="text">
+      <widget name="acquisitionDate" type="text">
         <labels>
-          <label mode="any">AcquisitionDate</label>
+          <label mode="any">acquisitionDate</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:acquisitionDate</field>
+          <field>acquisitions_common:acquisitionDate</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionFunding" type="text">
+      <widget name="acquisitionFundingDenomination" type="text">
         <labels>
-          <label mode="any">AcquisitionFunding</label>
+          <label mode="any">acquisitionFundingDenomination</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:acquisitionFunding</field>
+          <field>acquisitions_common:acquisitionFundingDenomination</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="AcquisitionFundingDenomination" type="text">
+      <widget name="acquisitionFundingValue" type="text">
         <labels>
-          <label mode="any">AcquisitionFundingDenomination</label>
+          <label mode="any">acquisitionFundingValue</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:acquisitionFundingDenomination</field>
+          <field>acquisitions_common:acquisitionFundingValue</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="AcquisitionFundingDenomination" type="text">
+      <widget name="acquisitionFundingSource" type="text">
         <labels>
-          <label mode="any">AcquisitionFundingValue</label>
+          <label mode="any">acquisitionFundingSource</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:acquisitionFundingValue</field>
-        </fields>
-        <properties widgetMode="edit">
-          <property name="styleClass">dataInputText</property>
-        </properties>
-      </widget>
-
-      <widget name="AcquisitionFundingSource" type="text">
-        <labels>
-          <label mode="any">AcquisitionFundingSource</label>
-        </labels>
-        <translated>true</translated>
-        <fields>
-          <field>acq:acquisitionFundingSource</field>
+          <field>acquisitions_common:acquisitionFundingSource</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionFundingSourceProvisos" type="text">
+      <widget name="acquisitionFundingSourceProvisos" type="text">
         <labels>
-          <label mode="any">AcquisitionFundingSourceProvisos</label>
+          <label mode="any">acquisitionFundingSourceProvisos</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:AcquisitionFundingSourceProvisos</field>
+          <field>acquisitions_common:acquisitionFundingSourceProvisos</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionMethod" type="text">
+      <widget name="acquisitionMethod" type="text">
         <labels>
-          <label mode="any">AcquisitionMethod</label>
+          <label mode="any">acquisitionMethod</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:AcquisitionMethod</field>
+          <field>acquisitions_common:acquisitionMethod</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionNote" type="text">
+      <widget name="acquisitionNote" type="text">
         <labels>
-          <label mode="any">AcquisitionNote</label>
+          <label mode="any">acquisitionNote</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:AcquisitionNote</field>
+          <field>acquisitions_common:acquisitionNote</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionProvisos" type="text">
+      <widget name="acquisitionProvisos" type="text">
         <labels>
-          <label mode="any">AcquisitionProvisos</label>
+          <label mode="any">acquisitionProvisos</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:AcquisitionProvisos</field>
+          <field>acquisitions_common:acquisitionProvisos</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionReason" type="text">
+      <widget name="acquisitionReason" type="text">
         <labels>
-          <label mode="any">AcquisitionReason</label>
+          <label mode="any">acquisitionReason</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:AcquisitionReason</field>
+          <field>acquisitions_common:acquisitionReason</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionReferenceNumber" type="text">
+      <widget name="acquisitionReferenceNumber" type="text">
         <labels>
-          <label mode="any">AcquisitionReferenceNumber</label>
+          <label mode="any">acquisitionReferenceNumber</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:AcquisitionReferenceNumber</field>
+          <field>acquisitions_common:acquisitionReferenceNumber</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="AcquisitionSource" type="text">
+      <widget name="acquisitionSource" type="text">
         <labels>
-          <label mode="any">AcquisitionSource</label>
+          <label mode="any">acquisitionSources</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:AcquisitionSource</field>
+          <field>acquisitions_common:acquisitionSources</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="GroupPurchasePriceDenomination" type="text">
+      <widget name="groupPurchasePriceDenomination" type="text">
         <labels>
-          <label mode="any">GroupPurchasePriceDenomination</label>
+          <label mode="any">groupPurchasePriceDenomination</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:groupPurchasePriceDenomination</field>
+          <field>acquisitions_common:groupPurchasePriceDenomination</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="GroupPurchasePriceValue" type="text">
+      <widget name="groupPurchasePriceValue" type="text">
         <labels>
-          <label mode="any">GroupPurchasePriceValue</label>
+          <label mode="any">groupPurchasePriceValue</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:groupPurchasePriceValue</field>
+          <field>acquisitions_common:groupPurchasePriceValue</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="ObjectOfferPriceDenomination" type="text">
+      <widget name="objectOfferPriceDenomination" type="text">
         <labels>
-          <label mode="any">ObjectOfferPriceDenomination</label>
+          <label mode="any">objectOfferPriceDenomination</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:objectOfferPriceDenomination</field>
+          <field>acquisitions_common:objectOfferPriceDenomination</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-     <widget name="ObjectOfferPriceValue" type="text">
+     <widget name="objectOfferPriceValue" type="text">
         <labels>
           <label mode="any">objectOfferPriceValue</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:objectOfferPriceValue</field>
+          <field>acquisitions_common:objectOfferPriceValue</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
       
-      <widget name="ObjectPurchaseOfferPriceDenomination" type="text">
+      <widget name="objectPurchaseOfferPriceDenomination" type="text">
         <labels>
-          <label mode="any">ObjectPurchaseOfferPriceDenomination</label>
+          <label mode="any">objectPurchaseOfferPriceDenomination</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:objectPurchaseOfferPriceDenomination</field>
+          <field>acquisitions_common:objectPurchaseOfferPriceDenomination</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-       <widget name="ObjectPurchaseOfferPriceValue" type="text">
+       <widget name="objectPurchaseOfferPriceValue" type="text">
         <labels>
-          <label mode="any">ObjectPurchaseOfferPriceValue</label>
+          <label mode="any">objectPurchaseOfferPriceValue</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:objectPurchaseOfferPriceValue</field>
+          <field>acquisitions_common:objectPurchaseOfferPriceValue</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="ObjectPurchasePriceDenomination" type="text">
+      <widget name="objectPurchasePriceDenomination" type="text">
         <labels>
-          <label mode="any">ObjectPurchasePriceDenomination</label>
+          <label mode="any">objectPurchasePriceDenomination</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:objectPurchasePriceDenomination</field>
+          <field>acquisitions_common:objectPurchasePriceDenomination</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-       <widget name="ObjectPurchasePriceValue" type="text">
+       <widget name="objectPurchasePriceValue" type="text">
         <labels>
-          <label mode="any">ObjectPurchasePriceValue</label>
+          <label mode="any">objectPurchasePriceValue</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:objectPurchasePriceValue</field>
+          <field>acquisitions_common:objectPurchasePriceValue</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="OriginalObjectPurchasePriceDenomination" type="text">
+      <widget name="originalObjectPurchasePriceDenomination" type="text">
         <labels>
-          <label mode="any">OriginalObjectPurchasePriceDenomination</label>
+          <label mode="any">originalObjectPurchasePriceDenomination</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:OriginalObjectPurchasePriceDenomination</field>
+          <field>acquisitions_common:originalObjectPurchasePriceDenomination</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="OriginalObjectPurchasePriceValue" type="text">
+      <widget name="originalObjectPurchasePriceValue" type="text">
         <labels>
-          <label mode="any">OriginalObjectPurchasePriceValue</label>
+          <label mode="any">originalObjectPurchasePriceValue</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:originalObjectPurchasePriceValue</field>
+          <field>acquisitions_common:originalObjectPurchasePriceValue</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </properties>
       </widget>
 
-      <widget name="TransferOfTitleNumber" type="text">
+      <widget name="transferOfTitleNumber" type="text">
         <labels>
-          <label mode="any">TransferOfTitleNumber</label>
+          <label mode="any">transferOfTitleNumber</label>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:transferOfTitleNumber</field>
+          <field>acquisitions_common:transferOfTitleNumber</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:fieldCollectionDate</field>
+          <field>acquisitions_common:fieldCollectionDate</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:fieldCollectionEventName</field>
+          <field>acquisitions_common:fieldCollectionEventName</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:fieldCollectionNumber</field>
+          <field>acquisitions_common:fieldCollectionNumber</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
         </labels>
         <translated>true</translated>
         <fields>
-          <field>acq:fieldCollector</field>
+          <field>acquisitions_common:fieldCollector</field>
         </fields>
         <properties widgetMode="edit">
           <property name="styleClass">dataInputText</property>
index ab6a8c5d7edbef187265dab1d4d2acbfe848b454..5065ddb7855c5400dd29f82b38d7a44dcb132b61 100644 (file)
@@ -43,6 +43,7 @@ import javax.ws.rs.core.UriInfo;
 import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
@@ -433,7 +434,9 @@ public class AcquisitionResource
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            List<String> authRefFields = 
+               ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
+                               ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
             authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
index 643a29481af37f853c8c18e5b5f33bda8ffd1fb8..df2b554b9487bc9fe060470b3b0aabee15eae686 100644 (file)
@@ -49,6 +49,7 @@ import org.collectionspace.services.common.context.ServiceContextFactory;
 //import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.MultipartServiceContextFactory;
 import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
 import org.collectionspace.services.common.document.DocumentFilter;
@@ -439,7 +440,9 @@ public class CollectionObjectResource
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            List<String> authRefFields = 
+               ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
+                               ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
             authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
index a9cd3d2def71fbe5a914defd5ae58c6b6e0145d6..f77ae2107a0ff0de95c8b29edc10a31b0088c132 100644 (file)
             <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
                 org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler
             </service:validatorHandler>
-            <service:object name="CollectionObject" version="0.1"
+                                               <service:properties xmlns:service='http://collectionspace.org/services/common/service'>
+                                                       <types:item><types:key>objectNameProperty</types:key><types:value>objectName</types:value></types:item>
+                                                       <types:item><types:key>objectNumberProperty</types:key><types:value>objectNumber</types:value></types:item>
+                                               </service:properties>                                                                                                                   
+               <service:object name="CollectionObject" version="0.1"
                             xmlns:service='http://collectionspace.org/services/common/service'>
                 <service:part id="0" control_group="Managed"
                               versionable="true" auditable="false"
             <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
                 org.collectionspace.services.intake.nuxeo.IntakeValidatorHandler
             </service:validatorHandler>
+                                               <service:properties xmlns:service='http://collectionspace.org/services/common/service'>
+                                                       <!-- What to use for name??? 
+                                                       <types:item><types:key>objectNameProperty</types:key><types:value>objectName</types:value></types:item> -->
+                                                       <types:item><types:key>objectNumberProperty</types:key><types:value>entryNumber</types:value></types:item>
+                                               </service:properties>                                                                                                                   
             <service:object name="Intake" version="0.1"
                             xmlns:service='http://collectionspace.org/services/common/service'>
                 <service:part id="0" control_group="Managed"
             <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
                 org.collectionspace.services.loanin.nuxeo.LoaninValidatorHandler
             </service:validatorHandler>
+                                               <service:properties xmlns:service='http://collectionspace.org/services/common/service'>
+                                                       <!-- What to use for name??? 
+                                                       <types:item><types:key>objectNameProperty</types:key><types:value>objectName</types:value></types:item> -->
+                                                       <types:item><types:key>objectNumberProperty</types:key><types:value>loanInNumber</types:value></types:item>
+                                               </service:properties>                                                                                                                   
             <service:object name="Loanin" version="0.1"
                             xmlns:service='http://collectionspace.org/services/common/service'>
                 <service:part id="0" control_group="Managed"
                         <types:item><types:key>authRef</types:key><types:value>borrowersContact</types:value></types:item>
                         <types:item><types:key>authRef</types:key><types:value>lendersAuthorizer</types:value></types:item>
                         <types:item><types:key>authRef</types:key><types:value>lendersContact</types:value></types:item>
-                    </service:properties>
+                                                                                       </service:properties>
                     <service:content contentType="application/xml">
                         <service:xmlContent
                             namespaceURI="http://collectionspace.org/services/loanout"
                 <service:part id="1" control_group="Managed"
                               versionable="true" auditable="false"
                               label="organizations_common" updated="" order="1">
+                                                                               <service:properties>
+                                                                                       <types:item><types:key>authRef</types:key><types:value>contactName</types:value></types:item>
+                                                                               </service:properties>
+
                     <service:content contentType="application/xml">
                         <service:xmlContent
                             namespaceURI="http://collectionspace.org/services/organization"
             <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
                 org.collectionspace.services.acquisition.nuxeo.AcquisitionValidatorHandler
             </service:validatorHandler>
+                                               <service:properties xmlns:service='http://collectionspace.org/services/common/service'>
+                                                       <!-- What to use for name??? 
+                                                       <types:item><types:key>objectNameProperty</types:key><types:value>objectName</types:value></types:item> -->
+                                                       <types:item><types:key>objectNumberProperty</types:key><types:value>acquisitionReferenceNumber</types:value></types:item>
+                                               </service:properties>                                                                                                                   
             <service:object name="Acquisition" version="0.1"
                             xmlns:service='http://collectionspace.org/services/common/service'>
                 <service:part id="0" control_group="Managed"
index 6c56370e174eb14f3b47e7e14ac24464dc050cdc..cb79c418f20b99a0278e318b4b8c9c7daed8134c 100644 (file)
@@ -13,12 +13,12 @@ public class PropertyItemUtils {
      * @param propName the property to fetch\r
      * @return the String value of the named property\r
      */\r
-    public static String getPropertyValueFromNodeList(List<PropertyType> propNodeList,\r
+    public static String getPropertyValueByNameFromNodeList(List<PropertyType> propNodeList,\r
                String propName) {\r
                if(propNodeList.isEmpty()) {\r
                        return null;\r
                }\r
-               return getPropertyValue(propNodeList.get(0).getItem(), propName);\r
+               return getPropertyValueByName(propNodeList.get(0).getItem(), propName);\r
     }\r
        \r
        \r
@@ -27,7 +27,7 @@ public class PropertyItemUtils {
      * @param propName the property to fetch\r
      * @return the String value of the named property\r
      */\r
-    public static String getPropertyValue(List<PropertyItemType> propList,\r
+    public static String getPropertyValueByName(List<PropertyItemType> propList,\r
                String propName) {\r
        if(propName==null) {\r
                throw new IllegalArgumentException("PropertyItemUtils.getPropertyValues: null property name!");\r
@@ -40,27 +40,56 @@ public class PropertyItemUtils {
        return null;\r
     }\r
     \r
+    /**\r
+     * @param propNodeList the JAXB wrapping node of for the list to search for the named property\r
+     * @param propName the name of the property of interest\r
+     * @param qualPrefix a namespace qualifier prefix (with ':') to prepend, or null\r
+     * @return a List of string values found for the named property\r
+     */\r
     public static List<String> getPropertyValuesByNameInNodeList(\r
-               List<PropertyType> propNodeList, String propName) {\r
-       return getPropertyValuesByNameInNodeList(propNodeList, propName, null);\r
+               List<PropertyType> propNodeList, String propName, String qualPrefix) {\r
+       return getPropertyValuesByNameInNodeList(propNodeList, propName, qualPrefix, null);\r
     }\r
     \r
+    /**\r
+     * @param propNodeList the JAXB wrapping node of for the list to search for the named property\r
+     * @param propName the name of the property of interest\r
+     * @param qualPrefix a namespace qualifier prefix (with ':') to prepend, or null\r
+     * @param values and existing list to append values to. If null, a new one will be created.\r
+     * @return values, or that is null, a new List of string values found for the named property\r
+     */\r
     public static List<String> getPropertyValuesByNameInNodeList(\r
-               List<PropertyType> propNodeList, String propName, List<String> values) {\r
+               List<PropertyType> propNodeList, String propName, String qualPrefix,\r
+               List<String> values) {\r
                if(propNodeList.isEmpty()) {\r
                if(values==null)\r
-                       return new ArrayList<String>();\r
+                       values = new ArrayList<String>();\r
+               return values;\r
                }\r
-       return getPropertyValuesByName(propNodeList.get(0).getItem(), propName, null);\r
+       return getPropertyValuesByName(propNodeList.get(0).getItem(), \r
+                                                                       propName, qualPrefix, values);\r
     }\r
     \r
+    /**\r
+     * @param propNodeList the Item list to search for the named property\r
+     * @param propName the name of the property of interest\r
+     * @param qualPrefix a namespace qualifier prefix (with ':') to prepend, or null\r
+     * @return a List of string values found for the named property\r
+     */\r
     public static List<String> getPropertyValuesByName(\r
-               List<PropertyItemType> propItems, String propName) {\r
-       return getPropertyValuesByName(propItems, propName, null);\r
+               List<PropertyItemType> propItems, String propName, String qualPrefix) {\r
+       return getPropertyValuesByName(propItems, propName, qualPrefix, null);\r
     }\r
     \r
+    /**\r
+     * @param propNodeList the Item list to search for the named property\r
+     * @param propName the name of the property of interest\r
+     * @param qualPrefix a namespace qualifier prefix (with ':') to prepend, or null\r
+     * @param values and existing list to append values to. If null, a new one will be created.\r
+     * @return values, or that is null, a new List of string values found for the named property\r
+     */\r
     public static List<String> getPropertyValuesByName(\r
-               List<PropertyItemType> propItems, String propName,\r
+               List<PropertyItemType> propItems, String propName, String qualPrefix,\r
                List<String> values ) {\r
        if(values==null)\r
                values = new ArrayList<String>();\r
@@ -68,7 +97,7 @@ public class PropertyItemUtils {
                if(propName.equals(propItem.getKey())) {\r
                        String value = propItem.getValue();\r
                        if(value!=null) {\r
-                               values.add(value);\r
+                               values.add((qualPrefix!=null)?(qualPrefix+value):value);\r
                        }\r
                }\r
        }\r
index b92cbe2709b91f08d91af39514399ad719ad925c..c30b1fbe88088f0360ab1dad2b078b72c629e9df 100644 (file)
@@ -241,7 +241,7 @@ public class TenantBindingConfigReaderImpl
         TenantBindingType tenant = tenantBindings.get(tenantId);
         if (tenant != null) {
             for (ServiceBindingType sb : tenant.getServiceBindings()) {
-                if (sb.getType().equals(serviceType)) {
+                if (serviceType.equals(sb.getType())) {
                     if (list == null) {
                         list = new ArrayList<ServiceBindingType>();
                     }
@@ -263,6 +263,11 @@ public class TenantBindingConfigReaderImpl
         return serviceWorkspaces.get(tenantService);
     }
 
+    /**
+     * @param tenantId
+     * @param serviceName
+     * @return the properly qualified service name
+     */
     public static String getTenantQualifiedServiceName(
             String tenantId, String serviceName) {
         return tenantId + "." + serviceName.toLowerCase();
@@ -272,6 +277,14 @@ public class TenantBindingConfigReaderImpl
         return RepositoryClientFactory.getInstance().getClient(clientName);
     }
 
+    /**
+     * Sets properties in the passed list on the local properties for this TenantBinding.
+     * Note: will only set properties not already set on the TenantBinding.
+     * 
+     * @param propList
+     * @param propagateToServices If true, recurses to set set properties 
+     *                         on the associated services.
+     */
     public void setDefaultPropertiesOnTenants(List<PropertyItemType> propList,
             boolean propagateToServices) {
         // For each tenant, set properties in list that are not already set
index 3aa85947e648b6a9fab439aec9e10fdef6d2f668..de64c3e371c62bd4ccfc88788c0133e71683434d 100644 (file)
@@ -25,7 +25,7 @@ public class TenantBindingUtils {
                throw new IllegalArgumentException("TenantBindingUtils.getPropertyValues: null property name!");\r
        }\r
                List<PropertyType> tenantPropList = tenantBinding.getProperties();\r
-               return PropertyItemUtils.getPropertyValueFromNodeList(tenantPropList, propName );\r
+               return PropertyItemUtils.getPropertyValueByNameFromNodeList(tenantPropList, propName );\r
     }\r
     \r
     /**\r
index b30bf5a0db88b72f511c9a2547cd5996f963f925..00ea2611eba6b17499934080928e8d610a9dceae 100644 (file)
@@ -61,6 +61,18 @@ import org.slf4j.LoggerFactory;
  * $LastChangedRevision: $
  * $LastChangedDate: $
  */
+/**
+ * @author pschmitz
+ *
+ * @param <IT>
+ * @param <OT>
+ */
+/**
+ * @author pschmitz
+ *
+ * @param <IT>
+ * @param <OT>
+ */
 public abstract class AbstractServiceContextImpl<IT, OT>
         implements ServiceContext<IT, OT> {
 
@@ -178,27 +190,26 @@ public abstract class AbstractServiceContextImpl<IT, OT>
     }
 
     /**
-     * Gets the property values for part.
-     * 
-     * @param partLabel the part label
-     * @param propName the prop name
-     * 
-     * @return the property values for part
+     * @param partLabel The name of the scehma part to search in
+     * @param propName The name of the property (or properties) to find
+     * @param qualified Whether the returned values should be qualified with the
+     *                 partLabel. This is when the property values are schema field references.
+     * @return List of property values for the matched property on the named schema part.
      */
-    public List<String> getPropertyValuesForPart(String partLabel, String propName) {
+    public List<String> getPropertyValuesForPart(String partLabel, String propName, boolean qualified) {
        List<PropertyItemType> allProps = getPropertiesForPart(partLabel);
-       return PropertyItemUtils.getPropertyValuesByName(allProps, propName);
+       return PropertyItemUtils.getPropertyValuesByName(allProps, propName, 
+                                                                                                       (qualified?(partLabel+":"):null));
     }
 
     /**
-     * Gets the all parts property values.
-     * 
-     * @param propName the prop name
-     * 
-     * @return the all parts property values
+     * @param propName The name of the property (or properties) to find
+     * @param qualified Whether the returned values should be qualified with the
+     *                 partLabel. This is when the property values are schema field references.
+     * @return List of property values for the matched property on any schema part.
      */
-    public List<String> getAllPartsPropertyValues(String propName) {
-        return ServiceBindingUtils.getAllPartsPropertyValues(getServiceBinding(), propName);
+    public List<String> getAllPartsPropertyValues(String propName, boolean qualified) {
+        return ServiceBindingUtils.getAllPartsPropertyValues(getServiceBinding(), propName, qualified);
     }
     
     /* (non-Javadoc)
@@ -218,14 +229,13 @@ public abstract class AbstractServiceContextImpl<IT, OT>
     }
 
     /**
-     * Gets the common part property values.
-     * 
-     * @param propName the prop name
-     * 
-     * @return the common part property values
+     * @param propName The name of the property (or properties) to find
+     * @param qualified Whether the returned values should be qualified with the
+     *                 partLabel. This is when the property values are schema field references.
+     * @return List of property values for the matched property on the common schema part.
      */
-    public List<String> getCommonPartPropertyValues(String propName) {
-        return getPropertyValuesForPart(getCommonPartLabel(), propName);
+    public List<String> getCommonPartPropertyValues(String propName, boolean qualified) {
+        return getPropertyValuesForPart(getCommonPartLabel(), propName, qualified);
     }
 
     /* (non-Javadoc)
index 31e2f4db53e4097daa1059f1bcefa6ec8ba3945b..8edfecbd0a8f7aecd951e6687f024cd905e4d5ac 100644 (file)
@@ -11,8 +11,23 @@ import org.collectionspace.services.common.service.ServiceObjectType;
 import org.collectionspace.services.common.tenant.TenantBindingType;\r
 import org.collectionspace.services.common.types.PropertyItemType;\r
 import org.collectionspace.services.common.types.PropertyType;\r
+import org.nuxeo.ecm.core.api.ClientException;\r
+import org.nuxeo.ecm.core.api.DocumentModel;\r
 \r
 public class ServiceBindingUtils {\r
+       public static final boolean QUALIFIED_PROP_NAMES = true;\r
+       public static final boolean UNQUALIFIED_PROP_NAMES = false;\r
+       public static final String AUTH_REF_PROP = "authRef";\r
+       public static final String OBJ_NUMBER_PROP = "objectNumberProperty";\r
+       public static final String OBJ_NAME_PROP = "objectNameProperty";\r
+       public static final String SERVICE_TYPE_PROP = "type";\r
+       public static final String SERVICE_TYPE_OBJECT = "object";\r
+       public static final String SERVICE_TYPE_PROCEDURE = "procedure";\r
+       \r
+       // TODO consider building up a hashTable of the properties for each\r
+       // service binding. There will be generic properties, as well as\r
+       // properties on each part. Could build up a key from tenant id, \r
+       // servicename, (partname for those props), propName\r
 \r
     public static void getPartsMetadata(ServiceBindingType serviceBinding, \r
                Map<String, ObjectPartType> objectPartMap) {\r
@@ -23,7 +38,7 @@ public class ServiceBindingUtils {
         }\r
     }\r
     \r
-    public static List<PropertyItemType> getPropertiesForPart(ServiceBindingType serviceBinding,\r
+    private static List<PropertyItemType> getPropertiesForPart(ServiceBindingType serviceBinding,\r
                String partLabel) {\r
         ServiceObjectType objectType = serviceBinding.getObject();\r
         List<ObjectPartType> objectPartTypes = objectType.getPart();\r
@@ -37,19 +52,27 @@ public class ServiceBindingUtils {
     }\r
 \r
     public static List<String> getPropertyValuesForPart(ServiceBindingType serviceBinding,\r
-               String partLabel, String propName) {\r
+               String partLabel, String propName, boolean qualify) {\r
        List<PropertyItemType> partProps = getPropertiesForPart(serviceBinding, partLabel);\r
-       return PropertyItemUtils.getPropertyValuesByName(partProps, propName);\r
+       return PropertyItemUtils.getPropertyValuesByName(partProps, propName, \r
+                                                                                                       (qualify?(partLabel+":"):null));\r
     }\r
 \r
+       /**\r
+        * @param serviceBinding the service to work from\r
+        * @param propName the name of the property of interest\r
+        * @param qualify if QUALIFIED_PROP_NAMES, will prefix all values with the part label\r
+        * @return a list of (qualified)\r
+        */\r
        public static List<String> getAllPartsPropertyValues(ServiceBindingType serviceBinding,\r
-               String propName) {\r
+               String propName, boolean qualify) {\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> propNodeList = objectPartType.getProperties();\r
-               PropertyItemUtils.getPropertyValuesByNameInNodeList(propNodeList, propName, values);\r
+               PropertyItemUtils.getPropertyValuesByNameInNodeList(propNodeList, \r
+                               propName, (qualify?(objectPartType.getLabel()+":"):null), values);\r
         }\r
        return values;\r
     }\r
@@ -65,7 +88,7 @@ public class ServiceBindingUtils {
                throw new IllegalArgumentException("ServiceBindingUtils.getPropertyValues: null property name!");\r
        }\r
                List<PropertyType> servicePropList = service.getProperties();\r
-               return PropertyItemUtils.getPropertyValueFromNodeList(servicePropList, propName );\r
+               return PropertyItemUtils.getPropertyValueByNameFromNodeList(servicePropList, propName );\r
     }\r
     \r
     /**\r
@@ -103,4 +126,27 @@ public class ServiceBindingUtils {
                                propName, value, onlyIfNotSet);\r
     }\r
     \r
+    public static String getMappedFieldInDoc( ServiceBindingType sb,\r
+               String logicalFieldName, DocumentModel docModel ) {\r
+       // Now we have to get the number, which is configured as some field\r
+       // on each docType\r
+       /* If we go to qualified field names, we'll need this\r
+       String[] strings = qPropName.split(":");\r
+       if(strings.length!=2) {\r
+               throw new RuntimeException(\r
+                               "getMappedFieldInDoc: Bad configuration of "\r
+                               +logicalFieldName+" field for: "+docModel.getDocumentType().getName());\r
+       }\r
+       */\r
+       String propName = getPropertyValue(sb, logicalFieldName);\r
+       if(propName==null||propName.isEmpty())\r
+               return null;\r
+       try {\r
+               return (String)docModel.getPropertyValue(propName);\r
+       } catch(ClientException ce) {\r
+               throw new RuntimeException(\r
+                               "getMappedFieldInDoc: Problem fetching: "+propName, ce);\r
+       }\r
+    } \r
+\r
 }\r
index 4a6467dd25d7ed7c4737a32f447a2c214f086184..3e8874a9dc45d331bad79e8790cc896537973bd6 100644 (file)
@@ -230,7 +230,6 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * filter that is relevant to be used with this document handler
      * and corresponding storage client
      * 
-     * @param ctx ServiceContext used to fetch default pagination, etc.
      * @return
      */
     public DocumentFilter createDocumentFilter();
index 98aab7e38dfcacc812f84fa1b138e99f69b5a03e..98b0d1d7c12cc922c7a9aee74261a93ba0ab001c 100644 (file)
 package org.collectionspace.services.common.vocabulary;\r
 \r
 import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
 import java.util.List;\r
 \r
+import org.nuxeo.ecm.core.api.ClientException;\r
+import org.nuxeo.ecm.core.api.DocumentModel;\r
 import org.nuxeo.ecm.core.api.DocumentModelList;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
@@ -39,6 +43,7 @@ import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;\r
 import org.collectionspace.services.common.repository.RepositoryClient;\r
 import org.collectionspace.services.common.service.ServiceBindingType;\r
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
 \r
 /**\r
  * RefNameServiceUtils is a collection of services utilities related to refName usage.\r
@@ -47,12 +52,10 @@ import org.collectionspace.services.common.service.ServiceBindingType;
  * $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
+    public static AuthorityRefDocList getAuthorityRefDocs(RepositoryClient repoClient, \r
                String tenantId, String serviceType, String refName,\r
                int pageSize, int pageNum, boolean computeTotal )\r
                throws DocumentException, DocumentNotFoundException {\r
@@ -62,26 +65,127 @@ public class RefNameServiceUtils {
        TenantBindingConfigReaderImpl tReader =\r
             ServiceMain.getInstance().getTenantBindingConfigReader();\r
        List<ServiceBindingType> servicebindings = tReader.getServiceBindingsByType(tenantId, serviceType);\r
-       if(servicebindings==null || servicebindings.size()>0)\r
+       if(servicebindings==null || servicebindings.isEmpty())\r
                return null;\r
+       // Need to escape the quotes in the refName\r
+       // TODO What if they are already escaped?\r
+       String escapedRefName = refName.replaceAll("'", "\\\\'");\r
        String domain = tReader.getTenantBinding(tenantId).getRepositoryDomain();\r
        ArrayList<String> docTypes = new ArrayList<String>(); \r
+       HashMap<String, ServiceBindingType> queriedServiceBindings = new HashMap<String, ServiceBindingType>(); \r
+       HashMap<String, List<String>> authRefFieldsByService = new HashMap<String, List<String>>(); \r
        StringBuilder whereClause = new StringBuilder();\r
+       boolean fFirst = true;\r
        for(ServiceBindingType sb:servicebindings) {\r
-               List<String> authRefFields = ServiceBindingUtils.getAllPartsPropertyValues(sb, AUTH_REF_PROP);\r
+               List<String> authRefFields = \r
+                       ServiceBindingUtils.getAllPartsPropertyValues(sb, \r
+                               ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);\r
+               if(authRefFields.isEmpty())\r
+                       continue;\r
                String docType = sb.getObject().getName();\r
+               queriedServiceBindings.put(docType, sb);\r
+               authRefFieldsByService.put(docType, authRefFields);\r
                docTypes.add(docType);\r
+               /*\r
+               // HACK - need to get qualified properties from the ServiceBinding\r
+               String prefix = "";\r
+               if(docType.equalsIgnoreCase("Intake"))\r
+                       prefix = "intakes_common:";\r
+               else if(docType.equalsIgnoreCase("Loanin"))\r
+                       prefix = "loansin_common:";\r
+               else if(docType.equalsIgnoreCase("Acquisition"))\r
+                       prefix = "acquisitions_common:";\r
+               */\r
                for(String field:authRefFields) {\r
                        // Build up the where clause for each authRef field\r
-                       throw new UnsupportedOperationException();\r
+                       if(fFirst) {\r
+                               fFirst = false;\r
+                       } else {\r
+                               whereClause.append(" OR ");\r
+                       }\r
+                       //whereClause.append(prefix);\r
+                       whereClause.append(field);\r
+                       whereClause.append("='");\r
+                       whereClause.append(escapedRefName);\r
+                       whereClause.append("'");\r
                }\r
        }\r
+       if(fFirst) // found no authRef fields - nothing to query\r
+               return wrapperList;\r
+       String fullQuery = whereClause.toString(); // for debug\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
+               // Now we gather the info for each document into the list and return\r
+        DocumentModelList docList = docListWrapper.getWrappedObject();\r
+        Iterator<DocumentModel> iter = docList.iterator();\r
+        while(iter.hasNext()){\r
+            DocumentModel docModel = iter.next();\r
+            AuthorityRefDocList.AuthorityRefDocItem ilistItem = new AuthorityRefDocList.AuthorityRefDocItem();\r
+            String csid = NuxeoUtils.extractId(docModel.getPathAsString());\r
+            String docType = docModel.getDocumentType().getName();\r
+            ServiceBindingType sb = queriedServiceBindings.get(docType);\r
+            if(sb==null) {\r
+               throw new RuntimeException(\r
+                               "getAuthorityRefDocs: No Service Binding for docType: "+docType);\r
+            }\r
+            String serviceContextPath = "/" + sb.getName().toLowerCase() + "/";\r
+            // The id and URI are the same on all doctypes\r
+            ilistItem.setDocId(csid);\r
+            ilistItem.setUri(serviceContextPath+csid);\r
+            ilistItem.setDocType(docType);\r
+            ilistItem.setDocNumber(\r
+                       ServiceBindingUtils.getMappedFieldInDoc(sb, ServiceBindingUtils.OBJ_NUMBER_PROP, docModel));\r
+            ilistItem.setDocName(\r
+                       ServiceBindingUtils.getMappedFieldInDoc(sb, ServiceBindingUtils.OBJ_NAME_PROP, docModel));\r
+            // Now, we have to loop over the authRefFieldsByService to figure\r
+            // out which field matched this. Ignore multiple matches.\r
+            List<String> authRefFields = authRefFieldsByService.get(docType);\r
+            if(authRefFields==null || authRefFields.isEmpty()){\r
+               throw new RuntimeException(\r
+                               "getAuthorityRefDocs: internal logic error: can't fetch authRefFields for DocType." );\r
+            }\r
+            boolean fRefFound = false;\r
+            /* Use this if we go to qualified field names\r
+            for(String field:authRefFields){\r
+                String[] strings = field.split(":");\r
+                if(strings.length!=2) {\r
+                       throw new RuntimeException(\r
+                                       "getAuthorityRefDocs: Bad configuration of authRefField.");\r
+                }\r
+               try {\r
+                    if(refName.equals(docModel.getProperty(strings[0], strings[1]))) {\r
+                        ilistItem.setSourceField(field);\r
+                        fRefFound = true;\r
+                        break;\r
+                    }\r
+               } catch(ClientException ce) {\r
+                       throw new RuntimeException(\r
+                                       "getAuthorityRefDocs: Problem fetching: "+field, ce);\r
+               }\r
+            }\r
+            */\r
+            for(String field:authRefFields){\r
+               try {\r
+                    if(refName.equals(docModel.getPropertyValue(field))) {\r
+                        ilistItem.setSourceField(field);\r
+                        fRefFound = true;\r
+                        break;\r
+                    }\r
+               } catch(ClientException ce) {\r
+                       throw new RuntimeException(\r
+                                       "getAuthorityRefDocs: Problem fetching: "+field, ce);\r
+               }\r
+            }\r
+            if(!fRefFound) {\r
+               throw new RuntimeException(\r
+                               "getAuthorityRefDocs: Could not find refname in object:"\r
+                               +docType+":"+csid);\r
+            }\r
+            list.add(ilistItem);\r
+        }\r
+       return wrapperList;\r
     }\r
 \r
-               \r
 }\r
 \r
index 4f660b26363339cea5a98c44718fca7c59561633..6e29b3467c2456733f08382289ed2f7e6ecffadf 100644 (file)
@@ -204,6 +204,12 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
         return result;
     }
     
+    /**
+     * @param docWrapper
+     * @param authRefFields list of schema-qualified field names
+     * @return
+     * @throws PropertyException
+     */
     public AuthorityRefList getAuthorityRefs(
                 DocumentWrapper<DocumentModel> docWrapper,
                List<String> authRefFields) throws PropertyException {
index 9ce6d6d7795ba4a1197a77560e9dd8c06027b769..cd371656aa4caa9b8ddaa814fb8f47417e882638 100644 (file)
@@ -409,8 +409,6 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
             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);
@@ -763,8 +761,9 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
         boolean fFirst = true;
         for(String docType:docTypes) {
                if(fFirst) {
-                query.append(",");
                 fFirst = false;
+               } else {
+                       query.append(",");
                }
             query.append(docType);
         }
index 26b89598e86557dc9e529d1298e58db5cdaabb2a..499910fa2ce9b3271e3cb6b5f7a64fe47efc50ea 100644 (file)
             <artifactId>org.collectionspace.services.jaxb</artifactId>\r
             <version>${project.version}</version>\r
         </dependency>        \r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.common</artifactId>\r
+            <optional>true</optional>\r
+            <version>${project.version}</version>\r
+        </dependency>        \r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.intake.jaxb</artifactId>\r
diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java
new file mode 100644 (file)
index 0000000..05d2d68
--- /dev/null
@@ -0,0 +1,317 @@
+/**
+ * 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 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.collectionspace.services.client.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.PersonJAXBSchema;
+import org.collectionspace.services.client.IntakeClient;
+import org.collectionspace.services.client.PersonAuthorityClient;
+import org.collectionspace.services.client.PersonAuthorityClientUtils;
+import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
+import org.collectionspace.services.intake.IntakesCommon;
+import org.collectionspace.services.intake.IntakesCommonList;
+
+import org.jboss.resteasy.client.ClientResponse;
+
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * PersonAuthRefDocsTest, carries out tests against a
+ * deployed and running Person Service.
+ *
+ * $LastChangedRevision: 1327 $
+ * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
+ */
+public class PersonAuthRefDocsTest extends BaseServiceTest {
+
+   private final Logger logger =
+       LoggerFactory.getLogger(PersonAuthRefDocsTest.class);
+
+    // Instance variables specific to this test.
+    private IntakeClient intakeClient = new IntakeClient();
+    private PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
+    final String SERVICE_PATH_COMPONENT = "intakes";
+    final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
+    private String knownIntakeId = null;
+    private List<String> intakeIdsCreated = new ArrayList();
+    private List<String> personIdsCreated = new ArrayList();
+    private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
+    private int OK_STATUS = Response.Status.OK.getStatusCode();
+    private String personAuthCSID = null; 
+    private String currentOwnerPersonCSID = null; 
+    private String currentOwnerRefName = null;
+    private String depositorRefName = null;
+    private String conditionCheckAssesorRefName = null;
+    private String insurerRefName = null;
+    private String fieldCollectorRefName = null;
+    private String valuerRefName = null;
+    private final int NUM_AUTH_REF_DOCS_EXPECTED = 1;
+
+    // ---------------------------------------------------------------
+    // CRUD tests : CREATE tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+    public void createIntakeWithAuthRefs(String testName) throws Exception {
+
+        testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName);
+
+        // Submit the request to the service and store the response.
+        String identifier = createIdentifier();
+        
+        // Create all the person refs and entities
+        createPersonRefs();
+        
+        MultipartOutput multipart = createIntakeInstance(
+                "entryNumber-" + identifier,
+                "entryDate-" + identifier,
+                                                               currentOwnerRefName,
+                                                               depositorRefName,
+                                                               conditionCheckAssesorRefName,
+                                                               insurerRefName,
+                                                               fieldCollectorRefName,
+                                                               valuerRefName );
+
+        ClientResponse<Response> res = intakeClient.create(multipart);
+
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        //
+        // Specifically:
+        // Does it fall within the set of valid status codes?
+        // Does it exactly match the expected status code?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Store the ID returned from the first resource created
+        // for additional tests below.
+        if (knownIntakeId == null){
+            knownIntakeId = extractId(res);
+            if (logger.isDebugEnabled()) {
+                logger.debug(testName + ": knownIntakeId=" + knownIntakeId);
+            }
+        }
+        
+        // Store the IDs from every resource created by tests,
+        // so they can be deleted after tests have been run.
+        intakeIdsCreated.add(extractId(res));
+    }
+    
+    protected void createPersonRefs(){
+       String authRefName = 
+               PersonAuthorityClientUtils.createPersonAuthRefName(PERSON_AUTHORITY_NAME, false);
+       MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
+                       PERSON_AUTHORITY_NAME, authRefName, personAuthClient.getCommonPartName());
+        ClientResponse<Response> res = personAuthClient.create(multipart);
+        int statusCode = res.getStatus();
+
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, CREATED_STATUS);
+        personAuthCSID = extractId(res);
+        
+        currentOwnerRefName = PersonAuthorityClientUtils.createPersonRefName(
+                                                               authRefName, "Olivier Owner", true);
+                               currentOwnerPersonCSID = createPerson("Olivier", "Owner", currentOwnerRefName);
+        personIdsCreated.add(currentOwnerPersonCSID);
+        
+        depositorRefName = PersonAuthorityClientUtils.createPersonRefName(
+                                                                       authRefName, "Debbie Depositor", true);
+        personIdsCreated.add(createPerson("Debbie", "Depositor", depositorRefName));
+        
+        conditionCheckAssesorRefName = PersonAuthorityClientUtils.createPersonRefName(
+                                                                       authRefName, "Andrew Assessor", true);
+        personIdsCreated.add(createPerson("Andrew", "Assessor", conditionCheckAssesorRefName));
+        
+        insurerRefName = PersonAuthorityClientUtils.createPersonRefName(
+                                                                       authRefName, "Ingrid Insurer", true);
+        personIdsCreated.add(createPerson("Ingrid", "Insurer", insurerRefName));
+        
+        fieldCollectorRefName = PersonAuthorityClientUtils.createPersonRefName(
+                                                                       authRefName, "Connie Collector", true);
+        personIdsCreated.add(createPerson("Connie", "Collector", fieldCollectorRefName));
+        
+        valuerRefName = PersonAuthorityClientUtils.createPersonRefName(
+                                                                       authRefName, "Vince Valuer", true);
+        personIdsCreated.add(createPerson("Vince", "Valuer", valuerRefName));
+        
+
+    }
+    
+    protected String createPerson(String firstName, String surName, String refName ) {
+        Map<String, String> personInfo = new HashMap<String,String>();
+        personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
+        personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
+       MultipartOutput multipart = 
+               PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, 
+                               refName, personInfo, personAuthClient.getItemCommonPartName());
+        ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
+        int statusCode = res.getStatus();
+
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, CREATED_STATUS);
+       return extractId(res);
+    }
+
+    // Success outcomes
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+        dependsOnMethods = {"createIntakeWithAuthRefs"})
+    public void readAndCheckAuthRefDocs(String testName) throws Exception {
+
+        // Perform setup.
+        testSetup(OK_STATUS, ServiceRequestType.READ,testName);
+        
+        // Get the auth ref docs and check them
+        ClientResponse<AuthorityRefDocList> refDocListResp =
+               personAuthClient.getReferencingObjects(personAuthCSID, currentOwnerPersonCSID);
+
+        int statusCode = refDocListResp.getStatus();
+
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ".getReferencingObjects: status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        AuthorityRefDocList list = refDocListResp.getEntity();
+
+        // Optionally output additional data about list members for debugging.
+        boolean iterateThroughList = true;
+        boolean fFoundIntake = false;
+        if(iterateThroughList && logger.isDebugEnabled()){
+            List<AuthorityRefDocList.AuthorityRefDocItem> items =
+                    list.getAuthorityRefDocItem();
+            int i = 0;
+            logger.debug(testName + ": Docs that use: " + currentOwnerRefName);
+            for(AuthorityRefDocList.AuthorityRefDocItem item : items){
+                logger.debug(testName + ": list-item[" + i + "] " +
+                               item.getDocType() + "(" +
+                               item.getDocId() + ") Name:[" +
+                               item.getDocName() + "] Number:[" +
+                               item.getDocNumber() + "] in field:[" +
+                               item.getSourceField() + "]");
+                if(!fFoundIntake && knownIntakeId.equalsIgnoreCase(item.getDocId())) {
+                               fFoundIntake = true;
+                }
+                i++;
+            }
+            Assert.assertTrue(fFoundIntake, "Did not find Intake with authref!");
+        }
+    }
+
+
+    // ---------------------------------------------------------------
+    // Cleanup of resources created during testing
+    // ---------------------------------------------------------------
+
+    /**
+     * Deletes all resources created by tests, after all tests have been run.
+     *
+     * This cleanup method will always be run, even if one or more tests fail.
+     * For this reason, it attempts to remove all resources created
+     * at any point during testing, even if some of those resources
+     * may be expected to be deleted by certain tests.
+     */
+    @AfterClass(alwaysRun=true)
+    public void cleanUp() {
+       String noTest = System.getProperty("noTestCleanup");
+       if("true".equalsIgnoreCase(noTest)) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Skipping Cleanup phase");
+            }
+            return;
+       }
+        if (logger.isDebugEnabled()) {
+            logger.debug("Cleaning up temporary resources created for testing ...");
+        }
+        // Note: Any non-success responses are ignored and not reported.
+        for (String resourceId : intakeIdsCreated) {
+            ClientResponse<Response> res = intakeClient.delete(resourceId);
+        }
+        // Delete persons before PersonAuth
+        for (String resourceId : personIdsCreated) {
+            ClientResponse<Response> res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+        }
+        ClientResponse<Response> res = personAuthClient.delete(personAuthCSID);
+    }
+
+    // ---------------------------------------------------------------
+    // Utility methods used by tests above
+    // ---------------------------------------------------------------
+    @Override
+    public String getServicePathComponent() {
+        return SERVICE_PATH_COMPONENT;
+    }
+
+   private MultipartOutput createIntakeInstance(String entryNumber,
+               String entryDate,
+                               String currentOwner,
+                               String depositor,
+                               String conditionCheckAssesor,
+                               String insurer,
+                               String fieldCollector,
+                               String Valuer ) {
+        IntakesCommon intake = new IntakesCommon();
+        intake.setEntryNumber(entryNumber);
+        intake.setEntryDate(entryDate);
+        intake.setCurrentOwner(currentOwner);
+        intake.setDepositor(depositor);
+        intake.setConditionCheckAssesor(conditionCheckAssesor);
+        intake.setInsurer(insurer);
+        intake.setFieldCollector(fieldCollector);
+        intake.setValuer(Valuer);
+        MultipartOutput multipart = new MultipartOutput();
+        OutputPart commonPart =
+            multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", intakeClient.getCommonPartName());
+
+        if(logger.isDebugEnabled()){
+            logger.debug("to be created, intake common");
+            logger.debug(objectAsXmlString(intake, IntakesCommon.class));
+        }
+
+        return multipart;
+    }
+}
index a7be7687cc00fa8de38a5943bb600dead02c3b59..08ca4bb9203242f92a7779b54f9875e9ca83c499 100644 (file)
@@ -49,6 +49,7 @@ import org.collectionspace.services.common.authorityref.AuthorityRefList;
 //import org.collectionspace.services.common.context.MultipartServiceContext;
 //import org.collectionspace.services.common.context.MultipartServiceContextFactory;
 import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
@@ -293,7 +294,9 @@ public class IntakeResource extends
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            List<String> authRefFields = 
+               ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
+                               ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
             authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
diff --git a/services/jaxb/src/main/resources/authorityrefdocs.xsd b/services/jaxb/src/main/resources/authorityrefdocs.xsd
new file mode 100644 (file)
index 0000000..906bace
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+       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
+
+       Document   : authorityrefdocs.xsd
+       Revision   : $LastChangedRevision: 1292 $
+       Created on : $LastChangedDate: 2010-01-29 14:55:28 -0800 (Fri, 29 Jan 2010) $
+       Author     : $LastChangedBy: $
+       Description: AuthorityRefDocs describes a list of values that describe
+                                                               document (CollectionObject, Intake, etc.) 
+                                                               references to a given authority term.
+-->
+<xs:schema
+       xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xmlns="http://collectionspace.org/services/common/authorityref"
+       targetNamespace="http://collectionspace.org/services/common/authorityref"
+       version="0.1"
+       >
+
+       <xs:element name="authority-ref-doc-list">
+               <xs:complexType>
+                       <xs:sequence>
+                                <xs:element name="authority-ref-doc-item" maxOccurs="unbounded">
+                                       <xs:complexType>
+                                               <xs:sequence>
+                                                       <xs:element name="docType"         type="xs:string" minOccurs="1" />
+                                                       <xs:element name="docId"           type="xs:string" minOccurs="1" />
+                                                       <xs:element name="docNumber"       type="xs:string" minOccurs="0" />
+                                                       <xs:element name="docName"         type="xs:string" minOccurs="0" />
+                                                       <xs:element name="sourceField"     type="xs:string" minOccurs="1" />
+                                                       <xs:element name="uri"             type="xs:anyURI" minOccurs="1" />
+                                               </xs:sequence>
+                                       </xs:complexType>
+                               </xs:element>
+                       </xs:sequence>
+               </xs:complexType>
+       </xs:element>
+
+</xs:schema>
index 79c302bdaa0ca2149c640c46bdf272d2f268e9b1..de642b32cee7b22676284cb2f6a2dee9c4a4dabf 100644 (file)
@@ -48,6 +48,7 @@ import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.MultipartServiceContextFactory;
 import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
@@ -291,7 +292,9 @@ public class LoaninResource extends
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            List<String> authRefFields = 
+               ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
+                               ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
             authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
index 6ea529f887d91e196a2b231b9961da89456a0de0..bf6ef7c564938e5630eda907bc2c42fdbe8baf6f 100644 (file)
@@ -48,6 +48,7 @@ import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.MultipartServiceContextFactory;
 import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
@@ -291,7 +292,9 @@ public class LoanoutResource extends
                getRepositoryClient(ctx).getDoc(ctx, csid);
             RemoteDocumentModelHandlerImpl handler 
                = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
-            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            List<String> authRefFields = 
+               ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
+                               ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
             authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
         } catch (UnauthorizedException ue) {
             Response response = Response.status(
index e12fe3816f850c3581db9d946a185f2a209f0d9a..7f9a831915b0d0b5d80c52c29d97942b7f2827cc 100644 (file)
             <scope>test</scope>\r
         </dependency>\r
         <!-- CollectionSpace dependencies -->\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.jaxb</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>        \r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.common</artifactId>\r
+            <optional>true</optional>\r
+            <version>${project.version}</version>\r
+        </dependency>        \r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.person.jaxb</artifactId>\r
index c17eeec0b48b3fabbdb53bfd4c85046951edfcfd..af2efcd169b6e630137efaa1e88dc00c7c9066aa 100644 (file)
@@ -3,6 +3,8 @@ package org.collectionspace.services.client;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
 import org.collectionspace.services.contact.ContactsCommonList;
 import org.collectionspace.services.person.PersonauthoritiesCommonList;
 import org.collectionspace.services.person.PersonsCommonList;
@@ -139,6 +141,15 @@ public class PersonAuthorityClient extends AbstractServiceClientImpl {
         return personAuthorityProxy.readItemList(vcsid);
     }
 
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.IntakeProxy#getAuthorityRefs(java.lang.String)
+     */
+    public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
+        return personAuthorityProxy.getReferencingObjects(parentcsid, csid);
+    }
+
     /**
      * @return
      * @see org.collectionspace.services.client.PersonAuthorityProxy#readItemListForNamedAuthority()
index 10c27a0011a9a8e92712fd018528dceede8fe827..ca8f4e688e51fe6e27006fb7b26512c6a20f3467 100644 (file)
@@ -10,6 +10,7 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
 import org.collectionspace.services.contact.ContactsCommonList;
 import org.collectionspace.services.person.PersonauthoritiesCommonList;
 import org.collectionspace.services.person.PersonsCommonList;
@@ -60,6 +61,18 @@ public interface PersonAuthorityProxy {
     @Path("/{vcsid}/items/")
     ClientResponse<PersonsCommonList> readItemList(@PathParam("vcsid") String vcsid);
 
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.IntakeProxy#getAuthorityRefs(java.lang.String)
+     */
+    @GET
+    @Path("{csid}/items/{itemcsid}/refObjs")
+    @Produces("application/xml")
+    ClientResponse<AuthorityRefDocList> getReferencingObjects(
+            @PathParam("csid") String parentcsid,
+            @PathParam("itemcsid") String itemcsid);
+
     // List Items for a named authority
     @GET
     @Produces({"application/xml"})
index 71a025cb375e6aeb9c44423bc58a239af18ef2e3..1b6070ee28bdcf0f2c61fef6aa5a17a077133b94 100644 (file)
@@ -23,7 +23,8 @@
  */
 package org.collectionspace.services.person;
 
-//import java.net.URI;
+import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -35,7 +36,6 @@ 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.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
@@ -46,27 +46,35 @@ import org.collectionspace.services.PersonJAXBSchema;
 import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.ClientType;
 import org.collectionspace.services.common.ServiceMain;
-//import org.collectionspace.services.common.context.MultipartServiceContext;
-//import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
+import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.common.context.MultipartServiceContext;
+import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
+import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
-//import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.common.security.UnauthorizedException;
-//import org.collectionspace.services.common.vocabulary.RefNameUtils;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.common.vocabulary.RefNameUtils;
 import org.collectionspace.services.common.query.IQueryManager;
 import org.collectionspace.services.contact.ContactResource;
 import org.collectionspace.services.contact.ContactsCommon;
 import org.collectionspace.services.contact.ContactsCommonList;
 import org.collectionspace.services.contact.ContactJAXBSchema;
 import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.collectionspace.services.person.nuxeo.PersonDocumentModelHandler;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.util.HttpResponseCodes;
-//import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -313,12 +321,88 @@ public class PersonAuthorityResource extends
     }
 
     /**
-     * Gets the person authority.
+     * Gets the entities referencing this Person instance. The service type
+     * can be passed as a query param "type", and must match a configured type
+     * for the service bindings. If not set, the type defaults to
+     * ServiceBindingUtils.SERVICE_TYPE_PROCEDURE.
      * 
-     * @param csid the csid
+     * @param csid the parent csid
+     * @param itemcsid the person csid
+     * @param ui the ui
      * 
-     * @return the person authority
+     * @return the info for the referencing objects
      */
+    @GET
+    @Path("{csid}/items/{itemcsid}/refObjs")
+    @Produces("application/xml")
+    public AuthorityRefDocList getReferencingObjects(
+            @PathParam("csid") String parentcsid,
+            @PathParam("itemcsid") String itemcsid,
+               @Context UriInfo ui) {
+       AuthorityRefDocList authRefDocList = null;
+        if (logger.isDebugEnabled()) {
+            logger.debug("getReferencingObjects with parentcsid=" 
+                       + parentcsid + " and itemcsid=" + itemcsid);
+        }
+        if (parentcsid == null || "".equals(parentcsid)
+                || itemcsid == null || "".equals(itemcsid)) {
+            logger.error("getPerson: missing parentcsid or itemcsid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "get failed on Person with parentcsid=" 
+                       + parentcsid + " and itemcsid=" + itemcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+    try {
+        // Note that we have to create the service context for the Items, not the main service
+        ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(getItemServiceName());
+        DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+        RepositoryClient repoClient = getRepositoryClient(ctx); 
+        DocumentFilter myFilter = handler.createDocumentFilter();
+        MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+        myFilter.setPagination(queryParams);
+       String serviceType = ServiceBindingUtils.SERVICE_TYPE_PROCEDURE;
+        List<String> list = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
+        if (list != null) {
+               serviceType = list.get(0);
+        }
+        DocumentWrapper<DocumentModel> docWrapper = repoClient.getDoc(ctx, itemcsid);
+        DocumentModel docModel = docWrapper.getWrappedObject();
+        String refName = (String)docModel.getPropertyValue(PersonJAXBSchema.REF_NAME);
+
+        authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(repoClient, 
+                       ctx.getTenantId(), serviceType, refName,
+                       myFilter.getPageSize(), myFilter.getStartPage(), true );
+    } catch (UnauthorizedException ue) {
+        Response response = Response.status(
+                Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
+        throw new WebApplicationException(response);
+    } catch (DocumentNotFoundException dnfe) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("getReferencingObjects", dnfe);
+        }
+        Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                "GetReferencingObjects failed with parentcsid=" 
+                       + parentcsid + " and itemcsid=" + itemcsid).type(
+                "text/plain").build();
+        throw new WebApplicationException(response);
+    } catch (Exception e) {    // Includes DocumentException
+        if (logger.isDebugEnabled()) {
+            logger.debug("GetReferencingObjects", e);
+        }
+        Response response = Response.status(
+                Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
+        throw new WebApplicationException(response);
+    }
+    if (authRefDocList == null) {
+        Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                "Get failed, the requested Person CSID:" + itemcsid + ": was not found.").type(
+                "text/plain").build();
+        throw new WebApplicationException(response);
+    }
+    return authRefDocList;
+    }
+
     @GET
     @Path("{csid}")
     public MultipartOutput getPersonAuthority(@PathParam("csid") String csid) {
@@ -552,17 +636,12 @@ public class PersonAuthorityResource extends
         if (logger.isDebugEnabled()) {
             logger.debug("getPerson with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
         }
-        if (parentcsid == null || "".equals(parentcsid)) {
-            logger.error("getPerson: missing csid!");
+        if (parentcsid == null || "".equals(parentcsid)
+            || itemcsid == null || "".equals(itemcsid)) {
+            logger.error("getPerson: missing parentcsid or itemcsid!");
             Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "get failed on Person csid=" + parentcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (itemcsid == null || "".equals(itemcsid)) {
-            logger.error("getPerson: missing itemcsid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "get failed on Person itemcsid=" + itemcsid).type(
+                    "get failed on Person with parentcsid=" 
+                       + parentcsid + " and itemcsid=" + itemcsid).type(
                     "text/plain").build();
             throw new WebApplicationException(response);
         }
@@ -660,6 +739,7 @@ public class PersonAuthorityResource extends
         }
         return personObjectList;
     }
+    
 
     /**
      * Gets the person list by auth name.