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

项目: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    文件: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();
}
项目:ibm-cos-sdk-java    文件:BucketConfigurationXmlFactory.java   
private void writeRule(XmlWriter xml, TagSet tagset) {
    xml.start("TagSet");
    for ( String key : tagset.getAllTags().keySet() ) {
        xml.start("Tag");
        xml.start("Key").value(key).end();
        xml.start("Value").value(tagset.getTag(key)).end();
        xml.end(); // </Tag>
    }
    xml.end(); // </TagSet>
}
项目: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);
}
项目:cmn-project    文件:CreateBucketTask.java   
@Override
public void execute(Context context) throws Exception {
    resource.remoteBucket = AWS.s3.createBucket(resource.name);
    context.output("s3/" + resource.id, "bucketName=" + resource.remoteBucket.getName());

    TagSet tagSet = new TagSet();
    tagSet.setTag("cloud-manager:env", context.env.name);
    tagSet.setTag("cloud-manager:env:" + context.env.name + ":resource-id", resource.id);
    AWS.s3.createTags(resource.name, tagSet);
}
项目:ibm-cos-sdk-java    文件:BucketConfigurationXmlFactory.java   
private boolean hasTags(TagSet tagSet) {
    return tagSet != null && tagSet.getAllTags() != null && tagSet.getAllTags().size() > 0;
}
项目: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));
}