From: Patrick Schmitz Date: Fri, 16 Jul 2010 21:25:36 +0000 (+0000) Subject: NOJIRA - Fixed a bug in the processing of authority items when fetching by name ... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=1c5e9006daec446c6cb79626baa539d9f43d8d9e;p=tmp%2Fjakarta-migration.git NOJIRA - Fixed a bug in the processing of authority items when fetching by name - was not correctly qualifying by authority. Should allow shortIdentifier clash across (but not within) authorities, but was coughing on cross-authority clash. Typo in PersonAuthorityClient caused problems in test. --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 9bda83231..4d822cee1 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -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 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 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? diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java index b3fcc20b7..4e9ef1fea 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java @@ -258,7 +258,7 @@ public class PersonAuthorityClient extends AbstractServiceClientImpl { * @return the client response */ public ClientResponse readNamedItemInNamedAuthority(String authShortId, String itemShortId) { - return personAuthorityProxy.readNamedItem(authShortId, itemShortId); + return personAuthorityProxy.readNamedItemInNamedAuthority(authShortId, itemShortId); } /** diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index 84b284cd8..6e14845c0 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -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();