Merge of BRANCHES/DEV/4.2_ENT_DEV/ADMIN_CONSOLE - Admin Console 46247-46672

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@46677 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2013-02-15 11:44:53 +00:00
parent dc60a53187
commit a625d87120
27 changed files with 930 additions and 51 deletions

View File

@@ -346,6 +346,36 @@ public class ModuleComponentHelper
throw AlfrescoRuntimeException.create(ERR_ORPHANED_COMPONENTS, missedComponents.size());
}
}
/**
* Gets a list of all registered modules.
*
* @return A Collection of module IDs
*/
Collection<String> getRegistryModuleIDs()
{
// Get the IDs of all modules from the registry
RegistryKey moduleKeyAllIds = new RegistryKey(
ModuleComponentHelper.URI_MODULES_1_0,
REGISTRY_PATH_MODULES, null);
return registryService.getChildElements(moduleKeyAllIds);
}
/**
* Returns the version number of a module from the Registry.
*
* @param moduleId
* @return
*/
VersionNumber getVersion(String moduleId)
{
RegistryKey moduleKeyCurrentVersion = new RegistryKey(
ModuleComponentHelper.URI_MODULES_1_0,
REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_CURRENT_VERSION);
VersionNumber versionCurrent = (VersionNumber) registryService.getProperty(moduleKeyCurrentVersion);
return versionCurrent;
}
/**
* Checks to see if there are any modules registered as installed that aren't in the
@@ -356,10 +386,7 @@ public class ModuleComponentHelper
private void checkForMissingModules()
{
// Get the IDs of all modules from the registry
RegistryKey moduleKeyAllIds = new RegistryKey(
ModuleComponentHelper.URI_MODULES_1_0,
REGISTRY_PATH_MODULES, null);
Collection<String> moduleIds = registryService.getChildElements(moduleKeyAllIds);
Collection<String> moduleIds = getRegistryModuleIDs();
// Check that each module is present in the distribution
for (String moduleId : moduleIds)
@@ -375,10 +402,8 @@ public class ModuleComponentHelper
else
{
// Get the specifics of the missing module
RegistryKey moduleKeyCurrentVersion = new RegistryKey(
ModuleComponentHelper.URI_MODULES_1_0,
REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_CURRENT_VERSION);
VersionNumber versionCurrent = (VersionNumber) registryService.getProperty(moduleKeyCurrentVersion);
VersionNumber versionCurrent = getVersion(moduleId);
// The module is missing, so warn
loggerService.warn(I18NUtil.getMessage(MSG_MISSING, moduleId, versionCurrent));
}

View File

@@ -247,6 +247,24 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase
{
throw new UnsupportedOperationException();
}
@Override
public List<ModuleDetails> getMissingModules()
{
// Create some module details
List<ModuleDetails> details = new ArrayList<ModuleDetails>(3);
for (int i = 0; i < 3; i++)
{
ModuleDetails moduleDetails = new ModuleDetailsImpl(
MODULE_IDS[i],
currentVersion,
"Module-" + i,
"Description-" + i);
details.add(moduleDetails);
}
// Done
return details;
}
}
/** Keep track of the execution count */

View File

@@ -27,14 +27,17 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.admin.registry.RegistryKey;
import org.alfresco.repo.admin.registry.RegistryService;
import org.alfresco.repo.tenant.TenantAdminService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.module.ModuleDetails;
import org.alfresco.service.cmr.module.ModuleService;
import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.util.VersionNumber;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
@@ -43,6 +46,7 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* This component controls the execution of
@@ -162,6 +166,35 @@ public class ModuleServiceImpl implements ApplicationContextAware, ModuleService
return result;
}
/**
* {@inheritDoc}
*/
public List<ModuleDetails> getMissingModules()
{
cacheModuleDetails();
// Get the IDs of all modules from the registry
Collection<String> moduleIds = moduleComponentHelper.getRegistryModuleIDs();
List<ModuleDetails> result = new ArrayList<ModuleDetails>();
//Check for missing modules
for (String moduleId : moduleIds)
{
ModuleDetails moduleDetails = getModule(moduleId);
if (moduleDetails == null)
{
// Get the specifics of the missing module and add them to the list.
VersionNumber currentVersion = moduleComponentHelper.getVersion(moduleId);
ModuleDetails newModuleDetails = new ModuleDetailsImpl(moduleId, currentVersion, "", "");
result.add(newModuleDetails);
}
}
return result;
}
/**
* Ensure that the {@link #moduleDetailsById module details} are populated.
* <p/>