From: <ap...@vh...> - 2006-03-29 14:41:35
|
Author: apevec Date: 2006-03-29 16:40:02 +0200 (Wed, 29 Mar 2006) New Revision: 1107 Modified: trunk/ccm-cms/src/com/arsdigita/cms/workflow/CMSTask.java Log: use history instead of audit trail to find the author which should get the workflow notification Modified: trunk/ccm-cms/src/com/arsdigita/cms/workflow/CMSTask.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/workflow/CMSTask.java 2006-03-28 17:16:20 UTC (rev 1106) +++ trunk/ccm-cms/src/com/arsdigita/cms/workflow/CMSTask.java 2006-03-29 14:40:02 UTC (rev 1107) @@ -43,6 +43,10 @@ import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.util.Assert; +import com.arsdigita.versioning.TagCollection; +import com.arsdigita.versioning.Transaction; +import com.arsdigita.versioning.TransactionCollection; +import com.arsdigita.versioning.Versions; import com.arsdigita.web.URL; import com.arsdigita.workflow.simple.TaskComment; import com.arsdigita.workflow.simple.TaskException; @@ -459,7 +463,24 @@ protected void sendMessageToAssignees(Message msg) { if (m_authorOnly) { ContentItem item = getItem(); - User author = item.getLastModifiedUser(); + User author = null; + // XXX lastModifiedUser in audit trail is overwritten on each save + // author = item.getLastModifiedUser(); + // workaround: use the latest history record with 'Authored' tag + TransactionCollection hist = Versions.getTaggedTransactions(item.getOID()); + while (author == null && hist.next()) { + Transaction txn = hist.getTransaction(); + TagCollection tags = txn.getTags(); + while (tags.next()) { + String tag = tags.getTag().getDescription(); + if ("Authored".equals(tag)) { + author = txn.getUser(); + if (s_log.isDebugEnabled()) { + s_log.debug("author from hist="+author+" at "+txn.getTimestamp()); + } + } + } + } if (author == null) { // fallback: creator is always available in audit trail author = item.getCreationUser(); |