@Override public int getStatusCode() { return response.getStatusCode(); }
@Override public int getStatusCode() { return response.getStatusCode(); }
private void checkStatus(ODataResponse response, int expectedStatusCode) throws CMODataClientException { if (response.getStatusCode() != expectedStatusCode) { IOException suspressed = null; String bodyContent = "<n/a>"; try { /* * Does not work for http-4xx and http.5xx since Olingo prefers to answer * with an exception in this case rather with an response entity. But it might * be helpful also for inexpected http responses outside that range. */ bodyContent = IOUtils.toString(response.getRawResponse()); } catch(IOException e) { suspressed = e; logger.warn("Cannot read response body content.", e); } CMODataClientException e = new CMODataClientException( format("Response status code '%d' does not match expected status code '%d'. Response body: '%s'.", response.getStatusCode(), expectedStatusCode, bodyContent)); if(suspressed != null) e.addSuppressed(suspressed); throw e; } }
private void checkStatus(ODataResponse response, int expectedStatusCode) throws CMODataClientException { if (response.getStatusCode() != expectedStatusCode) { IOException suspressed = null; String bodyContent = "<n/a>"; try { /* * Does not work for http-4xx and http.5xx since Olingo prefers to answer * with an exception in this case rather with an response entity. But it might * be helpful also for inexpected http responses outside that range. */ bodyContent = IOUtils.toString(response.getRawResponse()); } catch(IOException e) { suspressed = e; logger.warn("Cannot read response body content.", e); } CMODataClientException e = new CMODataClientException( format("Response status code '%d' does not match expected status code '%d'. Response body: '%s'.", response.getStatusCode(), expectedStatusCode, bodyContent)); if(suspressed != null) e.addSuppressed(suspressed); throw e; } }
private ODataResponse nextExpected() { // consume item for condition above (used like a counter ...) expectedItemsIterator.next(); final Map<String, Collection<String>> nextItemHeaders = ODataBatchUtilities.nextItemHeaders(batchLineIterator, boundary); if (nextItemHeaders.isEmpty()) { throw new IllegalStateException("Expected item not found"); } final Map.Entry<Integer, String> responseLine = ODataBatchUtilities.readResponseLine(batchLineIterator); LOG.debug("Retrieved item response {}", responseLine); final Map<String, Collection<String>> headers = ODataBatchUtilities.readHeaders(batchLineIterator); LOG.debug("Retrieved item headers {}", headers); Collection<String> contentId = nextItemHeaders.get(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME); if (contentId == null || contentId.isEmpty()) { contentId = headers.get(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME); if (contentId == null || contentId.isEmpty()) { throw new IllegalStateException("Content-ID is missing"); } } current = getResponse(contentId.iterator().next()); if (current == null) { throw new IllegalStateException("Unexpected '" + contentId + "' item found"); } current.initFromBatch(responseLine, headers, batchLineIterator, boundary); if (current.getStatusCode() >= 400 && !continueOnError) { // found error .... breaking = true; } return current; }
private ODataResponse nextExpected() { // consume item for condition above (used like a counter ...) expectedItemsIterator.next(); final Map<String, Collection<String>> nextItemHeaders = ODataBatchUtilities.nextItemHeaders(batchLineIterator, boundary); if (nextItemHeaders.isEmpty()) { throw new IllegalStateException("Expected item not found"); } final Map.Entry<Integer, String> responseLine = ODataBatchUtilities.readResponseLine(batchLineIterator); LOG.debug("Retrieved item response {}", responseLine); final Map<String, Collection<String>> headers = ODataBatchUtilities.readHeaders(batchLineIterator); LOG.debug("Retrieved item headers {}", headers); Collection<String> contentId = nextItemHeaders.get(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME); if (contentId == null || contentId.isEmpty()) { contentId = headers.get(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME); if (contentId == null || contentId.isEmpty()) { throw new IllegalStateException("Content-ID is missing"); } } current = getResponse(contentId.iterator().next()); if (current == null) { throw new IllegalStateException("Unexpected '" + contentId + "' item found"); } current.initFromBatch(responseLine, headers, batchLineIterator, boundary); if (current.getStatusCode() >= 400 && !continueOnError) { // found error .... breaking = true; } return current; }
&& response instanceof ODataEntityCreateResponse && (response.getStatusCode() == 201 || response .getStatusCode() == 204)) { if (response.getStatusCode() == 201) { entry.getValue().setEntity(((ODataEntityCreateResponse<?>) response).getBody()); responses.put(index, entry.getValue().getEntityURI()); && response instanceof ODataEntityUpdateResponse && (response.getStatusCode() == 200 || response .getStatusCode() == 204)) { if (response.getStatusCode() == 200) { entry.getValue().setEntity(((ODataEntityUpdateResponse<?>) response).getBody()); responses.put(index, entry.getValue().getEntityURI());
&& response instanceof ODataEntityCreateResponse && (response.getStatusCode() == 201 || response .getStatusCode() == 204)) { if (response.getStatusCode() == 201) { entry.getValue().setEntity(((ODataEntityCreateResponse<?>) response).getBody()); responses.put(index, entry.getValue().getEntityURI()); && response instanceof ODataEntityUpdateResponse && (response.getStatusCode() == 200 || response .getStatusCode() == 204)) { if (response.getStatusCode() == 200) { entry.getValue().setEntity(((ODataEntityUpdateResponse<?>) response).getBody()); responses.put(index, entry.getValue().getEntityURI());
if (res.getStatusCode() >= 400) { errors.add(new ODataResponseError(ODataErrorResponseChecker.checkResponse( service.getClient(), if (res instanceof ODataEntityCreateResponse && (res.getStatusCode() == 201 || res .getStatusCode() == 204)) { if (res.getStatusCode() == 201) { handler.setEntity(((ODataEntityCreateResponse<?>) res).getBody()); LOG.debug("Upgrade created object '{}'", handler); handler.applyChanges(); } else if (res instanceof ODataEntityUpdateResponse && (res.getStatusCode() == 200 || res .getStatusCode() == 204)) { if (res.getStatusCode() == 201) { handler.setEntity(((ODataEntityUpdateResponse<?>) res).getBody()); LOG.debug("Upgrade updated object '{}'", handler);
if (res.getStatusCode() >= 400) { errors.add(new ODataResponseError(ODataErrorResponseChecker.checkResponse( service.getClient(), if (res instanceof ODataEntityCreateResponse && (res.getStatusCode() == 201 || res .getStatusCode() == 204)) { if (res.getStatusCode() == 201) { handler.setEntity(((ODataEntityCreateResponse<?>) res).getBody()); LOG.debug("Upgrade created object '{}'", handler); handler.applyChanges(); } else if (res instanceof ODataEntityUpdateResponse && (res.getStatusCode() == 200 || res .getStatusCode() == 204)) { if (res.getStatusCode() == 201) { handler.setEntity(((ODataEntityUpdateResponse<?>) res).getBody()); LOG.debug("Upgrade updated object '{}'", handler);