mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix ALF-2210 - incorrect version history (version label incremented twice, in certain cases)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19897 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -82,6 +82,7 @@ import org.alfresco.service.cmr.rule.Rule;
|
|||||||
import org.alfresco.service.cmr.rule.RuleService;
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.cmr.rule.RuleServiceException;
|
import org.alfresco.service.cmr.rule.RuleServiceException;
|
||||||
import org.alfresco.service.cmr.rule.RuleType;
|
import org.alfresco.service.cmr.rule.RuleType;
|
||||||
|
import org.alfresco.service.cmr.version.VersionService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
@@ -119,6 +120,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
private CopyService copyService;
|
private CopyService copyService;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private FileFolderService fileFolderService;
|
private FileFolderService fileFolderService;
|
||||||
|
private VersionService versionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category related values
|
* Category related values
|
||||||
@@ -159,6 +161,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
this.transformerRegistry = (ContentTransformerRegistry)applicationContext.getBean("contentTransformerRegistry");
|
this.transformerRegistry = (ContentTransformerRegistry)applicationContext.getBean("contentTransformerRegistry");
|
||||||
this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
||||||
this.fileFolderService = serviceRegistry.getFileFolderService();
|
this.fileFolderService = serviceRegistry.getFileFolderService();
|
||||||
|
this.versionService = serviceRegistry.getVersionService();
|
||||||
|
|
||||||
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||||
//authenticationComponent.setSystemUserAsCurrentUser();
|
//authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
@@ -330,12 +333,13 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
|
|
||||||
NodeRef newNodeRef = this.nodeService.createNode(
|
NodeRef newNodeRef = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT,
|
ContentModel.TYPE_CONTENT,
|
||||||
getContentProperties()).getChildRef();
|
getContentProperties()).getChildRef();
|
||||||
addContentToNode(newNodeRef);
|
addContentToNode(newNodeRef);
|
||||||
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(newNodeRef).getAllVersions().size());
|
||||||
|
|
||||||
Map<String, Serializable> params2 = new HashMap<String, Serializable>(2);
|
Map<String, Serializable> params2 = new HashMap<String, Serializable>(2);
|
||||||
params2.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ApplicationModel.ASPECT_SIMPLE_WORKFLOW);
|
params2.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ApplicationModel.ASPECT_SIMPLE_WORKFLOW);
|
||||||
@@ -449,13 +453,13 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
this.nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_LOCKABLE, null);
|
this.nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_LOCKABLE, null);
|
||||||
|
|
||||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
params.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
params.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
||||||
|
|
||||||
Rule rule = createRule(
|
Rule rule = createRule(
|
||||||
RuleType.INBOUND,
|
RuleType.INBOUND,
|
||||||
AddFeaturesActionExecuter.NAME,
|
AddFeaturesActionExecuter.NAME,
|
||||||
params,
|
params,
|
||||||
NoConditionEvaluator.NAME,
|
NoConditionEvaluator.NAME,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
@@ -463,23 +467,24 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
|
|
||||||
NodeRef newNodeRef = this.nodeService.createNode(
|
NodeRef newNodeRef = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT,
|
ContentModel.TYPE_CONTENT,
|
||||||
getContentProperties()).getChildRef();
|
getContentProperties()).getChildRef();
|
||||||
addContentToNode(newNodeRef);
|
addContentToNode(newNodeRef);
|
||||||
assertFalse(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
|
||||||
this.ruleService.enableRule(rule);
|
this.ruleService.enableRule(rule);
|
||||||
|
|
||||||
NodeRef newNodeRef2 = this.nodeService.createNode(
|
NodeRef newNodeRef2 = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT,
|
ContentModel.TYPE_CONTENT,
|
||||||
getContentProperties()).getChildRef();
|
getContentProperties()).getChildRef();
|
||||||
addContentToNode(newNodeRef2);
|
addContentToNode(newNodeRef2);
|
||||||
assertTrue(this.nodeService.hasAspect(newNodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(newNodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(newNodeRef2).getAllVersions().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,7 +672,8 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
NodeRef newNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(callback1);
|
NodeRef newNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(callback1);
|
||||||
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(newNodeRef).getAllVersions().size());
|
||||||
|
|
||||||
// Check rule does not get fired when the node has the incorrect category value
|
// Check rule does not get fired when the node has the incorrect category value
|
||||||
RetryingTransactionCallback<NodeRef> callback3 = new RetryingTransactionCallback<NodeRef>()
|
RetryingTransactionCallback<NodeRef> callback3 = new RetryingTransactionCallback<NodeRef>()
|
||||||
@@ -1121,8 +1127,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
* condition: no-condition()
|
* condition: no-condition()
|
||||||
* action: checkin()
|
* action: checkin()
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
public void testCheckInAction()
|
||||||
public void testCheckInAction()
|
|
||||||
{
|
{
|
||||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
params.put(CheckInActionExecuter.PARAM_DESCRIPTION, "The version description.");
|
params.put(CheckInActionExecuter.PARAM_DESCRIPTION, "The version description.");
|
||||||
@@ -1180,37 +1185,38 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
public void testRulesDisabled()
|
public void testRulesDisabled()
|
||||||
{
|
{
|
||||||
Map<String, Serializable> actionParams = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> actionParams = new HashMap<String, Serializable>(1);
|
||||||
actionParams.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
actionParams.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
||||||
|
|
||||||
Rule rule = createRule(
|
Rule rule = createRule(
|
||||||
RuleType.INBOUND,
|
RuleType.INBOUND,
|
||||||
AddFeaturesActionExecuter.NAME,
|
AddFeaturesActionExecuter.NAME,
|
||||||
actionParams,
|
actionParams,
|
||||||
NoConditionEvaluator.NAME,
|
NoConditionEvaluator.NAME,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
this.ruleService.disableRules(this.nodeRef);
|
this.ruleService.disableRules(this.nodeRef);
|
||||||
|
|
||||||
NodeRef newNodeRef = this.nodeService.createNode(
|
NodeRef newNodeRef = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT,
|
ContentModel.TYPE_CONTENT,
|
||||||
getContentProperties()).getChildRef();
|
getContentProperties()).getChildRef();
|
||||||
addContentToNode(newNodeRef);
|
addContentToNode(newNodeRef);
|
||||||
assertFalse(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
|
||||||
this.ruleService.enableRules(this.nodeRef);
|
this.ruleService.enableRules(this.nodeRef);
|
||||||
|
|
||||||
NodeRef newNodeRef2 = this.nodeService.createNode(
|
NodeRef newNodeRef2 = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT,
|
ContentModel.TYPE_CONTENT,
|
||||||
getContentProperties()).getChildRef();
|
getContentProperties()).getChildRef();
|
||||||
addContentToNode(newNodeRef2);
|
addContentToNode(newNodeRef2);
|
||||||
assertTrue(this.nodeService.hasAspect(newNodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(newNodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(newNodeRef2).getAllVersions().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1412,67 +1418,90 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
public void testInboundRuleType()
|
public void testInboundRuleType()
|
||||||
{
|
{
|
||||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
params.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
params.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
||||||
Rule rule = createRule(
|
Rule rule = createRule(
|
||||||
RuleType.INBOUND,
|
RuleType.INBOUND,
|
||||||
AddFeaturesActionExecuter.NAME,
|
AddFeaturesActionExecuter.NAME,
|
||||||
params,
|
params,
|
||||||
NoConditionEvaluator.NAME,
|
NoConditionEvaluator.NAME,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
|
|
||||||
// Create a non-content node
|
// Create a non-content node
|
||||||
NodeRef newNodeRef = this.nodeService.createNode(
|
NodeRef newNodeRef = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTAINER).getChildRef();
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
||||||
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(newNodeRef).getAllVersions().size());
|
||||||
|
|
||||||
// Create a content node
|
// Create a content node
|
||||||
NodeRef contentNodeRef = this.nodeService.createNode(
|
NodeRef contentNodeRef = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT).getChildRef();
|
ContentModel.TYPE_CONTENT).getChildRef();
|
||||||
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
addContentToNode(contentNodeRef);
|
addContentToNode(contentNodeRef);
|
||||||
assertTrue(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(contentNodeRef).getAllVersions().size());
|
||||||
|
|
||||||
|
// Create a content node in a single txn
|
||||||
|
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||||
|
{
|
||||||
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
|
NodeRef contentNodeRef = nodeService.createNode(
|
||||||
|
nodeRef,
|
||||||
|
ContentModel.ASSOC_CHILDREN,
|
||||||
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
|
ContentModel.TYPE_CONTENT).getChildRef();
|
||||||
|
addContentToNode(contentNodeRef);
|
||||||
|
return contentNodeRef;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NodeRef contentNodeRef2 = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||||
|
|
||||||
|
assertTrue(this.nodeService.hasAspect(contentNodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(contentNodeRef2).getAllVersions().size());
|
||||||
|
|
||||||
// Create a node to be moved
|
// Create a node to be moved
|
||||||
NodeRef moveNode = this.nodeService.createNode(
|
NodeRef moveNode = this.nodeService.createNode(
|
||||||
newNodeRef,
|
newNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT).getChildRef();
|
ContentModel.TYPE_CONTENT).getChildRef();
|
||||||
addContentToNode(moveNode);
|
addContentToNode(moveNode);
|
||||||
assertFalse(this.nodeService.hasAspect(moveNode, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(moveNode, ContentModel.ASPECT_VERSIONABLE));
|
||||||
this.nodeService.moveNode(
|
|
||||||
moveNode,
|
|
||||||
this.nodeRef,
|
|
||||||
ContentModel.ASSOC_CHILDREN,
|
|
||||||
QName.createQName(TEST_NAMESPACE, "children"));
|
|
||||||
assertTrue(this.nodeService.hasAspect(moveNode, ContentModel.ASPECT_VERSIONABLE));
|
|
||||||
|
|
||||||
// Enusre the rule type does not get fired when the node is updated
|
this.nodeService.moveNode(
|
||||||
|
moveNode,
|
||||||
|
this.nodeRef,
|
||||||
|
ContentModel.ASSOC_CHILDREN,
|
||||||
|
QName.createQName(TEST_NAMESPACE, "children"));
|
||||||
|
assertTrue(this.nodeService.hasAspect(moveNode, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(moveNode).getAllVersions().size());
|
||||||
|
|
||||||
|
// Ensure the rule type does not get fired when the node is updated
|
||||||
this.nodeService.removeAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE);
|
this.nodeService.removeAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE);
|
||||||
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
this.nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, "name.txt");
|
this.nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, "name.txt");
|
||||||
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
addContentToNode(contentNodeRef);
|
addContentToNode(contentNodeRef);
|
||||||
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateRuleType()
|
public void testUpdateRuleType()
|
||||||
{
|
{
|
||||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
params.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
params.put("aspect-name", ContentModel.ASPECT_VERSIONABLE);
|
||||||
Rule rule = createRule(
|
Rule rule = createRule(
|
||||||
RuleType.UPDATE,
|
RuleType.UPDATE,
|
||||||
AddFeaturesActionExecuter.NAME,
|
AddFeaturesActionExecuter.NAME,
|
||||||
params,
|
params,
|
||||||
NoConditionEvaluator.NAME,
|
NoConditionEvaluator.NAME,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
this.ruleService.saveRule(this.nodeRef, rule);
|
this.ruleService.saveRule(this.nodeRef, rule);
|
||||||
@@ -1480,7 +1509,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
// Create a non-content node
|
// Create a non-content node
|
||||||
NodeRef newNodeRef = this.nodeService.createNode(
|
NodeRef newNodeRef = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_FOLDER).getChildRef();
|
ContentModel.TYPE_FOLDER).getChildRef();
|
||||||
assertFalse(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
@@ -1488,25 +1517,27 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
// Update the non-content node
|
// Update the non-content node
|
||||||
this.nodeService.setProperty(newNodeRef, ContentModel.PROP_NAME, "testName");
|
this.nodeService.setProperty(newNodeRef, ContentModel.PROP_NAME, "testName");
|
||||||
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(newNodeRef).getAllVersions().size());
|
||||||
|
|
||||||
// Create a content node
|
// Create a content node
|
||||||
NodeRef contentNodeRef = this.nodeService.createNode(
|
NodeRef contentNodeRef = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_CONTENT).getChildRef();
|
ContentModel.TYPE_CONTENT).getChildRef();
|
||||||
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
|
||||||
addContentToNode(contentNodeRef);
|
|
||||||
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
addContentToNode(contentNodeRef);
|
addContentToNode(contentNodeRef);
|
||||||
|
assertFalse(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
addContentToNode(contentNodeRef);
|
||||||
assertTrue(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(contentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(contentNodeRef).getAllVersions().size());
|
||||||
|
|
||||||
// Create a non content node, setting a property at the same time
|
// Create a non content node, setting a property at the same time
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||||
props.put(ContentModel.PROP_NAME, "testName");
|
props.put(ContentModel.PROP_NAME, "testName");
|
||||||
NodeRef nodeRef2 = this.nodeService.createNode(
|
NodeRef nodeRef2 = this.nodeService.createNode(
|
||||||
this.nodeRef,
|
this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_FOLDER,
|
ContentModel.TYPE_FOLDER,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
@@ -1515,6 +1546,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
assertFalse(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
assertFalse(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
||||||
this.nodeService.setProperty(nodeRef2, ContentModel.PROP_NAME, "testName2");
|
this.nodeService.setProperty(nodeRef2, ContentModel.PROP_NAME, "testName2");
|
||||||
assertTrue(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(nodeRef2).getAllVersions().size());
|
||||||
|
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
||||||
{
|
{
|
||||||
@@ -1522,9 +1554,9 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
{
|
{
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||||
props.put(ContentModel.PROP_NAME, "testName");
|
props.put(ContentModel.PROP_NAME, "testName");
|
||||||
NodeRef nodeRef3 = RuleServiceCoverageTest.this.nodeService.createNode(
|
NodeRef nodeRef3 = RuleServiceCoverageTest.this.nodeService.createNode(
|
||||||
RuleServiceCoverageTest.this.nodeRef,
|
RuleServiceCoverageTest.this.nodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"),
|
QName.createQName(TEST_NAMESPACE, "children"),
|
||||||
ContentModel.TYPE_FOLDER,
|
ContentModel.TYPE_FOLDER,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
@@ -1570,11 +1602,12 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
|
|
||||||
// Move the node out of the actionable folder
|
// Move the node out of the actionable folder
|
||||||
this.nodeService.moveNode(
|
this.nodeService.moveNode(
|
||||||
newNodeRef,
|
newNodeRef,
|
||||||
this.rootNodeRef,
|
this.rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(TEST_NAMESPACE, "children"));
|
QName.createQName(TEST_NAMESPACE, "children"));
|
||||||
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(newNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(newNodeRef).getAllVersions().size());
|
||||||
|
|
||||||
// Check the deletion of a node
|
// Check the deletion of a node
|
||||||
|
|
||||||
@@ -1653,6 +1686,7 @@ public class RuleServiceCoverageTest extends TestCase
|
|||||||
for (NodeRef ref : nodeRefs)
|
for (NodeRef ref : nodeRefs)
|
||||||
{
|
{
|
||||||
assertTrue(this.nodeService.hasAspect(ref, ContentModel.ASPECT_VERSIONABLE));
|
assertTrue(this.nodeService.hasAspect(ref, ContentModel.ASPECT_VERSIONABLE));
|
||||||
|
assertEquals(1, versionService.getVersionHistory(ref).getAllVersions().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(sw.prettyPrint());
|
System.out.println(sw.prettyPrint());
|
||||||
|
@@ -251,7 +251,8 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
// Create the initial-version
|
// Create the initial-version
|
||||||
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(1);
|
||||||
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_INITIAL_VERSION));
|
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_INITIAL_VERSION));
|
||||||
this.versionService.createVersion(nodeRef, versionProperties);
|
|
||||||
|
createVersionImpl(nodeRef, versionProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,7 +297,8 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
// Create the auto-version
|
// Create the auto-version
|
||||||
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(1);
|
||||||
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION));
|
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION));
|
||||||
this.versionService.createVersion(nodeRef, versionProperties);
|
|
||||||
|
createVersionImpl(nodeRef, versionProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,17 +384,29 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
// Create the auto-version
|
// Create the auto-version
|
||||||
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(1);
|
||||||
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION_PROPS));
|
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION_PROPS));
|
||||||
this.versionService.createVersion(nodeRef, versionProperties);
|
|
||||||
|
createVersionImpl(nodeRef, versionProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createVersionImpl(NodeRef nodeRef, Map<String, Serializable> versionProperties)
|
||||||
|
{
|
||||||
|
recordCreateVersion(nodeRef, null);
|
||||||
|
this.versionService.createVersion(nodeRef, versionProperties);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy#onCreateVersion(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.util.Map, org.alfresco.repo.policy.PolicyScope)
|
* @see org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy#onCreateVersion(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.util.Map, org.alfresco.repo.policy.PolicyScope)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void afterCreateVersion(NodeRef versionableNode, Version version)
|
public void afterCreateVersion(NodeRef versionableNode, Version version)
|
||||||
|
{
|
||||||
|
recordCreateVersion(versionableNode, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void recordCreateVersion(NodeRef versionableNode, Version version)
|
||||||
{
|
{
|
||||||
Map<NodeRef, NodeRef> versionedNodeRefs = (Map<NodeRef, NodeRef>)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
|
Map<NodeRef, NodeRef> versionedNodeRefs = (Map<NodeRef, NodeRef>)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
|
||||||
if (versionedNodeRefs == null)
|
if (versionedNodeRefs == null)
|
||||||
|
Reference in New Issue
Block a user