S3StorageProvider extends StorageProviderBase { protected void doSetSpaceProperties(String spaceId, Map<String, String> spaceProperties) { log.debug("setSpaceProperties(" + spaceId + ")"); String bucketName = getBucketName(spaceId); Map<String, String> originalProperties; try { originalProperties = getAllSpaceProperties(spaceId); } catch (NotFoundException e) { originalProperties = new HashMap<>(); } 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); spaceProperties = replaceInMapValues(spaceProperties, "@", "+"); BucketTaggingConfiguration tagConfig = new BucketTaggingConfiguration() .withTagSets(new TagSet(spaceProperties)); try { s3Client.setBucketTaggingConfiguration(bucketName, tagConfig); } catch (AmazonClientException e) { String err = "Could not update bucket tagging configuration in S3 bucket " + bucketName + " due to error: " + e.getMessage(); throw new StorageException(err, e, RETRY); } } S3StorageProvider(String accessKey, String secretKey);  S3StorageProvider(String accessKey,
                             String secretKey,
                             Map<String, String> options);  S3StorageProvider(AmazonS3 s3Client,
                             String accessKey,
                             Map<String, String> options); @Override StorageProviderType getStorageProviderType(); Iterator<String> getSpaces(); Iterator<String> getSpaceContents(String spaceId,
                                             String prefix); List<String> getSpaceContentsChunked(String spaceId,
                                                String prefix,
                                                long maxResults,
                                                String marker); void createSpace(String spaceId); String createHiddenSpace(String spaceId, int expirationInDays); void setSpaceLifecycle(String bucketName,
                                  BucketLifecycleConfiguration config); void removeSpace(String spaceId); String addHiddenContent(String spaceId,
                                   String contentId,
                                   String contentMimeType,
                                   InputStream content); String addContent(String spaceId,
                             String contentId,
                             String contentMimeType,
                             Map<String, String> userProperties,
                             long contentSize,
                             String contentChecksum,
                             InputStream content); @Override String copyContent(String sourceSpaceId,
                              String sourceContentId,
                              String destSpaceId,
                              String destContentId); RetrievedContent getContent(String spaceId, String contentId); RetrievedContent getContent(String spaceId, String contentId, String range); void deleteContent(String spaceId, String contentId); void setContentProperties(String spaceId,
                                     String contentId,
                                     Map<String, String> contentProperties); Map<String, String> getContentProperties(String spaceId,
                                                    String contentId); @Override Map<String, String> getSpaceProperties(String spaceId); String getBucketName(String spaceId); static final String HIDDEN_SPACE_PREFIX; }
@Test public void testDoSetSpaceProperties() { setupS3Client(); String spaceId = "space-id"; addListBucketsMock(); expect( s3Client.getBucketTaggingConfiguration(EasyMock.isA(String.class))) .andThrow(new NotFoundException(spaceId)); Capture<BucketTaggingConfiguration> tagConfigCap = new Capture<>(); s3Client.setBucketTaggingConfiguration(EasyMock.isA(String.class), capture(tagConfigCap)); EasyMock.expectLastCall().once(); S3StorageProvider provider = getProvider(); Bucket bucket = new Bucket(); bucket.setName(provider.getNewBucketName(spaceId)); bucket.setCreationDate(new Date()); List<Bucket> buckets = new ArrayList<>(); buckets.add(bucket); replay(s3Client); Map<String, String> spaceProps = new HashMap<>(); spaceProps.put("one", "one-value"); spaceProps.put("two", "two@value.com"); provider.doSetSpaceProperties(spaceId, spaceProps); BucketTaggingConfiguration tagConfig = tagConfigCap.getValue(); Assert.assertNotNull(tagConfig); Map<String, String> props = tagConfig.getAllTagSets().get(0).getAllTags(); Assert.assertNotNull(props); Assert.assertEquals(3, props.size()); Assert.assertEquals("one-value", props.get("one")); Assert.assertEquals("two+value.com", props.get("two")); Assert.assertNotNull( props.get(StorageProvider.PROPERTIES_SPACE_CREATED)); verify(s3Client); }