mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Move RM 2.2 dependency to 4.2.2-SNAPSHOT
* fix issues so that RM 2.2 is still backwards compatible with 4.2.1 (and 4.2.0) * added 'bean extender' .. a post processor bean that allows us to extend, rather than overrite, core bean definitions. Gives us a technique we can use that won't be disrupted when changes are made to core bean definitions. * unit test for above * tested with 4.2.2-SNAPSHOT and 4.2.1 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@68290 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.compatibility;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
|
||||
/**
|
||||
* Dictionary bootstap post processor.
|
||||
* <p>
|
||||
* Ensures compatibility with 4.2 and 4.2.1 as well as 4.2.2.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class DictionaryBootstrapPostProcessor implements BeanFactoryPostProcessor
|
||||
{
|
||||
/** bean id's */
|
||||
private static final String BEAN_SITESERVICE_BOOTSTRAP = "siteService_dictionaryBootstrap";
|
||||
private static final String BEAN_RM_DICTIONARY_BOOTSTRAP = "org_alfresco_module_rm_dictionaryBootstrap";
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
|
||||
*/
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
|
||||
{
|
||||
// if the site service bootstrap bean and the RM dictionary bean are present in the bean factory
|
||||
if (beanFactory.containsBean(BEAN_SITESERVICE_BOOTSTRAP) &&
|
||||
beanFactory.containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP))
|
||||
{
|
||||
// get the RM dictionary bootstrap bean definition
|
||||
BeanDefinition beanDef = beanFactory.getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP);
|
||||
|
||||
// set the dependency
|
||||
beanDef.setDependsOn(new String[]{BEAN_SITESERVICE_BOOTSTRAP});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -825,7 +825,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
ParameterCheck.mandatory("name", name);
|
||||
|
||||
NodeRef destination = nodeRef;
|
||||
if (filePlanService.isFilePlan(nodeRef))
|
||||
if (isFilePlan(nodeRef))
|
||||
{
|
||||
// get the unfiled record container for the file plan
|
||||
destination = filePlanService.getUnfiledContainer(nodeRef);
|
||||
@@ -1144,7 +1144,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
|
||||
// DEBUG ...
|
||||
NodeRef filePlan = filePlanService.getFilePlan(record);
|
||||
NodeRef filePlan = getFilePlan(record);
|
||||
Set<Role> roles = filePlanRoleService.getRolesByUser(filePlan, AuthenticationUtil.getRunAsUser());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
|
||||
/**
|
||||
* Extends the definition of a bean with another.
|
||||
* <p>
|
||||
* Implements bean factory post processor.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class BeanExtender implements BeanFactoryPostProcessor
|
||||
{
|
||||
/** name of bean to extend */
|
||||
private String beanName;
|
||||
|
||||
/** extending bean name */
|
||||
private String extendingBeanName;
|
||||
|
||||
/**
|
||||
* @param beanName bean name
|
||||
*/
|
||||
public void setBeanName(String beanName)
|
||||
{
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extendingBeanName extending bean name
|
||||
*/
|
||||
public void setExtendingBeanName(String extendingBeanName)
|
||||
{
|
||||
this.extendingBeanName = extendingBeanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
|
||||
*/
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
|
||||
{
|
||||
ParameterCheck.mandatory("beanName", beanName);
|
||||
ParameterCheck.mandatory("extendingBeanName", extendingBeanName);
|
||||
|
||||
// check for bean name
|
||||
if (!beanFactory.containsBean(beanName))
|
||||
{
|
||||
throw new NoSuchBeanDefinitionException("Can't find bean '" + beanName + "' to be extended.");
|
||||
}
|
||||
|
||||
// check for extending bean
|
||||
if (!beanFactory.containsBean(extendingBeanName))
|
||||
{
|
||||
throw new NoSuchBeanDefinitionException("Can't find bean '" + extendingBeanName + "' that is going to extend origional bean definition.");
|
||||
}
|
||||
|
||||
// get the bean definitions
|
||||
BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
|
||||
BeanDefinition extendingBeanDefinition = beanFactory.getBeanDefinition(extendingBeanName);
|
||||
|
||||
// update class
|
||||
if (StringUtils.isNotBlank(extendingBeanDefinition.getBeanClassName()) &&
|
||||
!beanDefinition.getBeanClassName().equals(extendingBeanDefinition.getBeanClassName()))
|
||||
{
|
||||
beanDefinition.setBeanClassName(extendingBeanDefinition.getBeanClassName());
|
||||
}
|
||||
|
||||
// update properties
|
||||
MutablePropertyValues properties = beanDefinition.getPropertyValues();
|
||||
MutablePropertyValues extendingProperties = extendingBeanDefinition.getPropertyValues();
|
||||
for (PropertyValue propertyValue : extendingProperties.getPropertyValueList())
|
||||
{
|
||||
properties.add(propertyValue.getName(), propertyValue.getValue());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
|
Reference in New Issue
Block a user