]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA - Fixed some cruft and a bug with the creation/assignment of refNames to test...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Fri, 15 Jan 2010 00:30:43 +0000 (00:30 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Fri, 15 Jan 2010 00:30:43 +0000 (00:30 +0000)
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/person/import/src/main/java/org/collectionspace/services/person/importer/PersonAuthorityBaseImport.java
services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java

index 3f3a964652f4fd5a9c3e56e802cb825bfbe6ac40..ac5d68575d59ca97a003b35e3c7f41b0bcc538fc 100644 (file)
@@ -109,8 +109,7 @@ public class PersonAuthorityClientUtils {
                        personMap.get(PersonJAXBSchema.SUR_NAME),\r
                        personMap.get(PersonJAXBSchema.BIRTH_DATE),\r
                        personMap.get(PersonJAXBSchema.DEATH_DATE));\r
-       String refName = createPersonRefName(personAuthorityRefName, \r
-                       displayName);\r
+       String refName = createPersonRefName(personAuthorityRefName, displayName, true);\r
 \r
        if(logger.isDebugEnabled()){\r
                logger.debug("Import: Create Item: \""+displayName\r
@@ -136,14 +135,20 @@ public class PersonAuthorityClientUtils {
        return extractId(res);\r
     }\r
 \r
-    public static String createPersonAuthRefName(String personAuthorityName) {\r
-       return "urn:cspace:org.collectionspace.demo:personauthority:name("\r
+    public static String createPersonAuthRefName(String personAuthorityName, boolean withDisplaySuffix) {\r
+       String refName = "urn:cspace:org.collectionspace.demo:personauthority:name("\r
                        +personAuthorityName+")";\r
+       if(withDisplaySuffix)\r
+               refName += "'"+personAuthorityName+"'";\r
+       return refName;\r
     }\r
 \r
     public static String createPersonRefName(\r
-                                               String personAuthRefName, String personName) {\r
-       return personAuthRefName+":person:name("+personName+")";\r
+                                               String personAuthRefName, String personName, boolean withDisplaySuffix) {\r
+       String refName = personAuthRefName+":person:name("+personName+")";\r
+       if(withDisplaySuffix)\r
+               refName += "'"+personName+"'";\r
+       return refName;\r
     }\r
 \r
     public static String extractId(ClientResponse<Response> res) {\r
index e449dfdcbe4e6df6fb0cfcc251cf315f56c275f6..ae3ce7a43aa6f6949fe913c86dcb15dbbdcf1e36 100644 (file)
@@ -72,17 +72,6 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest {
     private Map<String, String> allResourceItemIdsCreated =
         new HashMap<String, String>();
     
-    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<Response> 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<MultipartInput> 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<MultipartInput> 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());
-    }
-
 }
index 0ff7ce5fab5e4ab0276d7698a3dfa0706c46a847..b69799cd2dd521eded60fc40c970ba99f1168091 100644 (file)
@@ -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());
index 00df2640aba6993511f159721314f370c871373e..bd3be3c6a776c893f1384d873cb2cf689f98581d 100644 (file)
@@ -80,8 +80,8 @@ public class Sample {
        ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
 \r
        logger.info("Import: Create personAuthority: \"" + personAuthorityName +"\"");\r
-       String basePersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName);\r
-       String fullPersonRefName = basePersonRefName+"'"+personAuthorityName+"'";\r
+       String basePersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, false);\r
+       String fullPersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, true);\r
        MultipartOutput multipart = \r
                PersonAuthorityClientUtils.createPersonAuthorityInstance(\r
                                personAuthorityName, fullPersonRefName, client.getCommonPartName() );\r
@@ -134,7 +134,7 @@ public class Sample {
                builtName.append("-");\r
        if(deathDate!=null)\r
                builtName.append(deathDate);\r
-       String refName = PersonAuthorityClientUtils.createPersonRefName(personAuthorityRefName, builtName.toString());\r
+       String refName = PersonAuthorityClientUtils.createPersonRefName(personAuthorityRefName, builtName.toString(), true);\r
        logger.info("Import: Create Item: \""+refName+"\" in personAuthority: \"" + personAuthorityRefName +"\"");\r
 \r
        if(logger.isDebugEnabled()){\r
@@ -470,49 +470,6 @@ public class Sample {
         return obj;\r
     }\r
 \r
-    /**\r
-     * Returns an error message indicating that the status code returned by a\r
-     * specific call to a service does not fall within a set of valid status\r
-     * codes for that service.\r
-     *\r
-     * @param serviceRequestType  A type of service request (e.g. CREATE, DELETE).\r
-     *\r
-     * @param statusCode  The invalid status code that was returned in the response,\r
-     *                    from submitting that type of request to the service.\r
-     *\r
-     * @return An error message.\r
-     */\r
-    /*\r
-    protected String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) {\r
-        return "Status code '" + statusCode + "' in response is NOT within the expected set: " +\r
-                requestType.validStatusCodesAsString();\r
-    }\r
-\r
-    protected String extractId(ClientResponse<Response> res) {\r
-        MultivaluedMap<String, Object> mvm = res.getMetadata();\r
-        String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);\r
-        if(logger.isDebugEnabled()){\r
-               logger.info("extractId:uri=" + uri);\r
-        }\r
-        String[] segments = uri.split("/");\r
-        String id = segments[segments.length - 1];\r
-        if(logger.isDebugEnabled()){\r
-               logger.debug("id=" + id);\r
-        }\r
-        return id;\r
-    }\r
-    \r
-    protected String createPersonAuthRefName(String personAuthorityName) {\r
-       return "urn:cspace:org.collectionspace.demo:personauthority:name("\r
-                       +personAuthorityName+")";\r
-    }\r
-\r
-    protected String createPersonRefName(\r
-                                               String personAuthRefName, String personName) {\r
-       return personAuthRefName+":person:name("+personName+")";\r
-    }\r
-    */\r
-\r
        public static void main(String[] args) {\r
 \r
         // Configure logging.\r