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:
Derek Hulley
2006-07-26 11:19:55 +00:00
parent 6168aac2cc
commit dcb735c5e3
10 changed files with 208 additions and 49 deletions

View File

@@ -46,14 +46,15 @@ import org.alfresco.service.namespace.QName;
public class VersionableAspect implements ContentServicePolicies.OnContentUpdatePolicy,
NodeServicePolicies.OnAddAspectPolicy,
NodeServicePolicies.OnRemoveAspectPolicy,
NodeServicePolicies.OnDeleteNodePolicy
NodeServicePolicies.OnDeleteNodePolicy,
VersionServicePolicies.AfterCreateVersionPolicy
{
/** 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";
/** Transaction resource key */
private static final String KEY_INITIAL_VERSION = "initial_version_";
private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs";
/** The policy component */
private PolicyComponent policyComponent;
@@ -114,6 +115,10 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
ContentModel.ASPECT_VERSIONABLE,
new JavaBehaviour(this, "onDeleteNode", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "afterCreateVersion"),
ContentModel.ASPECT_VERSIONABLE,
new JavaBehaviour(this, "afterCreateVersion", Behaviour.NotificationFrequency.EVERY_EVENT));
autoVersionBehaviour = new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.TRANSACTION_COMMIT);
this.policyComponent.bindClassBehaviour(
@@ -189,9 +194,6 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
Map<String, Serializable> versionDetails = new HashMap<String, Serializable>(1);
versionDetails.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_INITIAL_VERSION));
this.versionService.createVersion(nodeRef, versionDetails);
// Keep track of the fact that the initial version has been created
AlfrescoTransactionSupport.bindResource(KEY_INITIAL_VERSION + nodeRef.toString(), nodeRef);
}
}
}
@@ -210,12 +212,13 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
*
* @param nodeRef the node reference
*/
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
@SuppressWarnings("unchecked")
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
{
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
{
// Determine whether we have already created an initial version during this transaction
if (AlfrescoTransactionSupport.getResource(KEY_INITIAL_VERSION + nodeRef.toString()) == null)
if (this.nodeService.exists(nodeRef) == true && this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
{
Map<NodeRef, NodeRef> versionedNodeRefs = (Map)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
if (versionedNodeRefs == null || versionedNodeRefs.containsKey(nodeRef) == false)
{
// Determine whether the node is auto versionable or not
boolean autoVersion = false;
@@ -237,22 +240,19 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
}
}
}
/**
* Enable the auto version behaviour
*
* @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)
*/
public void enableAutoVersion()
{
this.autoVersionBehaviour.enable();
}
/**
* Disable the auto version behaviour
*
*/
public void disableAutoVersion()
{
this.autoVersionBehaviour.disable();
}
@SuppressWarnings("unchecked")
public void afterCreateVersion(NodeRef versionableNode, Version version)
{
Map<NodeRef, NodeRef> versionedNodeRefs = (Map<NodeRef, NodeRef>)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
if (versionedNodeRefs == null)
{
versionedNodeRefs = new HashMap<NodeRef, NodeRef>();
AlfrescoTransactionSupport.bindResource(KEY_VERSIONED_NODEREFS, versionedNodeRefs);
}
versionedNodeRefs.put(versionableNode, versionableNode);
}
}