S3StorageProvider extends StorageProviderBase { @Override public String copyContent(String sourceSpaceId, String sourceContentId, String destSpaceId, String destContentId) { log.debug("copyContent({}, {}, {}, {})", sourceSpaceId, sourceContentId, destSpaceId, destContentId); String sourceBucketName = getBucketName(sourceSpaceId); String destBucketName = getBucketName(destSpaceId); throwIfContentNotExist(sourceBucketName, sourceContentId); CopyObjectRequest request = new CopyObjectRequest(sourceBucketName, sourceContentId, destBucketName, destContentId); request.setStorageClass(DEFAULT_STORAGE_CLASS); request.setCannedAccessControlList(CannedAccessControlList.Private); CopyObjectResult result = doCopyObject(request); return StorageProviderUtil.compareChecksum(this, sourceSpaceId, sourceContentId, result.getETag()); } 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 testCopyContent() { Capture<CopyObjectRequest> capturedRequest = createS3ClientCopyContent(hexChecksum); S3StorageProvider provider = new S3StorageProvider(s3Client, accessKey, null); String srcSpaceId = "space-id"; String srcContentId = "contentId"; String destSpaceId = "dest-space-id"; String destContentId = "destContentId"; String md5 = provider.copyContent(srcSpaceId, srcContentId, destSpaceId, destContentId); Assert.assertNotNull(md5); CopyObjectRequest request = capturedRequest.getValue(); Assert.assertNotNull(request); String srcBucket = request.getSourceBucketName(); String srcKey = request.getSourceKey(); String destBucket = request.getDestinationBucketName(); String destKey = request.getDestinationKey(); String storageClass = request.getStorageClass(); Assert.assertNotNull(srcBucket); Assert.assertNotNull(srcKey); Assert.assertNotNull(destBucket); Assert.assertNotNull(destKey); Assert.assertNotNull(storageClass); String lowerSrcSpaceId = (accessKey + "." + srcSpaceId).toLowerCase(); String lowerDestSpaceId = (accessKey + "." + destSpaceId).toLowerCase(); Assert.assertEquals(lowerSrcSpaceId, srcBucket); Assert.assertEquals(srcContentId, srcKey); Assert.assertEquals(lowerDestSpaceId, destBucket); Assert.assertEquals(destContentId, destKey); Assert.assertEquals(StorageClass.Standard.toString(), storageClass); }