]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA - Fixed a bug in the processing of authority items when fetching by name ...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Fri, 16 Jul 2010 21:25:36 +0000 (21:25 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Fri, 16 Jul 2010 21:25:36 +0000 (21:25 +0000)
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java

index 9bda83231415fe18424cd587c807bd5bad5c2c30..4d822cee104beddc1e846398634010bb646b62be 100644 (file)
@@ -555,7 +555,10 @@ AbstractMultiPartCollectionSpaceResourceImpl {
         String whereClause =
                authorityItemCommonSchemaName+
                ":"+AuthorityJAXBSchema.SHORT_IDENTIFIER+
-               "='"+itemspecifier+"'";
+               "='"+itemspecifier+"' AND "
+                       + authorityItemCommonSchemaName + ":"
+                       + AuthorityItemJAXBSchema.IN_AUTHORITY + "="
+                       + "'" + parentcsid + "'";
                 
         if (logger.isDebugEnabled()) {
             logger.debug("getAuthorityItemByName with parentcsid=" + parentcsid + " and itemspecifier=" + itemspecifier);
@@ -621,22 +624,29 @@ AbstractMultiPartCollectionSpaceResourceImpl {
                     "text/plain").build();
             throw new WebApplicationException(response);
         }
-        // TODO REWRITE to get the CSID for the parent by name, and then call getAuthorityItemByName 
-        String whereClause =
-               authorityItemCommonSchemaName+
-               ":"+AuthorityJAXBSchema.SHORT_IDENTIFIER+
-               "='"+itemspecifier+"'";
+               String authWhereClause =
+                       authorityCommonSchemaName+
+                       ":"+AuthorityJAXBSchema.SHORT_IDENTIFIER+
+                       "='"+parentspecifier+"'";
         if (logger.isDebugEnabled()) {
             logger.debug("getAuthorityItemByNameInNamedAuthority with parentspecifier=" 
                        + parentspecifier + " and itemspecifier=" + itemspecifier);
         }
         MultipartOutput result = null;
         try {
-            // Note that we have to create the service context for the Items, not the main service
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
-               // HACK HACK Since we do not use the parent CSID yet this should work.
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentspecifier);
-            DocumentFilter myFilter = new DocumentFilter(whereClause, 0, 1);
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getServiceName());
+               String parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, authWhereClause);
+            String itemWhereClause =
+               authorityItemCommonSchemaName+
+               ":"+AuthorityJAXBSchema.SHORT_IDENTIFIER+
+               "='"+itemspecifier+"' AND "
+                       + authorityItemCommonSchemaName + ":"
+                       + AuthorityItemJAXBSchema.IN_AUTHORITY + "="
+                       + "'" + parentcsid + "'";
+            // Now that we have to create the service context for the Items, not the main service
+               ctx = createServiceContext(getItemServiceName());
+            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+            DocumentFilter myFilter = new DocumentFilter(itemWhereClause, 0, 1);
             handler.setDocumentFilter(myFilter);
             getRepositoryClient(ctx).get(ctx, handler);
             // TODO should we assert that the item is in the passed personAuthority?
index b3fcc20b778fdbbf344cec7704de46062bee9544..4e9ef1fea56b8798bcc71fee8b0707645162accd 100644 (file)
@@ -258,7 +258,7 @@ public class PersonAuthorityClient extends AbstractServiceClientImpl {
      * @return the client response
      */
     public ClientResponse<MultipartInput> readNamedItemInNamedAuthority(String authShortId, String itemShortId) {
-        return personAuthorityProxy.readNamedItem(authShortId, itemShortId);
+        return personAuthorityProxy.readNamedItemInNamedAuthority(authShortId, itemShortId);
     }
 
     /**
index 84b284cd8eaaf6d53369f37ad3de48360d70f1f7..6e14845c0a08aac5b0956c57c217e8c5732f8400 100644 (file)
@@ -232,7 +232,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 
         final String testName = "createItemInAuthority";
         if(logger.isDebugEnabled()){
-            logger.debug(testName + ":...");
+            logger.debug(testName + ":"+vcsid+"...");
         }
 
         // Submit the request to the service and store the response.
@@ -289,6 +289,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
                 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);                
             }
         }
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + " (created):"+vcsid+"/("+newID+","+shortId+")");
+        }
 
         // Store the IDs from any item resources created
         // by tests, along with the IDs of their parents, so these items
@@ -662,6 +665,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 
         if (logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
+            logger.debug("Reading:"+((authCSID!=null)?authCSID:authShortId)+"/"+
+                       ((itemCSID!=null)?authCSID:itemShortId));
         }
         // Perform setup.
         setupRead();