diff --git a/source/java/org/alfresco/repo/action/ActionImpl.java b/source/java/org/alfresco/repo/action/ActionImpl.java index eac37d6750..c528d19401 100644 --- a/source/java/org/alfresco/repo/action/ActionImpl.java +++ b/source/java/org/alfresco/repo/action/ActionImpl.java @@ -142,6 +142,17 @@ public class ActionImpl extends ParameterizedItemImpl this.actionDefinitionName = actionDefinitionName; } + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append("Action") + .append("[ id=").append(getId()) + .append(", node=").append(nodeRef) + .append(" ]"); + return sb.toString(); + } + /** * @see org.alfresco.service.cmr.action.Action#getTitle() */ diff --git a/source/java/org/alfresco/repo/action/AsynchronousActionExecutionQueueImpl.java b/source/java/org/alfresco/repo/action/AsynchronousActionExecutionQueueImpl.java index 3903b101fb..bbb368a533 100644 --- a/source/java/org/alfresco/repo/action/AsynchronousActionExecutionQueueImpl.java +++ b/source/java/org/alfresco/repo/action/AsynchronousActionExecutionQueueImpl.java @@ -27,6 +27,7 @@ package org.alfresco.repo.action; import java.util.Set; import java.util.concurrent.ThreadPoolExecutor; +import org.alfresco.error.StackTraceUtil; import org.alfresco.repo.rule.RuleServiceImpl; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; @@ -116,6 +117,22 @@ public class AsynchronousActionExecutionQueueImpl implements AsynchronousActionE actionChain, executedRules); threadPoolExecutor.execute(runnable); + // Done + if (logger.isDebugEnabled()) + { + // get the stack trace + Exception e = new Exception(); + e.fillInStackTrace(); + StackTraceElement[] trace = e.getStackTrace(); + StringBuilder sb = new StringBuilder(); + sb.append("\n") + .append("Placed action on execution queue: \n") + .append(" Action: " + action); + String msg = sb.toString(); + sb = new StringBuilder(); + StackTraceUtil.buildStackTrace(msg, trace, sb, -1); + logger.debug(sb); + } } /** diff --git a/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java b/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java index 1303eb2e2b..cf6281fd3e 100644 --- a/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java +++ b/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java @@ -27,6 +27,7 @@ package org.alfresco.repo.rule; import java.io.File; import java.io.Serializable; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -60,8 +61,7 @@ import org.alfresco.repo.dictionary.M2Aspect; import org.alfresco.repo.dictionary.M2Model; import org.alfresco.repo.dictionary.M2Property; import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.transaction.TransactionUtil; -import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ActionCondition; @@ -160,15 +160,15 @@ public class RuleServiceCoverageTest extends TestCase //authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName()); //authenticationComponent.setSystemUserAsCurrentUser(); - TransactionWork setUserWork = new TransactionWork() + RetryingTransactionCallback setUserCallback = new RetryingTransactionCallback() { - public Object doWork() throws Exception + public Object execute() throws Exception { authenticationComponent.setCurrentUser("admin"); return null; } }; - TransactionUtil.executeInUserTransaction(transactionService, setUserWork); + transactionService.getRetryingTransactionHelper().doInTransaction(setUserCallback); this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef); @@ -218,7 +218,7 @@ public class RuleServiceCoverageTest extends TestCase genCatProp.setIndexed(true); genCatProp.setIndexedAtomically(true); genCatProp.setMandatory(true); - genCatProp.setMultiValued(false); + genCatProp.setMultiValued(true); genCatProp.setStoredInIndex(true); genCatProp.setTokenisedInIndex(true); genCatProp.setType("d:" + DataTypeDefinition.CATEGORY.getLocalName()); @@ -246,11 +246,10 @@ public class RuleServiceCoverageTest extends TestCase */ public void testAsyncRuleExecution() { - final NodeRef newNodeRef = TransactionUtil.executeInUserTransaction( - this.transactionService, - new TransactionUtil.TransactionWork() + final NodeRef newNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction( + new RetryingTransactionCallback() { - public NodeRef doWork() + public NodeRef execute() { RuleServiceCoverageTest.this.nodeService.addAspect( RuleServiceCoverageTest.this.nodeRef, @@ -677,9 +676,11 @@ public class RuleServiceCoverageTest extends TestCase addContentToNode(newNodeRef2); // Check that the category value has been set - NodeRef setValue = (NodeRef)this.nodeService.getProperty(newNodeRef2, CAT_PROP_QNAME); + // It has been declared as a multi-value property, so we expect that here + Collection setValue = (Collection) this.nodeService.getProperty(newNodeRef2, CAT_PROP_QNAME); assertNotNull(setValue); - assertEquals(this.catROne, setValue); + assertEquals(1, setValue.size()); + assertEquals(this.catROne, setValue.toArray()[0]); } @@ -1078,11 +1079,10 @@ public class RuleServiceCoverageTest extends TestCase this.ruleService.saveRule(this.nodeRef, rule); - List list = TransactionUtil.executeInUserTransaction( - this.transactionService, - new TransactionUtil.TransactionWork>() + List list = transactionService.getRetryingTransactionHelper().doInTransaction( + new RetryingTransactionCallback>() { - public List doWork() + public List execute() { // Create a new node and check-it out NodeRef newNodeRef = RuleServiceCoverageTest.this.nodeService.createNode( @@ -1459,9 +1459,9 @@ public class RuleServiceCoverageTest extends TestCase this.nodeService.setProperty(nodeRef2, ContentModel.PROP_NAME, "testName2"); assertTrue(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE)); - TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork() + transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { - public Object doWork() throws Exception + public Object execute() throws Exception { Map props = new HashMap(1); props.put(ContentModel.PROP_NAME, "testName");