use of com.qcloud.cos.internal.ResponseHeaderHandlerChain in project cos-java-sdk-v5 by tencentyun.
the class COSClient method getObjectTagging.
@Override
public GetObjectTaggingResult getObjectTagging(GetObjectTaggingRequest getObjectTaggingRequest) {
rejectNull(getObjectTaggingRequest, "The request parameter must be specified when getting the object tags");
rejectNull(getObjectTaggingRequest.getBucketName(), "The request bucketName must be specified when getting the object tags");
rejectNull(getObjectTaggingRequest.getKey(), "The request key must be specified when getting the object tags");
CosHttpRequest<GetObjectTaggingRequest> request = createRequest(getObjectTaggingRequest.getBucketName(), getObjectTaggingRequest.getKey(), getObjectTaggingRequest, HttpMethodName.GET);
request.addParameter("tagging", null);
addParameterIfNotNull(request, "versionId", getObjectTaggingRequest.getVersionId());
ResponseHeaderHandlerChain<GetObjectTaggingResult> handlerChain = new ResponseHeaderHandlerChain<GetObjectTaggingResult>(new Unmarshallers.GetObjectTaggingResponseUnmarshaller(), new GetObjectTaggingResponseHeaderHandler());
return invoke(request, handlerChain);
}
use of com.qcloud.cos.internal.ResponseHeaderHandlerChain in project cos-java-sdk-v5 by tencentyun.
the class COSClient method deleteObjectTagging.
@Override
public DeleteObjectTaggingResult deleteObjectTagging(DeleteObjectTaggingRequest deleteObjectTaggingRequest) {
rejectNull(deleteObjectTaggingRequest, "The request parameter must be specified when delete the object tags");
rejectNull(deleteObjectTaggingRequest.getBucketName(), "The request bucketName must be specified setting the object tags");
rejectNull(deleteObjectTaggingRequest.getKey(), "The request key must be specified setting the object tags");
CosHttpRequest<DeleteObjectTaggingRequest> request = createRequest(deleteObjectTaggingRequest.getBucketName(), deleteObjectTaggingRequest.getKey(), deleteObjectTaggingRequest, HttpMethodName.DELETE);
request.addParameter("tagging", null);
addParameterIfNotNull(request, "versionId", deleteObjectTaggingRequest.getVersionId());
ResponseHeaderHandlerChain<DeleteObjectTaggingResult> handlerChain = new ResponseHeaderHandlerChain<DeleteObjectTaggingResult>(new Unmarshallers.DeleteObjectTaggingResponseUnmarshaller(), new DeleteObjectTaggingHeaderHandler());
return invoke(request, handlerChain);
}
use of com.qcloud.cos.internal.ResponseHeaderHandlerChain in project cos-java-sdk-v5 by tencentyun.
the class COSClient method getAcl.
/**
* <p>
* Gets the AccessControlList for the specified resource. (bucket if only the bucketName
* parameter is specified, otherwise the object with the specified key in the bucket).
* </p>
*
* @param bucketName The name of the bucket whose ACL should be returned if the key parameter is
* not specified, otherwise the bucket containing the specified key.
* @param key The object key whose ACL should be retrieve. If not specified, the bucket's ACL is
* returned.
* @param versionId The version ID of the object version whose ACL is being retrieved.
* @param originalRequest The original, user facing request object.
*
* @return The ACL for the specified resource.
*/
private AccessControlList getAcl(String bucketName, String key, String versionId, CosServiceRequest originalRequest) {
if (originalRequest == null)
originalRequest = new GenericBucketRequest(bucketName);
CosHttpRequest<CosServiceRequest> request = createRequest(bucketName, key, originalRequest, HttpMethodName.GET);
request.addParameter("acl", null);
if (versionId != null) {
request.addParameter("versionId", versionId);
}
@SuppressWarnings("unchecked") ResponseHeaderHandlerChain<AccessControlList> responseHandler = new ResponseHeaderHandlerChain<AccessControlList>(new Unmarshallers.AccessControlListUnmarshaller(), new COSDefaultAclHeaderHandler());
return invoke(request, responseHandler);
}
use of com.qcloud.cos.internal.ResponseHeaderHandlerChain in project cos-java-sdk-v5 by tencentyun.
the class COSClient method deleteObjects.
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) throws MultiObjectDeleteException, CosClientException, CosServiceException {
rejectNull(deleteObjectsRequest, "The DeleteObjectsRequest parameter must be specified when deleting objects");
rejectNull(clientConfig.getRegion(), "region is null, region in clientConfig must be specified when deleting objects");
CosHttpRequest<DeleteObjectsRequest> request = createRequest(deleteObjectsRequest.getBucketName(), null, deleteObjectsRequest, HttpMethodName.POST);
request.addParameter("delete", null);
byte[] content = new MultiObjectDeleteXmlFactory().convertToXmlByteArray(deleteObjectsRequest);
request.addHeader("Content-Length", String.valueOf(content.length));
request.addHeader("Content-Type", "application/xml");
request.setContent(new ByteArrayInputStream(content));
try {
byte[] md5 = Md5Utils.computeMD5Hash(content);
String md5Base64 = BinaryUtils.toBase64(md5);
request.addHeader("Content-MD5", md5Base64);
} catch (Exception e) {
throw new CosClientException("Couldn't compute md5 sum", e);
}
@SuppressWarnings("unchecked") ResponseHeaderHandlerChain<DeleteObjectsResponse> responseHandler = new ResponseHeaderHandlerChain<DeleteObjectsResponse>(new Unmarshallers.DeleteObjectsResultUnmarshaller());
DeleteObjectsResponse response = invoke(request, responseHandler);
/*
* If the result was only partially successful, throw an exception
*/
if (!response.getErrors().isEmpty()) {
Map<String, String> headers = responseHandler.getResponseHeaders();
MultiObjectDeleteException ex = new MultiObjectDeleteException(response.getErrors(), response.getDeletedObjects());
ex.setStatusCode(200);
ex.setRequestId(headers.get(Headers.REQUEST_ID));
throw ex;
}
DeleteObjectsResult result = new DeleteObjectsResult(response.getDeletedObjects());
return result;
}
Aggregations