Make sure that ContentStoreCleaner doesn't clean up in-use

AVM content. Doh!


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3612 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-25 14:00:32 +00:00
parent 0606fa3ab6
commit e2c66899cc
7 changed files with 68 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMNodeDAO;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.node.db.NodeDaoService;
import org.alfresco.repo.transaction.TransactionUtil;
@@ -49,6 +50,7 @@ public class ContentStoreCleaner
private DictionaryService dictionaryService;
private NodeDaoService nodeDaoService;
private TransactionService transactionService;
private AVMNodeDAO avmNodeDAO;
private List<ContentStore> stores;
private List<ContentStoreCleanerListener> listeners;
private int protectDays;
@@ -76,6 +78,15 @@ public class ContentStoreCleaner
this.nodeDaoService = nodeDaoService;
}
/**
* Setter for Spring.
* @param avmNodeDAO The AVM Node DAO to get urls with.
*/
public void setAvmNodeDAO(AVMNodeDAO avmNodeDAO)
{
this.avmNodeDAO = avmNodeDAO;
}
/**
* @param transactionService the component to ensure proper transactional wrapping
*/
@@ -152,6 +163,7 @@ public class ContentStoreCleaner
private Set<String> getValidUrls()
{
// This does the work for the regular Alfresco repository.
// wrap to make the request in a transaction
TransactionWork<List<String>> getUrlsWork = new TransactionWork<List<String>>()
{
@@ -166,6 +178,20 @@ public class ContentStoreCleaner
getUrlsWork,
true);
// Do the same for the AVM repository.
TransactionWork<List<String>> getAVMUrlsWork = new TransactionWork<List<String>>()
{
public List<String> doWork() throws Exception
{
return avmNodeDAO.getContentUrls();
}
};
List<String> avmContentUrls = TransactionUtil.executeInUserTransaction(
transactionService,
getAVMUrlsWork,
true);
// get all valid URLs
Set<String> validUrls = new HashSet<String>(contentDataStrings.size());
// convert the strings to objects and extract the URL
@@ -178,6 +204,12 @@ public class ContentStoreCleaner
validUrls.add(contentData.getContentUrl());
}
}
// put all the avm urls into validUrls.
for (String url : avmContentUrls)
{
validUrls.add(url);
}
// done
if (logger.isDebugEnabled())
{

View File

@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.alfresco.repo.avm.AVMNodeDAO;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.content.filestore.FileContentStore;
import org.alfresco.repo.node.db.NodeDaoService;
@@ -56,6 +57,7 @@ public class ContentStoreCleanerTest extends TestCase
TransactionService transactionService = serviceRegistry.getTransactionService();
DictionaryService dictionaryService = serviceRegistry.getDictionaryService();
NodeDaoService nodeDaoService = (NodeDaoService) ctx.getBean("nodeDaoService");
AVMNodeDAO avmNodeDAO = (AVMNodeDAO) ctx.getBean("avmNodeDAO");
// we need a store
store = new FileContentStore(TempFileProvider.getTempDir().getAbsolutePath());
@@ -69,6 +71,7 @@ public class ContentStoreCleanerTest extends TestCase
cleaner.setTransactionService(transactionService);
cleaner.setDictionaryService(dictionaryService);
cleaner.setNodeDaoService(nodeDaoService);
cleaner.setAvmNodeDAO(avmNodeDAO);
cleaner.setStores(Collections.singletonList(store));
cleaner.setListeners(Collections.singletonList(listener));
}