S3StorageProvider extends StorageProviderBase { protected Map<String, String> getAllSpaceProperties(String spaceId) { log.debug("getAllSpaceProperties(" + spaceId + ")"); String bucketName = getBucketName(spaceId); Map<String, String> spaceProperties = new HashMap<>(); BucketTaggingConfiguration tagConfig; try { tagConfig = s3Client.getBucketTaggingConfiguration(bucketName); } catch (AmazonClientException e) { String err = "Could not get bucket tagging configuration in S3 bucket " + bucketName + " due to error: " + e.getMessage(); throw new StorageException(err, e, RETRY); } if (null != tagConfig) { for (TagSet tagSet : tagConfig.getAllTagSets()) { spaceProperties.putAll(tagSet.getAllTags()); } } spaceProperties = replaceInMapValues(spaceProperties, "+", "@"); spaceProperties.put(PROPERTIES_SPACE_COUNT, getSpaceCount(spaceId, MAX_ITEM_COUNT)); return spaceProperties; } 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 testGetAllSpaceProperties() throws Exception { setupS3Client(); addListBucketsMock(); Map<String, String> bucketTags = new HashMap<>(); bucketTags.put("tag-one", "tag-one-value"); bucketTags.put("tag-two", "tagtwo+test.com"); BucketTaggingConfiguration tagConfig = new BucketTaggingConfiguration().withTagSets(new TagSet(bucketTags)); expect( s3Client.getBucketTaggingConfiguration(EasyMock.isA(String.class))) .andReturn(tagConfig); ObjectListing objectListing = createMock("ObjectListing", ObjectListing.class); setUpListObjects(objectListing, 1); setUpListObjects(objectListing, 0); replay(s3Client, objectListing); S3StorageProvider provider = getProvider(); Map<String, String> spaceProps = provider.getAllSpaceProperties(spaceId); Assert.assertNotNull(spaceProps); Assert.assertEquals("tag-one-value", spaceProps.get("tag-one")); Assert.assertEquals("tagtwo@test.com", spaceProps.get("tag-two")); Assert.assertEquals(String.valueOf(1), spaceProps.get( StorageProvider.PROPERTIES_SPACE_COUNT)); verify(s3Client, objectListing); }