@Override public SdkHttpFullResponse execute(Pair<SdkHttpFullRequest, SdkHttpFullResponse> input, RequestExecutionContext context) throws Exception { context.interceptorChain().beforeUnmarshalling(context.executionContext().interceptorContext(), context.executionAttributes()); InterruptMonitor.checkInterrupted(input.right()); return input.right(); } }
@SuppressWarnings("unchecked") private T unmarshallResponse(SdkHttpFullResponse response) throws Exception { SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML."); Pair<T, Map<String, String>> result = unmarshaller.unmarshall(pojoSupplier.apply(response), response); SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response."); AwsResponseMetadata responseMetadata = generateResponseMetadata(response, result.right()); return (T) result.left().toBuilder().responseMetadata(responseMetadata).build(); }
@SuppressWarnings("unchecked") private T unmarshallResponse(SdkHttpFullResponse response) throws Exception { SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML."); Pair<T, Map<String, String>> result = unmarshaller.unmarshall(pojoSupplier.apply(response), response); SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response."); AwsResponseMetadata responseMetadata = generateResponseMetadata(response, result.right()); return (T) result.left().toBuilder().responseMetadata(responseMetadata).build(); }
@Override public AwsServiceException handle(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) { Pair<XmlElement, SdkBytes> xmlAndBytes = parseXml(response); XmlElement document = xmlAndBytes.left(); Optional<XmlElement> errorRoot = errorRootExtractor.apply(document); String errorCode = getErrorCode(errorRoot); AwsServiceException.Builder builder = errorRoot .map(e -> invokeSafely(() -> unmarshallFromErrorCode(response, e, errorCode))) .orElseGet(this::defaultException); AwsErrorDetails awsErrorDetails = AwsErrorDetails.builder() .errorCode(errorCode) .errorMessage(builder.message()) .rawResponse(xmlAndBytes.right()) .sdkHttpResponse(response) .serviceName(executionAttributes.getAttribute(AwsExecutionAttribute.SERVICE_NAME)) .build(); builder.requestId(getRequestId(response, document)) .statusCode(response.statusCode()) .awsErrorDetails(awsErrorDetails); return builder.build(); }
@Override public AwsServiceException handle(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) { Pair<XmlElement, SdkBytes> xmlAndBytes = parseXml(response); XmlElement document = xmlAndBytes.left(); Optional<XmlElement> errorRoot = errorRootExtractor.apply(document); String errorCode = getErrorCode(errorRoot); AwsServiceException.Builder builder = errorRoot .map(e -> invokeSafely(() -> unmarshallFromErrorCode(response, e, errorCode))) .orElseGet(this::defaultException); AwsErrorDetails awsErrorDetails = AwsErrorDetails.builder() .errorCode(errorCode) .errorMessage(builder.message()) .rawResponse(xmlAndBytes.right()) .sdkHttpResponse(response) .serviceName(executionAttributes.getAttribute(AwsExecutionAttribute.SERVICE_NAME)) .build(); builder.requestId(getRequestId(response, document)) .statusCode(response.statusCode()) .awsErrorDetails(awsErrorDetails); return builder.build(); }