From: Ray Lee Date: Thu, 24 Apr 2014 22:33:05 +0000 (-0700) Subject: CSPACE-6372: Compare display names case sensitively when checking if refnames have... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=97b392afb3975ab513bd2a0d79f683095319c459;p=tmp%2Fjakarta-migration.git CSPACE-6372: Compare display names case sensitively when checking if refnames have changed. --- diff --git a/services/common-api/src/main/java/org/collectionspace/services/common/api/RefNameUtils.java b/services/common-api/src/main/java/org/collectionspace/services/common/api/RefNameUtils.java index 78cb700f1..1bee824eb 100644 --- a/services/common-api/src/main/java/org/collectionspace/services/common/api/RefNameUtils.java +++ b/services/common-api/src/main/java/org/collectionspace/services/common/api/RefNameUtils.java @@ -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. diff --git a/services/common/pom.xml b/services/common/pom.xml index 9676e2f37..56702bd7c 100644 --- a/services/common/pom.xml +++ b/services/common/pom.xml @@ -148,6 +148,11 @@ commons-codec 1.4 + + commons-lang + commons-lang + 2.6 + org.apache.tomcat dbcp diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java index 7559b24ab..b0e71aeee 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java @@ -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 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;