AbstractFileSystemAssetStore implements AssetStore { @Override public boolean delete(DeletionSelector sel) throws AssetStoreException { File dir = getDeletionSelectorDir(sel); try { FileUtils.deleteDirectory(dir); FileSupport.deleteHierarchyIfEmpty(file(path(getRootDirectory(), sel.getOrganizationId())), dir.getParentFile()); return true; } catch (IOException e) { logger.error("Error deleting directory from archive {}", dir); throw new AssetStoreException(e); } }  @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 testDeleteWithVersion() throws Exception { DeletionSelector versionSelector = DeletionSelector.delete(ORG_ID, MP_ID, VERSION_2); assertTrue(repo.delete(versionSelector)); assertFalse(sampleElemDir.exists()); File file = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID, VERSION_2.toString() })); assertFalse(file.exists()); file = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID })); assertFalse(file.exists()); file = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID })); assertTrue(file.exists()); }
@Test public void testDeleteNoneVersion() throws Exception { DeletionSelector noneVersionSelector = DeletionSelector.deleteAll(ORG_ID, MP_ID); assertTrue(repo.delete(noneVersionSelector)); assertFalse(sampleElemDir.exists()); File file = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID })); assertFalse(file.exists()); }
@Test public void testDeleteWrongVersion() throws Exception { DeletionSelector versionSelector = DeletionSelector.delete(ORG_ID, MP_ID, VERSION_1); repo.delete(versionSelector); assertTrue(sampleElemDir.exists()); }