]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-90: Fixed problem with /servicegroupd/common/item/${csid} when csid pointed...
authorremillet <remillet@yahoo.com>
Sun, 26 Feb 2017 08:05:31 +0000 (00:05 -0800)
committerremillet <remillet@yahoo.com>
Sun, 26 Feb 2017 08:05:31 +0000 (00:05 -0800)
services/common-api/src/main/java/org/collectionspace/services/common/api/RefName.java
services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java
services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationValidatorHandler.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java

index ee87e0bca90144f4d7d5baf55a5238656db103dd..4541efd7cce95ab13ea52e5e8f4ce56e0617b3d6 100644 (file)
@@ -173,14 +173,27 @@ public class RefName {
         public String shortIdentifier = "";
         public String displayName = "";
 
-        public static AuthorityItem parse(String urn) throws IllegalArgumentException {
+        // Returns null value if urn can't be parsed and exceptionOnFail is set to 'false'
+        // Throws exception if urn can't be parsed and exceptionOnFail is set to 'true'
+        public static AuthorityItem parse(String urn, boolean exceptionOnFail) throws IllegalArgumentException {
             AuthorityItem authorityItem = null;
 
-            RefNameUtils.AuthorityTermInfo termInfo = RefNameUtils.parseAuthorityTermInfo(urn);
-            authorityItem = authorityItemFromTermInfo(termInfo);
+            try {
+                   RefNameUtils.AuthorityTermInfo termInfo = RefNameUtils.parseAuthorityTermInfo(urn);
+                   authorityItem = authorityItemFromTermInfo(termInfo);
+            } catch (IllegalArgumentException e) {
+               if (exceptionOnFail == true) {
+                       throw e;
+               }
+            }
 
             return authorityItem;
         }
+        
+        // Returns null value if urn can't be parsed
+        public static AuthorityItem parse(String urn) {
+               return parse(urn, false);
+        }
 
         public String getDisplayName() {
                return this.displayName;
index bdd234001f7602ab1759aea3cc613f834f5fc918..14cc33603e76077684b809121c1da83b595ed58c 100644 (file)
@@ -657,6 +657,6 @@ public abstract class NuxeoBasedResource
 
     public DocumentModel getDocModelForRefName(CoreSessionInterface repoSession, String refName) 
                        throws Exception, DocumentNotFoundException {
-       return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName));
+       return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName, true));
     }
 }
index 4afb237fc039731727e6542247ec85d75d9ddbbe..e8a213641251b8769e18c1efc1a04043a08ef73b 100644 (file)
@@ -742,7 +742,7 @@ public class NuxeoUtils {
        // Let's see if our refname refers to an authority item/term.
        //
        try {
-               item = RefName.AuthorityItem.parse(refName);
+               item = RefName.AuthorityItem.parse(refName, true);
                if (item != null) {
                        NuxeoBasedResource resource = (NuxeoBasedResource) resourceMap.get(item.inAuthority.resource);
                        return resource.getDocModelForAuthorityItem(repoSession, item);
index 90ffd2f0dc3b5056ecb6841f92cd261842317bb7..d00793877fb1002bb2729fca503acfe9ba9da418 100644 (file)
@@ -116,7 +116,7 @@ public class RelationValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn,
                    if (authority != null) {
                        result = true;
                    } else {
-                       AuthorityItem authItem = AuthorityItem.parse(refName); // See if it is a refname to an authority item or vocabulary term
+                       AuthorityItem authItem = AuthorityItem.parse(refName, true); // See if it is a refname to an authority item or vocabulary term
                        result = authItem != null;
                    }
                } catch (IllegalArgumentException e) {
index bab793a981e7df5a8aa155d20435723780d86323..f318e359edbdac8d52981964f243a17fbd312c30 100644 (file)
@@ -88,7 +88,7 @@ public class ServiceGroupDocumentModelHandler
     private PoxPayloadOut getAuthorityItem(ServiceContext ctx, String termRefName) throws Exception {
        PoxPayloadOut result = null;
        
-       RefName.AuthorityItem item = RefName.AuthorityItem.parse(termRefName);
+       RefName.AuthorityItem item = RefName.AuthorityItem.parse(termRefName, true);
        AuthorityResource authorityResource = (AuthorityResource) ctx.getResourceMap().get(item.inAuthority.resource);
        
        AuthorityTermInfo authorityTermInfo = RefNameUtils.parseAuthorityTermInfo(termRefName);
@@ -163,7 +163,7 @@ public class ServiceGroupDocumentModelHandler
                try {
                //String inAuthorityCsid = (String) NuxeoUtils.getProperyValue(docModel, "inAuthority"); //docModel.getPropertyValue("inAuthority"); // AuthorityItemJAXBSchema.IN_AUTHORITY
                //String refName = (String) NuxeoUtils.getProperyValue(docModel, CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME);
-               RefName.AuthorityItem item = RefName.AuthorityItem.parse(termRefName);
+               RefName.AuthorityItem item = RefName.AuthorityItem.parse(termRefName, true);
                } catch (IllegalArgumentException e) {
                        result = false;
                }