Allow other types of content URLs other than store://...

Enforce restriction that all content URLs must be of form protocol://identifier
Allow for read-only stores.
Improved tests so that it is easier, when writing a new store, to determine if the store is compliant or not.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5899 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-06-09 00:43:02 +00:00
parent 9b03b15674
commit f30ccf8d6c
28 changed files with 1685 additions and 628 deletions

View File

@@ -30,6 +30,7 @@ import java.util.Set;
import junit.framework.TestCase;
import org.alfresco.repo.content.AbstractContentStore;
import org.alfresco.repo.content.ContentContext;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.content.filestore.FileContentStore;
import org.alfresco.service.cmr.repository.ContentWriter;
@@ -76,7 +77,7 @@ public class ContentStoreReplicatorTest extends TestCase
*/
public void testSinglePassReplication() throws Exception
{
ContentWriter writer = sourceStore.getWriter(null, null);
ContentWriter writer = sourceStore.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
writer.putContent("123");
// replicate
@@ -92,7 +93,7 @@ public class ContentStoreReplicatorTest extends TestCase
targetStore.exists(writer.getContentUrl()));
// this was a single pass, so now more replication should be done
writer = sourceStore.getWriter(null, null);
writer = sourceStore.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
writer.putContent("456");
// wait a second
@@ -119,21 +120,22 @@ public class ContentStoreReplicatorTest extends TestCase
{
replicator.start();
String duplicateUrl = AbstractContentStore.createNewUrl();
String duplicateUrl = null;
// start the replicator - it won't wait between iterations
for (int i = 0; i < 10; i++)
{
// put some content into both the target and source
duplicateUrl = AbstractContentStore.createNewUrl();
ContentWriter duplicateTargetWriter = targetStore.getWriter(null, duplicateUrl);
ContentWriter duplicateSourceWriter = sourceStore.getWriter(null, duplicateUrl);
ContentWriter duplicateSourceWriter = sourceStore.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
duplicateUrl = duplicateSourceWriter.getContentUrl();
ContentContext targetContentCtx = new ContentContext(null, duplicateUrl);
ContentWriter duplicateTargetWriter = targetStore.getWriter(targetContentCtx);
duplicateTargetWriter.putContent("Duplicate Target Content: " + i);
duplicateSourceWriter.putContent(duplicateTargetWriter.getReader());
for (int j = 0; j < 100; j++)
{
// write content
ContentWriter writer = sourceStore.getWriter(null, null);
ContentWriter writer = sourceStore.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
writer.putContent("Repeated put: " + j);
}
}

View File

@@ -202,6 +202,23 @@ public class ReplicatingContentStore extends AbstractContentStore
this.outboundThreadPoolExecutor = outboundThreadPoolExecutor;
}
/**
* @return Returns <tt>true</tt> if the primary store supports writing
*/
public boolean isWriteSupported()
{
return primaryStore.isWriteSupported();
}
/**
* @return Returns <tt>true</tt> if the primary store supports the URL
*/
@Override
public boolean isContentUrlSupported(String contentUrl)
{
return primaryStore.isContentUrlSupported(contentUrl);
}
/**
* Forwards the call directly to the first store in the list of stores.
*/
@@ -444,6 +461,13 @@ public class ReplicatingContentStore extends AbstractContentStore
" to store: " + store);
}
}
catch (UnsupportedOperationException e)
{
throw new ContentIOException(
"Unable to replicate content. The target store doesn't support replication: \n" +
" Content: " + writer.getContentUrl() + "\n" +
" To Store: " + store);
}
catch (Throwable e)
{
throw new ContentIOException("Content replication failed: \n" +

View File

@@ -32,7 +32,7 @@ import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.alfresco.repo.content.AbstractContentReadWriteTest;
import org.alfresco.repo.content.AbstractWritableContentStoreTest;
import org.alfresco.repo.content.ContentContext;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.content.filestore.FileContentStore;
@@ -51,7 +51,7 @@ import org.alfresco.util.TempFileProvider;
*
* @author Derek Hulley
*/
public class ReplicatingContentStoreTest extends AbstractContentReadWriteTest
public class ReplicatingContentStoreTest extends AbstractWritableContentStoreTest
{
private static final String SOME_CONTENT = "The No. 1 Ladies' Detective Agency";