//
// 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,
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";
}
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()
*/
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;
+ }
+
}
/**
* 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();
*/
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();
}
// 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) {
}
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);
}
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()) {
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