diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml
index 9267826f3f..c473dee35c 100644
--- a/config/alfresco/core-services-context.xml
+++ b/config/alfresco/core-services-context.xml
@@ -555,8 +555,6 @@
cm:content
-
-
@@ -639,6 +637,7 @@
+
diff --git a/config/alfresco/model/contentModel.xml b/config/alfresco/model/contentModel.xml
index 53f30c333a..53db2849da 100644
--- a/config/alfresco/model/contentModel.xml
+++ b/config/alfresco/model/contentModel.xml
@@ -1042,12 +1042,12 @@
Auto Version
d:boolean
- true
+ ${version.store.enableAutoVersioning}|true
Auto Version - on update properties only
d:boolean
- true
+ ${version.store.enableAutoVersionOnUpdateProps}|true
diff --git a/source/java/org/alfresco/repo/version/VersionableAspect.java b/source/java/org/alfresco/repo/version/VersionableAspect.java
index 8c38f71aea..3a567aca28 100644
--- a/source/java/org/alfresco/repo/version/VersionableAspect.java
+++ b/source/java/org/alfresco/repo/version/VersionableAspect.java
@@ -112,12 +112,6 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
private Set excludedOnUpdatePropQNames = Collections.emptySet();
- /** flag indicating whether auto-versioning should be enabled or not */
- private boolean enableAutoVersioning = true;
-
- /** flag indicating whether auto-versioning should be enabled on properties update or not */
- private boolean enableAutoVersionOnUpdateProps = false;
-
/**
* Set the policy component
*
@@ -196,38 +190,11 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
this.excludedOnUpdateProps = Collections.unmodifiableList(excludedOnUpdateProps);
}
- /**
- * Set whether the aspect-associated behaviour should be enabled or disabled. This is only used
- * during {@link #init() initialization}.
- *
- * @param enableAutoVersioning true to enable the aspect behaviour otherwise false
- */
- public void setEnableAutoVersioning(boolean enableAutoVersioning)
- {
- this.enableAutoVersioning = enableAutoVersioning;
- }
-
- /**
- * Set whether the OnUpdatePropertiesPolicy should be binded or not. This is only used
- * during {@link #init() initialization}.
- *
- * @param enableAutoVersionOnUpdateProps true to bind OnUpdatePropertiesPolicy sotherwise false
- */
- public void setEnableAutoVersionOnUpdateProps(boolean enableAutoVersionOnUpdateProps)
- {
- this.enableAutoVersionOnUpdateProps = enableAutoVersionOnUpdateProps;
- }
-
/**
* Initialise the versionable aspect policies
*/
public void init()
{
- if (!enableAutoVersioning)
- {
- return;
- }
-
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeAddAspect"),
ContentModel.ASPECT_VERSIONABLE,
@@ -467,8 +434,7 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
Map before,
Map after)
{
- if (this.enableAutoVersionOnUpdateProps && // MNT-12226 : additional setting to override the behavior for metadata versioning
- (this.nodeService.exists(nodeRef) == true) &&
+ if ((this.nodeService.exists(nodeRef) == true) &&
!LockUtils.isLockedAndReadOnly(nodeRef, lockService) &&
(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true) &&
(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) == false))
diff --git a/source/test-java/org/alfresco/opencmis/CMISTest.java b/source/test-java/org/alfresco/opencmis/CMISTest.java
index d53b68273c..019ddfb5e6 100644
--- a/source/test-java/org/alfresco/opencmis/CMISTest.java
+++ b/source/test-java/org/alfresco/opencmis/CMISTest.java
@@ -41,6 +41,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.alfresco.cmis.CMISChangeEvent;
import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
@@ -64,7 +65,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
-import org.alfresco.repo.version.VersionableAspect;
+import org.alfresco.repo.version.VersionableAspectTest;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
@@ -168,7 +169,7 @@ public class CMISTest
private RuleService ruleService;
private NodeArchiveService nodeArchiveService;
private DictionaryService dictionaryService;
- private VersionableAspect versionableAspect;
+ private java.util.Properties globalProperties;
private AlfrescoCmisServiceFactory factory;
@@ -342,14 +343,14 @@ public class CMISTest
this.nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
this.dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
- this.versionableAspect = (VersionableAspect) ctx.getBean("versionableAspect");
- this.versionableAspect.setEnableAutoVersionOnUpdateProps(true);
+ this.globalProperties = (java.util.Properties) ctx.getBean("global-properties");
+ this.globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true");
}
@After
public void after()
{
- this.versionableAspect.setEnableAutoVersionOnUpdateProps(false);
+ this.globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "false");
}
/**
diff --git a/source/test-java/org/alfresco/repo/version/VersionServiceImplTest.java b/source/test-java/org/alfresco/repo/version/VersionServiceImplTest.java
index 8f9dc26820..91ebf92990 100644
--- a/source/test-java/org/alfresco/repo/version/VersionServiceImplTest.java
+++ b/source/test-java/org/alfresco/repo/version/VersionServiceImplTest.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import junit.framework.AssertionFailedError;
@@ -94,6 +95,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
private PersonService personService;
private VersionableAspect versionableAspect;
private List excludedOnUpdateProps;
+ private Properties globalProperties;
@Override
protected void onSetUpInTransaction() throws Exception
@@ -102,7 +104,8 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
personService = (PersonService) applicationContext.getBean("personService");
versionableAspect = (VersionableAspect) applicationContext.getBean("versionableAspect");
excludedOnUpdateProps = versionableAspect.getExcludedOnUpdateProps();
- versionableAspect.setEnableAutoVersionOnUpdateProps(true);
+ globalProperties = (Properties) applicationContext.getBean("global-properties");
+ globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true");
}
@Override
@@ -110,8 +113,8 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
{
super.onTearDownAfterTransaction();
versionableAspect.setExcludedOnUpdateProps(excludedOnUpdateProps);
- versionableAspect.setEnableAutoVersionOnUpdateProps(false);
versionableAspect.afterDictionaryInit();
+ globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "false");
}
public void testSetup()
diff --git a/source/test-java/org/alfresco/repo/version/VersionableAspectTest.java b/source/test-java/org/alfresco/repo/version/VersionableAspectTest.java
index 124a83eaf2..5197d7263a 100644
--- a/source/test-java/org/alfresco/repo/version/VersionableAspectTest.java
+++ b/source/test-java/org/alfresco/repo/version/VersionableAspectTest.java
@@ -21,6 +21,7 @@ package org.alfresco.repo.version;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import junit.framework.TestCase;
@@ -52,6 +53,9 @@ import org.springframework.context.ApplicationContext;
@Category(OwnJVMTestsCategory.class)
public class VersionableAspectTest extends TestCase
{
+ public static final String AUTO_VERSION_KEY = "version.store.enableAutoVersioning";
+ public static final String AUTO_VERSION_PROPS_KEY = "version.store.enableAutoVersionOnUpdateProps";
+
private static final String NAME_AND_EXT_DELIMETER = ".";
private static final String NAME_AND_EXT_DELIMETER_REGEXP = "\\" + NAME_AND_EXT_DELIMETER;
@@ -78,7 +82,7 @@ public class VersionableAspectTest extends TestCase
private TransactionService transactionService = (TransactionService) applicationContext.getBean("transactionService");
private CheckOutCheckInService checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("checkOutCheckInService");
private AuthenticationService authenticationService = (AuthenticationService) applicationContext.getBean("authenticationService");
- private VersionableAspect versionableAspect = (VersionableAspect) applicationContext.getBean("versionableAspect");
+ private Properties globalProperties = (Properties) applicationContext.getBean("global-properties");
private NodeRef document;
private NodeRef parentFolder;
@@ -86,8 +90,7 @@ public class VersionableAspectTest extends TestCase
@Override
protected void setUp() throws Exception
{
- versionableAspect.setEnableAutoVersionOnUpdateProps(true);
-
+ globalProperties.setProperty(AUTO_VERSION_PROPS_KEY, "true");
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
{
@Override
@@ -139,8 +142,7 @@ public class VersionableAspectTest extends TestCase
@Override
protected void tearDown() throws Exception
{
- versionableAspect.setEnableAutoVersionOnUpdateProps(false);
-
+ globalProperties.setProperty(AUTO_VERSION_PROPS_KEY, "false");
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
{
@Override