From: Patrick Schmitz Date: Fri, 15 Jan 2010 00:30:43 +0000 (+0000) Subject: NOJIRA - Fixed some cruft and a bug with the creation/assignment of refNames to test... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=de2a3455ffb42b20036b8e50358e26292799b6ba;p=tmp%2Fjakarta-migration.git NOJIRA - Fixed some cruft and a bug with the creation/assignment of refNames to test objects and imported ones. --- diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java index 3f3a96465..ac5d68575 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java @@ -109,8 +109,7 @@ public class PersonAuthorityClientUtils { personMap.get(PersonJAXBSchema.SUR_NAME), personMap.get(PersonJAXBSchema.BIRTH_DATE), personMap.get(PersonJAXBSchema.DEATH_DATE)); - String refName = createPersonRefName(personAuthorityRefName, - displayName); + String refName = createPersonRefName(personAuthorityRefName, displayName, true); if(logger.isDebugEnabled()){ logger.debug("Import: Create Item: \""+displayName @@ -136,14 +135,20 @@ public class PersonAuthorityClientUtils { return extractId(res); } - public static String createPersonAuthRefName(String personAuthorityName) { - return "urn:cspace:org.collectionspace.demo:personauthority:name(" + public static String createPersonAuthRefName(String personAuthorityName, boolean withDisplaySuffix) { + String refName = "urn:cspace:org.collectionspace.demo:personauthority:name(" +personAuthorityName+")"; + if(withDisplaySuffix) + refName += "'"+personAuthorityName+"'"; + return refName; } public static String createPersonRefName( - String personAuthRefName, String personName) { - return personAuthRefName+":person:name("+personName+")"; + String personAuthRefName, String personName, boolean withDisplaySuffix) { + String refName = personAuthRefName+":person:name("+personName+")"; + if(withDisplaySuffix) + refName += "'"+personName+"'"; + return refName; } public static String extractId(ClientResponse res) { 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 e449dfdcb..ae3ce7a43 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 @@ -72,17 +72,6 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { private Map allResourceItemIdsCreated = new HashMap(); - protected String createPersonAuthRefName(String personAuthorityName) { - return "urn:cspace:org.collectionspace.demo:personauthority:name(" - +personAuthorityName+")"; - } - - protected String createPersonRefName( - String personAuthRefName, String personName) { - return personAuthRefName+":person:name("+personName+")"; - } - - // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- @@ -99,10 +88,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // Submit the request to the service and store the response. String identifier = createIdentifier(); String displayName = "displayName-" + identifier; - String refName = createPersonAuthRefName(displayName); + String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, false); + String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( - displayName, refName, client.getCommonPartName()); + displayName, fullRefName, client.getCommonPartName()); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -121,7 +111,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // Store the refname from the first resource created // for additional tests below. - knownResourceRefName = refName; + knownResourceRefName = baseRefName; lastPersonAuthId = PersonAuthorityClientUtils.extractId(res); // Store the ID returned from the first resource created @@ -171,7 +161,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { "American icon. He is famous for his distinctive voice, walk and height. " + "He was also known for his conservative political views and his support in " + "the 1950s for anti-communist positions."); - String refName = createPersonRefName(authRefName, "John Wayne"); + String refName = PersonAuthorityClientUtils.createPersonRefName(authRefName, "John Wayne", true); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonInstance(vcsid, refName, johnWayneMap, client.getItemCommonPartName() ); @@ -801,7 +791,10 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // The only relevant ID may be the one used in update(), below. // The only relevant ID may be the one used in update(), below. - MultipartOutput multipart = createPersonAuthorityInstance(NON_EXISTENT_ID); + String displayName = "displayName-NON_EXISTENT_ID"; + String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true); + MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + displayName, fullRefName, client.getCommonPartName()); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); int statusCode = res.getStatus(); @@ -834,7 +827,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { nonexMap.put(PersonJAXBSchema.GENDER, "male"); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID, - createPersonRefName(NON_EXISTENT_ID, NON_EXISTENT_ID), nonexMap, + PersonAuthorityClientUtils.createPersonRefName(NON_EXISTENT_ID, NON_EXISTENT_ID, true), nonexMap, client.getItemCommonPartName() ); ClientResponse res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart); @@ -1062,12 +1055,4 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { return getItemServiceRootURL(parentResourceIdentifier) + "/" + resourceIdentifier; } - private MultipartOutput createPersonAuthorityInstance(String identifier) { - String displayName = "displayName-" + identifier; - String refName = createPersonAuthRefName(displayName); - return - PersonAuthorityClientUtils.createPersonAuthorityInstance( - displayName, refName, client.getCommonPartName()); - } - } diff --git a/services/person/import/src/main/java/org/collectionspace/services/person/importer/PersonAuthorityBaseImport.java b/services/person/import/src/main/java/org/collectionspace/services/person/importer/PersonAuthorityBaseImport.java index 0ff7ce5fa..b69799cd2 100644 --- a/services/person/import/src/main/java/org/collectionspace/services/person/importer/PersonAuthorityBaseImport.java +++ b/services/person/import/src/main/java/org/collectionspace/services/person/importer/PersonAuthorityBaseImport.java @@ -74,9 +74,9 @@ public class PersonAuthorityBaseImport { logger.debug("Import: Create personAuthority: \"" + personAuthorityName +"\""); } String basePersonRefName = - PersonAuthorityClientUtils.createPersonAuthRefName( - personAuthorityName); - String fullPersonRefName = basePersonRefName+"'"+personAuthorityName+"'"; + PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, false); + String fullPersonRefName = + PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, true); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( personAuthorityName, fullPersonRefName, client.getCommonPartName()); diff --git a/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java b/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java index 00df2640a..bd3be3c6a 100644 --- a/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java +++ b/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java @@ -80,8 +80,8 @@ public class Sample { ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; logger.info("Import: Create personAuthority: \"" + personAuthorityName +"\""); - String basePersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName); - String fullPersonRefName = basePersonRefName+"'"+personAuthorityName+"'"; + String basePersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, false); + String fullPersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, true); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( personAuthorityName, fullPersonRefName, client.getCommonPartName() ); @@ -134,7 +134,7 @@ public class Sample { builtName.append("-"); if(deathDate!=null) builtName.append(deathDate); - String refName = PersonAuthorityClientUtils.createPersonRefName(personAuthorityRefName, builtName.toString()); + String refName = PersonAuthorityClientUtils.createPersonRefName(personAuthorityRefName, builtName.toString(), true); logger.info("Import: Create Item: \""+refName+"\" in personAuthority: \"" + personAuthorityRefName +"\""); if(logger.isDebugEnabled()){ @@ -470,49 +470,6 @@ public class Sample { return obj; } - /** - * Returns an error message indicating that the status code returned by a - * specific call to a service does not fall within a set of valid status - * codes for that service. - * - * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). - * - * @param statusCode The invalid status code that was returned in the response, - * from submitting that type of request to the service. - * - * @return An error message. - */ - /* - protected String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) { - return "Status code '" + statusCode + "' in response is NOT within the expected set: " + - requestType.validStatusCodesAsString(); - } - - protected String extractId(ClientResponse res) { - MultivaluedMap mvm = res.getMetadata(); - String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - if(logger.isDebugEnabled()){ - logger.info("extractId:uri=" + uri); - } - String[] segments = uri.split("/"); - String id = segments[segments.length - 1]; - if(logger.isDebugEnabled()){ - logger.debug("id=" + id); - } - return id; - } - - protected String createPersonAuthRefName(String personAuthorityName) { - return "urn:cspace:org.collectionspace.demo:personauthority:name(" - +personAuthorityName+")"; - } - - protected String createPersonRefName( - String personAuthRefName, String personName) { - return personAuthRefName+":person:name("+personName+")"; - } - */ - public static void main(String[] args) { // Configure logging.