diff --git a/source/java/org/alfresco/repo/admin/patch/impl/ContentUrlConverterPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/ContentUrlConverterPatch.java index 96ea2f1502..8bf77ebac5 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/ContentUrlConverterPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/ContentUrlConverterPatch.java @@ -602,7 +602,7 @@ public class ContentUrlConverterPatch extends AbstractPatch return true; } - final long totalSize = contentStore.getSpaceUsed(); + final long totalSize = contentStore.getSpaceTotal(); final MutableLong currentSize = new MutableLong(0L); final MutableInt count = new MutableInt(); diff --git a/source/java/org/alfresco/repo/content/AbstractContentStore.java b/source/java/org/alfresco/repo/content/AbstractContentStore.java index c2e0c10323..31b6a68d19 100644 --- a/source/java/org/alfresco/repo/content/AbstractContentStore.java +++ b/source/java/org/alfresco/repo/content/AbstractContentStore.java @@ -78,6 +78,14 @@ public abstract class AbstractContentStore implements ContentStore } protected ContentLimitProvider contentLimitProvider = new NoLimitProvider(); + + /** + * An object that prevents abuse of the underlying store(s) + */ + public void setContentLimitProvider(ContentLimitProvider contentLimitProvider) + { + this.contentLimitProvider = contentLimitProvider; + } /** * Splits the content URL into its component parts as separated by @@ -119,6 +127,7 @@ public abstract class AbstractContentStore implements ContentStore * * @since 2.1 */ + @Override public boolean isContentUrlSupported(String contentUrl) { try @@ -140,6 +149,7 @@ public abstract class AbstractContentStore implements ContentStore * * @since 2.1 */ + @Override public boolean delete(String contentUrl) { throw new UnsupportedOperationException(); @@ -148,6 +158,8 @@ public abstract class AbstractContentStore implements ContentStore /** * @see #getUrls(Date, Date, ContentUrlHandler) */ + @SuppressWarnings("deprecation") + @Override public final void getUrls(ContentUrlHandler handler) throws ContentIOException { getUrls(null, null, handler); @@ -159,6 +171,8 @@ public abstract class AbstractContentStore implements ContentStore * * @throws UnsupportedOperationException always */ + @SuppressWarnings("deprecation") + @Override public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException { throw new UnsupportedOperationException(); @@ -193,6 +207,7 @@ public abstract class AbstractContentStore implements ContentStore * @see #getWriterInternal(ContentReader, String) * @since 2.1 */ + @Override public ContentWriter getWriter(ContentContext context) { ContentReader existingContentReader = context.getExistingContentReader(); @@ -249,44 +264,18 @@ public abstract class AbstractContentStore implements ContentStore return writer; } - /** - * @see ContentContext - * @see ContentStore#getWriter(ContentContext) - */ - public final ContentWriter getWriter(ContentReader existingContentReader, String newContentUrl) - { - ContentContext ctx = new ContentContext(existingContentReader, newContentUrl); - return getWriter(ctx); - } - /** * Simple implementation that uses the * {@link ContentReader#exists() reader's exists} method as its implementation. * Override this method if a more efficient implementation is possible. */ + @Override public boolean exists(String contentUrl) { ContentReader reader = getReader(contentUrl); return reader.exists(); } - /** - * Uses {@link #getSpaceUsed()}, which is the equivalent method. This method is now - * final in order to catch any implementations that should switch over to {@link #getSpaceUsed()}. - */ - public final long getTotalSize() - { - return getSpaceUsed(); - } - - /** - * @return Returns -1 always - */ - public long getSpaceUsed() - { - return -1L; - } - /** * @return Returns -1 always */ @@ -306,15 +295,11 @@ public abstract class AbstractContentStore implements ContentStore } /** - * {@inheritDoc} + * @return Returns a '.' (period) always */ + @Override public String getRootLocation() { return "."; } - - public void setContentLimitProvider(ContentLimitProvider contentLimitProvider) - { - this.contentLimitProvider = contentLimitProvider; - } } diff --git a/source/java/org/alfresco/repo/content/AbstractRoutingContentStore.java b/source/java/org/alfresco/repo/content/AbstractRoutingContentStore.java index 4b8ce28a08..eb609827a4 100644 --- a/source/java/org/alfresco/repo/content/AbstractRoutingContentStore.java +++ b/source/java/org/alfresco/repo/content/AbstractRoutingContentStore.java @@ -251,23 +251,6 @@ public abstract class AbstractRoutingContentStore implements ContentStore return "."; } - /** - * Uses {@link #getSpaceUsed()}, which is the equivalent method. This method is now - * final in order to catch any implementations that should switch over to {@link #getSpaceUsed()}. - */ - public final long getTotalSize() - { - return getSpaceUsed(); - } - - /** - * @return Returns -1 always - */ - public long getSpaceUsed() - { - return -1L; - } - /** * @return Returns -1 always */ @@ -406,6 +389,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore /** * @see #getUrls(Date, Date, ContentUrlHandler) */ + @SuppressWarnings("deprecation") public void getUrls(ContentUrlHandler handler) throws ContentIOException { getUrls(null, null, handler); @@ -416,6 +400,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore * * @see ContentStore#getUrls(Date, Date, ContentUrlHandler) */ + @SuppressWarnings("deprecation") public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException { List stores = getAllStores(); diff --git a/source/java/org/alfresco/repo/content/ContentStore.java b/source/java/org/alfresco/repo/content/ContentStore.java index 7a521f6550..41b33868c0 100644 --- a/source/java/org/alfresco/repo/content/ContentStore.java +++ b/source/java/org/alfresco/repo/content/ContentStore.java @@ -97,32 +97,7 @@ public interface ContentStore public boolean isWriteSupported(); /** - * @deprecated Since 3.3.3 use {@link #getSpaceUsed()}. - * @see #getSpaceFree() - * @see #getSpaceTotal() - */ - public long getTotalSize(); - - /** - * Calculates the total size of stored content, excluding any other data in the underlying - * storage. - *

- * NOTE: Calculating this value can be time-consuming - use sparingly. - *

- * NOTE: For efficiency, some implementations may provide a guess. If not, this call could - * take a long time. - * - * @return - * Returns the total, possibly approximate size (in bytes) of the binary data stored or -1 - * if no size data is available. - * - * @since 3.3.3 - * @deprecated This method takes too long to complete in many situations (see ALF-12410). - */ - public long getSpaceUsed(); - - /** - * Calcualates the remaing free space in the underlying store. + * Calculates the remaning free space in the underlying store. *

* NOTE: For efficiency, some implementations may provide a guess. *

@@ -231,15 +206,6 @@ public interface ContentStore */ public ContentWriter getWriter(ContentContext context); - /** - * Shortcut method to {@link #getWriter(ContentContext)}. - * - * @see #getWriter(ContentContext) - * - * @deprecated - */ - public ContentWriter getWriter(ContentReader existingContentReader, String newContentUrl); - /** * Get all URLs for the store, regardless of creation time. * @return @@ -250,7 +216,11 @@ public interface ContentStore * if the store is unable to provide the information * * @see #getUrls(Date, Date) + * + * @deprecated in 5.0. The API is no longer used by Alfresco; + * efficient APIs can be provided by the implementations, if required */ + @Deprecated public void getUrls(ContentUrlHandler handler) throws ContentIOException; /** @@ -266,7 +236,11 @@ public interface ContentStore * if an error occurs * @throws UnsupportedOperationException * if the store is unable to provide the information + * + * @deprecated in 5.0. The API is no longer used by Alfresco; + * efficient APIs can be provided by the implementations, if required */ + @Deprecated public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException; /** @@ -294,7 +268,9 @@ public interface ContentStore * * @author Derek Hulley * @since 2.0 + * @deprecated in 5.0 */ + @Deprecated public interface ContentUrlHandler { void handle(String contentUrl); diff --git a/source/java/org/alfresco/repo/content/caching/CachingContentStore.java b/source/java/org/alfresco/repo/content/caching/CachingContentStore.java index d797bddf54..25c0c87101 100644 --- a/source/java/org/alfresco/repo/content/caching/CachingContentStore.java +++ b/source/java/org/alfresco/repo/content/caching/CachingContentStore.java @@ -92,81 +92,42 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis eventPublisher.publishEvent(new CachingContentStoreCreatedEvent(this)); } - /* - * @see org.alfresco.repo.content.ContentStore#isContentUrlSupported(java.lang.String) - */ @Override public boolean isContentUrlSupported(String contentUrl) { return backingStore.isContentUrlSupported(contentUrl); } - /* - * @see org.alfresco.repo.content.ContentStore#isWriteSupported() - */ @Override public boolean isWriteSupported() { return backingStore.isWriteSupported(); } - /* - * @see org.alfresco.repo.content.ContentStore#getTotalSize() - */ - @Override - public long getTotalSize() - { - return backingStore.getTotalSize(); - } - - /* - * @see org.alfresco.repo.content.ContentStore#getSpaceUsed() - */ - @Override - public long getSpaceUsed() - { - return backingStore.getSpaceUsed(); - } - - /* - * @see org.alfresco.repo.content.ContentStore#getSpaceFree() - */ @Override public long getSpaceFree() { return backingStore.getSpaceFree(); } - /* - * @see org.alfresco.repo.content.ContentStore#getSpaceTotal() - */ @Override public long getSpaceTotal() { return backingStore.getSpaceTotal(); } - /* - * @see org.alfresco.repo.content.ContentStore#getRootLocation() - */ @Override public String getRootLocation() { return backingStore.getRootLocation(); } - /* - * @see org.alfresco.repo.content.ContentStore#exists(java.lang.String) - */ @Override public boolean exists(String contentUrl) { return backingStore.exists(contentUrl); } - /* - * @see org.alfresco.repo.content.ContentStore#getReader(java.lang.String) - */ @Override public ContentReader getReader(String contentUrl) { @@ -284,9 +245,6 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis return reader; } - /* - * @see org.alfresco.repo.content.ContentStore#getWriter(org.alfresco.repo.content.ContentContext) - */ @Override public ContentWriter getWriter(final ContentContext context) { @@ -335,28 +293,14 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis } } - /* - * @see org.alfresco.repo.content.ContentStore#getWriter(org.alfresco.service.cmr.repository.ContentReader, java.lang.String) - */ - @Override - public ContentWriter getWriter(ContentReader existingContentReader, String newContentUrl) - { - ContentContext ctx = new ContentContext(existingContentReader, newContentUrl); - return getWriter(ctx); - } - - /* - * @see org.alfresco.repo.content.ContentStore#getUrls(org.alfresco.repo.content.ContentStore.ContentUrlHandler) - */ + @SuppressWarnings("deprecation") @Override public void getUrls(ContentUrlHandler handler) throws ContentIOException { backingStore.getUrls(handler); } - /* - * @see org.alfresco.repo.content.ContentStore#getUrls(java.util.Date, java.util.Date, org.alfresco.repo.content.ContentStore.ContentUrlHandler) - */ + @SuppressWarnings("deprecation") @Override public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException @@ -364,9 +308,6 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis backingStore.getUrls(createdAfter, createdBefore, handler); } - /* - * @see org.alfresco.repo.content.ContentStore#delete(java.lang.String) - */ @Override public boolean delete(String contentUrl) { diff --git a/source/java/org/alfresco/repo/content/filestore/FileContentStore.java b/source/java/org/alfresco/repo/content/filestore/FileContentStore.java index d6fb79e1c9..67a8d26979 100644 --- a/source/java/org/alfresco/repo/content/filestore/FileContentStore.java +++ b/source/java/org/alfresco/repo/content/filestore/FileContentStore.java @@ -123,7 +123,7 @@ public class FileContentStore { this(rootDirectoryStr); setApplicationContext(context); - publishEvent(context, Collections.EMPTY_MAP); + publishEvent(context, Collections. emptyMap()); } /** @@ -138,7 +138,7 @@ public class FileContentStore { this(rootDirectory); setApplicationContext(context); - publishEvent(context, Collections.EMPTY_MAP); + publishEvent(context, Collections. emptyMap()); } public FileContentStore(ApplicationContext context, File rootDirectory, Map extendedEventParams) @@ -513,6 +513,7 @@ public class FileContentStore * the handler * @return the urls */ + @SuppressWarnings("deprecation") public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) { // recursively get all files within the root @@ -533,6 +534,7 @@ public class FileContentStore * @param createdBefore only get URLs for content created before this date * @return a list of all files within the given directory and all subdirectories */ + @SuppressWarnings("deprecation") private void getUrls(File directory, ContentUrlHandler handler, Date createdAfter, Date createdBefore) { File[] files = directory.listFiles(); @@ -662,7 +664,7 @@ public class FileContentStore // (e.g. for monitoring purposes) if (event instanceof ContextRefreshedEvent && event.getSource() == this.applicationContext) { - publishEvent(((ContextRefreshedEvent) event).getApplicationContext(), Collections.EMPTY_MAP); + publishEvent(((ContextRefreshedEvent) event).getApplicationContext(), Collections. emptyMap()); } } diff --git a/source/java/org/alfresco/repo/content/replication/ContentStoreReplicator.java b/source/java/org/alfresco/repo/content/replication/ContentStoreReplicator.java index 0e59505b47..4e8f592529 100644 --- a/source/java/org/alfresco/repo/content/replication/ContentStoreReplicator.java +++ b/source/java/org/alfresco/repo/content/replication/ContentStoreReplicator.java @@ -18,6 +18,7 @@ */ package org.alfresco.repo.content.replication; +import org.alfresco.repo.content.ContentContext; import org.alfresco.repo.content.ContentStore; import org.alfresco.repo.content.ContentStore.ContentUrlHandler; import org.alfresco.repo.node.index.IndexRecovery; @@ -41,6 +42,7 @@ import org.quartz.JobExecutionException; * * @author Derek Hulley */ +@SuppressWarnings("deprecation") public class ContentStoreReplicator { private static Log logger = LogFactory.getLog(ContentStoreReplicator.class); @@ -54,6 +56,7 @@ public class ContentStoreReplicator public ContentStoreReplicator() { this.busy = false; + logger.warn("DEPRECATION: The ContentStoreReplicator component has been deprecated in 5.0 as it only works against optionally-implemented, deprecated APIs."); } /** @@ -192,7 +195,8 @@ public class ContentStoreReplicator return; } // get a writer to the target store - this can fail if the content is there now - ContentWriter writer = targetStore.getWriter(null, contentUrl); + ContentContext ctx = new ContentContext(null, contentUrl); + ContentWriter writer = targetStore.getWriter(ctx); // get the source reader ContentReader reader = sourceStore.getReader(contentUrl); if (!reader.exists()) diff --git a/source/java/org/alfresco/repo/content/replication/ReplicatingContentStore.java b/source/java/org/alfresco/repo/content/replication/ReplicatingContentStore.java index 7f3d7a1e8d..6853c6a14f 100644 --- a/source/java/org/alfresco/repo/content/replication/ReplicatingContentStore.java +++ b/source/java/org/alfresco/repo/content/replication/ReplicatingContentStore.java @@ -377,6 +377,7 @@ public class ReplicatingContentStore extends AbstractContentStore * Iterates over results as given by the primary store and all secondary stores. It is up to the handler to eliminate * duplicates that will occur between the primary and secondary stores. */ + @SuppressWarnings("deprecation") public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException { // add in URLs from primary store @@ -399,8 +400,6 @@ public class ReplicatingContentStore extends AbstractContentStore /** * Replicates the content upon stream closure. If the thread pool is available, * then the process will be asynchronous. - *

- * * @author Derek Hulley */ diff --git a/source/test-java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java b/source/test-java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java index cfd0a0e629..95d43b3335 100644 --- a/source/test-java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java +++ b/source/test-java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java @@ -109,6 +109,7 @@ public abstract class AbstractReadOnlyContentStoreTest extends TestCase * @return * Return any valid URL for the store, or null if the store is empty. */ + @SuppressWarnings("deprecation") protected String getExistingContentUrl() { ContentStore store = getStore(); diff --git a/source/test-java/org/alfresco/repo/content/AbstractWritableContentStoreTest.java b/source/test-java/org/alfresco/repo/content/AbstractWritableContentStoreTest.java index a029d30d7d..b05f63566a 100644 --- a/source/test-java/org/alfresco/repo/content/AbstractWritableContentStoreTest.java +++ b/source/test-java/org/alfresco/repo/content/AbstractWritableContentStoreTest.java @@ -50,6 +50,7 @@ import org.apache.commons.logging.LogFactory; * * @author Derek Hulley */ +@SuppressWarnings("deprecation") public abstract class AbstractWritableContentStoreTest extends AbstractReadOnlyContentStoreTest { private static Log logger = LogFactory.getLog(AbstractWritableContentStoreTest.class); @@ -98,15 +99,6 @@ public abstract class AbstractWritableContentStoreTest extends AbstractReadOnlyC assertTrue("The store cannot be read-only", store.isWriteSupported()); } - /** - * Just check that the method doesn't blow up - */ - public void testSpaceUsed() throws Exception - { - ContentStore store = getStore(); - store.getSpaceUsed(); - } - /** * Just checks that the method doesn't blow up */ diff --git a/source/test-java/org/alfresco/repo/content/RoutingContentStoreTest.java b/source/test-java/org/alfresco/repo/content/RoutingContentStoreTest.java index ab485916bd..9bc558a434 100644 --- a/source/test-java/org/alfresco/repo/content/RoutingContentStoreTest.java +++ b/source/test-java/org/alfresco/repo/content/RoutingContentStoreTest.java @@ -212,6 +212,7 @@ public class RoutingContentStoreTest extends AbstractWritableContentStoreTest return fileStore.getReader(contentUrl); } + @SuppressWarnings("deprecation") @Override public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException { @@ -239,11 +240,5 @@ public class RoutingContentStoreTest extends AbstractWritableContentStoreTest { throw new UnsupportedContentUrlException(this, contentUrl); } - - @Override - public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException - { - throw new UnsupportedOperationException("getUrls not supported"); - } } } diff --git a/source/test-java/org/alfresco/repo/content/caching/CachingContentStoreTest.java b/source/test-java/org/alfresco/repo/content/caching/CachingContentStoreTest.java index 550c140eca..7c76763429 100644 --- a/source/test-java/org/alfresco/repo/content/caching/CachingContentStoreTest.java +++ b/source/test-java/org/alfresco/repo/content/caching/CachingContentStoreTest.java @@ -34,12 +34,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.IOException; -import java.util.Date; import java.util.Locale; import org.alfresco.repo.content.ContentContext; import org.alfresco.repo.content.ContentStore; -import org.alfresco.repo.content.ContentStore.ContentUrlHandler; import org.alfresco.repo.content.caching.quota.QuotaManagerStrategy; import org.alfresco.repo.content.caching.quota.UnlimitedQuotaStrategy; import org.alfresco.service.cmr.repository.ContentIOException; @@ -398,22 +396,6 @@ public class CachingContentStoreTest } - @Test - public void delegatedGetTotalSize() - { - when(backingStore.getTotalSize()).thenReturn(234L); - assertEquals(234L, cachingStore.getTotalSize()); - } - - - @Test - public void delegatedGetSpaceUsed() - { - when(backingStore.getSpaceUsed()).thenReturn(453L); - assertEquals(453L, cachingStore.getSpaceUsed()); - } - - @Test public void delegatedGetSpaceFree() { @@ -449,30 +431,6 @@ public class CachingContentStoreTest } - @Test - public void delegatedGetUrls1() - { - ContentUrlHandler handler = createDummyUrlHandler(); - - cachingStore.getUrls(handler); - - verify(backingStore).getUrls(handler); - } - - - @Test - public void delegatedGetUrls2() - { - ContentUrlHandler handler = createDummyUrlHandler(); - Date after = new Date(123L); - Date before = new Date(456L); - - cachingStore.getUrls(after, before, handler); - - verify(backingStore).getUrls(after, before, handler); - } - - @Test public void delegatedDelete() { @@ -482,23 +440,4 @@ public class CachingContentStoreTest when(backingStore.delete("url")).thenReturn(false); assertFalse(cachingStore.delete("url")); } - - - /** - * Create a stub handler - just so we can check it has been passed around correctly. - * - * @return ContentUrlHandler - */ - private ContentUrlHandler createDummyUrlHandler() - { - ContentUrlHandler handler = new ContentUrlHandler() - { - @Override - public void handle(String contentUrl) - { - } - }; - return handler; - } - } diff --git a/source/test-java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java b/source/test-java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java index 9a07e4d8c4..4882b74fe5 100644 --- a/source/test-java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java +++ b/source/test-java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java @@ -42,7 +42,7 @@ import org.springframework.context.support.StaticApplicationContext; * * @author Derek Hulley */ -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "deprecation"}) public class ContentStoreReplicatorTest extends TestCase { private static final String SOME_CONTENT = "The No. 1 Ladies' Detective Agency";