mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-24753 Restore from Archive when we have multiple content stores (#3066)
* Pre-commit changes * Method requestRestoreContentFromArchive needs to use injected ContentStore
This commit is contained in:
@@ -33,6 +33,9 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.cache.SimpleCache;
|
import org.alfresco.repo.cache.SimpleCache;
|
||||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||||
@@ -40,12 +43,9 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
|||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A store providing support for content store implementations that provide
|
* A store providing support for content store implementations that provide routing of content read and write requests based on context.
|
||||||
* routing of content read and write requests based on context.
|
|
||||||
*
|
*
|
||||||
* @see ContentContext
|
* @see ContentContext
|
||||||
*
|
*
|
||||||
@@ -69,7 +69,8 @@ public abstract class AbstractRoutingContentStore implements ContentStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param storesCache cache of stores used to access URLs
|
* @param storesCache
|
||||||
|
* cache of stores used to access URLs
|
||||||
*/
|
*/
|
||||||
public void setStoresCache(SimpleCache<Pair<String, String>, ContentStore> storesCache)
|
public void setStoresCache(SimpleCache<Pair<String, String>, ContentStore> storesCache)
|
||||||
{
|
{
|
||||||
@@ -82,21 +83,19 @@ public abstract class AbstractRoutingContentStore implements ContentStore
|
|||||||
protected abstract List<ContentStore> getAllStores();
|
protected abstract List<ContentStore> getAllStores();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a content store based on the context provided. The applicability of the
|
* Get a content store based on the context provided. The applicability of the context and even the types of context allowed are up to the implementation, but normally there should be a fallback case for when the parameters are not adequate to make a decision.
|
||||||
* context and even the types of context allowed are up to the implementation, but
|
|
||||||
* normally there should be a fallback case for when the parameters are not adequate
|
|
||||||
* to make a decision.
|
|
||||||
*
|
*
|
||||||
* @param ctx the context to use to make the choice
|
* @param ctx
|
||||||
* @return Returns the store most appropriate for the given context and
|
* the context to use to make the choice
|
||||||
* <b>never <tt>null</tt></b>
|
* @return Returns the store most appropriate for the given context and <b>never <tt>null</tt></b>
|
||||||
*/
|
*/
|
||||||
protected abstract ContentStore selectWriteStore(ContentContext ctx);
|
protected abstract ContentStore selectWriteStore(ContentContext ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the cache for the store and ensures that the URL is in the store.
|
* Checks the cache for the store and ensures that the URL is in the store.
|
||||||
*
|
*
|
||||||
* @param contentUrl the content URL to search for
|
* @param contentUrl
|
||||||
|
* the content URL to search for
|
||||||
* @return Returns the store matching the content URL
|
* @return Returns the store matching the content URL
|
||||||
*/
|
*/
|
||||||
private ContentStore selectReadStore(String contentUrl)
|
private ContentStore selectReadStore(String contentUrl)
|
||||||
@@ -288,8 +287,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns a valid reader from one of the stores otherwise
|
* @return Returns a valid reader from one of the stores otherwise a {@link EmptyContentReader} is returned.
|
||||||
* a {@link EmptyContentReader} is returned.
|
|
||||||
*/
|
*/
|
||||||
public ContentReader getReader(String contentUrl) throws ContentIOException
|
public ContentReader getReader(String contentUrl) throws ContentIOException
|
||||||
{
|
{
|
||||||
@@ -335,13 +333,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore
|
|||||||
{
|
{
|
||||||
throw new ContentExistsException(this, contentUrl);
|
throw new ContentExistsException(this, contentUrl);
|
||||||
}
|
}
|
||||||
/*
|
/* We could go further and check each store for the existence of the URL, but that would be overkill. The main problem we need to prevent is the simultaneous access of the same store. The router represents a single store and therefore if the URL is present in any of the stores, it is effectively present in all of them. */
|
||||||
* We could go further and check each store for the existence of the URL,
|
|
||||||
* but that would be overkill. The main problem we need to prevent is
|
|
||||||
* the simultaneous access of the same store. The router represents
|
|
||||||
* a single store and therefore if the URL is present in any of the stores,
|
|
||||||
* it is effectively present in all of them.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -396,8 +388,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This operation has to be performed on all the stores in order to maintain the
|
* This operation has to be performed on all the stores in order to maintain the {@link ContentStore#exists(String)} contract.
|
||||||
* {@link ContentStore#exists(String)} contract.
|
|
||||||
*/
|
*/
|
||||||
public boolean delete(String contentUrl) throws ContentIOException
|
public boolean delete(String contentUrl) throws ContentIOException
|
||||||
{
|
{
|
||||||
@@ -470,7 +461,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore
|
|||||||
}
|
}
|
||||||
final String message = "Restoring content from archive: ";
|
final String message = "Restoring content from archive: ";
|
||||||
logExecution(contentUrl, contentStore, message);
|
logExecution(contentUrl, contentStore, message);
|
||||||
return ContentStore.super.requestRestoreContentFromArchive(contentUrl, restoreParams);
|
return contentStore.requestRestoreContentFromArchive(contentUrl, restoreParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logExecution(final String contentUrl, final ContentStore contentStore, final String message)
|
private void logExecution(final String contentUrl, final ContentStore contentStore, final String message)
|
||||||
|
Reference in New Issue
Block a user