Java Code Examples for org.alfresco.repo.content.ContentStore#delete()
The following examples show how to use
org.alfresco.repo.content.ContentStore#delete() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Empty parent directories should be removed when a URL is removed. */ @Test public void testDeleteRemovesEmptyDirs() throws Exception { ContentStore store = getStore(); String url = "store://1965/12/1/13/12/file.bin"; // Ensure clean test data if (store.exists(url)) store.delete(url); String content = "Content for test: " + getName(); store.getWriter(new ContentContext(null, url)).putContent(content); File root = new File(store.getRootLocation()); assertDirExists(root, ""); assertDirExists(root, "1965/12/1/13/12"); store.delete(url); assertDirNotExists(root, "1965"); // root should be untouched. assertDirExists(root, ""); }
Example 2
Source File: MoveCapableCommonRoutingContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 6 votes |
/** * * {@inheritDoc} */ @Override public boolean delete(final String contentUrl) throws ContentIOException { boolean deleted = true; final List<ContentStore> stores = this.getAllStores(); /* * This operation has to be performed on all the stores in order to maintain the * {@link ContentStore#exists(String)} contract. * Still need to apply the isContentUrlSupported guard though. */ for (final ContentStore store : stores) { if (store.isContentUrlSupported(contentUrl) && store.isWriteSupported()) { deleted &= store.delete(contentUrl); } } LOGGER.debug("Deleted content URL from stores: \n\tStores: {}\n\tDeleted: {}", stores.size(), deleted); return deleted; }
Example 3
Source File: EagerContentStoreCleaner.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Attempts to delete the URL from the store, catching and reporing errors. */ protected boolean deleteFromStore(String contentUrl, ContentStore store) { try { // Since we are in post-commit, we do best-effort if (!store.delete(contentUrl)) { logger.error( "Content deletion failed (no exception): \n" + " URL: " + contentUrl + "\n" + " Source: " + store); return false; } else { return true; } } catch (Throwable e) { logger.error( "Content deletion failed: \n" + " URL: " + contentUrl + "\n" + " Source: " + store, e); return false; } }
Example 4
Source File: FileContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Only non-empty directories should be deleted. */ @Test public void testDeleteLeavesNonEmptyDirs() { ContentStore store = getStore(); String url = "store://1965/12/1/13/12/file.bin"; // Ensure clean test data if (store.exists(url)) store.delete(url); String content = "Content for test: " + getName(); store.getWriter(new ContentContext(null, url)).putContent(content); File root = new File(store.getRootLocation()); assertDirExists(root, ""); assertDirExists(root, "1965/12/1/13/12"); // Make a directory non-empty String anotherUrl = "store://1965/12/3/another.bin"; if (store.exists(anotherUrl)) store.delete(anotherUrl); store.getWriter(new ContentContext(null, anotherUrl)); store.delete(url); // Parents of another.bin cannot be deleted assertDirExists(root, "1965"); assertDirExists(root, "1965/12"); // Non-parents of another.bin could be deleted assertDirNotExists(root, "1965/12/1"); // root should be untouched. assertDirExists(root, ""); }