Merge release/V2.2.1.x into release/V2.2.

Conflicts:
	pom.xml
	rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties
	rm-server/pom.xml
	rm-share/config/alfresco/module/org_alfresco_module_rm_share/module.properties
	rm-share/pom.xml
	rm-ui-tests/pom.xml
This commit is contained in:
Tom Page
2016-06-20 10:31:36 +01:00
10 changed files with 436 additions and 159 deletions

1
.gitignore vendored
View File

@@ -24,6 +24,7 @@ test-output
/rm-server/alfresco-solr.zip
/rm-server/solr
/rm-server/shared
/rm-server/alf_data
# /rm-server/config/
/rm-server/config/alfresco-global.properties

View File

@@ -168,7 +168,6 @@
<!-- init caveatConfig behaviours -->
<property name="caveatConfigService" ref="caveatConfigService"/>
<property name="customEmailMappingService" ref="customEmailMappingService"/>
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService"/>
</bean>
<!-- Java script interface for rm caveat config-->

View File

@@ -770,6 +770,7 @@
<property name="nodeService" ref="NodeService"/>
<property name="policyComponent" ref="policyComponent"/>
<property name="contentService" ref="contentService"/>
<property name="transactionService" ref="transactionService"/>
<property name="dictionaryRepositoryBootstrap" ref="dictionaryRepositoryBootstrap"/>
<property name="customisableTypes">
<list>
@@ -813,7 +814,6 @@
<property name="objectDefinitionSource">
<value>
<![CDATA[
org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService.initialiseCustomModel=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService.getCustomisable=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService.isCustomisable=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService.makeCustomisable=RM_ALLOW

View File

@@ -42,11 +42,6 @@ import org.alfresco.service.namespace.QName;
*/
public interface RecordsManagementAdminService
{
/**
* Initialise the custom model
*/
void initialiseCustomModel();
/**
* Get a list of all registered customisable types and aspects.
*

View File

@@ -63,6 +63,7 @@ import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.Constraint;
@@ -83,9 +84,13 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.GUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered;
import org.springframework.extensions.surf.util.I18NUtil;
import org.springframework.extensions.surf.util.ParameterCheck;
import org.springframework.extensions.surf.util.URLDecoder;
@@ -100,7 +105,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
RecordsManagementCustomModel,
NodeServicePolicies.OnAddAspectPolicy,
NodeServicePolicies.OnRemoveAspectPolicy,
NodeServicePolicies.OnCreateNodePolicy
NodeServicePolicies.OnCreateNodePolicy,
ApplicationListener<ContextRefreshedEvent>,
Ordered
{
/** Logger */
private static Log logger = LogFactory.getLog(RecordsManagementAdminServiceImpl.class);
@@ -153,6 +160,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
/** Policy component */
private PolicyComponent policyComponent;
/** Transaction service */
private TransactionService transactionService;
/** Policy delegates */
private ClassPolicyDelegate<BeforeCreateReference> beforeCreateReferenceDelegate;
private ClassPolicyDelegate<OnCreateReference> onCreateReferenceDelegate;
@@ -163,6 +173,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
private List<QName> pendingCustomisableTypes;
private Map<QName, QName> customisableTypes;
/** indicates whether the custom map has been initialised or not */
private boolean isCustomMapInit = false;
/**
* @param dictionaryService the dictionary service
*/
@@ -213,6 +226,14 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
this.dictonaryRepositoryBootstrap = dictonaryRepositoryBootstrap;
}
/**
* @param transactionService transaction service
*/
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}
/**
* Initialisation method
*/
@@ -225,6 +246,48 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
onRemoveReferenceDelegate = policyComponent.registerClassPolicy(OnRemoveReference.class);
}
/**
* Indicate that this application content listener must be executed with the lowest
* precedence. (ie last)
*
* @see Ordered#getOrder()
*/
@Override
public int getOrder()
{
return Ordered.LOWEST_PRECEDENCE;
}
/**
* Load the custom properties map
*
* @see ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
*/
@Override
public void onApplicationEvent(ContextRefreshedEvent event)
{
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
// initialise custom properties
initCustomMap();
return null;
}
});
}
/**
* Helper method to indicate whether the custom map is initialised or not.
*
* @return boolean true if initialised, false otherwise
*/
public boolean isCustomMapInit()
{
return isCustomMapInit;
}
/**
* Invoke before create reference policy
*
@@ -300,6 +363,8 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
notificationFrequency = NotificationFrequency.FIRST_EVENT
)
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
{
if (isCustomMapInit)
{
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
@@ -318,6 +383,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
}
}, AuthenticationUtil.getSystemUserName());
}
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
@@ -330,6 +396,8 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
notificationFrequency = NotificationFrequency.FIRST_EVENT
)
public void onRemoveAspect(final NodeRef nodeRef, final QName aspectTypeQName)
{
if (isCustomMapInit)
{
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
@@ -347,6 +415,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
}
}, AuthenticationUtil.getSystemUserName());
}
}
/**
* Make sure any custom property aspects are applied to newly created nodes.
@@ -361,6 +430,8 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
notificationFrequency = NotificationFrequency.FIRST_EVENT
)
public void onCreateNode(final ChildAssociationRef childAssocRef)
{
if (isCustomMapInit)
{
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
@@ -395,14 +466,6 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
}
}, AuthenticationUtil.getSystemUserName());
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#initialiseCustomModel()
*/
public void initialiseCustomModel()
{
// Initialise the map
getCustomisableMap();
}
/**
@@ -485,13 +548,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
}
/**
* Gets a map containing all the customisable types
*
* @return map from the customisable type to its custom aspect
* Initialise custom type map
*/
private Map<QName, QName> getCustomisableMap()
{
if (customisableTypes == null)
private void initCustomMap()
{
customisableTypes = new HashMap<QName, QName>(7);
Collection<QName> aspects = dictionaryService.getAspects(RM_CUSTOM_MODEL);
@@ -569,6 +628,21 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
writeCustomContentModel(modelRef, model);
}
}
// indicate map is initialised
isCustomMapInit = true;
}
/**
* Gets a map containing all the customisable types
*
* @return map from the customisable type to its custom aspect
*/
private Map<QName, QName> getCustomisableMap()
{
if (customisableTypes == null)
{
throw AlfrescoRuntimeException.create("Customisable map has not been initialised correctly.");
}
return customisableTypes;
}

