ContentResourceImpl implements ContentResource { @Override public String copyContent(String srcStoreID, String srcSpaceID, String srcContentID, String destStoreID, String destSpaceID, String destContentID) throws ResourceException { BrokeredStorageProvider srcProvider = getStorageProvider(srcStoreID); BrokeredStorageProvider destProvider = getStorageProvider(destStoreID); if (srcProvider.equals(destProvider)) { return copyContent(srcProvider, srcSpaceID, srcContentID, destSpaceID, destContentID, srcStoreID); } else { return copyContentBetweenStorageProviders(srcProvider, srcSpaceID, srcContentID, srcStoreID, destProvider, destSpaceID, destContentID, destStoreID); } } ContentResourceImpl(StorageProviderFactory storageProviderFactory); @Override RetrievedContent getContent(String spaceID,
                                       String contentID,
                                       String storeID,
                                       String range); @Override Map<String, String> getContentProperties(String spaceID,
                                                    String contentID,
                                                    String storeID); @Override void updateContentProperties(String spaceID,
                                        String contentID,
                                        String contentMimeType,
                                        Map<String, String> userProperties,
                                        String storeID); @Override String addContent(String spaceID,
                             String contentID,
                             InputStream content,
                             String contentMimeType,
                             Map<String, String> userProperties,
                             long contentSize,
                             String checksum,
                             String storeID); @Override String copyContent(String srcStoreID,
                              String srcSpaceID,
                              String srcContentID,
                              String destStoreID,
                              String destSpaceID,
                              String destContentID); @Override void deleteContent(String spaceID, String contentID, String storeID);  }
@Test public void testLocalCopyContent() throws Exception { String srcSpaceId = "src-space-id"; String srcContentId = "src-content-id"; String destSpaceId = "dest-space-id"; String destContentId = "dest-content-id"; String storeId = "2"; String expectedMd5 = "md5"; createLocalCopyContentMocks(srcSpaceId, srcContentId, destSpaceId, destContentId, storeId, expectedMd5); replayMocks(); contentResource = new ContentResourceImpl(storageProviderFactory); String md5 = contentResource.copyContent(storeId, srcSpaceId, srcContentId, storeId, destSpaceId, destContentId); Assert.assertNotNull(md5); Assert.assertEquals(expectedMd5, md5); }
@Test public void testInterProviderCopyContent() throws Exception { String srcStoreId = "0"; String srcSpaceId = "src-space-id"; String srcContentId = "src-content-id"; String destStoreId = "1"; String destSpaceId = "dest-space-id"; String destContentId = "dest-content-id"; String expectedMd5 = "md5"; createInterProviderCopyContentMocks(srcStoreId, srcSpaceId, srcContentId, destStoreId, destSpaceId, destContentId, expectedMd5); replayMocks(); contentResource = new ContentResourceImpl(storageProviderFactory); String md5 = contentResource.copyContent(srcStoreId, srcSpaceId, srcContentId, destStoreId, destSpaceId, destContentId); Assert.assertNotNull(md5); Assert.assertEquals(expectedMd5, md5); }