From: remillet Date: Thu, 14 Jul 2016 15:41:37 +0000 (-0700) Subject: NOJIRA: Cleanup of client connection responses during authority synchronization. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=e87c9f4edd8d57dc1c157e65da9b20c704254a9c;p=tmp%2Fjakarta-migration.git NOJIRA: Cleanup of client connection responses during authority synchronization. --- 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 30016a379..5798be706 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 @@ -148,7 +148,7 @@ public abstract class AuthorityDocumentModelHandler // // First, sync all the authority items // - syncAllItems(ctx, sasSpecifier); + syncAllItems(ctx, sasSpecifier); // FIXME: We probably want to consider "paging" this instead of handling the entire set of items. // // Next, sync the authority resource/record itself // @@ -500,13 +500,13 @@ public abstract class AuthorityDocumentModelHandler if (statusCode != HttpStatus.OK_200) { String errMsg = String.format("Could not retrieve authority information for '%s' on remote server '%s'. Server returned status code %d", specifier.getURNValue(), client.getBaseURL(), statusCode); - res.close(); throw new DocumentException(statusCode, errMsg); } } /** - * Request an authority item list payload from the SAS server. + * 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 @@ -516,6 +516,7 @@ public abstract class AuthorityDocumentModelHandler private PoxPayloadIn requestPayloadInItemList(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(), @@ -525,8 +526,12 @@ public abstract class AuthorityDocumentModelHandler 0 // page number ); assertStatusCode(res, specifier, client); - AbstractCommonList commonList = res.readEntity(AbstractCommonList.class); - res.close(); + AbstractCommonList commonList; + try { + commonList = res.readEntity(AbstractCommonList.class); + } finally { + res.close(); + } long numOfItems = commonList.getTotalItems(); // @@ -538,7 +543,6 @@ public abstract class AuthorityDocumentModelHandler 0 // page number ); assertStatusCode(res, specifier, client); - try { result = new PoxPayloadIn((String)res.readEntity(getEntityResponseType())); // Get the entire response. } finally {