当前位置: 首页>>代码示例>>Java>>正文


Java AmazonServiceException类代码示例

本文整理汇总了Java中com.amazonaws.AmazonServiceException的典型用法代码示例。如果您正苦于以下问题:Java AmazonServiceException类的具体用法?Java AmazonServiceException怎么用?Java AmazonServiceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AmazonServiceException类属于com.amazonaws包,在下文中一共展示了AmazonServiceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unmarshall

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
/**
 * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object)
 */
public AmazonServiceException unmarshall(Node in) throws Exception {
    XPath xpath = xpath();
    String errorCode = parseErrorCode(in, xpath);
    String errorType = asString("ErrorResponse/Error/Type", in, xpath);
    String requestId = asString("ErrorResponse/RequestId", in, xpath);
    String message = asString("ErrorResponse/Error/Message", in, xpath);

    AmazonServiceException ase = newException(message);
    ase.setErrorCode(errorCode);
    ase.setRequestId(requestId);

    if (errorType == null) {
        ase.setErrorType(ErrorType.Unknown);
    } else if (errorType.equalsIgnoreCase("Receiver")) {
        ase.setErrorType(ErrorType.Service);
    } else if (errorType.equalsIgnoreCase("Sender")) {
        ase.setErrorType(ErrorType.Client);
    }

    return ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:25,代码来源:StandardErrorUnmarshaller.java

示例2: getObjectMetadata

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest)
        throws SdkClientException, AmazonServiceException {
    getObjectMetadataRequest = beforeClientExecution(getObjectMetadataRequest);
    rejectNull(getObjectMetadataRequest, "The GetObjectMetadataRequest parameter must be specified when requesting an object's metadata");

    String bucketName = getObjectMetadataRequest.getBucketName();
    String key = getObjectMetadataRequest.getKey();
    String versionId = getObjectMetadataRequest.getVersionId();

    rejectNull(bucketName, "The bucket name parameter must be specified when requesting an object's metadata");
    rejectNull(key, "The key parameter must be specified when requesting an object's metadata");

    Request<GetObjectMetadataRequest> request = createRequest(bucketName, key, getObjectMetadataRequest, HttpMethodName.HEAD);

    if (versionId != null) request.addParameter("versionId", versionId);

    populateRequesterPaysHeader(request, getObjectMetadataRequest.isRequesterPays());
    addPartNumberIfNotNull(request, getObjectMetadataRequest.getPartNumber());

    populateSSE_C(request, getObjectMetadataRequest.getSSECustomerKey());

    return invoke(request, new S3MetadataResponseHandler(), bucketName, key);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:25,代码来源:AmazonS3Client.java

示例3: setBucketAcl

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public void setBucketAcl(SetBucketAclRequest setBucketAclRequest)
        throws SdkClientException, AmazonServiceException {
    setBucketAclRequest = beforeClientExecution(setBucketAclRequest);

    String bucketName = setBucketAclRequest.getBucketName();
    rejectNull(bucketName, "The bucket name parameter must be specified when setting a bucket's ACL");

    AccessControlList acl = setBucketAclRequest.getAcl();
    CannedAccessControlList cannedAcl = setBucketAclRequest.getCannedAcl();

    if (acl == null && cannedAcl == null) {
        throw new IllegalArgumentException(
                "The ACL parameter must be specified when setting a bucket's ACL");
    }
    if (acl != null && cannedAcl != null) {
        throw new IllegalArgumentException(
                "Only one of the acl and cannedAcl parameter can be specified, not both.");
    }

    if (acl != null) {
        setAcl(bucketName, null, null, acl, false, setBucketAclRequest);
    } else {
        setAcl(bucketName, null, null, cannedAcl, false, setBucketAclRequest);
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:AmazonS3Client.java

示例4: testActualRetries

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
/**
 * Verifies the request is actually retried for the expected times.
 */
private void testActualRetries(int expectedRetryAttempts) {
    testedClient = new AmazonHttpClient(clientConfiguration);
    injectMockHttpClient(testedClient, new ReturnServiceErrorHttpClient(500, "fake 500 service error"));
    // The ExecutionContext should collect the expected RequestCount
    ExecutionContext context = new ExecutionContext(true);

    try {
        testedClient.requestExecutionBuilder()
                .request(getSampleRequestWithRepeatableContent(originalRequest))
                .errorResponseHandler(errorResponseHandler)
                .executionContext(context)
                .execute();
        Assert.fail("AmazonServiceException is expected.");
    } catch (AmazonServiceException ase) {}

    RetryTestUtils.assertExpectedRetryCount(expectedRetryAttempts, context);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:21,代码来源:ClientConfigurationMaxErrorRetryTest.java

示例5: handleErrorResponse

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
private void handleErrorResponse(InputStream errorStream, int statusCode, String responseMessage) throws IOException {
    String errorCode = null;

    // Parse the error stream returned from the service.
    if(errorStream != null) {
        String errorResponse = IOUtils.toString(errorStream);

        try {
            JsonNode node = Jackson.jsonNodeOf(errorResponse);
            JsonNode code = node.get("code");
            JsonNode message = node.get("message");
            if (code != null && message != null) {
                errorCode = code.asText();
                responseMessage = message.asText();
            }
        } catch (Exception exception) {
            LOG.debug("Unable to parse error stream");
        }
    }

    AmazonServiceException ase = new AmazonServiceException(responseMessage);
    ase.setStatusCode(statusCode);
    ase.setErrorCode(errorCode);
    throw ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:EC2CredentialsUtils.java

示例6: getObjectMetadata

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public ObjectMetadata getObjectMetadata(String bucketName, String key) throws AmazonServiceException {
  AmazonS3Exception exception = new AmazonS3Exception("Not Found");
  exception.setStatusCode(404);
  exception.setErrorType(ErrorType.Client);
  throw exception;
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:8,代码来源:FailsafeS3DecoratorTest.java

示例7: testAccessFailure

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Test
public void testAccessFailure() throws Exception {
    final AmazonServiceException f = new AmazonServiceException("message", null);
    f.setStatusCode(403);
    f.setErrorCode("AccessDenied");
    assertTrue(new AmazonServiceExceptionMappingService().map(f) instanceof AccessDeniedException);
    f.setErrorCode("SignatureDoesNotMatch");
    assertTrue(new AmazonServiceExceptionMappingService().map(f) instanceof LoginFailureException);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:10,代码来源:AmazonServiceExceptionMappingServiceTest.java

示例8: setObjectRedirectLocation

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public void setObjectRedirectLocation(String bucketName, String key,
        String newRedirectLocation) throws SdkClientException,
        AmazonServiceException {
    throw new UnsupportedOperationException("Extend AbstractAmazonS3 to provide an implementation");

}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:8,代码来源:AbstractAmazonS3.java

示例9: sendRequest

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public <T> Single<T> sendRequest(SqsAction<T> request) {
    return Single.defer(() -> delegate.sendRequest(request))
            .retry((errCount, error) -> {
                if (errCount > retryCount || request.isBatchAction()) {
                    return false;
                }
                if (error instanceof AmazonSQSException) {
                    return ((AmazonSQSException) error).getErrorType() == AmazonServiceException.ErrorType.Service;
                }
                return true;
            }).subscribeWith(SingleSubject.create());//convert to Hot single
}
 
开发者ID:Bandwidth,项目名称:async-sqs,代码行数:14,代码来源:RetryingSqsRequestSender.java

示例10: executeRequest

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
private void executeRequest() throws Exception {
    AmazonHttpClient httpClient = new AmazonHttpClient(new ClientConfiguration());
    try {
        httpClient.requestExecutionBuilder().request(newGetRequest(RESOURCE_PATH)).errorResponseHandler(stubErrorHandler()).execute();
        fail("Expected exception");
    } catch (AmazonServiceException expected) {
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:9,代码来源:SdkTransactionIdInHeaderTest.java

示例11: listBuckets

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
    ArrayList<Bucket> list = new ArrayList<Bucket>();
    Bucket bucket = new Bucket("camel-bucket");
    bucket.setOwner(new Owner("Camel", "camel"));
    bucket.setCreationDate(new Date());
    list.add(bucket);
    return list;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:10,代码来源:AmazonS3ClientMock.java

示例12: handle_UnmarshallerReturnsException_ClientErrorType

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Test
public void handle_UnmarshallerReturnsException_ClientErrorType() throws Exception {
    httpResponse.setStatusCode(400);
    expectUnmarshallerMatches();
    when(unmarshaller.unmarshall((JsonNode) anyObject()))
            .thenReturn(new CustomException("error"));

    AmazonServiceException ase = responseHandler.handle(httpResponse);

    assertEquals(ERROR_CODE, ase.getErrorCode());
    assertEquals(400, ase.getStatusCode());
    assertEquals(SERVICE_NAME, ase.getServiceName());
    assertEquals(ErrorType.Client, ase.getErrorType());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:JsonErrorResponseHandlerTest.java

示例13: deleteObject

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public void deleteObject(DeleteObjectRequest deleteObjectRequest)
        throws SdkClientException, AmazonServiceException {
    deleteObjectRequest = beforeClientExecution(deleteObjectRequest);
    rejectNull(deleteObjectRequest,
        "The delete object request must be specified when deleting an object");

    rejectNull(deleteObjectRequest.getBucketName(), "The bucket name must be specified when deleting an object");
    rejectNull(deleteObjectRequest.getKey(), "The key must be specified when deleting an object");

    Request<DeleteObjectRequest> request = createRequest(deleteObjectRequest.getBucketName(), deleteObjectRequest.getKey(), deleteObjectRequest, HttpMethodName.DELETE);
    invoke(request, voidResponseHandler, deleteObjectRequest.getBucketName(), deleteObjectRequest.getKey());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:AmazonS3Client.java

示例14: createBucket

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }
    
    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
 
开发者ID:syndesisio,项目名称:connectors,代码行数:13,代码来源:AmazonS3ClientMock.java

示例15: handleRequest

import com.amazonaws.AmazonServiceException; //导入依赖的package包/类
@Override
public Parameters handleRequest(S3Event event, Context context) {

    context.getLogger()
            .log("Input Function [" + context.getFunctionName() + "], S3Event [" + event.toJson().toString() + "]");

    Parameters parameters = new Parameters(
            event.getRecords().get(0).getS3().getBucket().getName(), 
            event.getRecords().get(0).getS3().getObject().getKey());

    AWSStepFunctions client = AWSStepFunctionsClientBuilder.defaultClient();
    ObjectMapper jsonMapper = new ObjectMapper();
    
    StartExecutionRequest request = new StartExecutionRequest();
    request.setStateMachineArn(System.getenv("STEP_MACHINE_ARN"));
    try {
        request.setInput(jsonMapper.writeValueAsString(parameters));
    } catch (JsonProcessingException e) {
        throw new AmazonServiceException("Error in ["+context.getFunctionName()+"]", e);
    }

    context.getLogger()
            .log("Step Function [" + request.getStateMachineArn() + "] will be called with [" + request.getInput() + "]");

    StartExecutionResult result = client.startExecution(request);

    context.getLogger()
            .log("Output Function [" + context.getFunctionName() + "], Result [" + result.toString() + "]");

    return parameters;
}
 
开发者ID:markwest1972,项目名称:smart-security-camera,代码行数:32,代码来源:S3TriggerImageProcessingHandler.java


注:本文中的com.amazonaws.AmazonServiceException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。