View File

@@ -18,7 +18,6 @@
*/
package org.alfresco.module.org_alfresco_module_rm.bootstrap;
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
import org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction;
import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService;
import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService;
@@ -40,7 +39,6 @@ public class RecordsManagementBootstrap extends AbstractLifecycleBean
private TransactionService transactionService;
private RMCaveatConfigService caveatConfigService;
private CustomEmailMappingService customEmailMappingService;
private RecordsManagementAdminService adminService;
public void setTransactionService(TransactionService transactionService)
{
@@ -57,11 +55,6 @@ public class RecordsManagementBootstrap extends AbstractLifecycleBean
this.customEmailMappingService = customEmailMappingService;
}
public void setRecordsManagementAdminService(RecordsManagementAdminService adminService)
{
this.adminService = adminService;
}
public CustomEmailMappingService getCustomEmailMappingService()
{
return customEmailMappingService;
@@ -82,9 +75,6 @@ public class RecordsManagementBootstrap extends AbstractLifecycleBean
// initialise caveat config
caveatConfigService.init();
// Initialise the custom model
adminService.initialiseCustomModel();
// Initialise the SplitEmailAction
SplitEmailAction action = (SplitEmailAction)getApplicationContext().getBean("splitEmail");
action.bootstrap();

View File

@@ -18,6 +18,7 @@
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -44,7 +45,8 @@ import org.junit.runners.Suite.SuiteClasses;
RM1039Test.class,
RM1799Test.class,
//RM2190Test.class,
RM2192Test.class
RM2192Test.class,
RM3314Test.class
})
public class IssueTestSuite
{

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2005-2016 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
/**
* Test for https://issues.alfresco.com/jira/browse/RM-3114
*
* @author Roy Wetherall
* @since 2.2.1.5
*/
public class RM3314Test extends BaseRMTestCase
{
/** registry to record callback from test beans "test.rm3114.1" and "test.rm3114.2" */
public static Map<String, Boolean> callback = new HashMap<String, Boolean>(2);
/**
* Given that the custom model hasn't been initialised
* When an aspect is added
* Then nothing happens
*
* Given that the custom model has been initialised
* When an aspect is added
* Then something happens
*/
public void testListenersExecutedInTheCorrectOrder()
{
/**
* The related test beans will call back into the callback map showing
* whether at the end of their execution whether the custom model has been
* initialised or not. Given the order in which these test beans are executed
* on spring context load, we would expect that .1 executes with the custom
* map unloaded, and the .2 with it loaded.
*/
assertFalse(callback.isEmpty());
assertFalse(callback.get("test.rm3314.1"));
assertTrue(callback.get("test.rm3314.2"));
}
}

View File

@@ -0,0 +1,134 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminServiceImpl;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered;
import org.springframework.jdbc.BadSqlGrammarException;
/**
* Simple bean used to test RM-3314
*
* @author rwetherall
* @since 2.2.1.5
*/
public class RM3314TestListener implements ApplicationListener<ContextRefreshedEvent>,
Ordered,
BeanNameAware
{
private RecordsManagementAdminServiceImpl recordsManagementAdminService;
private NodeService nodeService;
private FileFolderService fileFolderService;
private Repository repository;
private String name;
private int order = Ordered.LOWEST_PRECEDENCE;
public void setRecordsManagementAdminService(RecordsManagementAdminServiceImpl recordsManagementAdminService)
{
this.recordsManagementAdminService = recordsManagementAdminService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setRepository(Repository repository)
{
this.repository = repository;
}
@Override
public void setBeanName(String name)
{
this.name = name;
}
public void setOrder(int order)
{
this.order = order;
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event)
{
// call back to show whether the custom map is initialised or not
RM3314Test.callback.put(name, recordsManagementAdminService.isCustomMapInit());
// Do some work on a node to show that reguardless of whether the custom map is
// init or not, things still work.
// Note: using public services to ensure new transaction for each service call
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
public Void doWork() throws Exception
{
try
{
// create node
NodeRef folder = fileFolderService.create(
repository.getCompanyHome(),
name,
ContentModel.TYPE_FOLDER).getNodeRef();
try
{
// add aspect
nodeService.addAspect(folder, ContentModel.ASPECT_CLASSIFIABLE, null);
// remove aspect
nodeService.removeAspect(folder, ContentModel.ASPECT_CLASSIFIABLE);
}
finally
{
// delete node
nodeService.deleteNode(folder);
}
}
catch (BadSqlGrammarException e)
{
// ignore and carry on
}
return null;
}
});
}
@Override
public int getOrder()
{
return order;
}
}

View File

@@ -240,4 +240,25 @@
</property>
</bean>
<!-- Test listeners -->
<!-- Executed with '0' order. This is default order and as such the application event will be executed relative to the other
beans in the order in which they appear in the spring context -->
<bean id="test.rm3314.1" class="org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314TestListener">
<property name="order" value="0"/>
<property name="recordsManagementAdminService" ref="recordsManagementAdminService"/>
<property name="nodeService" ref="NodeService"/>
<property name="fileFolderService" ref="FileFolderService" />
<property name="repository" ref="repositoryHelper" />
</bean>
<!-- The default order has this bean executing its application event with the lowest precendence, ie after all the other
beans set to '0' precendence by default -->
<bean id="test.rm3314.2" class="org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314TestListener">
<property name="recordsManagementAdminService" ref="recordsManagementAdminService"/>
<property name="nodeService" ref="NodeService"/>
<property name="fileFolderService" ref="FileFolderService" />
<property name="repository" ref="repositoryHelper" />
</bean>
</beans>