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:
Eva Vasques
2024-12-02 14:22:51 +00:00
committed by GitHub
parent 26d8c7dcbe
commit 37231e50a2

View File

@@ -33,6 +33,9 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
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.repo.cache.SimpleCache;
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.util.GUID;
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
* routing of content read and write requests based on context.
* A store providing support for content store implementations that provide routing of content read and write requests based on context.
*
* @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)
{
@@ -82,21 +83,19 @@ public abstract class AbstractRoutingContentStore implements ContentStore
protected abstract List<ContentStore> getAllStores();
/**
* 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.
* 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.
*
* @param ctx the context to use to make the choice
* @return Returns the store most appropriate for the given context and
* <b>never <tt>null</tt></b>
* @param ctx
* the context to use to make the choice
* @return Returns the store most appropriate for the given context and <b>never <tt>null</tt></b>
*/
protected abstract ContentStore selectWriteStore(ContentContext ctx);
/**
* 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
*/
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
* a {@link EmptyContentReader} is returned.
* @return Returns a valid reader from one of the stores otherwise a {@link EmptyContentReader} is returned.
*/
public ContentReader getReader(String contentUrl) throws ContentIOException
{
@@ -335,13 +333,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore
{
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
{
@@ -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
* {@link ContentStore#exists(String)} contract.
* This operation has to be performed on all the stores in order to maintain the {@link ContentStore#exists(String)} contract.
*/
public boolean delete(String contentUrl) throws ContentIOException
{
@@ -470,7 +461,7 @@ public abstract class AbstractRoutingContentStore implements ContentStore
}
final String message = "Restoring content from archive: ";
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)