From 8c2ad19b2f3f25e67485832f23bf37d1a38101d6 Mon Sep 17 00:00:00 2001 From: Britt Park Date: Mon, 4 Sep 2006 14:14:39 +0000 Subject: [PATCH] OrphanReaper now cleans up content as well. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3678 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/repo/avm/AVMStoreImpl.java | 15 ------------- .../org/alfresco/repo/avm/OrphanReaper.java | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java index 75d159fe8b..2825238fae 100644 --- a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java +++ b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java @@ -316,18 +316,6 @@ public class AVMStoreImpl implements AVMStore, Serializable throw new AVMNotFoundException(path + " has no content."); } return reader.getContentInputStream(); - /* - Lookup lPath = lookup(version, path, false); - AVMNode node = lPath.getCurrentNode(); - if (node.getType() != AVMNodeType.PLAIN_FILE && - node.getType() != AVMNodeType.LAYERED_FILE) - { - throw new AVMExistsException("Not a file: " + path + " r " + version); - } - FileNode file = (FileNode)node; - FileContent content = file.getContentForRead(); - return content.getInputStream(); - */ } /** @@ -352,9 +340,6 @@ public class AVMStoreImpl implements AVMStore, Serializable NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, fName + ":" + path); ContentWriter writer = AVMContext.fgInstance.getContentService().getWriter(nodeRef, ContentModel.PROP_CONTENT, true); - // TODO This can't perform very well. What this gets down to - // is that integration with ContentService is awkward. - // setContentData(path, writer.getContentData()); return writer; } diff --git a/source/java/org/alfresco/repo/avm/OrphanReaper.java b/source/java/org/alfresco/repo/avm/OrphanReaper.java index 1634c8dbe8..bef0793a6c 100644 --- a/source/java/org/alfresco/repo/avm/OrphanReaper.java +++ b/source/java/org/alfresco/repo/avm/OrphanReaper.java @@ -22,8 +22,7 @@ import java.util.List; import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.service.transaction.TransactionService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Logger; /** * This is the background thread for reaping no longer referenced nodes @@ -32,7 +31,7 @@ import org.apache.commons.logging.LogFactory; */ public class OrphanReaper implements Runnable { - private Log fgLogger = LogFactory.getLog(OrphanReaper.class); + private Logger fgLogger = Logger.getLogger(OrphanReaper.class); /** * The Transaction Service @@ -122,6 +121,10 @@ public class OrphanReaper implements Runnable fBatchSize = size; } + /** + * Set the transaction service. + * @param transactionService The service. + */ public void setTransactionService(TransactionService transactionService) { fTransactionService = transactionService; @@ -290,13 +293,17 @@ public class OrphanReaper implements Runnable // More special work for layered directories. AVMContext.fgInstance.fDeletedChildDAO.deleteByParent(node); } - AVMContext.fgInstance.fAVMNodeDAO.delete(node); } - // TODO Need to properly clean up deleted files. - else + else if (node.getType() == AVMNodeType.PLAIN_FILE) { - AVMContext.fgInstance.fAVMNodeDAO.delete(node); + PlainFileNode file = (PlainFileNode)node; + String url = file.getContentData(null).getContentUrl(); + if (url != null) + { + AVMContext.fgInstance.getContentStore().delete(url); + } } + AVMContext.fgInstance.fAVMNodeDAO.delete(node); } return null; }