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


Java AmazonServiceException.getStatusCode方法代码示例

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


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

示例1: doesBucketExist

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public boolean doesBucketExist(String bucketName)
        throws SdkClientException, AmazonServiceException {

    try {
        headBucket(new HeadBucketRequest(bucketName));
        return true;
    } catch (AmazonServiceException ase) {
        // A redirect error or a forbidden error means the bucket exists. So
        // returning true.
        if ((ase.getStatusCode() == Constants.BUCKET_REDIRECT_STATUS_CODE)
                || (ase.getStatusCode() == Constants.BUCKET_ACCESS_FORBIDDEN_STATUS_CODE)) {
            return true;
        }
        if (ase.getStatusCode() == Constants.NO_SUCH_BUCKET_STATUS_CODE) {
            return false;
        }
        throw ase;

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

示例2: getBucketCrossOriginConfiguration

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest) {
    getBucketCrossOriginConfigurationRequest = beforeClientExecution(getBucketCrossOriginConfigurationRequest);
    rejectNull(getBucketCrossOriginConfigurationRequest, "The request object parameter getBucketCrossOriginConfigurationRequest must be specified.");
    String bucketName = getBucketCrossOriginConfigurationRequest.getBucketName();
    rejectNull(bucketName, "The bucket name must be specified when retrieving the bucket cross origin configuration.");

    Request<GetBucketCrossOriginConfigurationRequest> request = createRequest(bucketName, null, getBucketCrossOriginConfigurationRequest, HttpMethodName.GET);
    request.addParameter("cors", null);

    try {
        return invoke(request, new Unmarshallers.BucketCrossOriginConfigurationUnmarshaller(), bucketName, null);
    } catch (AmazonServiceException ase) {
        switch (ase.getStatusCode()) {
        case 404:
            return null;
        default:
            throw ase;
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:22,代码来源:AmazonS3Client.java

示例3: getBucketTaggingConfiguration

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(GetBucketTaggingConfigurationRequest getBucketTaggingConfigurationRequest) {
    getBucketTaggingConfigurationRequest = beforeClientExecution(getBucketTaggingConfigurationRequest);
    rejectNull(getBucketTaggingConfigurationRequest, "The request object parameter getBucketTaggingConfigurationRequest must be specifed.");
    String bucketName = getBucketTaggingConfigurationRequest.getBucketName();
    rejectNull(bucketName, "The bucket name must be specified when retrieving the bucket tagging configuration.");

    Request<GetBucketTaggingConfigurationRequest> request = createRequest(bucketName, null, getBucketTaggingConfigurationRequest, HttpMethodName.GET);
    request.addParameter("tagging", null);

    try {
        return invoke(request, new Unmarshallers.BucketTaggingConfigurationUnmarshaller(), bucketName, null);
    } catch (AmazonServiceException ase) {
        switch (ase.getStatusCode()) {
        case 404:
            return null;
        default:
            throw ase;
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:22,代码来源:AmazonS3Client.java

示例4: map

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public BackgroundException map(final AmazonClientException e) {
    final StringBuilder buffer = new StringBuilder();
    if(e instanceof AmazonServiceException) {
        final AmazonServiceException failure = (AmazonServiceException) e;
        this.append(buffer, failure.getErrorMessage());
        switch(failure.getStatusCode()) {
            case HttpStatus.SC_BAD_REQUEST:
                switch(failure.getErrorCode()) {
                    case "Throttling":
                        return new RetriableAccessDeniedException(buffer.toString(), e);
                    case "AccessDeniedException":
                        return new AccessDeniedException(buffer.toString(), e);
                    case "UnrecognizedClientException":
                        return new LoginFailureException(buffer.toString(), e);
                }
            case HttpStatus.SC_FORBIDDEN:
                switch(failure.getErrorCode()) {
                    case "SignatureDoesNotMatch":
                        return new LoginFailureException(buffer.toString(), e);
                    case "InvalidAccessKeyId":
                        return new LoginFailureException(buffer.toString(), e);
                    case "InvalidClientTokenId":
                        return new LoginFailureException(buffer.toString(), e);
                    case "InvalidSecurity":
                        return new LoginFailureException(buffer.toString(), e);
                    case "MissingClientTokenId":
                        return new LoginFailureException(buffer.toString(), e);
                    case "MissingAuthenticationToken":
                        return new LoginFailureException(buffer.toString(), e);
                }
        }
        return new HttpResponseExceptionMappingService().map(new HttpResponseException(failure.getStatusCode(), buffer.toString()));
    }
    this.append(buffer, e.getMessage());
    return this.wrap(e, buffer);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:38,代码来源:AmazonServiceExceptionMappingService.java

示例5: isThrottlingException

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
/**
 * Returns true if the specified exception is a throttling error.
 *
 * @param exception The exception to test.
 * @return True if the exception resulted from a throttling error message from a service, otherwise false.
 */
public static boolean isThrottlingException(SdkBaseException exception) {
    if (!isAse(exception)) {
        return false;
    }
    final AmazonServiceException ase = toAse(exception);
    return THROTTLING_ERROR_CODES.contains(ase.getErrorCode()) || ase.getStatusCode() == 429;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:RetryUtils.java

示例6: afterError

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public void afterError(Request<?> request, Response<?> response, Exception e) {
    if (isSubsegmentDuplicate(recorder.getCurrentSubsegmentOptional(), request)) {
        Optional<Subsegment> currentSubsegmentOptional = recorder.getCurrentSubsegmentOptional();
        if (!currentSubsegmentOptional.isPresent()) {
            return;
        }
        Subsegment currentSubsegment = currentSubsegmentOptional.get();

        int statusCode = -1;

        if (null != response) {
            statusCode = response.getHttpResponse().getStatusCode();
        } else {
            if (e instanceof AmazonServiceException) {
                AmazonServiceException ase = (AmazonServiceException) e;
                statusCode = ase.getStatusCode();
                /*
                 * The S3 client will throw and re-swallow AmazonServiceExceptions if they have these status codes. Customers will never see the exceptions in their application code but they still
                 * travel through our TracingHandler#afterError method. We special case these status codes in order to prevent addition of the full exception object to the current subsegment.
                 * Instead, we'll just add any exception error message to the current subsegment's cause's message.
                 */
                if ((304 == statusCode || 412 == statusCode) && S3_SERVICE_NAME.equals(ase.getServiceName())) {
                    populateAndEndSubsegment(currentSubsegment, request, response, ase);
                    return;
                }
                if (RetryUtils.isThrottlingException(ase)) {
                    currentSubsegment.setError(true);
                    currentSubsegment.setThrottle(true);
                }
            }
        }

        if (-1 != statusCode) {
            int statusCodePrefix = statusCode / 100;
            if (4 == statusCodePrefix) {
                currentSubsegment.setError(true);
                if (429 == statusCode) {
                    currentSubsegment.setThrottle(true);
                }
            }
        }

        currentSubsegment.addException(e);

        if (e instanceof AmazonServiceException) {
            populateAndEndSubsegment(currentSubsegment, request, response, (AmazonServiceException) e);
        } else {
            populateAndEndSubsegment(currentSubsegment, request, response);
        }
    }
}
 
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:53,代码来源:TracingHandler.java

示例7: matches

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public boolean matches(AmazonServiceException ase) {
    return expectedStatusCode == ase.getStatusCode();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:5,代码来源:HttpFailureStatusAcceptor.java


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