Merged 5.0.N (5.0.3) to HEAD (5.1)

110205: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3)
      110092: Merged V4.2.5 (4.2.5) to V4.2-BUG-FIX (4.2.6)
         110055: Merged DEV to PATCHES/V4.2.5 (4.2.5)
            109047 : MNT-12226 : Alfresco fails to version metadata after uploading new content version even when autoVersionOnUpdateProps=true
               - Reimplemented previous solution. Configuration properties for autoVersioning should not affect all nodes in repo. They should just provide default behavior.
               - Added ability to specify default values for model properties using standard alfresco GLOBAL_PROPERTIES file.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@110627 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tatyana Valkevych
2015-08-21 16:42:09 +00:00
parent 5e0d90bb8d
commit 9cdc1f1377
6 changed files with 22 additions and 51 deletions

View File

@@ -555,8 +555,6 @@
<value>cm:content</value>
</list>
</property>
<property name="enableAutoVersioning" value="${version.store.enableAutoVersioning}" />
<property name="enableAutoVersionOnUpdateProps" value="${version.store.enableAutoVersionOnUpdateProps}" />
</bean>
<!-- -->
@@ -639,6 +637,7 @@
<property name="tenantService">
<ref bean="tenantService"/>
</property>
<property name="globalProperties" ref="global-properties"/>
</bean>
<bean id="dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="resourceBundles">

View File

@@ -1042,12 +1042,12 @@
<property name="cm:autoVersion">
<title>Auto Version</title>
<type>d:boolean</type>
<default>true</default>
<default>${version.store.enableAutoVersioning}|true</default>
</property>
<property name="cm:autoVersionOnUpdateProps">
<title>Auto Version - on update properties only</title>
<type>d:boolean</type>
<default>true</default>
<default>${version.store.enableAutoVersionOnUpdateProps}|true</default>
</property>
</properties>
</aspect>

View File

@@ -112,12 +112,6 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
private Set<QName> 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 <tt>true</tt> to enable the aspect behaviour otherwise <tt>false</tt>
*/
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 <tt>true</tt> to bind OnUpdatePropertiesPolicy sotherwise <tt>false</tt>
*/
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<QName, Serializable> before,
Map<QName, Serializable> 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))

View File

@@ -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");
}
/**

View File

@@ -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<String> 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()

View File

@@ -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<Void>()
{
@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<Void>()
{
@Override