- Expired content job now uses a query to find expired items rather than crawling all nodes

- Fixed bug when handling expired items submitted by users removed from web project
- Re-applied config for comments in manage task dialogs
- Re-applied config for expired items actions
- Removed fix width for comment column in workflow history

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5811 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2007-05-30 12:08:36 +00:00
parent 299f3599d1
commit 389687464d
2 changed files with 91 additions and 84 deletions

View File

@@ -311,6 +311,9 @@
<property name="virtServerRegistry"> <property name="virtServerRegistry">
<ref bean="VirtServerRegistry" /> <ref bean="VirtServerRegistry" />
</property> </property>
<property name="searchService">
<ref bean="SearchService" />
</property>
</bean> </bean>
<!-- AVM Locking. --> <!-- AVM Locking. -->

View File

@@ -27,6 +27,7 @@ package org.alfresco.repo.avm;
import java.io.Serializable; import java.io.Serializable;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -52,6 +53,9 @@ import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowDefinition;
@@ -63,6 +67,7 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.DNSNameMangler; import org.alfresco.util.DNSNameMangler;
import org.alfresco.util.GUID; import org.alfresco.util.GUID;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -88,6 +93,7 @@ public class AVMExpiredContentProcessor
protected PermissionService permissionService; protected PermissionService permissionService;
protected TransactionService transactionService; protected TransactionService transactionService;
protected VirtServerRegistry virtServerRegistry; protected VirtServerRegistry virtServerRegistry;
protected SearchService searchService;
private static Log logger = LogFactory.getLog(AVMExpiredContentProcessor.class); private static Log logger = LogFactory.getLog(AVMExpiredContentProcessor.class);
@@ -148,6 +154,11 @@ public class AVMExpiredContentProcessor
this.virtServerRegistry = virtServerRegistry; this.virtServerRegistry = virtServerRegistry;
} }
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
/** /**
* Executes the expired content processor. * Executes the expired content processor.
* The work is performed within a transaction running as the system user. * The work is performed within a transaction running as the system user.
@@ -207,12 +218,36 @@ public class AVMExpiredContentProcessor
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Searching store '" + storeName + "' for expired content..."); logger.debug("Searching store '" + storeName + "' for expired content...");
// crawl the whole directory tree looking for nodes with the // find ant nodes with an expiration *date* of today or before
// content expiration aspect. Calendar cal = Calendar.getInstance();
// TODO: This would be a LOT better and effecient using a search StringBuilder query = new StringBuilder("@wca\\:expirationDate:[0001\\-01\\-01T00:00:00 TO ");
// but it doesn't exist yet! query.append(cal.get(Calendar.YEAR));
AVMNodeDescriptor rootNode = this.avmService.getStoreRoot(-1, storeName); query.append("\\-");
processFolder(storeName, rootNode); query.append((cal.get(Calendar.MONTH)+1));
query.append("\\-");
query.append(cal.get(Calendar.DAY_OF_MONTH));
query.append("T00:00:00]");
// do the query
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_AVM, storeName);
ResultSet results = this.searchService.query(storeRef, SearchService.LANGUAGE_LUCENE,
query.toString());
if (logger.isDebugEnabled())
logger.debug("Found " + results.length() + " potential expired item(s) in store '" + storeName + "'");
if (results.length() > 0)
{
for (NodeRef resultNode : results.getNodeRefs())
{
// get the AVMNodeDescriptor object for each node found
Pair<Integer, String> path = AVMNodeConverter.ToAVMVersionPath(resultNode);
AVMNodeDescriptor node = this.avmService.lookup(path.getFirst(), path.getSecond());
// process the node to see whether the date and time has passed
processNode(storeName, node);
}
}
} }
else else
{ {
@@ -248,42 +283,13 @@ public class AVMExpiredContentProcessor
} }
} }
/**
* Recursively processes the given folder looking for expired content.
*
* @param storeName The name of the store the folder belongs to
* @param folder The folder to start the search in
*/
private void processFolder(String storeName, AVMNodeDescriptor folder)
{
// check supplied node is a folder
if (folder.isDirectory())
{
// get listing of contents of supplied folder
Map<String, AVMNodeDescriptor> nodes = this.avmService.getDirectoryListing(folder);
for (AVMNodeDescriptor node: nodes.values())
{
if (node.isDirectory())
{
// recurse through folders
processFolder(storeName, node);
}
else
{
// process the node
processNode(storeName, node);
}
}
}
}
/** /**
* Processes the given node. * Processes the given node.
* <p> * <p>
* If the 'wca:expires' aspect is applied and the wca:expired property * This method is called if the node has been identified as being expired,
* is false the wca:expirationDate property is checked. If the date is * the date and time is checked to make sure it has actually passed i.e. the
* today's date or prior to today the last modifier of the node is retrieved * date maybe todat but the time set to later in the day. If the item is
* and the node's path added to the users list of expired content. * indeed expired it's added to the expired list and the date reset.
* </p> * </p>
* *
* @param storeName The name of the store the folder belongs to * @param storeName The name of the store the folder belongs to
@@ -296,8 +302,6 @@ public class AVMExpiredContentProcessor
{ {
// check for existence of expires aspect // check for existence of expires aspect
String nodePath = node.getPath(); String nodePath = node.getPath();
if (this.avmService.hasAspect(-1, nodePath, WCMAppModel.ASPECT_EXPIRES))
{
PropertyValue expirationDateProp = this.avmService.getNodeProperty(-1, nodePath, PropertyValue expirationDateProp = this.avmService.getNodeProperty(-1, nodePath,
WCMAppModel.PROP_EXPIRATIONDATE); WCMAppModel.PROP_EXPIRATIONDATE);
@@ -345,7 +349,6 @@ public class AVMExpiredContentProcessor
} }
} }
} }
}
/** /**
* Starts a workflow for the given user prompting them to review the list of given * Starts a workflow for the given user prompting them to review the list of given
@@ -385,6 +388,7 @@ public class AVMExpiredContentProcessor
storeCreator + "' as they created store '" + storeName + "'"); storeCreator + "' as they created store '" + storeName + "'");
userName = storeCreator; userName = storeCreator;
userStore = storeName + STORE_SEPARATOR + userName;
} }
// lookup the NodeRef for the user // lookup the NodeRef for the user
@@ -399,8 +403,8 @@ public class AVMExpiredContentProcessor
// create the workflow parameters map // create the workflow parameters map
Map<QName, Serializable> params = new HashMap<QName, Serializable>(5); Map<QName, Serializable> params = new HashMap<QName, Serializable>(5);
params.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage); params.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage);
params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, workflowTitle);
params.put(WorkflowModel.ASSOC_ASSIGNEE, assignee); params.put(WorkflowModel.ASSOC_ASSIGNEE, assignee);
params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, workflowTitle);
// transition the workflow to send it to the users inbox // transition the workflow to send it to the users inbox
this.workflowService.updateTask(startTask.id, params, null, null); this.workflowService.updateTask(startTask.id, params, null, null);