Search in sources :

Example 1 with SourceStorageRecordsClient

use of org.folio.rest.client.SourceStorageRecordsClient in project mod-inventory by folio-org.

the class Instances method updateSuppressFromDiscoveryFlag.

/**
 * Call Source record storage to update suppress from discovery flag in underlying record
 *
 * @param wContext        - webContext
 * @param updatedInstance - Updated instance entity
 */
private void updateSuppressFromDiscoveryFlag(WebContext wContext, Instance updatedInstance) {
    try {
        SourceStorageRecordsClient client = new SourceStorageRecordsClient(wContext.getOkapiLocation(), wContext.getTenantId(), wContext.getToken());
        client.putSourceStorageRecordsSuppressFromDiscoveryById(updatedInstance.getId(), "INSTANCE", updatedInstance.getDiscoverySuppress(), httpClientResponse -> {
            if (httpClientResponse.result().statusCode() == HttpStatus.HTTP_OK.toInt()) {
                log.info(format("Suppress from discovery flag was successfully updated for record in SRS. InstanceID: %s", updatedInstance.getId()));
            } else {
                log.error(format("Suppress from discovery wasn't changed for SRS record. InstanceID: %s StatusCode: %s", updatedInstance.getId(), httpClientResponse.result().statusCode()));
            }
        });
    } catch (Exception e) {
        log.error("Error during updating suppress from discovery flag for record in SRS", e);
    }
}
Also used : SourceStorageRecordsClient(org.folio.rest.client.SourceStorageRecordsClient) EndpointFailureHandler.getKnownException(org.folio.inventory.support.EndpointFailureHandler.getKnownException) UnprocessableEntityException(org.folio.inventory.exceptions.UnprocessableEntityException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 UnprocessableEntityException (org.folio.inventory.exceptions.UnprocessableEntityException)1 EndpointFailureHandler.getKnownException (org.folio.inventory.support.EndpointFailureHandler.getKnownException)1 SourceStorageRecordsClient (org.folio.rest.client.SourceStorageRecordsClient)1