Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

77148: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      73957: ContentStore API cleanup
       - Removed previously-deprecated ContentStore.getWriter(ContentReader existingContentReader, String newContentUrl)
       - Removed previously-deprecated getSpaceUsed()
       - Removed previously-deprecated getTotalSize()
       - Deprecated optional and unused getUrls() and variants
       - Clean up of implementations to ignore relevant deprecations, etc


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@78004 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2014-07-23 15:57:20 +00:00
parent 7fff2b6627
commit f1310c6c8d
13 changed files with 49 additions and 230 deletions

View File

@@ -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 <tt>-1</tt> always
*/
public long getSpaceUsed()
{
return -1L;
}
/**
* @return Returns <tt>-1</tt> 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;
}
}

View File

@@ -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 <tt>-1</tt> always
*/
public long getSpaceUsed()
{
return -1L;
}
/**
* @return Returns <tt>-1</tt> 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<ContentStore> stores = getAllStores();

View File

@@ -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 <b>stored content</b>, excluding any other data in the underlying
* storage.
* <p/>
* <b>NOTE:</b> Calculating this value can be time-consuming - use sparingly.
* <p/>
* <b>NOTE:</b> 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 <tt>-1</tt>
* 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 <i>free</i> space in the underlying store.
* Calculates the remaning <i>free</i> space in the underlying store.
* <p>
* <b>NOTE:</b> For efficiency, some implementations may provide a guess.
* <p>
@@ -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);

View File

@@ -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)
{

View File

@@ -123,7 +123,7 @@ public class FileContentStore
{
this(rootDirectoryStr);
setApplicationContext(context);
publishEvent(context, Collections.EMPTY_MAP);
publishEvent(context, Collections.<String, Serializable> emptyMap());
}
/**
@@ -138,7 +138,7 @@ public class FileContentStore
{
this(rootDirectory);
setApplicationContext(context);
publishEvent(context, Collections.EMPTY_MAP);
publishEvent(context, Collections.<String, Serializable> emptyMap());
}
public FileContentStore(ApplicationContext context, File rootDirectory, Map<String, Serializable> 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.<String, Serializable> emptyMap());
}
}

View File

@@ -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())

View File

@@ -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.
* <p>
*
* @author Derek Hulley
*/