]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6372: Compare display names case sensitively when checking if refnames have...
authorRay Lee <rhlee@berkeley.edu>
Thu, 24 Apr 2014 22:33:05 +0000 (15:33 -0700)
committerRay Lee <rhlee@berkeley.edu>
Thu, 24 Apr 2014 23:16:08 +0000 (16:16 -0700)
services/common-api/src/main/java/org/collectionspace/services/common/api/RefNameUtils.java
services/common/pom.xml
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java

index 78cb700f1aebffa4dca439ba9556157c1092e8b3..1bee824ebaa1ec60493c62b3781831807bbabc3b 100644 (file)
@@ -249,6 +249,34 @@ public class RefNameUtils {
         }
         return name;
     }
+    
+    
+    /**
+     * Extracts the display name from a refName. The refName may either be for an
+     * authority term, or an authority/procedure.
+     *
+     * @param  refName The refName
+     * @return The display name contained in the refName
+     */
+    public static String getDisplayName(String refName) throws IllegalArgumentException {
+       String displayName = null;
+       
+       try {
+               AuthorityTermInfo authorityTermInfo = parseAuthorityTermInfo(refName);
+               displayName = authorityTermInfo.displayName;
+       }
+       catch(IllegalArgumentException invalidAuthorityTermRefNameException) {
+               try {                   
+                       AuthorityInfo termInfo = parseAuthorityInfo(refName);
+                       displayName = termInfo.displayName;
+               }
+               catch(IllegalArgumentException invalidRefNameException) {
+                       throw new IllegalArgumentException("Invalid refName");
+               }
+       }
+       
+       return displayName;
+    }
 
     /**
      * Creates a refName in the name / shortIdentifier form.
index 9676e2f370761aaeb3ee8ef38c88f052196f327f..56702bd7c3169e2b5272926582695ba155b0c7d7 100644 (file)
                        <artifactId>commons-codec</artifactId>\r
                        <version>1.4</version>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>commons-lang</groupId>\r
+            <artifactId>commons-lang</artifactId>\r
+            <version>2.6</version>\r
+        </dependency>\r
         <dependency>\r
                <groupId>org.apache.tomcat</groupId>\r
                <artifactId>dbcp</artifactId>\r
index 7559b24ab256cba943d2fca2fef73492c77610ac..b0e71aeee599a0ece44064580973566367d35947 100644 (file)
@@ -28,6 +28,7 @@ import java.util.List;
 
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.apache.commons.lang.StringUtils;
 import org.collectionspace.services.client.Profiler;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.IQueryManager;
@@ -37,6 +38,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
 import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.api.RefName.RefNameInterface;
+import org.collectionspace.services.common.api.RefNameUtils;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.ServiceContext;
@@ -392,6 +394,14 @@ public abstract class DocumentModelHandler<T, TL>
                if (newRefNameOnUpdate.equalsIgnoreCase(oldRefNameOnUpdate) == false) {
                        result = true; // refNames are different so updates are needed
                }
+               else {
+                       String newDisplayNameOnUpdate = RefNameUtils.getDisplayName(newRefNameOnUpdate);
+                       String oldDisplayNameOnUpdate = RefNameUtils.getDisplayName(oldRefNameOnUpdate);
+                       
+                       if (StringUtils.equals(newDisplayNameOnUpdate, oldDisplayNameOnUpdate) == false) {
+                               result = true; // display names are different so updates are needed
+                       }
+               }
        }
        
        return result;