]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-3178
authorLaramie Crocker <laramie@berkeley.edu>
Sat, 29 Jan 2011 02:21:36 +0000 (02:21 +0000)
committerLaramie Crocker <laramie@berkeley.edu>
Sat, 29 Jan 2011 02:21:36 +0000 (02:21 +0000)
services/common-api/pom.xml
services/common-api/src/main/java/org/collectionspace/services/common/api/RefName.java

index e7594081a66a0326510fb41aab7eba4a9e8e2ed0..944db707eb7f67ff6a30953bec4e01155f90ce32 100755 (executable)
@@ -28,6 +28,7 @@
             <groupId>org.testng</groupId>\r
             <artifactId>testng</artifactId>\r
             <version>5.6</version>\r
+            <scope>provided</scope>\r
         </dependency>\r
 \r
     </dependencies>\r
index 169626c0f5119e6f976815e6c2b992101f5dfac5..c1be211043fbfd30c72596cc7de4204783ce9f2d 100755 (executable)
@@ -9,10 +9,18 @@ import java.util.regex.Pattern;
  * $LastChangedDate:  $\r
  */\r
 public class RefName {\r
+    public static final String HACK_VOCABULARIES = "Vocabularies"; //TODO: get rid of these.\r
+    public static final String HACK_ORGANIZATIONS = "Organizations"; //TODO: get rid of these.\r
+    public static final String HACK_ORGAUTHORITIES = "Orgauthorities";  //TODO: get rid of these.\r
+    public static final String HACK_PERSONAUTHORITIES = "Personauthorities";  //TODO: get rid of these.\r
+    public static final String HACK_LOCATIONAUTHORITIES = "Locationauthorities";  //TODO: get rid of these.\r
 \r
-    public static final String URN_PREFIX = "urn:cspace:";\r
+    public static final String URN_PREFIX      = "urn:cspace:";\r
+    public static final String URN_NAME_PREFIX = "urn:cspace:name";\r
 \r
-    public static final String AUTHORITY_REGEX =      "urn:cspace:(.*):(.*)\\((.*)\\)\\'?([^\\']*)\\'?";\r
+    public static final String REFNAME = "refName";\r
+\r
+    public static final String AUTHORITY_REGEX      = "urn:cspace:(.*):(.*)\\((.*)\\)\\'?([^\\']*)\\'?";\r
     public static final String AUTHORITY_ITEM_REGEX = "urn:cspace:(.*):(.*)\\((.*)\\):items\\((.*)\\)\\'?([^\\']*)\\'?";\r
 \r
     public static final String AUTHORITY_EXAMPLE  = "urn:cspace:collectionspace.org:Loansin(shortID)'displayName'";\r
@@ -49,10 +57,6 @@ public class RefName {
             }\r
             return null;\r
         }\r
-        public String toString() {\r
-            String displaySuffix = (displayName != null && (!displayName.isEmpty())) ? '\'' + displayName + '\'' : "";\r
-            return URN_PREFIX + tenantName + ':' + resource + "(" + shortIdentifier + ")" + displaySuffix;\r
-        }\r
         public boolean equals(Object other){\r
             if (other == null){\r
                 return false;\r
@@ -67,6 +71,14 @@ public class RefName {
                 return false;\r
             }\r
         }\r
+        public String getRelativeUri() {\r
+               return "/"+resource+"/"+URN_NAME_PREFIX+"("+shortIdentifier+")";\r
+        }\r
+        public String toString() {\r
+            String displaySuffix = (displayName != null && (!displayName.isEmpty())) ? '\'' + displayName + '\'' : "";\r
+            return URN_PREFIX + tenantName + ':' + resource + "(" + shortIdentifier + ")" + displaySuffix;\r
+        }\r
+\r
     }\r
 \r
     public static class AuthorityItem {\r
@@ -108,6 +120,9 @@ public class RefName {
                 return false;\r
             }\r
         }\r
+        public String getRelativeUri() {\r
+               return inAuthority.getRelativeUri()+"/items/"+URN_NAME_PREFIX+"("+shortIdentifier+")";\r
+        }\r
         public String toString() {\r
             String displaySuffix = (displayName != null && (!displayName.isEmpty())) ? '\'' + displayName + '\'' : "";\r
             Authority ai = inAuthority;\r
@@ -131,12 +146,6 @@ public class RefName {
         return authority;\r
     }\r
 \r
-    public static String buildRefNameForAuthorityItem(String tenantName, String serviceName, String authorityShortIdentifier,\r
-                                                      String itemShortIdentifier, String itemDisplayName) {\r
-        AuthorityItem item = buildAuthorityItem(tenantName, serviceName, authorityShortIdentifier, itemShortIdentifier, itemDisplayName);\r
-        return item.toString();\r
-    }\r
-\r
     public static AuthorityItem buildAuthorityItem(String tenantName, String serviceName, String authorityShortIdentifier,\r
                                                    String itemShortIdentifier, String itemDisplayName) {\r
         Authority authority = buildAuthority(tenantName, serviceName, authorityShortIdentifier, "");\r
@@ -157,6 +166,16 @@ public class RefName {
         return item;\r
     }\r
 \r
+    /** Use this method to avoid formatting any urn's outside of this unit;\r
+     * Caller passes in a shortId, such as "TestAuthority", and method returns\r
+     * the correct urn path element, without any path delimiters such as '/'\r
+     * so that calling shortIdToPath("TestAuthority") returns "urn:cspace:name(TestAuthority)", and\r
+     * then this value may be put into a path, such as "/personauthorities/urn:cspace:name(TestAuthority)/items".\r
+     */\r
+    public static String shortIdToPath(String shortId){\r
+        return URN_NAME_PREFIX+'('+shortId+')';\r
+    }\r
+\r
 \r
     /*\r
     public static String buildRefName(String tenantName, String serviceName, String shortIdentifier, String displayName, String authorityRefBaseName) {\r