mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-20770: Share non responsive during direct download from S3 if content store selector is also configured
- add specific implementation for exists to bypass getting the complete reader and in some cases (e.g. aggregating a CachingContentStore) trigger a complete download of the file
cherry-picked from 933161a
master to support/SP/7.N
This commit is contained in:
@@ -34,6 +34,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.content.AbstractContentStore;
|
||||
import org.alfresco.repo.content.ContentContext;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.content.UnsupportedContentUrlException;
|
||||
import org.alfresco.repo.content.caching.CachingContentStore;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
@@ -166,6 +167,76 @@ public class AggregatingContentStore extends AbstractContentStore
|
||||
}
|
||||
}
|
||||
|
||||
public boolean exists(String contentUrl)
|
||||
{
|
||||
if (primaryStore == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("ReplicatingContentStore not initialised");
|
||||
}
|
||||
|
||||
// get a read lock so that we are sure that no replication is underway
|
||||
readLock.lock();
|
||||
try
|
||||
{
|
||||
// Keep track of the unsupported state of the content URL - it might be a rubbish URL
|
||||
boolean contentUrlSupported = false;
|
||||
|
||||
boolean contentUrlExists = false;
|
||||
|
||||
// Check the primary store
|
||||
try
|
||||
{
|
||||
contentUrlExists = primaryStore.exists(contentUrl);
|
||||
|
||||
// At least the content URL was supported
|
||||
contentUrlSupported = true;
|
||||
}
|
||||
catch (UnsupportedContentUrlException e)
|
||||
{
|
||||
// The store can't handle the content URL
|
||||
}
|
||||
|
||||
if (contentUrlExists)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// the content is not in the primary store so we have to go looking for it
|
||||
for (ContentStore store : secondaryStores)
|
||||
{
|
||||
contentUrlExists = false;
|
||||
try
|
||||
{
|
||||
contentUrlExists = store.exists(contentUrl);
|
||||
|
||||
// At least the content URL was supported
|
||||
contentUrlSupported = true;
|
||||
}
|
||||
catch (UnsupportedContentUrlException e)
|
||||
{
|
||||
// The store can't handle the content URL
|
||||
}
|
||||
|
||||
if (contentUrlExists)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the content URL was supported
|
||||
if (!contentUrlSupported)
|
||||
{
|
||||
throw new UnsupportedContentUrlException(this, contentUrl);
|
||||
}
|
||||
|
||||
return contentUrlExists;
|
||||
}
|
||||
finally
|
||||
{
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public ContentWriter getWriter(ContentContext ctx)
|
||||
{
|
||||
// get the writer
|
||||
|
Reference in New Issue
Block a user