mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2320 Java API for getExemptionCategories.
Also RM-2321 automation testing for the initial loading of exemption categories. +review RM git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@106565 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -82,6 +82,7 @@
|
||||
org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getClassificationLevelById=ACL_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getClassificationReasonById=ACL_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getUnclassifiedClassificationLevel=ACL_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getExemptionCategories=ACL_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.*=ACL_DENY
|
||||
</value>
|
||||
</property>
|
||||
|
@@ -71,4 +71,11 @@ public interface ClassificationSchemeService
|
||||
* @throws ReasonIdNotFound If the given classification reason id is not found
|
||||
*/
|
||||
ClassificationReason getClassificationReasonById(String classificationReasonId) throws ReasonIdNotFound;
|
||||
|
||||
/**
|
||||
* Returns an immutable list of the defined exemption categories.
|
||||
*
|
||||
* @return The exemption categories in the order that they are defined.
|
||||
*/
|
||||
List<ExemptionCategory> getExemptionCategories();
|
||||
}
|
||||
|
@@ -40,6 +40,8 @@ public class ClassificationSchemeServiceImpl extends ServiceBaseImpl implements
|
||||
private ClassificationLevelManager levelManager;
|
||||
/** The classification reasons currently configured in this server. */
|
||||
private ClassificationReasonManager reasonManager;
|
||||
/** The exemption categories currently configured in this server. */
|
||||
private ExemptionCategoryManager exemptionCategoryManager;
|
||||
private SecurityClearanceService securityClearanceService;
|
||||
private ClassificationServiceBootstrap classificationServiceBootstrap;
|
||||
|
||||
@@ -52,6 +54,7 @@ public class ClassificationSchemeServiceImpl extends ServiceBaseImpl implements
|
||||
{
|
||||
levelManager = classificationServiceBootstrap.getClassificationLevelManager();
|
||||
reasonManager = classificationServiceBootstrap.getClassificationReasonManager();
|
||||
exemptionCategoryManager = classificationServiceBootstrap.getExemptionCategoryManager();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,4 +115,11 @@ public class ClassificationSchemeServiceImpl extends ServiceBaseImpl implements
|
||||
checkNotBlank("classificationReasonId", classificationReasonId);
|
||||
return reasonManager.findReasonById(classificationReasonId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExemptionCategory> getExemptionCategories()
|
||||
{
|
||||
return (exemptionCategoryManager == null ? Collections.<ExemptionCategory>emptyList() :
|
||||
Collections.unmodifiableList(exemptionCategoryManager.getExemptionCategories()));
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationE
|
||||
* Container for the configured {@link ExemptionCategory} objects.
|
||||
*
|
||||
* @author tpage
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ExemptionCategoryManager
|
||||
{
|
||||
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* Tests of exemption category loading.
|
||||
*
|
||||
* @author tpage
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ExemptionCategoriesTest extends BaseRMTestCase
|
||||
{
|
||||
/**
|
||||
* Initial exemption category loading.
|
||||
* <p>
|
||||
* <a href="https://issues.alfresco.com/jira/browse/RM-2321">RM-2321</a><pre>
|
||||
* Given that I have a clean system
|
||||
* When I boot it for the first time
|
||||
* Then the default set of exemption categories are loaded
|
||||
* And are available throughout the application
|
||||
* </pre><p>
|
||||
* Note that this test requires a clean db, as otherwise the classification scheme service will use
|
||||
* the persisted exemption categories in preference to those given on the classpath (see the logic in
|
||||
* {@link ClassificationServiceBootstrap#onBootstrap(ApplicationEvent)}).
|
||||
*/
|
||||
public void testLoadBootstrappedExemptionCategories() throws Exception
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
public void given() throws Exception
|
||||
{
|
||||
// NOOP: I have a clean system.
|
||||
}
|
||||
|
||||
public void when() throws Exception
|
||||
{
|
||||
// NOOP: I boot it for the first time.
|
||||
}
|
||||
|
||||
public void then() throws Exception
|
||||
{
|
||||
// Check the classification scheme service exposes the classification reasons.
|
||||
List<ExemptionCategory> exemptionCategories = classificationSchemeService.getExemptionCategories();
|
||||
assertNotNull(exemptionCategories);
|
||||
assertEquals("The default exemption categories in test/resources/alfresco/module/"
|
||||
+ "org_alfresco_module_rm/classification/rm-exemption-categories.json "
|
||||
+ "contains three categories.", 3, exemptionCategories.size());
|
||||
// Check a couple of fields in the loaded data.
|
||||
assertEquals("Unexpected id for the first test category.", "Test Category 1", exemptionCategories.get(0).getId());
|
||||
assertEquals("Unexpected displayLabelKey for the third test category.",
|
||||
"rm.test.exemption-category.three", exemptionCategories.get(2).getDisplayLabel());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
[{
|
||||
"id" : "Test Category 1",
|
||||
"displayLabel" : "rm.test.exemption-category.one"
|
||||
},{
|
||||
"id" : "Test Category 2",
|
||||
"displayLabel" : "rm.test.exemption-category.two"
|
||||
},{
|
||||
"id" : "Test Category 3",
|
||||
"displayLabel" : "rm.test.exemption-category.three"
|
||||
}]
|
Reference in New Issue
Block a user