RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
List<String> serviceTypes,\r
String refName,\r
- String refPropName,\r
+ String refPropName, // authRef or termRef, authorities or vocab terms.\r
DocumentFilter filter, boolean computeTotal)\r
throws DocumentException, DocumentNotFoundException {\r
AuthorityRefDocList wrapperList = new AuthorityRefDocList();\r
// item within any individual document scanned, so the number of\r
// authority references may potentially exceed the total number\r
// of documents scanned.\r
- int nRefsFound = processRefObjsDocList(docList, ctx.getTenantId(), refName, queriedServiceBindings, authRefFieldsByService, // the actual list size needs to be updated to the size of "list"\r
+\r
+ // Strip off displayName and only match the base, so we get references to all \r
+ // the NPTs as well as the PT.\r
+ String strippedRefName = RefNameUtils.stripAuthorityTermDisplayName(refName);\r
+ int nRefsFound = processRefObjsDocList(docList, ctx.getTenantId(), strippedRefName, true, queriedServiceBindings, authRefFieldsByService, // the actual list size needs to be updated to the size of "list"\r
list, null);\r
\r
commonList.setPageSize(pageSize);\r
morePages = false;\r
}\r
\r
- int nRefsFoundThisPage = processRefObjsDocList(docList, ctx.getTenantId(), oldRefName, queriedServiceBindings, authRefFieldsByService, // Perform the refName updates on the list of document models\r
+ // Only match complete refNames - unless and until we decide how to resolve changes\r
+ // to NPTs we will defer that and only change PTs or refNames as passed in.\r
+ int nRefsFoundThisPage = processRefObjsDocList(docList, ctx.getTenantId(), oldRefName, false, queriedServiceBindings, authRefFieldsByService, // Perform the refName updates on the list of document models\r
null, newRefName);\r
if (nRefsFoundThisPage > 0) {\r
((RepositoryJavaClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true); // Flush the document model list out to Nuxeo storage\r
DocumentModelList docList,\r
String tenantId,\r
String refName,\r
+ boolean matchBaseOnly,\r
Map<String, ServiceBindingType> queriedServiceBindings,\r
Map<String, List<AuthRefConfigInfo>> authRefFieldsByService,\r
List<AuthorityRefDocList.AuthorityRefDocItem> list,\r
\r
ArrayList<RefNameServiceUtils.AuthRefInfo> foundProps = new ArrayList<RefNameServiceUtils.AuthRefInfo>();\r
try {\r
- findAuthRefPropertiesInDoc(docModel, matchingAuthRefFields, refName, foundProps); // REM - side effect that foundProps is set\r
+ findAuthRefPropertiesInDoc(docModel, matchingAuthRefFields, refName, matchBaseOnly, foundProps); // REM - side effect that foundProps is set\r
for (RefNameServiceUtils.AuthRefInfo ari : foundProps) {\r
if (ilistItem != null) {\r
if (nRefsFoundInDoc == 0) { // First one?\r
List<AuthRefConfigInfo> authRefFieldInfo,\r
String refNameToMatch,\r
List<AuthRefInfo> foundProps) {\r
+ return findAuthRefPropertiesInDoc(docModel, authRefFieldInfo, \r
+ refNameToMatch, false, foundProps);\r
+ }\r
+ \r
+ public static List<AuthRefInfo> findAuthRefPropertiesInDoc(\r
+ DocumentModel docModel,\r
+ List<AuthRefConfigInfo> authRefFieldInfo,\r
+ String refNameToMatch,\r
+ boolean matchBaseOnly,\r
+ List<AuthRefInfo> foundProps) {\r
// Assume that authRefFieldInfo is keyed by the field name (possibly mapped for UI)\r
// and the values are elPaths to the field, where intervening group structures in\r
// lists of complex structures are replaced with "*". Thus, valid paths include\r
try {\r
// Get first property and work down as needed.\r
Property prop = docModel.getProperty(arci.pathEls[0]);\r
- findAuthRefPropertiesInProperty(foundProps, prop, arci, 0, refNameToMatch);\r
+ findAuthRefPropertiesInProperty(foundProps, prop, arci, 0, refNameToMatch, matchBaseOnly);\r
} catch (Exception e) {\r
logger.error("Problem fetching property: " + arci.pathEls[0]);\r
}\r
return foundProps;\r
}\r
\r
- public static List<AuthRefInfo> findAuthRefPropertiesInProperty(\r
+ private static List<AuthRefInfo> findAuthRefPropertiesInProperty(\r
List<AuthRefInfo> foundProps,\r
Property prop,\r
AuthRefConfigInfo arci,\r
int pathStartIndex, // Supports recursion and we work down the path\r
- String refNameToMatch) {\r
+ String refNameToMatch,\r
+ boolean matchBaseOnly ) {\r
if (pathStartIndex >= arci.pathEls.length) {\r
throw new ArrayIndexOutOfBoundsException("Index = " + pathStartIndex + " for path: "\r
+ arci.pathEls.toString());\r
}\r
\r
if (prop instanceof StringProperty) { // scalar string\r
- addARIifMatches(refNameToMatch, arci, prop, foundProps);\r
+ addARIifMatches(refNameToMatch, matchBaseOnly, arci, prop, foundProps);\r
} else if (prop instanceof List) {\r
List<Property> propList = (List<Property>) prop;\r
// run through list. Must either be list of Strings, or Complex\r
+ arci.pathEls.toString());\r
break;\r
} else {\r
- addARIifMatches(refNameToMatch, arci, listItemProp, foundProps);\r
+ addARIifMatches(refNameToMatch, matchBaseOnly, arci, listItemProp, foundProps);\r
}\r
} else if (listItemProp.isComplex()) {\r
// Just recurse to handle this. Note that since this is a list of complex, \r
// which should look like listName/*/... we add 2 to the path start index \r
findAuthRefPropertiesInProperty(foundProps, listItemProp, arci,\r
- pathStartIndex + 2, refNameToMatch);\r
+ pathStartIndex + 2, refNameToMatch, matchBaseOnly);\r
} else {\r
logger.error("Configuration for authRefs does not match schema structure: "\r
+ arci.pathEls.toString());\r
Property localProp = prop.get(localPropName);\r
// Now just recurse, pushing down the path 1 step\r
findAuthRefPropertiesInProperty(foundProps, localProp, arci,\r
- pathStartIndex, refNameToMatch);\r
+ pathStartIndex, refNameToMatch, matchBaseOnly);\r
} catch (PropertyNotFoundException pnfe) {\r
logger.error("Could not find property: [" + localPropName + "] in path: "\r
+ arci.getFullPath());\r
\r
private static void addARIifMatches(\r
String refNameToMatch,\r
+ boolean matchBaseOnly,\r
AuthRefConfigInfo arci,\r
Property prop,\r
List<AuthRefInfo> foundProps) {\r
// OR have no refName to match but be non-empty\r
try {\r
String value = (String) prop.getValue();\r
- if (((refNameToMatch != null) && refNameToMatch.equals(value))\r
+ if (((refNameToMatch != null) && \r
+ (matchBaseOnly?\r
+ (value!=null && value.startsWith(refNameToMatch))\r
+ :refNameToMatch.equals(value)))\r
|| ((refNameToMatch == null) && Tools.notBlank(value))) {\r
// Found a match\r
logger.debug("Found a match on property: " + prop.getPath() + " with value: [" + value + "]");\r