diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-classified-records-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-classified-records-context.xml index e42ba76443..6ed0851f8a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-classified-records-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-classified-records-context.xml @@ -49,4 +49,11 @@ + + + + + + diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrap.java new file mode 100644 index 0000000000..8a5c712471 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrap.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005-2015 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.classification; + +import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.transaction.TransactionService; +import org.springframework.context.ApplicationEvent; +import org.springframework.extensions.surf.util.AbstractLifecycleBean; + +/** + * This class is responsible for initialising any Classification-specific data on server bootstrap. + * + * @author Neil Mc Erlean + * @since 3.0 + */ +public class ClassificationServiceBootstrap extends AbstractLifecycleBean +{ + private final AuthenticationUtil authenticationUtil; + private final ClassificationServiceImpl classificationService; + private final TransactionService transactionService; + + public ClassificationServiceBootstrap(AuthenticationUtil authUtil, + ClassificationServiceImpl cService, + TransactionService txService) + { + this.authenticationUtil = authUtil; + this.classificationService = cService; + this.transactionService = txService; + } + + @Override protected void onBootstrap(ApplicationEvent event) + { + authenticationUtil.runAsSystem(new org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork() + { + public Void doWork() + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + public Void execute() + { + classificationService.initConfiguredClassificationLevels(); + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(callback); + return null; + } + }); + } + + @Override protected void onShutdown(ApplicationEvent event) + { + // Intentionally empty. + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java index bb744d2a5e..affc7b89cc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java @@ -54,7 +54,7 @@ public class ClassificationServiceImpl extends ServiceBaseImpl public void setAttributeService(AttributeService service) { this.attributeService = service; } - public void initConfiguredClassificationLevels() + void initConfiguredClassificationLevels() { final List allPersistedLevels = getPersistedLevels(); final List configuredLevels = getConfiguredLevels(); @@ -62,7 +62,7 @@ public class ClassificationServiceImpl extends ServiceBaseImpl if (logger.isDebugEnabled()) { // Note! We cannot log the level names or even the size of these lists for security reasons. - logger.debug("Persisted classification levels: " + loggableStatusOf(allPersistedLevels)); + logger.debug("Persisted classification levels: " + loggableStatusOf(allPersistedLevels)); logger.debug("Configured classification levels: " + loggableStatusOf(configuredLevels)); }