Example usage for com.amazonaws.services.s3.model TagSet TagSet

List of usage examples for com.amazonaws.services.s3.model TagSet TagSet

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model TagSet TagSet.

Prototype

public TagSet(Map<String, String> tags) 

Source Link

Document

Creates a new TagSet with the set of tags defined.

Usage

From source file:org.duracloud.s3storage.S3StorageProvider.java

License:Apache License

/**
 * {@inheritDoc}/*from   w ww  . j a  v a2s. co  m*/
 */
protected void doSetSpaceProperties(String spaceId, Map<String, String> spaceProperties) {
    log.debug("setSpaceProperties(" + spaceId + ")");

    // Will throw if bucket does not exist
    String bucketName = getBucketName(spaceId);

    Map<String, String> originalProperties;
    try {
        originalProperties = getAllSpaceProperties(spaceId);
    } catch (NotFoundException e) {
        // Likely adding a new space, so no existing properties yet.
        originalProperties = new HashMap<>();
    }

    // Set creation date
    String creationDate = originalProperties.get(PROPERTIES_SPACE_CREATED);
    if (creationDate == null) {
        creationDate = spaceProperties.get(PROPERTIES_SPACE_CREATED);
        if (creationDate == null) {
            creationDate = getBucketCreationDate(bucketName);
        }
    }
    spaceProperties.put(PROPERTIES_SPACE_CREATED, creationDate);

    // Handle @ symbol (change to +), to allow for email usernames in ACLs
    spaceProperties = replaceInMapValues(spaceProperties, "@", "+");

    // Store properties
    BucketTaggingConfiguration tagConfig = new BucketTaggingConfiguration()
            .withTagSets(new TagSet(spaceProperties));
    s3Client.setBucketTaggingConfiguration(bucketName, tagConfig);
}