Java 类com.amazonaws.transform.Unmarshaller 实例源码

项目:ibm-cos-sdk-java    文件:JsonResponseHandler.java   
/**
 * Constructs a new response handler that will use the specified JSON unmarshaller to unmarshall
 * the service response and uses the specified response element path to find the root of the
 * business data in the service's response.
 * @param responseUnmarshaller    The JSON unmarshaller to use on the response.
 * @param simpleTypeUnmarshallers List of unmarshallers to be used for scalar types.
 * @param customTypeMarshallers   List of custom unmarshallers to be used for special types.
 * @param jsonFactory             the json factory to be used for parsing the response.
 */
public JsonResponseHandler(Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller,
                           Map<Class<?>, Unmarshaller<?, JsonUnmarshallerContext>> simpleTypeUnmarshallers,
                           Map<UnmarshallerType, Unmarshaller<?, JsonUnmarshallerContext>> customTypeMarshallers,
                           JsonFactory jsonFactory, boolean needsConnectionLeftOpen,
                           boolean isPayloadJson) {
    /*
     * Even if the invoked operation just returns null, we still need an
     * unmarshaller to run so we can pull out response metadata.
     *
     * We might want to pass this in through the client class so that we
     * don't have to do this check here.
     */
    this.responseUnmarshaller =
            responseUnmarshaller != null ? responseUnmarshaller : new VoidJsonUnmarshaller<T>();

    this.needsConnectionLeftOpen = needsConnectionLeftOpen;
    this.isPayloadJson = isPayloadJson;

    this.simpleTypeUnmarshallers = ValidationUtils.assertNotNull(simpleTypeUnmarshallers, "simple type unmarshallers");
    this.customTypeMarshallers = ValidationUtils.assertNotNull(customTypeMarshallers, "custom type marshallers");
    this.jsonFactory = ValidationUtils.assertNotNull(jsonFactory, "JSONFactory");
}
项目:ibm-cos-sdk-java    文件:DefaultErrorResponseHandler.java   
private AmazonServiceException createAse(HttpResponse errorResponse) throws Exception {
    // Try to parse the error response as XML
    final Document document = documentFromContent(errorResponse.getContent(), idString(errorResponse));

    /*
     * We need to select which exception unmarshaller is the correct one to
     * use from all the possible exceptions this operation can throw.
     * Currently we rely on the unmarshallers to return null if they can't
     * unmarshall the response, but we might need something a little more
     * sophisticated in the future.
     */
    for (Unmarshaller<AmazonServiceException, Node> unmarshaller : unmarshallerList) {
        AmazonServiceException ase = unmarshaller.unmarshall(document);
        if (ase != null) {
            ase.setStatusCode(errorResponse.getStatusCode());
            return ase;
        }
    }
    return null;
}
项目:ibm-cos-sdk-java    文件:S3XmlResponseHandlerTest.java   
/**
 * Test the IBM_SSE_KP_ENABLED & IBM_SSE_KP_CRK are set in the ObjectLIsting
 * response object
 * @throws Exception 
 * 
 */ 
@Test
public void testHeadersAddedToObjectListing() throws Exception {

    Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
    S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
    HttpResponse httpResponse = new HttpResponse(null, null);
    httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, "True");
    httpResponse.addHeader(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN, "123456");

    InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
    httpResponse.setContent(is);

    AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);

    assertEquals(objectListing.getResult().getIBMSSEKPCrk(), "123456");
    assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), true);
}
项目:ibm-cos-sdk-java    文件:S3XmlResponseHandlerTest.java   
/**
 * Test the IBM_SSE_KP_ENABLED & IBM_SSE_KP_CRK null headers are handled
 * 
 * @throws Exception 
 * 
 */ 
@Test
public void testNullKPHeadersAreHandled() throws Exception {

    Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
    S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
    HttpResponse httpResponse = new HttpResponse(null, null);
    httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, null);
    httpResponse.addHeader(Headers.IBM_SSE_KP_CRK, null);

    InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
    httpResponse.setContent(is);

    AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);

    assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null);
    assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false);
}
项目:ibm-cos-sdk-java    文件:S3XmlResponseHandlerTest.java   
/**
 * Test the IBM_SSE_KP_ENABLED & IBM_SSE_KP_CRK empty headers are handled
 * 
 * @throws Exception 
 * 
 */ 
