Another lookup cache checkpoint.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4407 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-11-21 01:46:55 +00:00
parent 837095a411
commit 75f3c91b12
5 changed files with 124 additions and 4 deletions

View File

@@ -0,0 +1,44 @@
/**
*
*/
package org.alfresco.repo.avm;
import org.alfresco.repo.transaction.TransactionListenerAdapter;
/**
* This is the listener that cleans up the lookup cache on transaction
* rollback.
* @author britt
*/
public class AVMLookupCacheListener extends TransactionListenerAdapter
{
/**
* The lookup cache.
*/
private LookupCache fLookupCache;
/**
* A default constructor.
*/
public AVMLookupCacheListener()
{
}
/**
* Set the Lookup Cache.
* @param lookupCache
*/
public void setLookupCache(LookupCache lookupCache)
{
fLookupCache = lookupCache;
}
/* (non-Javadoc)
* @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterRollback()
*/
@Override
public void afterRollback()
{
fLookupCache.onRollback();
}
}

View File

@@ -30,6 +30,8 @@ import java.util.SortedMap;
import org.alfresco.repo.avm.AVMRepository;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionListener;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMExistsException;
@@ -63,6 +65,8 @@ public class AVMServiceImpl implements AVMService
*/
private AVMRepository fAVMRepository;
private TransactionListener fTransactionListener;
/**
* Basic constructor for the service.
*/
@@ -79,6 +83,15 @@ public class AVMServiceImpl implements AVMService
fAVMRepository = avmRepository;
}
/**
* Set the transaction listener.
* @param transactionListener
*/
public void setTransactionListener(TransactionListener transactionListener)
{
fTransactionListener = transactionListener;
}
/**
* Get an InputStream from a file.
* @param version The version to look under.
@@ -104,6 +117,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.getOutputStream(path);
}
@@ -133,6 +147,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.createContentWriter(path);
}
@@ -324,6 +339,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.createFile(path, name);
}
@@ -340,6 +356,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
// Save the contents to temp space.
File temp;
try
@@ -380,6 +397,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createDirectory(path, name);
}
@@ -396,6 +414,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createLayeredFile(srcPath, parent, name);
}
@@ -412,6 +431,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createLayeredDirectory(srcPath, parent, name);
}
@@ -443,6 +463,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createBranch(version, srcPath, dstPath, name);
}
@@ -458,6 +479,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.remove(parent, name);
}
@@ -476,6 +498,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Cannot remove root node.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.remove(basePath[0], basePath[1]);
}
@@ -494,6 +517,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.rename(srcParent, srcName, dstParent, dstName);
}
@@ -508,6 +532,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.uncover(dirPath, name);
}
@@ -523,6 +548,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.flatten(dirPath, name);
}
@@ -802,6 +828,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.retargetLayeredDirectory(path, target);
}
@@ -815,6 +842,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Path is null.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.makePrimary(path);
}
@@ -906,6 +934,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setOpacity(path, opacity);
}
@@ -956,6 +985,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setNodeProperty(path, name, value);
}
@@ -970,6 +1000,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setNodeProperties(path, properties);
}
@@ -1015,6 +1046,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.deleteNodeProperty(path, name);
}
@@ -1028,6 +1060,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.deleteNodeProperties(path);
}
@@ -1130,6 +1163,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Invalid null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.deleteStoreProperty(store, name);
}
@@ -1159,6 +1193,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null Path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.getContentDataForWrite(path);
}
@@ -1176,6 +1211,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null Path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setContentData(path, data);
}
@@ -1190,6 +1226,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setMetaDataFrom(path, from);
}
@@ -1206,6 +1243,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.addAspect(path, aspectName);
}
@@ -1235,6 +1273,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.removeAspect(path, aspectName);
}
@@ -1266,6 +1305,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.link(parentPath, name, toLink);
}
@@ -1279,6 +1319,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null Path.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.forceCopy(path);
}
@@ -1317,6 +1358,7 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal name.");
}
AlfrescoTransactionSupport.bindListener(fTransactionListener);
AVMNodeDescriptor srcDesc = lookup(srcVersion, srcPath);
recursiveCopy(srcVersion, srcDesc, dstPath, name);
}

View File

@@ -84,6 +84,31 @@ class Lookup
*/
private boolean fNeedsCopying;
public Lookup(Lookup other, AVMNodeDAO nodeDAO, AVMStoreDAO storeDAO)
{
fAVMStore = storeDAO.getByName(other.fAVMStore.getName());
fStoreName = fAVMStore.getName();
fComponents = new ArrayList<LookupComponent>();
fLayeredYet = other.fLayeredYet;
if (other.fTopLayer != null)
{
fTopLayer = (LayeredDirectoryNode)nodeDAO.getByID(other.fTopLayer.getId());
}
fPosition = other.fPosition;
fTopLayerIndex = other.fTopLayerIndex;
fLowestLayerIndex = other.fLowestLayerIndex;
fNeedsCopying = other.fNeedsCopying;
fDirectlyContained = other.fDirectlyContained;
for (LookupComponent comp : other.fComponents)
{
LookupComponent newComp = new LookupComponent();
newComp.setName(comp.getName());
newComp.setIndirection(comp.getIndirection());
newComp.setNode(nodeDAO.getByID(comp.getNode().getId()));
fComponents.add(newComp);
}
}
/**
* Create a new one.
* @param store The AVMStore that's being looked in.