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:
Matt Ward
2011-12-09 14:18:00 +00:00
parent bb62b42981
commit 2d323dd56f
2 changed files with 58 additions and 1 deletions

View File

@@ -50,6 +50,8 @@ import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
/**
@@ -58,6 +60,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
* @author Roy Wetherall, janv
*/
public class VersionableAspect implements ContentServicePolicies.OnContentUpdatePolicy,
NodeServicePolicies.BeforeAddAspectPolicy,
NodeServicePolicies.OnAddAspectPolicy,
NodeServicePolicies.OnRemoveAspectPolicy,
NodeServicePolicies.OnDeleteNodePolicy,
@@ -66,6 +69,8 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
CopyServicePolicies.OnCopyNodePolicy,
DictionaryListener
{
protected static Log logger = LogFactory.getLog(VersionableAspect.class);
/** The i18n'ized messages */
private static final String MSG_INITIAL_VERSION = "create_version.initial_version";
private static final String MSG_AUTO_VERSION = "create_version.auto_version";
@@ -193,11 +198,16 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
return;
}
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeAddAspect"),
ContentModel.ASPECT_VERSIONABLE,
new JavaBehaviour(this, "beforeAddAspect", Behaviour.NotificationFrequency.EVERY_EVENT));
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
ContentModel.ASPECT_VERSIONABLE,
new JavaBehaviour(this, "onAddAspect", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
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
*