mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-23 18:05:32 +00:00
Added support to limit module execution to a specific range of repository versions.
e.g. the PHP SDK module has the following: module.repo.version.min=2.0 module.repo.version.max=2.1 This limits it to being installed on 2.0 or 2.1 versions of Alfresco. Roy can change this, if required. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5532 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
5fed27a6d9
commit
c1a69f0f3f
@ -7,6 +7,7 @@ module.msg.upgrading= Upgrading module ''{0}'' version {1} (was {2}).
|
|||||||
module.msg.missing= A previously-installed module ''{0}'' (version {1}) is not present in your distribution.
|
module.msg.missing= A previously-installed module ''{0}'' (version {1}) is not present in your distribution.
|
||||||
|
|
||||||
module.err.downgrading_not_supported=\nDowngrading of modules is not supported.\nModule ''{0}'' version {1} is currently installed and must be uninstalled before version {2} can be installed.
|
module.err.downgrading_not_supported=\nDowngrading of modules is not supported.\nModule ''{0}'' version {1} is currently installed and must be uninstalled before version {2} can be installed.
|
||||||
|
module.err.unsupported_repo_version=\nModule ''{0}'' version {1} is incompatible with the current repository version {2}.\n The repository version required must be in range [{3} : {4}].
|
||||||
module.err.already_executed=The module component has already been executed: {0}.{1}
|
module.err.already_executed=The module component has already been executed: {0}.{1}
|
||||||
module.err.execution_failed=A module component ''{0}'' failed to execute: {1}
|
module.err.execution_failed=A module component ''{0}'' failed to execute: {1}
|
||||||
module.err.component_already_registered=A component named ''{0}'' has already been registered for module ''{1}''.
|
module.err.component_already_registered=A component named ''{0}'' has already been registered for module ''{1}''.
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
<!-- The ModuleService implementation -->
|
<!-- The ModuleService implementation -->
|
||||||
<bean id="moduleService" class="org.alfresco.repo.module.ModuleServiceImpl">
|
<bean id="moduleService" class="org.alfresco.repo.module.ModuleServiceImpl">
|
||||||
<property name="serviceRegistry" ref="ServiceRegistry" />
|
<property name="serviceRegistry" ref="ServiceRegistry" />
|
||||||
|
<property name="descriptorService" ref="DescriptorService" />
|
||||||
<property name="authenticationComponent" ref="AuthenticationComponent" />
|
<property name="authenticationComponent" ref="AuthenticationComponent" />
|
||||||
<property name="registryService" ref="RegistryService" />
|
<property name="registryService" ref="RegistryService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
@ -50,6 +50,7 @@ import org.alfresco.service.namespace.NamespaceService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.AbstractLifecycleBean;
|
import org.alfresco.util.AbstractLifecycleBean;
|
||||||
|
import org.alfresco.util.VersionNumber;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
@ -453,6 +454,11 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
|||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VersionNumber getVersionNumber()
|
||||||
|
{
|
||||||
|
return new VersionNumber("1.0.0");
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
|
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
|
||||||
*/
|
*/
|
||||||
@ -503,9 +509,17 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
|||||||
*/
|
*/
|
||||||
public abstract class BaseDescriptor implements Descriptor
|
public abstract class BaseDescriptor implements Descriptor
|
||||||
{
|
{
|
||||||
/* (non-Javadoc)
|
public VersionNumber getVersionNumber()
|
||||||
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
|
{
|
||||||
*/
|
StringBuilder version = new StringBuilder();
|
||||||
|
version.append(getVersionMajor());
|
||||||
|
version.append(".");
|
||||||
|
version.append(getVersionMinor());
|
||||||
|
version.append(".");
|
||||||
|
version.append(getVersionRevision());
|
||||||
|
return new VersionNumber(version.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public String getVersion()
|
public String getVersion()
|
||||||
{
|
{
|
||||||
StringBuilder version = new StringBuilder(getVersionMajor());
|
StringBuilder version = new StringBuilder(getVersionMajor());
|
||||||
|
@ -45,6 +45,7 @@ import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
|||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.module.ModuleDetails;
|
import org.alfresco.service.cmr.module.ModuleDetails;
|
||||||
import org.alfresco.service.cmr.module.ModuleService;
|
import org.alfresco.service.cmr.module.ModuleService;
|
||||||
|
import org.alfresco.service.descriptor.DescriptorService;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.alfresco.util.VersionNumber;
|
import org.alfresco.util.VersionNumber;
|
||||||
@ -71,6 +72,7 @@ public class ModuleComponentHelper
|
|||||||
private static final String MSG_STARTING = "module.msg.starting";
|
private static final String MSG_STARTING = "module.msg.starting";
|
||||||
private static final String MSG_INSTALLING = "module.msg.installing";
|
private static final String MSG_INSTALLING = "module.msg.installing";
|
||||||
private static final String MSG_UPGRADING = "module.msg.upgrading";
|
private static final String MSG_UPGRADING = "module.msg.upgrading";
|
||||||
|
private static final String ERR_UNSUPPORTED_REPO_VERSION = "module.err.unsupported_repo_version";
|
||||||
private static final String ERR_NO_DOWNGRADE = "module.err.downgrading_not_supported";
|
private static final String ERR_NO_DOWNGRADE = "module.err.downgrading_not_supported";
|
||||||
private static final String ERR_COMPONENT_ALREADY_REGISTERED = "module.err.component_already_registered";
|
private static final String ERR_COMPONENT_ALREADY_REGISTERED = "module.err.component_already_registered";
|
||||||
private static final String MSG_MISSING = "module.msg.missing";
|
private static final String MSG_MISSING = "module.msg.missing";
|
||||||
@ -79,6 +81,7 @@ public class ModuleComponentHelper
|
|||||||
private static Log loggerService = LogFactory.getLog(ModuleServiceImpl.class);
|
private static Log loggerService = LogFactory.getLog(ModuleServiceImpl.class);
|
||||||
|
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
private DescriptorService descriptorService;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private RegistryService registryService;
|
private RegistryService registryService;
|
||||||
private ModuleService moduleService;
|
private ModuleService moduleService;
|
||||||
@ -98,6 +101,14 @@ public class ModuleComponentHelper
|
|||||||
this.serviceRegistry = serviceRegistry;
|
this.serviceRegistry = serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param descriptorService gives access to the current repository version
|
||||||
|
*/
|
||||||
|
public void setDescriptorService(DescriptorService descriptorService)
|
||||||
|
{
|
||||||
|
this.descriptorService = descriptorService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param authenticationComponent allows execution as system user.
|
* @param authenticationComponent allows execution as system user.
|
||||||
*/
|
*/
|
||||||
@ -271,6 +282,20 @@ public class ModuleComponentHelper
|
|||||||
{
|
{
|
||||||
String moduleId = module.getId();
|
String moduleId = module.getId();
|
||||||
VersionNumber moduleVersion = module.getVersion();
|
VersionNumber moduleVersion = module.getVersion();
|
||||||
|
|
||||||
|
// First check that the module version is fundamentall compatible with the repository
|
||||||
|
VersionNumber repoVersionNumber = descriptorService.getServerDescriptor().getVersionNumber();
|
||||||
|
VersionNumber minRepoVersionNumber = module.getRepoVersionMin();
|
||||||
|
VersionNumber maxRepoVersionNumber = module.getRepoVersionMax();
|
||||||
|
if ((minRepoVersionNumber != null && repoVersionNumber.compareTo(minRepoVersionNumber) < 0) ||
|
||||||
|
(maxRepoVersionNumber != null && repoVersionNumber.compareTo(maxRepoVersionNumber) > 0))
|
||||||
|
{
|
||||||
|
// The current repo version is not supported
|
||||||
|
throw AlfrescoRuntimeException.create(
|
||||||
|
ERR_UNSUPPORTED_REPO_VERSION,
|
||||||
|
moduleId, moduleVersion, repoVersionNumber, minRepoVersionNumber, maxRepoVersionNumber);
|
||||||
|
}
|
||||||
|
|
||||||
// Get the module details from the registry
|
// Get the module details from the registry
|
||||||
RegistryKey moduleKeyInstalledVersion = new RegistryKey(
|
RegistryKey moduleKeyInstalledVersion = new RegistryKey(
|
||||||
ModuleComponentHelper.URI_MODULES_1_0,
|
ModuleComponentHelper.URI_MODULES_1_0,
|
||||||
|
@ -33,6 +33,7 @@ import java.util.Map;
|
|||||||
import org.alfresco.repo.admin.registry.RegistryService;
|
import org.alfresco.repo.admin.registry.RegistryService;
|
||||||
import org.alfresco.service.cmr.module.ModuleDetails;
|
import org.alfresco.service.cmr.module.ModuleDetails;
|
||||||
import org.alfresco.service.cmr.module.ModuleService;
|
import org.alfresco.service.cmr.module.ModuleService;
|
||||||
|
import org.alfresco.service.descriptor.DescriptorService;
|
||||||
import org.alfresco.util.BaseAlfrescoTestCase;
|
import org.alfresco.util.BaseAlfrescoTestCase;
|
||||||
import org.alfresco.util.VersionNumber;
|
import org.alfresco.util.VersionNumber;
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase
|
|||||||
};
|
};
|
||||||
|
|
||||||
private RegistryService registryService;
|
private RegistryService registryService;
|
||||||
|
private DescriptorService descriptorService;
|
||||||
private DummyModuleService moduleService;
|
private DummyModuleService moduleService;
|
||||||
private ModuleComponentHelper helper;
|
private ModuleComponentHelper helper;
|
||||||
|
|
||||||
@ -93,6 +95,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase
|
|||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
registryService = (RegistryService) ctx.getBean("RegistryService");
|
registryService = (RegistryService) ctx.getBean("RegistryService");
|
||||||
|
descriptorService = serviceRegistry.getDescriptorService();
|
||||||
|
|
||||||
moduleService = new DummyModuleService();
|
moduleService = new DummyModuleService();
|
||||||
helper = new ModuleComponentHelper();
|
helper = new ModuleComponentHelper();
|
||||||
@ -100,6 +103,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase
|
|||||||
helper.setModuleService(moduleService);
|
helper.setModuleService(moduleService);
|
||||||
helper.setRegistryService(registryService);
|
helper.setRegistryService(registryService);
|
||||||
helper.setServiceRegistry(serviceRegistry);
|
helper.setServiceRegistry(serviceRegistry);
|
||||||
|
helper.setDescriptorService(descriptorService);
|
||||||
|
|
||||||
// Register the components
|
// Register the components
|
||||||
components = new DummyModuleComponent[3][3]; // i,j
|
components = new DummyModuleComponent[3][3]; // i,j
|
||||||
|
@ -42,6 +42,9 @@ import org.alfresco.util.VersionNumber;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @author Derek Hulley
|
||||||
|
*/
|
||||||
public class ModuleDetailsImpl implements ModuleDetails
|
public class ModuleDetailsImpl implements ModuleDetails
|
||||||
{
|
{
|
||||||
private String id;
|
private String id;
|
||||||
@ -114,6 +117,13 @@ public class ModuleDetailsImpl implements ModuleDetails
|
|||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("The following module properties need to be defined: " + missingProperties);
|
throw new AlfrescoRuntimeException("The following module properties need to be defined: " + missingProperties);
|
||||||
}
|
}
|
||||||
|
if (repoVersionMax.compareTo(repoVersionMin) < 0)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("The max repo version must be greater than the min repo version:\n" +
|
||||||
|
" ID: " + id + "\n" +
|
||||||
|
" Min repo version: " + repoVersionMin + "\n" +
|
||||||
|
" Max repo version: " + repoVersionMax);
|
||||||
|
}
|
||||||
|
|
||||||
// Set other defaults
|
// Set other defaults
|
||||||
installState = ModuleInstallState.INSTALLED;
|
installState = ModuleInstallState.INSTALLED;
|
||||||
@ -195,11 +205,21 @@ public class ModuleDetailsImpl implements ModuleDetails
|
|||||||
return repoVersionMin;
|
return repoVersionMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRepoVersionMin(VersionNumber repoVersionMin)
|
||||||
|
{
|
||||||
|
this.repoVersionMin = repoVersionMin;
|
||||||
|
}
|
||||||
|
|
||||||
public VersionNumber getRepoVersionMax()
|
public VersionNumber getRepoVersionMax()
|
||||||
{
|
{
|
||||||
return repoVersionMax;
|
return repoVersionMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRepoVersionMax(VersionNumber repoVersionMax)
|
||||||
|
{
|
||||||
|
this.repoVersionMax = repoVersionMax;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getInstallDate()
|
public Date getInstallDate()
|
||||||
{
|
{
|
||||||
return installDate;
|
return installDate;
|
||||||
|
@ -40,6 +40,7 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
|||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.module.ModuleDetails;
|
import org.alfresco.service.cmr.module.ModuleDetails;
|
||||||
import org.alfresco.service.cmr.module.ModuleService;
|
import org.alfresco.service.cmr.module.ModuleService;
|
||||||
|
import org.alfresco.service.descriptor.DescriptorService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@ -73,6 +74,7 @@ public class ModuleServiceImpl implements ModuleService
|
|||||||
private static Log logger = LogFactory.getLog(ModuleServiceImpl.class);
|
private static Log logger = LogFactory.getLog(ModuleServiceImpl.class);
|
||||||
|
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
private DescriptorService descriptorService;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private ModuleComponentHelper moduleComponentHelper;
|
private ModuleComponentHelper moduleComponentHelper;
|
||||||
/** A cache of module details by module ID */
|
/** A cache of module details by module ID */
|
||||||
@ -91,6 +93,12 @@ public class ModuleServiceImpl implements ModuleService
|
|||||||
this.moduleComponentHelper.setServiceRegistry(this.serviceRegistry);
|
this.moduleComponentHelper.setServiceRegistry(this.serviceRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDescriptorService(DescriptorService descriptorService)
|
||||||
|
{
|
||||||
|
this.descriptorService = descriptorService;
|
||||||
|
this.moduleComponentHelper.setDescriptorService(descriptorService);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param authenticationComponent allows execution as system user.
|
* @param authenticationComponent allows execution as system user.
|
||||||
*/
|
*/
|
||||||
|
@ -81,6 +81,26 @@ public interface ModuleDetails
|
|||||||
*/
|
*/
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the minimum version of the repository in which the module may be active
|
||||||
|
*/
|
||||||
|
VersionNumber getRepoVersionMin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param repoVersionMin the minimum version of the repository in which the module may be acitve
|
||||||
|
*/
|
||||||
|
void setRepoVersionMin(VersionNumber repoVersionMin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the maximum version of the repository in which the module may be active
|
||||||
|
*/
|
||||||
|
VersionNumber getRepoVersionMax();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param repoVersionMax the maximum version of the repository in which the module may be acitve
|
||||||
|
*/
|
||||||
|
void setRepoVersionMax(VersionNumber repoVersionMax);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the modules install date
|
* Get the modules install date
|
||||||
*
|
*
|
||||||
|
@ -25,13 +25,18 @@
|
|||||||
package org.alfresco.service.cmr.module;
|
package org.alfresco.service.cmr.module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum used to indicate the install state of a module
|
* Enum used to indicate the install state of a module.
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public enum ModuleInstallState
|
public enum ModuleInstallState
|
||||||
{
|
{
|
||||||
INSTALLED, // indicates that a module is installed
|
/** The state of the module is unknown */
|
||||||
DISABLED, // indicates that a module is installed but it functionality is disabled
|
UKNOWN,
|
||||||
UNINSTALLED // indicates that a module is uninstalled
|
/** The module is installed */
|
||||||
|
INSTALLED,
|
||||||
|
/** The module is disabled */
|
||||||
|
DISABLED,
|
||||||
|
/** The module has been uninstalled */
|
||||||
|
UNINSTALLED;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.service.descriptor;
|
package org.alfresco.service.descriptor;
|
||||||
|
|
||||||
|
import org.alfresco.util.VersionNumber;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides meta-data for the Alfresco stack.
|
* Provides meta-data for the Alfresco stack.
|
||||||
@ -67,6 +69,11 @@ public interface Descriptor
|
|||||||
*/
|
*/
|
||||||
public String getVersionBuild();
|
public String getVersionBuild();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the object representing the major-minor-revision numbers
|
||||||
|
*/
|
||||||
|
public VersionNumber getVersionNumber();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the full version number
|
* Gets the full version number
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user