Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Raluca Munteanu
2016-04-26 13:03:25 +00:00
parent 8674e2bfc8
commit dc6b2852d0
830 changed files with 142585 additions and 142585 deletions

View File

@@ -1,197 +1,197 @@
package org.alfresco.repo.content.replication;
import java.util.Date;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
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.caching.CachingContentStore;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* </h1><u>Aggregating Content Store</u></h1>
* <p>
* A content store implementation that aggregates a set of stores. Content is not
* persisted by this store, but rather it relies on any number of
* child {@link org.alfresco.repo.content.ContentStore stores} to provide access
* to content readers and writers.
* <p>
* The order in which the stores appear in the list of stores participating is
* important. The first store in the list is known as the <i>primary store</i>.
<p>
* Content is written to the primary store only. The other stores are
* only used to retrieve content and the primary store is not updated with
* the content.
*
* @author Derek Hulley
* @author Mark Rogers
* @see CachingContentStore
*/
public class AggregatingContentStore extends AbstractContentStore
{
private static Log logger = LogFactory.getLog(AggregatingContentStore.class);
private ContentStore primaryStore;
private List<ContentStore> secondaryStores;
private Lock readLock;
private Lock writeLock;
/**
* Default constructor
*/
public AggregatingContentStore()
{
ReadWriteLock storeLock = new ReentrantReadWriteLock();
readLock = storeLock.readLock();
writeLock = storeLock.writeLock();
}
/**
* Set the primary store that content will be replicated to or from
*
* @param primaryStore the primary content store
*/
public void setPrimaryStore(ContentStore primaryStore)
{
this.primaryStore = primaryStore;
}
/**
* Set the secondary stores that this component will replicate to or from
*
* @param secondaryStores a list of stores to replicate to or from
*/
public void setSecondaryStores(List<ContentStore> secondaryStores)
{
this.secondaryStores = secondaryStores;
}
/**
* @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);
}
/**
* @return Return the primary store root location
*/
@Override
public String getRootLocation()
{
return primaryStore.getRootLocation();
}
/**
* Forwards the call directly to the first store in the list of stores.
*/
public ContentReader getReader(String contentUrl) throws ContentIOException
{
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
{
// get a reader from the primary store
ContentReader primaryReader = primaryStore.getReader(contentUrl);
// give it straight back if the content is there
if (primaryReader.exists())
{
return primaryReader;
}
// the content is not in the primary reader so we have to go looking for it
ContentReader secondaryContentReader = null;
for (ContentStore store : secondaryStores)
{
ContentReader reader = store.getReader(contentUrl);
if (reader.exists())
{
// found the content in a secondary store
return reader;
}
}
return primaryReader;
}
finally
{
readLock.unlock();
}
}
public ContentWriter getWriter(ContentContext ctx)
{
// get the writer
ContentWriter writer = primaryStore.getWriter(ctx);
return writer;
}
/**
* Performs a delete on the local store and if outbound replication is on, propogates
* the delete to the other stores too.
*
* @return Returns the value returned by the delete on the primary store.
*/
public boolean delete(String contentUrl) throws ContentIOException
{
// delete on the primary store
boolean deleted = primaryStore.delete(contentUrl);
if (logger.isDebugEnabled())
{
logger.debug("Deleted content for URL: " + contentUrl);
}
return deleted;
}
/**
* Iterates over results as given by the primary store and all secondary stores. It is up to the handler to eliminate
* duplicates that will occur between the primary and secondary stores.
*/
@SuppressWarnings("deprecation")
public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException
{
// add in URLs from primary store
primaryStore.getUrls(createdAfter, createdBefore, handler);
// add in URLs from secondary stores (they are visible for reads)
for (ContentStore secondaryStore : secondaryStores)
{
secondaryStore.getUrls(createdAfter, createdBefore, handler);
}
// done
if (logger.isDebugEnabled())
{
logger.debug("Iterated over content URLs: \n" +
" created after: " + createdAfter + "\n" +
" created before: " + createdBefore);
}
}
}
package org.alfresco.repo.content.replication;
import java.util.Date;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
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.caching.CachingContentStore;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* </h1><u>Aggregating Content Store</u></h1>
* <p>
* A content store implementation that aggregates a set of stores. Content is not
* persisted by this store, but rather it relies on any number of
* child {@link org.alfresco.repo.content.ContentStore stores} to provide access
* to content readers and writers.
* <p>
* The order in which the stores appear in the list of stores participating is
* important. The first store in the list is known as the <i>primary store</i>.
<p>
* Content is written to the primary store only. The other stores are
* only used to retrieve content and the primary store is not updated with
* the content.
*
* @author Derek Hulley
* @author Mark Rogers
* @see CachingContentStore
*/
public class AggregatingContentStore extends AbstractContentStore
{
private static Log logger = LogFactory.getLog(AggregatingContentStore.class);
private ContentStore primaryStore;
private List<ContentStore> secondaryStores;
private Lock readLock;
private Lock writeLock;
/**
* Default constructor
*/
public AggregatingContentStore()
{
ReadWriteLock storeLock = new ReentrantReadWriteLock();
readLock = storeLock.readLock();
writeLock = storeLock.writeLock();
}
/**
* Set the primary store that content will be replicated to or from
*
* @param primaryStore the primary content store
*/
public void setPrimaryStore(ContentStore primaryStore)
{
this.primaryStore = primaryStore;
}
/**
* Set the secondary stores that this component will replicate to or from
*
* @param secondaryStores a list of stores to replicate to or from
*/
public void setSecondaryStores(List<ContentStore> secondaryStores)
{
this.secondaryStores = secondaryStores;
}
/**
* @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);
}
/**
* @return Return the primary store root location
*/
@Override
public String getRootLocation()
{
return primaryStore.getRootLocation();
}
/**
* Forwards the call directly to the first store in the list of stores.
*/
public ContentReader getReader(String contentUrl) throws ContentIOException
{
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
{
// get a reader from the primary store
ContentReader primaryReader = primaryStore.getReader(contentUrl);
// give it straight back if the content is there
if (primaryReader.exists())
{
return primaryReader;
}
// the content is not in the primary reader so we have to go looking for it
ContentReader secondaryContentReader = null;
for (ContentStore store : secondaryStores)
{
ContentReader reader = store.getReader(contentUrl);
if (reader.exists())
{
// found the content in a secondary store
return reader;
}
}
return primaryReader;
}
finally
{
readLock.unlock();
}
}
public ContentWriter getWriter(ContentContext ctx)
{
// get the writer
ContentWriter writer = primaryStore.getWriter(ctx);
return writer;
}
/**
* Performs a delete on the local store and if outbound replication is on, propogates
* the delete to the other stores too.
*
* @return Returns the value returned by the delete on the primary store.
*/
public boolean delete(String contentUrl) throws ContentIOException
{
// delete on the primary store
boolean deleted = primaryStore.delete(contentUrl);
if (logger.isDebugEnabled())
{
logger.debug("Deleted content for URL: " + contentUrl);
}
return deleted;
}
/**
* Iterates over results as given by the primary store and all secondary stores. It is up to the handler to eliminate
* duplicates that will occur between the primary and secondary stores.
*/
@SuppressWarnings("deprecation")
public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException
{
// add in URLs from primary store
primaryStore.getUrls(createdAfter, createdBefore, handler);
// add in URLs from secondary stores (they are visible for reads)
for (ContentStore secondaryStore : secondaryStores)
{
secondaryStore.getUrls(createdAfter, createdBefore, handler);
}
// done
if (logger.isDebugEnabled())
{
logger.debug("Iterated over content URLs: \n" +
" created after: " + createdAfter + "\n" +
" created before: " + createdBefore);
}
}
}