mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V1.3 to HEAD (3247:3249, 3250:3280, 3281:3324)
svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3247 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3249 . svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3250 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3280 . svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3281 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3324 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3411 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1547,4 +1547,90 @@ public class RuleServiceCoverageTest extends TestCase
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void testAsyncExecutionWithPotentialLoop()
|
||||
{
|
||||
if (this.transformerRegistry.getTransformer(MimetypeMap.MIMETYPE_EXCEL, MimetypeMap.MIMETYPE_TEXT_PLAIN) != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(TransformActionExecuter.PARAM_MIME_TYPE, MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
params.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, this.nodeRef);
|
||||
params.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME, ContentModel.ASSOC_CONTAINS);
|
||||
params.put(TransformActionExecuter.PARAM_ASSOC_QNAME, QName.createQName(TEST_NAMESPACE, "transformed"));
|
||||
|
||||
Rule rule = createRule(
|
||||
RuleType.INBOUND,
|
||||
TransformActionExecuter.NAME,
|
||||
params,
|
||||
NoConditionEvaluator.NAME,
|
||||
null);
|
||||
rule.setExecuteAsynchronously(true);
|
||||
rule.setTitle("Transform document to text");
|
||||
|
||||
UserTransaction tx0 = transactionService.getUserTransaction();
|
||||
tx0.begin();
|
||||
this.ruleService.saveRule(this.nodeRef, rule);
|
||||
tx0.commit();
|
||||
|
||||
UserTransaction tx = transactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
|
||||
Map<QName, Serializable> props =new HashMap<QName, Serializable>(1);
|
||||
props.put(ContentModel.PROP_NAME, "test.xls");
|
||||
|
||||
// Create the node at the root
|
||||
NodeRef newNodeRef = this.nodeService.createNode(
|
||||
this.nodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName(TEST_NAMESPACE, "origional"),
|
||||
ContentModel.TYPE_CONTENT,
|
||||
props).getChildRef();
|
||||
|
||||
// Set some content on the origional
|
||||
ContentWriter contentWriter = this.contentService.getWriter(newNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_EXCEL);
|
||||
File testFile = AbstractContentTransformerTest.loadQuickTestFile("xls");
|
||||
contentWriter.putContent(testFile);
|
||||
|
||||
tx.commit();
|
||||
|
||||
Thread.sleep(10000);
|
||||
//System.out.println(NodeStoreInspector.dumpNodeStore(this.nodeService, this.testStoreRef));
|
||||
|
||||
//AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
||||
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||
|
||||
// Check that the created node is still there
|
||||
//List<ChildAssociationRef> origRefs = this.nodeService.getChildAssocs(
|
||||
// this.nodeRef,
|
||||
// RegexQNamePattern.MATCH_ALL, QName.createQName(TEST_NAMESPACE, "origional"));
|
||||
//assertNotNull(origRefs);
|
||||
//assertEquals(1, origRefs.size());
|
||||
//NodeRef origNodeRef = origRefs.get(0).getChildRef();
|
||||
//assertEquals(newNodeRef, origNodeRef);
|
||||
|
||||
// Check that the created node has been copied
|
||||
//List<ChildAssociationRef> copyChildAssocRefs = this.nodeService.getChildAssocs(
|
||||
// this.rootNodeRef,
|
||||
// RegexQNamePattern.MATCH_ALL, QName.createQName(TEST_NAMESPACE, "transformed"));
|
||||
//assertNotNull(copyChildAssocRefs);
|
||||
//assertEquals(1, copyChildAssocRefs.size());
|
||||
//NodeRef copyNodeRef = copyChildAssocRefs.get(0).getChildRef();
|
||||
//assertTrue(this.nodeService.hasAspect(copyNodeRef, ContentModel.ASPECT_COPIEDFROM));
|
||||
//NodeRef source = (NodeRef)this.nodeService.getProperty(copyNodeRef, ContentModel.PROP_COPY_REFERENCE);
|
||||
//assertEquals(newNodeRef, source);
|
||||
|
||||
// Check the transformed content
|
||||
//ContentData contentData = (ContentData) nodeService.getProperty(copyNodeRef, ContentModel.PROP_CONTENT);
|
||||
//assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, contentData.getMimetype());
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -653,12 +653,18 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.rule.RuntimeRuleService#addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule)
|
||||
{
|
||||
addRulePendingExecution(actionableNodeRef, actionedUponNodeRef, rule, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.rule.RuntimeRuleService#addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule, boolean)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd)
|
||||
{
|
||||
@@ -684,7 +690,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent hte same rule being executed more than one in the same transaction
|
||||
// Prevent the same rule being executed more than once in the same transaction
|
||||
pendingRules.add(pendingRuleData);
|
||||
}
|
||||
else
|
||||
@@ -707,7 +713,10 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
{
|
||||
logger.debug("Creating the executed rules list");
|
||||
}
|
||||
AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>());
|
||||
if (AlfrescoTransactionSupport.getResource(KEY_RULES_EXECUTED) == null)
|
||||
{
|
||||
AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>());
|
||||
}
|
||||
try
|
||||
{
|
||||
List<PendingRuleData> executeAtEndRules = new ArrayList<PendingRuleData>();
|
||||
@@ -719,11 +728,11 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
}
|
||||
finally
|
||||
{
|
||||
AlfrescoTransactionSupport.unbindResource(KEY_RULES_EXECUTED);
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Unbinding resource");
|
||||
}
|
||||
//AlfrescoTransactionSupport.unbindResource(KEY_RULES_EXECUTED);
|
||||
//if (logger.isDebugEnabled() == true)
|
||||
//{
|
||||
// logger.debug("Unbinding resource");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -900,7 +909,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
private class ExecutedRuleData
|
||||
public class ExecutedRuleData
|
||||
{
|
||||
|
||||
protected NodeRef actionableNodeRef;
|
||||
|
Reference in New Issue
Block a user