@Test public void testCopy() throws Exception { StoragePath from = new StoragePath(ORG_ID, MP_ID, VERSION_2, MP_ELEM_ID); StoragePath to = new StoragePath(ORG_ID, MP_ID, VERSION_1, MP_ELEM_ID); assertTrue(repo.copy(from, to)); File srcFile = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID, VERSION_2.toString(), MP_ELEM_ID + XML_EXTENSTION })); File copyFile = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID, VERSION_1.toString(), MP_ELEM_ID + XML_EXTENSTION })); assertTrue(srcFile.exists()); assertTrue(copyFile.exists()); FileInputStream srcIn = null; FileInputStream copyIn = null; try { srcIn = new FileInputStream(srcFile); copyIn = new FileInputStream(copyFile); byte[] bytesOriginal = IOUtils.toByteArray(srcIn); byte[] bytesCopy = IOUtils.toByteArray(copyIn); Assert.assertEquals(bytesCopy.length, bytesOriginal.length); } finally { IOUtils.closeQuietly(srcIn); IOUtils.closeQuietly(copyIn); } }
@Override public boolean copy(final StoragePath from, final StoragePath to) throws AssetStoreException { return findStoragePathFile(from).map(new Fn<File, Boolean>() { @Override public Boolean apply(File f) { final File t = createFile(to, f); mkParent(t); logger.debug("Copying {} to {}", f.getAbsolutePath(), t.getAbsolutePath()); try { link(f, t, true); } catch (IOException e) { logger.error("Error copying archive file {} to {}", f, t); throw new AssetStoreException(e); } return true; } }).getOr(false); }
AbstractFileSystemAssetStore implements AssetStore { @Override public boolean copy(final StoragePath from, final StoragePath to) throws AssetStoreException { return findStoragePathFile(from).map(new Fn<File, Boolean>() { @Override public Boolean apply(File f) { final File t = createFile(to, f); mkParent(t); logger.debug("Copying {} to {}", f.getAbsolutePath(), t.getAbsolutePath()); try { link(f, t, true); } catch (IOException e) { logger.error("Error copying archive file {} to {}", f, t); throw new AssetStoreException(e); } return true; } }).getOr(false); } }
AbstractFileSystemAssetStore implements AssetStore { @Override public boolean copy(final StoragePath from, final StoragePath to) throws AssetStoreException { return findStoragePathFile(from).map(new Fn<File, Boolean>() { @Override public Boolean apply(File f) { final File t = createFile(to, f); mkParent(t); logger.debug("Copying {} to {}", f.getAbsolutePath(), t.getAbsolutePath()); try { link(f, t, true); } catch (IOException e) { logger.error("Error copying archive file {} to {}", f, t); throw new AssetStoreException(e); } return true; } }).getOr(false); }  }
AbstractFileSystemAssetStore implements AssetStore { @Override public boolean copy(final StoragePath from, final StoragePath to) throws AssetStoreException { return findStoragePathFile(from).map(new Fn<File, Boolean>() { @Override public Boolean apply(File f) { final File t = createFile(to, f); mkParent(t); logger.debug("Copying {} to {}", f.getAbsolutePath(), t.getAbsolutePath()); try { link(f, t, true); } catch (IOException e) { logger.error("Error copying archive file {} to {}", f, t); throw new AssetStoreException(e); } return true; } }).getOr(false); }  @Override void put(StoragePath storagePath, Source source); @Override boolean copy(final StoragePath from, final StoragePath to); @Override Opt<InputStream> get(final StoragePath path); @Override boolean contains(StoragePath path); @Override boolean delete(DeletionSelector sel); @Override Option<Long> getUsedSpace(); @Override Option<Long> getUsableSpace(); @Override Option<Long> getTotalSpace(); @Override String getStoreType(); }
AbstractFileSystemAssetStore implements AssetStore { @Override public boolean copy(final StoragePath from, final StoragePath to) throws AssetStoreException { return findStoragePathFile(from).map(new Fn<File, Boolean>() { @Override public Boolean apply(File f) { final File t = createFile(to, f); mkParent(t); logger.debug("Copying {} to {}", f.getAbsolutePath(), t.getAbsolutePath()); try { link(f, t, true); } catch (IOException e) { logger.error("Error copying archive file {} to {}", f, t); throw new AssetStoreException(e); } return true; } }).getOr(false); }  @Override void put(StoragePath storagePath, Source source); @Override boolean copy(final StoragePath from, final StoragePath to); @Override Opt<InputStream> get(final StoragePath path); @Override boolean contains(StoragePath path); @Override boolean delete(DeletionSelector sel); @Override Option<Long> getUsedSpace(); @Override Option<Long> getUsableSpace(); @Override Option<Long> getTotalSpace(); @Override String getStoreType();  }