]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-7069: Added query params to force sycn and normalize term references to use...
authorremillet <remillet@yahoo.com>
Thu, 9 Feb 2017 23:28:01 +0000 (15:28 -0800)
committerremillet <remillet@yahoo.com>
Thu, 9 Feb 2017 23:28:01 +0000 (15:28 -0800)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/client/src/main/java/org/collectionspace/services/client/IClientQueryParams.java
services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java

index 2d6f74a3c0dd7af08ee76635251d681427008b39..b8ca7f44959372c8228f301789cbdf4d73b7c1e0 100644 (file)
@@ -569,7 +569,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         //
         // If the shared authority item is newer, update our local copy
         //
-        if (sasRev > localItemRev || localIsProposed) {
+        if (sasRev > localItemRev || localIsProposed || ctx.shouldForceSync()) {
                sasPayloadIn = AuthorityServiceUtils.filterRefnameDomains(ctx, sasPayloadIn); // We need to filter the domain name part of any and all refnames in the payload
                AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath());
                PoxPayloadOut payloadOut = authorityResource.updateAuthorityItem(ctx, 
index 455e446b42ab766a395e65b184d15b26d40aa51d..52c4ee623c980305f60c77dd75f0d6ae02e247e3 100644 (file)
@@ -33,4 +33,6 @@ public interface IClientQueryParams {
     public static final String ORDER_BY_PARAM = "sortBy";
     public static final String IMPORT_TIMEOUT_PARAM = "impTimout";
     public static final String UPDATE_CORE_VALUES = "updateCoreValues";
+    public static final String FORCE_REFNAME_UPDATES = "forceRefnameUpdates";
+    public static final String FORCE_SYCN = "forceSync";
 }
index 9679a717754cc066af310527b48a8577332dd53d..0978b77ed770a1382c7376213a6e2ca9f485ebc2 100644 (file)
@@ -220,6 +220,28 @@ public abstract class AbstractServiceContextImpl<IT, OT>
                return recordUpdates;
     }
     
+       /**
+        * Default value is 'FALSE'
+        * If this returns true, it means that the refname values in referencing objects (records that reference authority or vocabulary terms) will be updated
+        * regardless of their current value.  This is sometimes needed when refname values become stale for one of several reasons.
+        * @return
+        */
+    @Override
+    public boolean shouldForceUpdateRefnameReferences() {
+               boolean forceUpdates = false;
+               
+               MultivaluedMap<String, String> queryParams = getQueryParams();
+               String paramValue = queryParams.getFirst(IClientQueryParams.FORCE_REFNAME_UPDATES);
+               if (paramValue != null && paramValue.equalsIgnoreCase(Boolean.TRUE.toString())) { // Find our if the caller wants us to force refname updates
+                       forceUpdates = true;
+               } else if (paramValue != null && paramValue.equals(Long.toString(1))) {
+                       forceUpdates = true;
+               }
+               
+               return forceUpdates;
+    }
+    
+    
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.context.ServiceContext#getCommonPartLabel()
      */
@@ -866,4 +888,24 @@ public abstract class AbstractServiceContextImpl<IT, OT>
        public void setRepositoryDomain(RepositoryDomainType repositoryDomain) {
                this.repositoryDomain = repositoryDomain;
        }
+       
+       /**
+        * Check for a query parameter that indicates if we should force a sync even if the revision numbers indicate otherwise.
+        * @return
+        */
+       @Override
+       public boolean shouldForceSync() {
+               boolean forceSync = false;
+               
+               MultivaluedMap<String, String> queryParams = getQueryParams();
+               String paramValue = queryParams.getFirst(IClientQueryParams.FORCE_SYCN);
+               if (paramValue != null && paramValue.equalsIgnoreCase(Boolean.TRUE.toString())) { // Find our if the caller wants us to force refname updates
+                       forceSync = true;
+               } else if (paramValue != null && paramValue.equals(Long.toString(1))) {
+                       forceSync = true;
+               }
+               
+               return forceSync;
+    }
+       
 }
