Java 类com.amazonaws.services.s3.model.BucketTaggingConfiguration 实例源码

项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@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;
        }
    }
}
项目:s3-cf-service-broker    文件:S3.java   
public Bucket createBucketForInstance(String instanceId, ServiceDefinition service, String planId,
        String organizationGuid, String spaceGuid) {
    String bucketName = getBucketNameForInstance(instanceId);
    logger.info("Creating bucket '{}' for serviceInstanceId '{}'", bucketName, instanceId);
    Bucket bucket = s3.createBucket(bucketName, Region.fromValue(region));

    // TODO allow for additional, custom tagging options
    BucketTaggingConfiguration bucketTaggingConfiguration = new BucketTaggingConfiguration();
    TagSet tagSet = new TagSet();
    tagSet.setTag("serviceInstanceId", instanceId);
    tagSet.setTag("serviceDefinitionId", service.getId());
    tagSet.setTag("planId", planId);
    tagSet.setTag("organizationGuid", organizationGuid);
    tagSet.setTag("spaceGuid", spaceGuid);
    bucketTaggingConfiguration.withTagSets(tagSet);
    s3.setBucketTaggingConfiguration(bucket.getName(), bucketTaggingConfiguration);

    return bucket;
}
项目:s3-cf-service-broker    文件:S3.java   
private ServiceInstance createServiceInstance(BucketTaggingConfiguration taggingConfiguration) {
    // While the Java API has multiple TagSets, it would appear from
    // http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTtagging.html
    // that only one TagSet is supported.
    TagSet tagSet = taggingConfiguration.getTagSet();
    String serviceInstanceId = tagSet.getTag("serviceInstanceId");
    if (serviceInstanceId == null) {
        // could occur if someone used this broker AWS ID to a bucket
        // outside of the broker process
        return null;
    }
    String serviceDefinitionId = tagSet.getTag("serviceDefinitionId");
    String planId = tagSet.getTag("planId");
    String organizationGuid = tagSet.getTag("organizationGuid");
    String spaceGuid = tagSet.getTag("spaceGuid");
    ServiceInstance serviceInstance = new ServiceInstance(serviceInstanceId, serviceDefinitionId, planId,
            organizationGuid, spaceGuid, null);
    return serviceInstance;
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public void setBucketTaggingConfiguration(
        SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest) {
    setBucketTaggingConfigurationRequest = beforeClientExecution(setBucketTaggingConfigurationRequest);
    rejectNull(setBucketTaggingConfigurationRequest,
            "The set bucket tagging configuration request object must be specified.");

    String bucketName = setBucketTaggingConfigurationRequest.getBucketName();
    BucketTaggingConfiguration bucketTaggingConfiguration = setBucketTaggingConfigurationRequest.getTaggingConfiguration();

    rejectNull(bucketName,
            "The bucket name parameter must be specified when setting bucket tagging configuration.");
    rejectNull(bucketTaggingConfiguration,
            "The tagging configuration parameter must be specified when setting bucket tagging configuration.");

    Request<SetBucketTaggingConfigurationRequest> request = createRequest(bucketName, null, setBucketTaggingConfigurationRequest, HttpMethodName.PUT);
    request.addParameter("tagging", null);

    byte[] content = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketTaggingConfiguration);
    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 SdkClientException("Couldn't compute md5 sum", e);
    }

    invoke(request, voidResponseHandler, bucketName, null);
}
项目:ibm-cos-sdk-java    文件:BucketConfigurationXmlFactory.java   
/**
 * Converts the specified {@link BucketTaggingConfiguration} object to an XML fragment that
 * can be sent to Amazon S3.
 *
 * @param config
 *            The {@link BucketTaggingConfiguration}
 */
/*
 * <Tagging>
     <TagSet>
        <Tag>
               <Key>Project</Key>
               <Value>Foo</Value>
        </Tag>
        <Tag>
               <Key>User</Key>
               <Value>nschnarr</Value>
        </Tag>
     </TagSet>
    </Tagging>
*/
public byte[] convertToXmlByteArray(BucketTaggingConfiguration config) throws SdkClientException {

    XmlWriter xml = new XmlWriter();
    xml.start("Tagging");

    for (TagSet tagset : config.getAllTagSets()) {
        writeRule(xml, tagset);
    }

    xml.end();

    return xml.getBytes();
}
项目:photon-model    文件:TestAWSEnumerationTask.java   
private void createS3BucketAndTags(Map<String, String> tags) {
    this.s3Client.createBucket(TEST_BUCKET_NAME);

    TagSet tagSet = new TagSet(tags);
    BucketTaggingConfiguration bucketTaggingConfiguration = new
            BucketTaggingConfiguration(Collections.singletonList(tagSet));

    this.s3Client.setBucketTaggingConfiguration(TEST_BUCKET_NAME, bucketTaggingConfiguration);
}
项目:s3-cf-service-broker    文件:S3.java   
public ServiceInstance findServiceInstance(String instanceId) {
    String bucketName = getBucketNameForInstance(instanceId);
    if (s3.doesBucketExist(bucketName)) {
        BucketTaggingConfiguration taggingConfiguration = s3.getBucketTaggingConfiguration(bucketName);
        return createServiceInstance(taggingConfiguration);
    }
    return null;
}
项目:s3-cf-service-broker    文件:S3.java   
public List<ServiceInstance> getAllServiceInstances() {
    List<ServiceInstance> serviceInstances = Lists.newArrayList();
    for (Bucket bucket : s3.listBuckets()) {
        BucketTaggingConfiguration taggingConfiguration = s3.getBucketTaggingConfiguration(bucket.getName());
        ServiceInstance serviceInstance = createServiceInstance(taggingConfiguration);
        serviceInstances.add(serviceInstance);
    }
    return serviceInstances;
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName) {
    return delegate.getBucketTaggingConfiguration(bucketName);
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration) {
    delegate.setBucketTaggingConfiguration(bucketName, bucketTaggingConfiguration);
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(GetBucketTaggingConfigurationRequest getBucketTaggingConfigurationRequest) {
    return delegate.getBucketTaggingConfiguration(getBucketTaggingConfigurationRequest);
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName) {
    return getBucketTaggingConfiguration(new GetBucketTaggingConfigurationRequest(bucketName));
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration) {
    setBucketTaggingConfiguration(new SetBucketTaggingConfigurationRequest(bucketName, bucketTaggingConfiguration));
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName) {
  return call(() -> getDelegate().getBucketTaggingConfiguration(bucketName));
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(GetBucketTaggingConfigurationRequest getBucketTaggingConfigurationRequest) {
  return call(() -> getDelegate().getBucketTaggingConfiguration(getBucketTaggingConfigurationRequest));
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration) {
  run(() -> getDelegate().setBucketTaggingConfiguration(bucketName, bucketTaggingConfiguration));
}
项目:presto    文件:MockAmazonS3.java   
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName)
{
    return null;
}
项目:presto    文件:MockAmazonS3.java   
@Override
public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration)
{
}
项目:cmn-project    文件:S3.java   
public void createTags(String bucketName, TagSet tags) {
    logger.info("tag s3 bucket, bucketName={}", bucketName);
    s3.setBucketTaggingConfiguration(bucketName, new BucketTaggingConfiguration().withTagSets(tags));
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName) {
  // TODO Auto-generated method stub
  return null;
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration) {
  // TODO Auto-generated method stub

}