/** * Constructor. * * @param res OData batch response. */ public AsyncResponseWrapperImpl(final ODataBatchResponse res) { super(); if (res.getStatusCode() == 202) { retrieveMonitorDetails(res); } else { response = res; } }
private void retrieveMonitorDetails(final ODataBatchResponse res) { Collection<String> headers = res.getHeader(HttpHeader.LOCATION); if (headers == null || headers.isEmpty()) { throw new AsyncRequestException("Invalid async request response. Monitor URL not found"); } else { this.location = URI.create(headers.iterator().next()); } headers = res.getHeader(HttpHeader.RETRY_AFTER); if (headers != null && !headers.isEmpty()) { this.retryAfter = Integer.parseInt(headers.iterator().next()); } headers = res.getHeader(HttpHeader.PREFERENCE_APPLIED); if (headers != null && !headers.isEmpty()) { for (String header : headers) { if (header.equalsIgnoreCase(new ODataPreferences().respondAsync())) { preferenceApplied = true; } } } IOUtils.closeQuietly(res.getRawResponse()); } }
if (response.getStatusCode() != 202 && response.getStatusCode() != 200) { throw new ODataServerErrorException(new ResponseStatusLine(response)); final List<ODataResponseError> errors = new ArrayList<ODataResponseError>(); final Iterator<ODataBatchResponseItem> batchResItor = response.getBody(); if (!batchResItor.hasNext()) { throw new IllegalStateException("Unexpected operation result"); ((ODataRequest) request).getAccept()), index, requests.get(index))); if (!service.getClient().getConfiguration().isContinueOnError()) { throw new ODataFlushException(response.getStatusCode(), errors); throw new ODataFlushException(response.getStatusCode(), errors); response.close();
if (response.getStatusCode() != 202 && response.getStatusCode() != 200) { throw new ODataServerErrorException(new ResponseStatusLine(response)); final List<ODataResponseError> errors = new ArrayList<ODataResponseError>(); final Iterator<ODataBatchResponseItem> batchResItor = response.getBody(); if (!batchResItor.hasNext()) { throw new IllegalStateException("Unexpected operation result"); ((ODataRequest) request).getAccept()), index, requests.get(index))); if (!service.getClient().getConfiguration().isContinueOnError()) { throw new ODataFlushException(response.getStatusCode(), errors); throw new ODataFlushException(response.getStatusCode(), errors); response.close();
private void retrieveMonitorDetails(final ODataBatchResponse res) { Collection<String> headers = res.getHeader(HttpHeader.LOCATION); if (headers == null || headers.isEmpty()) { throw new AsyncRequestException("Invalid async request response. Monitor URL not found"); } else { this.location = URI.create(headers.iterator().next()); } headers = res.getHeader(HttpHeader.RETRY_AFTER); if (headers != null && !headers.isEmpty()) { this.retryAfter = Integer.parseInt(headers.iterator().next()); } headers = res.getHeader(HttpHeader.PREFERENCE_APPLIED); if (headers != null && !headers.isEmpty()) { for (String header : headers) { if (header.equalsIgnoreCase(new ODataPreferences().respondAsync())) { preferenceApplied = true; } } } IOUtils.closeQuietly(res.getRawResponse()); } }
/** * Constructor. * * @param res OData batch response. */ public AsyncResponseWrapperImpl(final ODataBatchResponse res) { super(); if (res.getStatusCode() == 202) { retrieveMonitorDetails(res); } else { response = res; } }
public ODataBatchResponseManager( final ODataBatchResponse res, final List<ODataBatchResponseItem> expectedItems, final boolean continueOnError) { this.continueOnError = continueOnError; try { this.expectedItemsIterator = expectedItems.iterator(); this.batchLineIterator = new ODataBatchLineIteratorImpl( IOUtils.lineIterator(res.getRawResponse(), Constants.UTF8)); // search for boundary batchBoundary = ODataBatchUtilities.getBoundaryFromHeader( res.getHeader(HttpHeader.CONTENT_TYPE)); LOG.debug("Retrieved batch response bondary '{}'", batchBoundary); } catch (IOException e) { LOG.error("Error parsing batch response", e); throw new IllegalStateException(e); } }
public ODataBatchResponseManager( final ODataBatchResponse res, final List<ODataBatchResponseItem> expectedItems, final boolean continueOnError) { this.continueOnError = continueOnError; try { this.expectedItemsIterator = expectedItems.iterator(); this.batchLineIterator = new ODataBatchLineIteratorImpl( IOUtils.lineIterator(res.getRawResponse(), Constants.UTF8)); // search for boundary batchBoundary = ODataBatchUtilities.getBoundaryFromHeader( res.getHeader(HttpHeader.CONTENT_TYPE)); LOG.debug("Retrieved batch response bondary '{}'", batchBoundary); } catch (IOException e) { LOG.error("Error parsing batch response", e); throw new IllegalStateException(e); } }