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


Java AmazonServiceException.setStatusCode方法代码示例

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


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

示例1: listObjects

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public ObjectListing listObjects(ListObjectsRequest listObjectsRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(listObjectsRequest.getBucketName()) && !nonExistingBucketCreated) {
        AmazonServiceException ex = new AmazonServiceException("Unknown bucket");
        ex.setStatusCode(404);
        throw ex; 
    }
    int capacity;
    ObjectListing objectListing = new ObjectListing();
    if (!ObjectHelper.isEmpty(listObjectsRequest.getMaxKeys()) && listObjectsRequest.getMaxKeys() != null) {
        capacity = listObjectsRequest.getMaxKeys();
    } else {
        capacity = maxCapacity;
    }
    
    for (int index = 0; index < objects.size() && index < capacity; index++) {
        S3ObjectSummary s3ObjectSummary = new S3ObjectSummary();
        s3ObjectSummary.setBucketName(objects.get(index).getBucketName());
        s3ObjectSummary.setKey(objects.get(index).getKey());
        
        objectListing.getObjectSummaries().add(s3ObjectSummary);
    }

    return objectListing;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:26,代码来源:AmazonS3ClientMock.java

示例2: handle

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
    JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
    String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
    AmazonServiceException ase = createException(errorCode, jsonContent);

    // Jackson has special-casing for 'message' values when deserializing
    // Throwables, but sometimes the service passes the error message in
    // other JSON fields - handle it here.
    if (ase.getErrorMessage() == null) {
        ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
    }

    ase.setErrorCode(errorCode);
    ase.setServiceName(response.getRequest().getServiceName());
    ase.setStatusCode(response.getStatusCode());
    ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
    ase.setRawResponse(jsonContent.getRawContent());
    String requestId = getRequestIdFromHeaders(response.getHeaders());
    if (requestId != null) {
        ase.setRequestId(requestId);
    }
    ase.setHttpHeaders(response.getHeaders());
    return ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:JsonErrorResponseHandler.java

示例3: createAse

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
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;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:21,代码来源:DefaultErrorResponseHandler.java

示例4: 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

示例5: 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

示例6: handle

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
    final AmazonServiceException ase = handleAse(response);
    ase.setStatusCode(response.getStatusCode());
    ase.setServiceName(response.getRequest().getServiceName());
    awsRequestMetrics.addPropertyWith(AWSRequestMetrics.Field.AWSRequestID, ase.getRequestId())
            .addPropertyWith(AWSRequestMetrics.Field.AWSErrorCode, ase.getErrorCode())
            .addPropertyWith(AWSRequestMetrics.Field.StatusCode, ase.getStatusCode());
    return ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:11,代码来源:AwsErrorResponseHandler.java

示例7: isThrottlingException_FalseWhenErrorAndStatusCodeDoNotMatch

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Test
public void isThrottlingException_FalseWhenErrorAndStatusCodeDoNotMatch() throws Exception {
    AmazonServiceException ase = new AmazonServiceException("msg");
    ase.setStatusCode(500);
    ase.setErrorCode("InternalFailure");
    assertFalse("InternalFailure error code should be false", RetryUtils.isThrottlingException(ase));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:8,代码来源:RetryUtilsTest.java

示例8: handle

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public AmazonServiceException handle(
        com.amazonaws.http.HttpResponse response) throws Exception {
    AmazonServiceException ase = new AmazonServiceException("Fake service exception.");
    ase.setStatusCode(response.getStatusCode());
    ase.setErrorCode(response.getStatusText());
    return ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:9,代码来源:RetryPolicyTestBase.java

示例9: testLoginFailure

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

示例10: mockException

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
private AmazonServiceException mockException() {
    AmazonServiceException exception = new AmazonServiceException("Dummy error response");
    exception.setStatusCode(500);
    return exception;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:6,代码来源:WireMockTestBase.java

示例11: getAse

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
private AmazonServiceException getAse(int statusCode, String errorCode) {
    AmazonServiceException exception = new AmazonServiceException(errorCode);
    exception.setStatusCode(statusCode);
    exception.setErrorCode(errorCode);
    return exception;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:7,代码来源:SDKDefaultRetryConditionTest.java

示例12: isThrottlingException_TrueWhenStatusCodeIs429

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Test
public void isThrottlingException_TrueWhenStatusCodeIs429() throws Exception {
    AmazonServiceException ase = new AmazonServiceException("msg");
    ase.setStatusCode(429);
    assertTrue("ThrottlingException error code should be true", RetryUtils.isThrottlingException(ase));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:7,代码来源:RetryUtilsTest.java


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