當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。