MNT-20770: Share non responsive during direct download from S3 if content store selector is also configured (#654)

- 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
This commit is contained in:
Cristian Turlica
2019-11-05 14:30:42 +02:00
committed by GitHub
parent 67e9e5fbb7
commit 933161a914

View File

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