AbstractFileSystemAssetStore implements AssetStore { @Override public void put(StoragePath storagePath, Source source) throws AssetStoreException { final File origin = getUniqueFileFromWorkspace(source); final File destination = createFile(storagePath, source); try { mkParent(destination); link(origin, destination); } catch (IOException e) { logger.error("Error while linking/copying file {} to {}: {}", origin, destination, getMessage(e)); throw new AssetStoreException(e); } finally { if (origin != null) { FileUtils.deleteQuietly(origin); } } }  @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();  }
@Test public void testPut() throws Exception { StoragePath storagePath = new StoragePath(ORG_ID, MP_ID, VERSION_1, MP_ELEM_ID); repo.put(storagePath, Source.mk(getClass().getClassLoader().getResource(FILE_NAME).toURI())); File file = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID, VERSION_1.toString() })); assertTrue(file + " should be a directory", file.isDirectory()); assertTrue(file.listFiles().length == 1); InputStream original = null; FileInputStream fileInput = null; try { fileInput = new FileInputStream(file.listFiles()[0]); original = getClass().getClassLoader().getResourceAsStream(FILE_NAME); byte[] bytesFromRepo = IOUtils.toByteArray(fileInput); byte[] bytesFromClasspath = IOUtils.toByteArray(original); assertArrayEquals(bytesFromClasspath, bytesFromRepo); } finally { IOUtils.closeQuietly(original); IOUtils.closeQuietly(fileInput); } }