mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/BELARUS/HEAD-2011_11_10 to HEAD:
32408: ALF-1793: ACP import with UPDATE_EXISTING causes VersionServiceException git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32677 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -684,4 +684,35 @@ public class NodeServiceImplTest extends BaseVersionStoreTest
|
|||||||
assertEquals(1, nodeService.getChildAssocs(this.rootNodeRef, ContentModel.ASSOC_CONTAINS, jpQName).size());
|
assertEquals(1, nodeService.getChildAssocs(this.rootNodeRef, ContentModel.ASSOC_CONTAINS, jpQName).size());
|
||||||
assertEquals(jpNode, nodeService.getChildByName(rootNodeRef, ContentModel.ASSOC_CONTAINS, jpProp));
|
assertEquals(jpNode, nodeService.getChildByName(rootNodeRef, ContentModel.ASSOC_CONTAINS, jpProp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test that during applying versionable aspect to the node
|
||||||
|
* that does not already have versionable aspect
|
||||||
|
* version history of this node should be deleted
|
||||||
|
*/
|
||||||
|
public void testALF1793AddVersionableAspect()
|
||||||
|
{
|
||||||
|
// Create a new versionable node and create new version
|
||||||
|
NodeRef versionableNode = createNewVersionableNode();
|
||||||
|
createVersion(versionableNode, this.versionProperties);
|
||||||
|
|
||||||
|
//Copy UUID from node properties
|
||||||
|
Map<QName, Serializable> oldProperties = this.dbNodeService.getProperties(versionableNode);
|
||||||
|
Map<QName, Serializable> newProperties = new HashMap<QName, Serializable>();
|
||||||
|
newProperties.put(ContentModel.PROP_NODE_UUID, oldProperties.get(ContentModel.PROP_NODE_UUID));
|
||||||
|
|
||||||
|
// Delete node and create new one with the same UUID
|
||||||
|
this.dbNodeService.deleteNode(versionableNode);
|
||||||
|
NodeRef newNode = this.dbNodeService.createNode(
|
||||||
|
rootNodeRef,
|
||||||
|
ContentModel.ASSOC_CHILDREN,
|
||||||
|
QName.createQName("{test}MyNode"),
|
||||||
|
TEST_TYPE_QNAME,
|
||||||
|
newProperties).getChildRef();
|
||||||
|
|
||||||
|
// add the versionable aspect to the node and create new version
|
||||||
|
this.dbNodeService.addAspect(newNode, ContentModel.ASPECT_VERSIONABLE, null);
|
||||||
|
Version version = createVersion(newNode, this.versionProperties);
|
||||||
|
assertNotNull(version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,8 @@ import org.alfresco.service.namespace.NamespacePrefixResolver;
|
|||||||
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.util.EqualsHelper;
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +60,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
|||||||
* @author Roy Wetherall, janv
|
* @author Roy Wetherall, janv
|
||||||
*/
|
*/
|
||||||
public class VersionableAspect implements ContentServicePolicies.OnContentUpdatePolicy,
|
public class VersionableAspect implements ContentServicePolicies.OnContentUpdatePolicy,
|
||||||
|
NodeServicePolicies.BeforeAddAspectPolicy,
|
||||||
NodeServicePolicies.OnAddAspectPolicy,
|
NodeServicePolicies.OnAddAspectPolicy,
|
||||||
NodeServicePolicies.OnRemoveAspectPolicy,
|
NodeServicePolicies.OnRemoveAspectPolicy,
|
||||||
NodeServicePolicies.OnDeleteNodePolicy,
|
NodeServicePolicies.OnDeleteNodePolicy,
|
||||||
@@ -66,6 +69,8 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
CopyServicePolicies.OnCopyNodePolicy,
|
CopyServicePolicies.OnCopyNodePolicy,
|
||||||
DictionaryListener
|
DictionaryListener
|
||||||
{
|
{
|
||||||
|
protected static Log logger = LogFactory.getLog(VersionableAspect.class);
|
||||||
|
|
||||||
/** The i18n'ized messages */
|
/** The i18n'ized messages */
|
||||||
private static final String MSG_INITIAL_VERSION = "create_version.initial_version";
|
private static final String MSG_INITIAL_VERSION = "create_version.initial_version";
|
||||||
private static final String MSG_AUTO_VERSION = "create_version.auto_version";
|
private static final String MSG_AUTO_VERSION = "create_version.auto_version";
|
||||||
@@ -193,11 +198,16 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.policyComponent.bindClassBehaviour(
|
||||||
|
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeAddAspect"),
|
||||||
|
ContentModel.ASPECT_VERSIONABLE,
|
||||||
|
new JavaBehaviour(this, "beforeAddAspect", Behaviour.NotificationFrequency.EVERY_EVENT));
|
||||||
|
|
||||||
this.policyComponent.bindClassBehaviour(
|
this.policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
|
||||||
ContentModel.ASPECT_VERSIONABLE,
|
ContentModel.ASPECT_VERSIONABLE,
|
||||||
|
|
||||||
new JavaBehaviour(this, "onAddAspect", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
|
new JavaBehaviour(this, "onAddAspect", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
|
||||||
|
|
||||||
this.policyComponent.bindClassBehaviour(
|
this.policyComponent.bindClassBehaviour(
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
||||||
ContentModel.ASPECT_VERSIONABLE,
|
ContentModel.ASPECT_VERSIONABLE,
|
||||||
@@ -298,6 +308,22 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before add aspect policy behaviour
|
||||||
|
*
|
||||||
|
* @param nodeRef
|
||||||
|
* @param aspectTypeQName
|
||||||
|
*/
|
||||||
|
public void beforeAddAspect(NodeRef nodeRef, QName aspectTypeQName)
|
||||||
|
{
|
||||||
|
if(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == false &&
|
||||||
|
this.versionService.getVersionHistory(nodeRef) != null)
|
||||||
|
{
|
||||||
|
this.versionService.deleteVersionHistory(nodeRef);
|
||||||
|
logger.warn("The version history of node " + nodeRef + " that doesn't have versionable aspect was deleted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On add aspect policy behaviour
|
* On add aspect policy behaviour
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user