]> 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:13:00 +0000 (00:13 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Fri, 15 Jan 2010 00:13:00 +0000 (00:13 +0000)
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java

index dd21227b5c500450428009cc41d880a3f1ddc4fc..585b671a4fb6d8fe57dd94cf5d339b8a7b15ddb3 100644 (file)
@@ -107,18 +107,20 @@ public class OrgAuthorityClientUtils {
         return id;\r
     }\r
     \r
-    public static String createRefName(String displayName) {\r
-       return displayName.replaceAll("\\W", "");\r
-    }\r
-\r
-    public static String createOrgAuthRefName(String orgAuthorityName) {\r
-       return "urn:cspace:org.collectionspace.demo:orgauthority:name("\r
+    public static String createOrgAuthRefName(String orgAuthorityName, boolean withDisplaySuffix) {\r
+       String refName = "urn:cspace:org.collectionspace.demo:orgauthority:name("\r
                        +orgAuthorityName+")";\r
+       if(withDisplaySuffix)\r
+               refName += "'"+orgAuthorityName+"'";\r
+       return refName;\r
     }\r
 \r
     public static String createOrganizationRefName(\r
-                                               String orgAuthRefName, String orgName) {\r
-       return orgAuthRefName+":organization:name("+orgName+")";\r
+                                               String orgAuthRefName, String orgName, boolean withDisplaySuffix) {\r
+       String refName = orgAuthRefName+":organization:name("+orgName+")";\r
+       if(withDisplaySuffix)\r
+               refName += "'"+orgName+"'";\r
+       return refName;\r
     }\r
 \r
 }\r
index 586a100aab22cca84edb9388d1525c5df888d8e7..707277aa16e48311d023561f4c34f701da114d27 100644 (file)
@@ -72,10 +72,6 @@ public class OrgAuthorityServiceTest extends AbstractServiceTest {
     private Map<String, String> allResourceItemIdsCreated =
         new HashMap<String, String>();
     
-    protected String createRefName(String displayName) {
-       return displayName.replaceAll("\\W", "");
-    }    
-
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
@@ -92,7 +88,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTest {
         // Submit the request to the service and store the response.
         String identifier = createIdentifier();
         String displayName = "displayName-" + identifier;
-       String refName = createRefName(displayName);
+       String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true);
        MultipartOutput multipart = 
                OrgAuthorityClientUtils.createOrgAuthorityInstance(
                                displayName, refName, 
@@ -152,7 +148,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTest {
 
         // Submit the request to the service and store the response.
         String identifier = createIdentifier();
-        String refName = createRefName(identifier);
+        String refName = OrgAuthorityClientUtils.createOrganizationRefName(knownResourceRefName, identifier, true);
         Map<String, String> testOrgMap = new HashMap<String,String>();
         testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Test Org");
         testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
@@ -818,9 +814,10 @@ public class OrgAuthorityServiceTest extends AbstractServiceTest {
         // The only relevant ID may be the one used in update(), below.
         Map<String, String> nonexOrgMap = new HashMap<String,String>();
         nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
+        String refName = OrgAuthorityClientUtils.createOrganizationRefName(knownResourceRefName, NON_EXISTENT_ID, true);
         MultipartOutput multipart = 
                OrgAuthorityClientUtils.createOrganizationInstance(
-                       knownResourceId, createRefName(NON_EXISTENT_ID),
+                       knownResourceId, refName,
                        nonexOrgMap, client.getItemCommonPartName() );
         ClientResponse<MultipartInput> res =
                 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
@@ -1050,7 +1047,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTest {
 
     private MultipartOutput createOrgAuthorityInstance(String identifier) {
        String displayName = "displayName-" + identifier;
-       String refName = createRefName(displayName);
+       String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true);
         return OrgAuthorityClientUtils.createOrgAuthorityInstance(
                                displayName, refName, 
                                client.getCommonPartName());
index c7c6883bf129882e9630cedd8c5c78fe4276dbaf..17abbaefd0646221b1dcb2e4da98296786c27036 100644 (file)
@@ -69,8 +69,8 @@ public class OrgAuthorityBaseImport {
        if(logger.isDebugEnabled()){
                logger.debug("Import: Create orgAuthority: \"" + orgAuthorityName +"\"");
        }
-       String baseOrgAuthRefName = OrgAuthorityClientUtils.createOrgAuthRefName(orgAuthorityName);
-       String fullOrgAuthRefName = baseOrgAuthRefName+"'"+orgAuthorityName+"'";
+       String baseOrgAuthRefName = OrgAuthorityClientUtils.createOrgAuthRefName(orgAuthorityName, false);
+       String fullOrgAuthRefName = OrgAuthorityClientUtils.createOrgAuthRefName(orgAuthorityName, true);
        MultipartOutput multipart = 
                OrgAuthorityClientUtils.createOrgAuthorityInstance(
                                orgAuthorityName, fullOrgAuthRefName, 
@@ -109,7 +109,7 @@ public class OrgAuthorityBaseImport {
        ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
        String shortName = orgInfo.get(OrganizationJAXBSchema.SHORT_NAME);
        String refName = OrgAuthorityClientUtils.createOrganizationRefName(
-                                               orgAuthorityRefName, shortName)+"'"+shortName+"'";
+                                               orgAuthorityRefName, shortName, true);
 
        if(logger.isDebugEnabled()){
                logger.debug("Import: Create Item: \""+shortName