mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Work on RM-2027. Addition of the Java API code to retrieve classification reasons and some of the test code associated with that. WIP. Test code not complete. +review RM
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@100255 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,4 +37,10 @@ public interface ClassificationService
|
||||
* and therefore access to the most restricted documents).
|
||||
*/
|
||||
List<ClassificationLevel> getClassificationLevels();
|
||||
|
||||
/**
|
||||
* Returns an immutable list of the defined classification reasons.
|
||||
* @return classification reasons in the order that they are defined.
|
||||
*/
|
||||
List<ClassificationReason> getClassificationReasons();
|
||||
}
|
||||
|
@@ -98,28 +98,36 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
|
||||
void initConfiguredClassificationReasons() {
|
||||
final List<ClassificationReason> allPersistedReasons = getPersistedReasons();
|
||||
final List<ClassificationReason> configurationReasons = getConfigurationReasons();
|
||||
final List<ClassificationReason> persistedReasons = getPersistedReasons();
|
||||
final List<ClassificationReason> classpathReasons = getConfigurationReasons();
|
||||
|
||||
// Note! We cannot log the reasons or even the size of these lists for security reasons.
|
||||
LOGGER.debug("Persisted classification reasons: {}", loggableStatusOf(allPersistedReasons));
|
||||
LOGGER.debug("Classpath classification reasons: {}", loggableStatusOf(configurationReasons));
|
||||
// Note! We cannot log the reasons or even the size of these lists for security reasons.
|
||||
LOGGER.debug("Persisted classification reasons: {}", loggableStatusOf(persistedReasons));
|
||||
LOGGER.debug("Classpath classification reasons: {}", loggableStatusOf(classpathReasons));
|
||||
|
||||
if (configurationReasons == null || configurationReasons.isEmpty())
|
||||
if (isEmpty(persistedReasons))
|
||||
{
|
||||
throw new MissingConfiguration("Classification reason configuration is missing.");
|
||||
}
|
||||
else if ( !configurationReasons.equals(allPersistedReasons))
|
||||
{
|
||||
attributeService.setAttribute((Serializable) configurationReasons, REASONS_KEY);
|
||||
this.configuredReasons = configurationReasons;
|
||||
if (isEmpty(classpathReasons))
|
||||
{
|
||||
throw new MissingConfiguration("Classification reason configuration is missing.");
|
||||
}
|
||||
attributeService.setAttribute((Serializable) classpathReasons, REASONS_KEY);
|
||||
this.configuredReasons = classpathReasons;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.configuredReasons = allPersistedReasons;
|
||||
if (isEmpty(classpathReasons) || !classpathReasons.equals(persistedReasons))
|
||||
{
|
||||
LOGGER.warn("Classification reasons configured in classpath do not match those stored in Alfresco." +
|
||||
"Alfresco will use the unchanged values stored in the database.");
|
||||
// RM-2073 says that we should log a warning and proceed normally.
|
||||
}
|
||||
this.configuredReasons = persistedReasons;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEmpty(List<?> l) { return l == null || l.isEmpty(); }
|
||||
|
||||
/** Helper method for debug-logging of sensitive lists. */
|
||||
private String loggableStatusOf(List<?> l)
|
||||
{
|
||||
@@ -178,4 +186,9 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
|
||||
return configuredLevels == null ? Collections.<ClassificationLevel>emptyList() :
|
||||
Collections.unmodifiableList(configuredLevels);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public List<ClassificationReason> getClassificationReasons()
|
||||
{
|
||||
return configuredReasons == null ? Collections.<ClassificationReason>emptyList() :
|
||||
Collections.unmodifiableList(configuredReasons);
|
||||
}}
|
||||
|
@@ -84,7 +84,7 @@ class Configuration
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of classification reasons as defined in the system configuration.
|
||||
* Gets the list of classification reasons as defined in the classpath.
|
||||
*
|
||||
* @return the configured classification reasons in descending order, or an empty list if there are none.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user