use of com.qcloud.cos.internal.COSStringResponseHandler in project cos-java-sdk-v5 by tencentyun.
the class COSClient method getBucketPolicy.
@Override
public BucketPolicy getBucketPolicy(GetBucketPolicyRequest getBucketPolicyRequest) throws CosClientException, CosServiceException {
rejectNull(getBucketPolicyRequest, "The request object must be specified when getting a bucket policy");
String bucketName = getBucketPolicyRequest.getBucketName();
rejectNull(bucketName, "The bucket name must be specified when getting a bucket policy");
CosHttpRequest<GetBucketPolicyRequest> request = createRequest(bucketName, null, getBucketPolicyRequest, HttpMethodName.GET);
request.addParameter("policy", null);
BucketPolicy result = new BucketPolicy();
try {
String policyText = invoke(request, new COSStringResponseHandler());
result.setPolicyText(policyText);
return result;
} catch (CosServiceException cse) {
if (cse.getErrorCode().equals("NoSuchBucketPolicy"))
return result;
throw cse;
}
}
Aggregations