index 2eea17d9ac9a3cc77f5d93287e6454063cf87e85..206d7ef5ac51c413c09b00aa8ad6304be76552a8 100644 (file)
@@ -102,6 +102,7 @@ public interface ServiceContext<IT, OT> {
 
     /**
      * Returns TRUE unless the "recordUpdates" query param is set with a value of either "false", "FALSE", or "0"
+     * If set to false, core schema values (i.e. updated-at, updated-by, etc) won't be changed on updates.
      * @return
      */
     public boolean shouldUpdateCoreValues();
@@ -381,6 +382,19 @@ public interface ServiceContext<IT, OT> {
      */
        public CollectionSpaceResource<IT, OT> getResource(
                        String serviceName) throws Exception;
+
+       /**
+        * If this returns true, it means that the refname values in referencing objects (records that reference authority or vocabulary terms) will be updated
+        * regardless of their current value.  This is sometimes needed when refname values become stale for one of several reasons.
+        * @return
+        */
+       public boolean shouldForceUpdateRefnameReferences();
+
+       /**
+        * Check for a query parameter that indicates if we should force a sync even if the revision numbers indicate otherwise.
+        * @return
+        */
+       public boolean shouldForceSync();
 }
 
 
index e692420dc85f50427d95ca7df3f57a4c76fefdfe..aa623abc704ca030e9c344a983b96cf011fdd4d1 100644 (file)
@@ -594,7 +594,7 @@ public class RefNameServiceUtils {
 
                 // Only match complete refNames - unless and until we decide how to resolve changes
                 // to NPTs we will defer that and only change PTs or refNames as passed in.
-                int nRefsFoundThisPage = processRefObjsDocListForUpdate(docList, ctx.getTenantId(), oldRefName, 
+                int nRefsFoundThisPage = processRefObjsDocListForUpdate(ctx, docList, ctx.getTenantId(), oldRefName, 
                                queriedServiceBindings, authRefFieldsByService, // Perform the refName updates on the list of document models
                         newRefName);
                 if (nRefsFoundThisPage > 0) {
@@ -747,13 +747,21 @@ public class RefNameServiceUtils {
        }
 
     private static int processRefObjsDocListForUpdate(
+               ServiceContext ctx,
             DocumentModelList docList,
             String tenantId,
             String refName,
             Map<String, ServiceBindingType> queriedServiceBindings,
             Map<String, List<AuthRefConfigInfo>> authRefFieldsByService,
             String newAuthorityRefName) {
-       return processRefObjsDocList(docList, tenantId, refName, false, queriedServiceBindings,
+       boolean matchBaseOnly = false;
+       
+       if (ctx.shouldForceUpdateRefnameReferences() == true) {
+               refName = RefNameUtils.stripAuthorityTermDisplayName(refName);
+               matchBaseOnly = true;
+       }
+       
+       return processRefObjsDocList(docList, tenantId, refName, matchBaseOnly, queriedServiceBindings,
                        authRefFieldsByService, null, 0, 0, newAuthorityRefName);
     }
                        
@@ -881,7 +889,7 @@ public class RefNameServiceUtils {
                 ilistItem.setDocName(
                         ServiceBindingUtils.getMappedFieldInDoc(sb, ServiceBindingUtils.OBJ_NAME_PROP, docModel));
             }
-            // Now, we have to loop over the authRefFieldsByService to figure
+            // Now, we have to loop over the authRefFieldsByService to figure out
             // out which field(s) matched this.
             List<AuthRefConfigInfo> matchingAuthRefFields = authRefFieldsByService.get(docType);
             if (matchingAuthRefFields == null || matchingAuthRefFields.isEmpty()) {
index ba8eef040b03e18786a126148b668d3acbfa7518..0f4442248510b38ea1211f8e6c7a0ed0ab153c3a 100644 (file)
@@ -330,6 +330,13 @@ public abstract class DocumentModelHandler<T, TL>
     protected boolean hasRefNameUpdate() {
        boolean result = false;
        
+       //
+       // Check to see if the request contains a query parameter asking us to force a refname update
+       //
+       if (getServiceContext().shouldForceUpdateRefnameReferences() == true) {
+               return true;
+       }
+       
        if (Tools.notBlank(newRefNameOnUpdate) && Tools.notBlank(oldRefNameOnUpdate)) {
                // CSPACE-6372: refNames are different if:
                //   - any part of the refName is different, using a case insensitive comparison, or