@Test
public void testEmptyKPHeadersAreHandled() throws Exception {

    Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
    S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
    HttpResponse httpResponse = new HttpResponse(null, null);

    InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
    httpResponse.setContent(is);

    AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);

    assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null);
    assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false);
}
项目:ibm-cos-sdk-java    文件:S3XmlResponseHandlerTest.java   
/**
 * Test the IBM_SSE_KP_CRK empty header is handled
 * 
 * @throws Exception 
 * 
 */ 
@Test
public void testOnlyKPEnabledHeaderIsSet() throws Exception {

    Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
    S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
    HttpResponse httpResponse = new HttpResponse(null, null);
    httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, "True");

    InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
    httpResponse.setContent(is);

    AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);

    assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null);
    assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), true);
}
项目:ibm-cos-sdk-java    文件:S3XmlResponseHandlerTest.java   
/**
 * Test the IBM_SSE_KP_CRK empty header is handled
 * 
 * @throws Exception 
 * 
 */ 
@Test
public void testOnlyCRKHeaderIsSet() throws Exception {

    Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
    S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
    HttpResponse httpResponse = new HttpResponse(null, null);
    httpResponse.addHeader(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN, "34567");

    InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
    httpResponse.setContent(is);

    AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);

    assertEquals(objectListing.getResult().getIBMSSEKPCrk(), "34567");
    assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false);
}
项目:apigateway-generic-java-sdk    文件:GenericApiGatewayClient.java   
GenericApiGatewayClient(ClientConfiguration clientConfiguration, String endpoint, Region region,
                        AWSCredentialsProvider credentials, String apiKey, AmazonHttpClient httpClient) {
    super(clientConfiguration);
    setRegion(region);
    setEndpoint(endpoint);
    this.credentials = credentials;
    this.apiKey = apiKey;
    this.signer = new AWS4Signer();
    this.signer.setServiceName(API_GATEWAY_SERVICE_NAME);
    this.signer.setRegionName(region.getName());

    final JsonOperationMetadata metadata = new JsonOperationMetadata().withHasStreamingSuccessResponse(false).withPayloadJson(false);
    final Unmarshaller<GenericApiGatewayResponse, JsonUnmarshallerContext> responseUnmarshaller = in -> new GenericApiGatewayResponse(in.getHttpResponse());
    this.responseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createResponseHandler(metadata, responseUnmarshaller);
    JsonErrorUnmarshaller defaultErrorUnmarshaller = new JsonErrorUnmarshaller(GenericApiGatewayException.class, null) {
        @Override
        public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception {
            return new GenericApiGatewayException(jsonContent.toString());
        }
    };
    this.errorResponseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createErrorResponseHandler(
            Collections.singletonList(defaultErrorUnmarshaller), null);

    if (httpClient != null) {
        super.client = httpClient;
    }
}
项目:async-sqs    文件:SqsAwsSdkAction.java   
public SqsAwsSdkAction(RequestT request, String requestUrl,
        Marshaller<com.amazonaws.Request<RequestT>, RequestT> marshaller,
        Unmarshaller<ResponseT, StaxUnmarshallerContext> unmarshaller) {

    this.requestUrl = requestUrl;
    this.request = request;
    this.marshaller = marshaller;
    this.staxResponseHandler = new StaxResponseHandler<>(unmarshaller);
}
项目:ibm-cos-sdk-java    文件:SdkStructuredJsonFactoryImpl.java   
public SdkStructuredJsonFactoryImpl(JsonFactory jsonFactory,
                                    Map<Class<?>, Unmarshaller<?, JsonUnmarshallerContext>> unmarshallers,
                                    Map<UnmarshallerType, Unmarshaller<?, JsonUnmarshallerContext>> customTypeMarshallers) {
    this.jsonFactory = jsonFactory;
    this.unmarshallers = unmarshallers;
    this.customTypeMarshallers = customTypeMarshallers;
}
项目:ibm-cos-sdk-java    文件:SdkStructuredJsonFactoryImpl.java   
@Override
public <T> JsonResponseHandler<T> createResponseHandler(JsonOperationMetadata operationMetadata,
                                                        Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller) {
    return new JsonResponseHandler(responseUnmarshaller, unmarshallers, customTypeMarshallers, jsonFactory,
                                   operationMetadata.isHasStreamingSuccessResponse(),
                                   operationMetadata.isPayloadJson());
}
项目:ibm-cos-sdk-java    文件:StaxResponseHandler.java   
/**
 * Constructs a new response handler that will use the specified StAX
 * unmarshaller to unmarshall the service response and uses the specified
 * response element path to find the root of the business data in the
 * service's response.
 *
 * @param responseUnmarshaller
 *            The StAX unmarshaller to use on the response.
 */
