]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-765: Remove extra request to retrieve all remote items during SAS sync.
authorRay Lee <ray.lee@lyrasis.org>
Thu, 3 Oct 2019 19:55:49 +0000 (12:55 -0700)
committerRay Lee <ray.lee@lyrasis.org>
Fri, 11 Oct 2019 00:12:29 +0000 (17:12 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java

index 87f2cdd03c8242d82e7a1e024b8a4c4196deaf7d..816e2751af690c07be713ca181f5295021aea420 100644 (file)
@@ -195,8 +195,8 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
                //
                // Iterate over the list of items/terms in the remote authority
                //
-               PoxPayloadIn sasPayloadInItemList = requestPayloadInItemList(ctx, sasAuthoritySpecifier);
-               List<Element> itemList = getItemList(sasPayloadInItemList);
+               PoxPayloadIn itemListPayload = requestItemList(ctx, sasAuthoritySpecifier);
+               List<Element> 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<AuthCommon>
        }
 
        /**
-        * 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<AuthCommon>
                return result;
        }
 
-
        /*
         * Non standard injection of CSID into common part, since caller may access through
         * shortId, and not know the CSID.