RM-2401, RM-2400, RM-2409 Store classification schedule properties.

Update Java API to store the classification schedule properties.

Fix the classification aspect behaviour to check newly classified
documents.

Add an application context test that the downgrade instructions are
mandatory when the downgrade date is set.

+review RM

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@109015 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tom Page
2015-07-27 10:27:16 +00:00
parent 6d4df8571c
commit d8da135d63
5 changed files with 84 additions and 12 deletions

View File

@@ -19,8 +19,11 @@
package org.alfresco.module.org_alfresco_module_rm.classification;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
/**
* A data transfer object for properties from the classification aspect.
*
@@ -36,7 +39,7 @@ public class ClassificationAspectProperties
/** The name of the agency responsible for the classification of this content. */
private String classificationAgency;
/** A non-empty set of ids of reasons for classifying the content in this way. */
private Set<String> classificationReasonIds;
private Set<String> classificationReasonIds = new HashSet<>();
/** If provided, this is the date of the next downgrade evaluation. */
private Date downgradeDate;
/** If provided, this is the event at which the next downgrade evaluation will take place. */
@@ -47,8 +50,8 @@ public class ClassificationAspectProperties
private Date declassificationDate;
/** If provided, this is the event at which the next declassification evaluation will take place. */
private String declassificationEvent;
/** This is an optional list of exemption category ids. */
private Set<String> exemptionCategoryIds;
/** An optional list of exemption category ids. */
private Set<String> exemptionCategoryIds = new HashSet<>();
/** @return The security clearance needed to access the content. */
public String getClassificationLevelId()
@@ -85,10 +88,14 @@ public class ClassificationAspectProperties
{
return classificationReasonIds;
}
/** @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way. */
/**
* Store an immutable copy of the given set of classification reason ids.
*
* @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way.
*/
public void setClassificationReasonIds(Set<String> classificationReasonIds)
{
this.classificationReasonIds = classificationReasonIds;
this.classificationReasonIds = ImmutableSet.copyOf(classificationReasonIds);
}
/** @return If provided, this is the date of the next downgrade evaluation. */
public Date getDowngradeDate()
@@ -145,9 +152,13 @@ public class ClassificationAspectProperties
{
return exemptionCategoryIds;
}
/** @param exemptionCategoryIds This is an optional list of exemption category ids. */
/**
* Store an immutable copy of the given set of exemption category ids.
*
* @param exemptionCategoryIds This is an optional list of exemption category ids.
*/
public void setExemptionCategoryIds(Set<String> exemptionCategoryIds)
{
this.exemptionCategoryIds = exemptionCategoryIds;
this.exemptionCategoryIds = ImmutableSet.copyOf(exemptionCategoryIds);
}
}

View File

@@ -177,6 +177,15 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
HashSet<String> classificationReasons = new HashSet<>(propertiesDTO.getClassificationReasonIds());
propertiesMap.put(PROP_CLASSIFICATION_REASONS, classificationReasons);
propertiesMap.put(PROP_DOWNGRADE_DATE, propertiesDTO.getDowngradeDate());
propertiesMap.put(PROP_DOWNGRADE_EVENT, propertiesDTO.getDowngradeEvent());
propertiesMap.put(PROP_DOWNGRADE_INSTRUCTIONS, propertiesDTO.getDowngradeInstructions());
propertiesMap.put(PROP_DECLASSIFICATION_DATE, propertiesDTO.getDeclassificationDate());
propertiesMap.put(PROP_DECLASSIFICATION_EVENT, propertiesDTO.getDeclassificationEvent());
HashSet<String> declassificationExemptions = new HashSet<>(propertiesDTO.getExemptionCategoryIds());
propertiesMap.put(PROP_DECLASSIFICATION_EXEMPTIONS, declassificationExemptions);
return propertiesMap;
}

View File

@@ -115,6 +115,11 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
* Validates the consistency of the properties.
*/
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
notificationFrequency = NotificationFrequency.EVERY_EVENT
)
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
{
AuthenticationUtil.runAs(new RunAsWork<Void>()

View File

@@ -19,9 +19,11 @@
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification;
import java.util.Collections;
import java.util.Date;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingDowngradeInstructions;
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
@@ -210,4 +212,42 @@ public class ClassifyTest extends BaseRMTestCase
}
});
}
/**
* Downgrade instructions are mandatory when downgrade date is set.
* <p>
* <a href="https://issues.alfresco.com/jira/browse/RM-2409">RM-2409</a><pre>
* Given I am a cleared user
* And I am classifying the content for the first time
* And I enter a downgrade date and/or event
* When I attempt to save the classification information
* Then I will be informed that downgrade instructions are mandatory when the downgrade date and/or event are set
* And the save will not be successful
* </pre>
*/
public void testMissingDowngradeInstructions() throws Exception
{
doBehaviourDrivenTest(new BehaviourDrivenTest(MissingDowngradeInstructions.class)
{
private NodeRef record;
public void given() throws Exception
{
record = utils.createRecord(rmFolder, RECORD_NAME);
}
public void when() throws Exception
{
propertiesDTO.setDowngradeDate(new Date());
assertNull("Downgrade instructions should be null.", propertiesDTO.getDowngradeInstructions());
contentClassificationService.classifyContent(propertiesDTO, record);
}
public void after()
{
assertFalse("Record should not have been classified.",
nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED));
}
});
}
}

View File

@@ -115,11 +115,18 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
propertiesCaptor.capture());
// Check the properties that were received.
Map<QName, Serializable> properties = propertiesCaptor.getValue();
HashSet<QName> expectedPropertyKeys = Sets.newHashSet(ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION,
ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION,
ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY,
ClassifiedContentModel.PROP_CLASSIFIED_BY,
ClassifiedContentModel.PROP_CLASSIFICATION_REASONS);
HashSet<QName> expectedPropertyKeys = Sets.newHashSet(
PROP_INITIAL_CLASSIFICATION,
PROP_CURRENT_CLASSIFICATION,
PROP_CLASSIFICATION_AGENCY,
PROP_CLASSIFIED_BY,
PROP_CLASSIFICATION_REASONS,
PROP_DOWNGRADE_DATE,
PROP_DOWNGRADE_EVENT,
PROP_DOWNGRADE_INSTRUCTIONS,
PROP_DECLASSIFICATION_DATE,
PROP_DECLASSIFICATION_EVENT,
PROP_DECLASSIFICATION_EXEMPTIONS);
assertEquals("Aspect created with unexpected set of keys.", expectedPropertyKeys, properties.keySet());
assertEquals("Unexpected initial classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION));
assertEquals("Unexpected current classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION));