Search in sources :

Example 61 with RequestMessage

use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.

the class OSSBucketOperation method getBucketTagging.

/**
 * Get bucket tagging.
 */
public TagSet getBucketTagging(GenericRequest genericRequest) throws OSSException, ClientException {
    assertParameterNotNull(genericRequest, "genericRequest");
    String bucketName = genericRequest.getBucketName();
    assertParameterNotNull(bucketName, "bucketName");
    ensureBucketNameValid(bucketName);
    Map<String, String> params = new HashMap<String, String>();
    params.put(SUBRESOURCE_TAGGING, null);
    RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setBucket(bucketName).setParameters(params).setOriginalRequest(genericRequest).build();
    return doOperation(request, getBucketTaggingResponseParser, bucketName, null, true);
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) RequestMessage(com.aliyun.oss.common.comm.RequestMessage)

Example 62 with RequestMessage

use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.

the class OSSBucketOperation method addBucketReplication.

/**
 * Add bucket replication.
 */
public void addBucketReplication(AddBucketReplicationRequest addBucketReplicationRequest) throws OSSException, ClientException {
    assertParameterNotNull(addBucketReplicationRequest, "addBucketReplicationRequest");
    assertParameterNotNull(addBucketReplicationRequest.getTargetBucketName(), "targetBucketName");
    assertParameterNotNull(addBucketReplicationRequest.getTargetBucketLocation(), "targetBucketLocation");
    String bucketName = addBucketReplicationRequest.getBucketName();
    assertParameterNotNull(bucketName, "bucketName");
    ensureBucketNameValid(bucketName);
    Map<String, String> params = new LinkedHashMap<String, String>();
    params.put(RequestParameters.SUBRESOURCE_REPLICATION, null);
    params.put(RequestParameters.SUBRESOURCE_COMP, RequestParameters.COMP_ADD);
    RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.POST).setBucket(bucketName).setParameters(params).setInputStreamWithLength(addBucketReplicationRequestMarshaller.marshall(addBucketReplicationRequest)).setOriginalRequest(addBucketReplicationRequest).build();
    doOperation(request, emptyResponseParser, bucketName, null);
}
Also used : RequestMessage(com.aliyun.oss.common.comm.RequestMessage) LinkedHashMap(java.util.LinkedHashMap)

Example 63 with RequestMessage

use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.

the class OSSBucketOperation method getBucketWebsite.

/**
 * Get bucket website.
 */
public BucketWebsiteResult getBucketWebsite(GenericRequest genericRequest) throws OSSException, ClientException {
    assertParameterNotNull(genericRequest, "genericRequest");
    String bucketName = genericRequest.getBucketName();
    assertParameterNotNull(bucketName, "bucketName");
    ensureBucketNameValid(bucketName);
    Map<String, String> params = new HashMap<String, String>();
    params.put(SUBRESOURCE_WEBSITE, null);
    RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setBucket(bucketName).setParameters(params).setOriginalRequest(genericRequest).build();
    return doOperation(request, getBucketWebsiteResponseParser, bucketName, null, true);
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) RequestMessage(com.aliyun.oss.common.comm.RequestMessage)

Example 64 with RequestMessage

use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.

the class OSSBucketOperation method listImageStyle.

/**
 * List image style.
 */
public List<Style> listImageStyle(String bucketName, GenericRequest genericRequest) throws OSSException, ClientException {
    assertParameterNotNull(bucketName, "bucketName");
    ensureBucketNameValid(bucketName);
    Map<String, String> params = new HashMap<String, String>();
    ;
    params.put(SUBRESOURCE_STYLE, null);
    RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setBucket(bucketName).setParameters(params).setOriginalRequest(genericRequest).build();
    return doOperation(request, listImageStyleResponseParser, bucketName, null, true);
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) RequestMessage(com.aliyun.oss.common.comm.RequestMessage)

Example 65 with RequestMessage

use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.

the class OSSBucketOperation method createBucket.

/**
 * Create a bucket.
 */
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws OSSException, ClientException {
    assertParameterNotNull(createBucketRequest, "createBucketRequest");
    String bucketName = createBucketRequest.getBucketName();
    assertParameterNotNull(bucketName, "bucketName");
    ensureBucketNameValid(bucketName);
    Map<String, String> headers = new HashMap<String, String>();
    addOptionalACLHeader(headers, createBucketRequest.getCannedACL());
    RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.PUT).setBucket(bucketName).setHeaders(headers).setInputStreamWithLength(createBucketRequestMarshaller.marshall(createBucketRequest)).setOriginalRequest(createBucketRequest).build();
    ResponseMessage result = doOperation(request, emptyResponseParser, bucketName, null);
    return new Bucket(bucketName, result.getRequestId());
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Bucket(com.aliyun.oss.model.Bucket) RequestMessage(com.aliyun.oss.common.comm.RequestMessage) ResponseMessage(com.aliyun.oss.common.comm.ResponseMessage)

Aggregations

RequestMessage (com.aliyun.oss.common.comm.RequestMessage)98 LinkedHashMap (java.util.LinkedHashMap)88 HashMap (java.util.HashMap)78 ByteArrayInputStream (java.io.ByteArrayInputStream)23 ClientException (com.aliyun.oss.ClientException)9 ClientConfiguration (com.aliyun.oss.ClientConfiguration)6 ResponseHandler (com.aliyun.oss.common.comm.ResponseHandler)6 InputStream (java.io.InputStream)6 ResponseMessage (com.aliyun.oss.common.comm.ResponseMessage)5 IOUtils.newRepeatableInputStream (com.aliyun.oss.common.utils.IOUtils.newRepeatableInputStream)5 ProgressListener (com.aliyun.oss.event.ProgressListener)5 ArrayList (java.util.ArrayList)5 ExecutionContext (com.aliyun.oss.common.comm.ExecutionContext)4 ProgressInputStream (com.aliyun.oss.event.ProgressInputStream)4 URI (java.net.URI)4 CheckedInputStream (java.util.zip.CheckedInputStream)4 ServiceException (com.aliyun.oss.ServiceException)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 Credentials (com.aliyun.oss.common.auth.Credentials)2