public StaxResponseHandler(Unmarshaller<T, StaxUnmarshallerContext> responseUnmarshaller) {
    this.responseUnmarshaller = responseUnmarshaller;

    /*
     * Even if the invoked operation just returns null, we still need an
     * unmarshaller to run so we can pull out response metadata.
     *
     * We might want to pass this in through the client class so that we
     * don't have to do this check here.
     */
    if (this.responseUnmarshaller == null) {
        this.responseUnmarshaller = new VoidStaxUnmarshaller<T>();
    }
}
项目:WaterFlow    文件:TestUtil.java   
/**
 * Use SWF API to unmarshal a json document into a {@link DecisionTask}.
 * Note: json is expected to be in the native format used by SWF
 */
public static DecisionTask unmarshalDecisionTask(String json) {
    try {
        Unmarshaller<DecisionTask, JsonUnmarshallerContext> unmarshaller = new DecisionTaskJsonUnmarshaller();
        JsonParser parser = new JsonFactory().createParser(json);
        return unmarshaller.unmarshall(new JsonUnmarshallerContextImpl(parser));
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
项目:ivona-speechcloud-sdk-java    文件:IvonaSpeechCloudClient.java   
@Override
public ListVoicesResult listVoices(ListVoicesRequest listVoicesRequest) throws AmazonServiceException,
        AmazonClientException {

    ExecutionContext executionContext = createExecutionContext(listVoicesRequest);
    Request<ListVoicesRequest> request = ListVoicesRequestMarshallerFactory.getMarshaller(
            listVoicesRequest.getMethodType()).marshall(listVoicesRequest);
    Unmarshaller<ListVoicesResult, JsonUnmarshallerContext> unmarshaller = new ListVoicesResultJsonUnmarshaller();
    JsonResponseHandler<ListVoicesResult> responseHandler =
            new JsonResponseHandler<ListVoicesResult>(unmarshaller);
    Response<ListVoicesResult> response = invoke(request, responseHandler, executionContext);
    return response.getAwsResponse();
}
项目:ivona-speechcloud-sdk-java    文件:IvonaSpeechCloudClient.java   
@Override
public GetLexiconResult getLexicon(GetLexiconRequest getLexiconRequest)
        throws AmazonServiceException, AmazonClientException {

    ExecutionContext executionContext = createExecutionContext(getLexiconRequest);
    GetLexiconRequestMarshaller marshaller = new GetLexiconPostRequestMarshaller();
    Request<GetLexiconRequest> request = marshaller.marshall(getLexiconRequest);
    Unmarshaller<GetLexiconResult, JsonUnmarshallerContext> unmarshaller = new GetLexiconResultJsonUnmarshaller();
    JsonResponseHandler<GetLexiconResult> responseHandler = new JsonResponseHandler<GetLexiconResult>(unmarshaller);

    Response<GetLexiconResult> response = invoke(request, responseHandler, executionContext);
    return response.getAwsResponse();
}
项目:ivona-speechcloud-sdk-java    文件:IvonaSpeechCloudClient.java   
@Override
public ListLexiconsResult listLexicons() {
    ListLexiconsRequest listLexiconsRequest = new ListLexiconsRequest();
    ExecutionContext executionContext = createExecutionContext(listLexiconsRequest);
    ListLexiconsRequestMarshaller marshaller = new ListLexiconsPostRequestMarshaller();
    Request<ListLexiconsRequest> request = marshaller.marshall(listLexiconsRequest);
    Unmarshaller<ListLexiconsResult, JsonUnmarshallerContext> unmarshaller =
            new ListLexiconsResultJsonUnmarshaller();
    JsonResponseHandler<ListLexiconsResult> responseHandler =
            new JsonResponseHandler<ListLexiconsResult>(unmarshaller);

    Response<ListLexiconsResult> response = invoke(request, responseHandler, executionContext);
    return response.getAwsResponse();
}
项目:async-sqs    文件:SqsAwsSdkBatchAction.java   
public SqsAwsSdkBatchAction(RequestT request, String requestUrl,
        Marshaller<Request<RequestT>, RequestT> marshaller,
        Unmarshaller<ResponseT, StaxUnmarshallerContext> unmarshaller) {
    super(request, requestUrl, marshaller, unmarshaller);
}
项目:ibm-cos-sdk-java    文件:SdkJsonProtocolFactory.java   
/**
 * Returns the response handler to be used for handling a successful response.
 *
 * @param operationMetadata Additional context information about an operation to create the appropriate response handler.
 */
public <T> HttpResponseHandler<AmazonWebServiceResponse<T>> createResponseHandler(
        JsonOperationMetadata operationMetadata,
        Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller) {
    return getSdkFactory().createResponseHandler(operationMetadata, responseUnmarshaller);
}
项目:ibm-cos-sdk-java    文件:SdkStructuredIonFactory.java   
private SdkStructuredIonFactory(IonWriterBuilder builder) {
    super(JSON_FACTORY, UNMARSHALLERS,
          Collections.<JsonUnmarshallerContext.UnmarshallerType, Unmarshaller<?, JsonUnmarshallerContext>>emptyMap());
    this.builder = builder;
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
private <X, Y extends AmazonWebServiceRequest> X invoke(Request<Y> request,
                              Unmarshaller<X, InputStream> unmarshaller,
                              String bucketName,
                              String key) {
    return invoke(request, new S3XmlResponseHandler<X>(unmarshaller), bucketName, key);
}
项目:ibm-cos-sdk-java    文件:ResponseHeaderHandlerChain.java   
public ResponseHeaderHandlerChain(Unmarshaller<T, InputStream> responseUnmarshaller, HeaderHandler<T>... headerHandlers) {
    super(responseUnmarshaller);
    this.headerHandlers = Arrays.asList(headerHandlers);
}
项目:ivona-speechcloud-sdk-java    文件:StreamResponseHandler.java   
public StreamResponseHandler(Unmarshaller<T, HttpResponse> responseUnmarshaller) {
    this.responseUnmarshaller = responseUnmarshaller;
}
项目:aws-hal-client-java    文件:OptionalJsonResponseHandler.java   
OptionalJsonResponseHandler(Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller) {
    super(responseUnmarshaller);
}
项目:aws-hal-client-java    文件:HalJsonArrayUnmarshaller.java   
public HalJsonArrayUnmarshaller(Unmarshaller<T, JsonUnmarshallerContext> itemUnmarshaller) {
    this.itemUnmarshaller = itemUnmarshaller;
}
项目:kolich-aws    文件:KolichSESClient.java   
public AwsSESHttpClosure(final HttpClient client,
                               final int expectStatus,
                               final Unmarshaller<S,StaxUnmarshallerContext> unmarshaller) {
    super(client, expectStatus);
    unmarshaller_ = unmarshaller;
}
项目:kolich-aws    文件:KolichSQSClient.java   
public AwsSQSHttpClosure(final HttpClient client,
                               final int expectStatus,
                               final Unmarshaller<S,StaxUnmarshallerContext> unmarshaller) {
    super(client, expectStatus);
    unmarshaller_ = unmarshaller;
}
项目:ibm-cos-sdk-java    文件:SdkStructuredJsonFactory.java   
/**
 * Returns the response handler to be used for handling a successfull response.
 *
 * @param operationMetadata Additional context information about an operation to create the
 *                          appropriate response handler.
 */
<T> JsonResponseHandler<T> createResponseHandler(JsonOperationMetadata operationMetadata,
                                                 Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller);
项目:ibm-cos-sdk-java    文件:DefaultErrorResponseHandler.java   
/**
 * Constructs a new DefaultErrorResponseHandler that will handle error responses from Amazon
 * services using the specified list of unmarshallers. Each unmarshaller will be tried, in
 * order, until one is found that can unmarshall the error response.
 *
 * @param unmarshallerList The list of unmarshallers to try using when handling an error
 *                         response.
 */
public DefaultErrorResponseHandler(
        List<Unmarshaller<AmazonServiceException, Node>> unmarshallerList) {
    this.unmarshallerList = unmarshallerList;
}
项目:ibm-cos-sdk-java    文件:S3XmlResponseHandler.java   
/**
 * Constructs a new S3 response handler that will use the specified SAX
 * unmarshaller to turn the response into an object.
 *
 * @param responseUnmarshaller
 *            The SAX unmarshaller to use on the response from S3.
 */
public S3XmlResponseHandler(Unmarshaller<T, InputStream> responseUnmarshaller) {
    this.responseUnmarshaller = responseUnmarshaller;
}