From 34ac4145f9e4254b55007babff57f3ea4deb5a3f Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Thu, 3 Oct 2019 12:55:49 -0700 Subject: [PATCH] DRYD-765: Remove extra request to retrieve all remote items during SAS sync. --- .../nuxeo/AuthorityDocumentModelHandler.java | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java index 87f2cdd03..816e2751a 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java @@ -195,8 +195,8 @@ public abstract class AuthorityDocumentModelHandler // // Iterate over the list of items/terms in the remote authority // - PoxPayloadIn sasPayloadInItemList = requestPayloadInItemList(ctx, sasAuthoritySpecifier); - List itemList = getItemList(sasPayloadInItemList); + PoxPayloadIn itemListPayload = requestItemList(ctx, sasAuthoritySpecifier); + List itemList = getItemList(itemListPayload); if (itemList != null) { for (Element e:itemList) { String remoteRefName = XmlTools.getElementValue(e, AuthorityItemJAXBSchema.REF_NAME); @@ -507,46 +507,33 @@ public abstract class AuthorityDocumentModelHandler } /** - * Request an authority item list payload from the SAS server. This is a non-paging solution. If the authority - * has a very large number of items/terms, we might not be able to handle them all. + * Request an authority item list payload from the SAS server. This is a non-paging solution. + * If the authority has a very large number of items/terms, we might not be able to handle them + * all. * * @param ctx * @param specifier * @return * @throws Exception */ - private PoxPayloadIn requestPayloadInItemList(ServiceContext ctx, Specifier specifier) throws Exception { + private PoxPayloadIn requestItemList(ServiceContext ctx, Specifier specifier) throws Exception { PoxPayloadIn result = null; AuthorityClient client = (AuthorityClient) ctx.getClient(); - // - // First find out how many items exist - Response res = client.readItemList(specifier.getURNValue(), - null, // partial term string - null, // keyword string - 0, // page size - 0 // page number - ); - assertStatusCode(res, specifier, client); - AbstractCommonList commonList; - try { - commonList = res.readEntity(AbstractCommonList.class); - } finally { - res.close(); - } - long numOfItems = commonList.getTotalItems(); + // Request the item list using the max page size (0). + + Response res = client.readItemList( + specifier.getURNValue(), + null, // partial term string + null, // keyword string + 0, // page size + 0 // page number + ); - // - // Next, request a payload list with all the items - res = client.readItemList(specifier.getURNValue(), - null, // partial term string - null, // keyword string - numOfItems, // page size - 0 // page number - ); assertStatusCode(res, specifier, client); + try { - result = new PoxPayloadIn((String)res.readEntity(getEntityResponseType())); // Get the entire response. + result = new PoxPayloadIn((String) res.readEntity(getEntityResponseType())); // Get the entire response. } finally { res.close(); } @@ -554,7 +541,6 @@ public abstract class AuthorityDocumentModelHandler return result; } - /* * Non standard injection of CSID into common part, since caller may access through * shortId, and not know the CSID. -- 2.47.3