mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-2401 Pass classification schedule fields when classifying content.
Create a new data transfer object and add all the classification fields to it. Update everywhere we're classifying content with the API to use the data transfer object. Also update the new edit classification API. Break the classifyContent implementation into several smaller methods and update unit tests to target these methods. Don't actually use new fields in this commit, as there was plenty in this commit as it was! +review RM git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@108928 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.classification;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A data transfer object for properties from the classification aspect.
|
||||
*
|
||||
* @author Tom Page
|
||||
* @since 3.0.a
|
||||
*/
|
||||
public class ClassificationAspectProperties
|
||||
{
|
||||
/** The security clearance needed to access the content. */
|
||||
private String classificationLevelId;
|
||||
/** Free-form text identifying who classified the content. */
|
||||
private String classifiedBy;
|
||||
/** 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;
|
||||
/** 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. */
|
||||
private String downgradeEvent;
|
||||
/** If a downgrade date or event is given then this must be provided too with the instructions for the evaluation. */
|
||||
private String downgradeInstructions;
|
||||
/** If provided, this is the date of the next declassification evaluation. */
|
||||
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;
|
||||
|
||||
/** @return The security clearance needed to access the content. */
|
||||
public String getClassificationLevelId()
|
||||
{
|
||||
return classificationLevelId;
|
||||
}
|
||||
/** @param classificationLevelId The security clearance needed to access the content. */
|
||||
public void setClassificationLevelId(String classificationLevelId)
|
||||
{
|
||||
this.classificationLevelId = classificationLevelId;
|
||||
}
|
||||
/** @return Free-form text identifying who classified the content. */
|
||||
public String getClassifiedBy()
|
||||
{
|
||||
return classifiedBy;
|
||||
}
|
||||
/** @param classifiedBy Free-form text identifying who classified the content. */
|
||||
public void setClassifiedBy(String classifiedBy)
|
||||
{
|
||||
this.classifiedBy = classifiedBy;
|
||||
}
|
||||
/** @return The name of the agency responsible for the classification of this content. */
|
||||
public String getClassificationAgency()
|
||||
{
|
||||
return classificationAgency;
|
||||
}
|
||||
/** @param classificationAgency The name of the agency responsible for the classification of this content. */
|
||||
public void setClassificationAgency(String classificationAgency)
|
||||
{
|
||||
this.classificationAgency = classificationAgency;
|
||||
}
|
||||
/** @return A non-empty set of ids of reasons for classifying the content in this way. */
|
||||
public Set<String> getClassificationReasonIds()
|
||||
{
|
||||
return classificationReasonIds;
|
||||
}
|
||||
/** @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;
|
||||
}
|
||||
/** @return If provided, this is the date of the next downgrade evaluation. */
|
||||
public Date getDowngradeDate()
|
||||
{
|
||||
return downgradeDate;
|
||||
}
|
||||
/** @param downgradeDate If provided, this is the date of the next downgrade evaluation. */
|
||||
public void setDowngradeDate(Date downgradeDate)
|
||||
{
|
||||
this.downgradeDate = downgradeDate;
|
||||
}
|
||||
/** @return If provided, this is the event at which the next downgrade evaluation will take place. */
|
||||
public String getDowngradeEvent()
|
||||
{
|
||||
return downgradeEvent;
|
||||
}
|
||||
/** @param downgradeEvent If provided, this is the event at which the next downgrade evaluation will take place. */
|
||||
public void setDowngradeEvent(String downgradeEvent)
|
||||
{
|
||||
this.downgradeEvent = downgradeEvent;
|
||||
}
|
||||
/** @return If a downgrade date or event is given then this must be provided too with the instructions for the evaluation. */
|
||||
public String getDowngradeInstructions()
|
||||
{
|
||||
return downgradeInstructions;
|
||||
}
|
||||
/** @param downgradeInstructions If a downgrade date or event is given then this must be provided too with the instructions for the evaluation. */
|
||||
public void setDowngradeInstructions(String downgradeInstructions)
|
||||
{
|
||||
this.downgradeInstructions = downgradeInstructions;
|
||||
}
|
||||
/** @return If provided, this is the date of the next declassification evaluation. */
|
||||
public Date getDeclassificationDate()
|
||||
{
|
||||
return declassificationDate;
|
||||
}
|
||||
/** @param declassificationDate If provided, this is the date of the next declassification evaluation. */
|
||||
public void setDeclassificationDate(Date declassificationDate)
|
||||
{
|
||||
this.declassificationDate = declassificationDate;
|
||||
}
|
||||
/** @return If provided, this is the event at which the next declassification evaluation will take place. */
|
||||
public String getDeclassificationEvent()
|
||||
{
|
||||
return declassificationEvent;
|
||||
}
|
||||
/** @param declassificationEvent If provided, this is the event at which the next declassification evaluation will take place. */
|
||||
public void setDeclassificationEvent(String declassificationEvent)
|
||||
{
|
||||
this.declassificationEvent = declassificationEvent;
|
||||
}
|
||||
/** @return This is an optional list of exemption category ids. */
|
||||
public Set<String> getExemptionCategoryIds()
|
||||
{
|
||||
return exemptionCategoryIds;
|
||||
}
|
||||
/** @param exemptionCategoryIds This is an optional list of exemption category ids. */
|
||||
public void setExemptionCategoryIds(Set<String> exemptionCategoryIds)
|
||||
{
|
||||
this.exemptionCategoryIds = exemptionCategoryIds;
|
||||
}
|
||||
}
|
@@ -18,8 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound;
|
||||
@@ -45,10 +43,7 @@ public interface ContentClassificationService
|
||||
/**
|
||||
* Classify a piece of content.
|
||||
*
|
||||
* @param classificationLevelId The security clearance needed to access the content.
|
||||
* @param classifiedBy Free-form text identifying who classified the content.
|
||||
* @param classificationAgency The name of the agency responsible for the classification of this content.
|
||||
* @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way.
|
||||
* @param classificationAspectProperties The properties for the classification aspect.
|
||||
* @param content The node to classify.
|
||||
* @throws LevelIdNotFound If the supplied level id is not found.
|
||||
* @throws IllegalArgumentException If the supplied {@code classifiedBy} is {@code null},
|
||||
@@ -57,17 +52,13 @@ public interface ContentClassificationService
|
||||
* @throws InvalidNodeRefException If the node could not be found.
|
||||
* @throws InvalidNode If the supplied node is not a content node.
|
||||
*/
|
||||
void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency,
|
||||
Set<String> classificationReasonIds, NodeRef content)
|
||||
void classifyContent(ClassificationAspectProperties classificationAspectProperties, NodeRef content)
|
||||
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode;
|
||||
|
||||
/**
|
||||
* Edits the classified content.
|
||||
*
|
||||
* @param classificationLevelId The security clearance needed to access the content.
|
||||
* @param classifiedBy Free-form text identifying who edited the classified content.
|
||||
* @param classificationAgency The name of the agency responsible for editing the classified content.
|
||||
* @param classificationReasonIds A non-empty set of ids of reasons for editing the classified content in this way.
|
||||
* @param classificationAspectProperties The properties for the classification aspect.
|
||||
* @param content The classified content which will be edited.
|
||||
* @throws LevelIdNotFound If the supplied level id is not found.
|
||||
* @throws IllegalArgumentException If the supplied {@code classifiedBy} is {@code null},
|
||||
@@ -76,8 +67,7 @@ public interface ContentClassificationService
|
||||
* @throws InvalidNodeRefException If the node could not be found.
|
||||
* @throws InvalidNode If the supplied node is not a content node.
|
||||
*/
|
||||
void editClassifiedContent(String classificationLevelId, String classifiedBy, String classificationAgency,
|
||||
Set<String> classificationReasonIds, NodeRef content)
|
||||
void editClassifiedContent(ClassificationAspectProperties classificationAspectProperties, NodeRef content)
|
||||
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode;
|
||||
|
||||
/**
|
||||
|
@@ -26,7 +26,6 @@ import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.QuickShareModel;
|
||||
@@ -94,52 +93,12 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#classifyContent(java.lang.String, java.lang.String, java.lang.String, java.util.Set, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency,
|
||||
Set<String> classificationReasonIds, final NodeRef content)
|
||||
public void classifyContent(ClassificationAspectProperties classificationAspectProperties, final NodeRef content)
|
||||
{
|
||||
checkNotBlank("classificationLevelId", classificationLevelId);
|
||||
checkNotBlank("classifiedBy", classifiedBy);
|
||||
// classificationAgency can be blank
|
||||
mandatory("classificationReasonIds", classificationReasonIds);
|
||||
mandatory("content", content);
|
||||
validateProperties(classificationAspectProperties);
|
||||
validateContent(content);
|
||||
|
||||
if (!dictionaryService.isSubClass(nodeService.getType(content), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
throw new InvalidNode(content, "The supplied node is not a content node.");
|
||||
}
|
||||
if (nodeService.hasAspect(content, QuickShareModel.ASPECT_QSHARE))
|
||||
{
|
||||
throw new IllegalStateException("A shared content cannot be classified.");
|
||||
}
|
||||
if (!securityClearanceService.isCurrentUserClearedForClassification(classificationLevelId))
|
||||
{
|
||||
throw new LevelIdNotFound(classificationLevelId);
|
||||
}
|
||||
|
||||
final Map<QName, Serializable> properties = new HashMap<>();
|
||||
// Initial classification id
|
||||
if (nodeService.getProperty(content, PROP_INITIAL_CLASSIFICATION) == null)
|
||||
{
|
||||
properties.put(PROP_INITIAL_CLASSIFICATION, classificationLevelId);
|
||||
}
|
||||
|
||||
// Current classification id
|
||||
properties.put(PROP_CURRENT_CLASSIFICATION, classificationLevelId);
|
||||
|
||||
// Classification agency
|
||||
properties.put(PROP_CLASSIFICATION_AGENCY, classificationAgency);
|
||||
|
||||
properties.put(PROP_CLASSIFIED_BY, classifiedBy);
|
||||
|
||||
// Classification reason ids
|
||||
HashSet<String> classificationReasons = new HashSet<>();
|
||||
for (String classificationReasonId : classificationReasonIds)
|
||||
{
|
||||
// Check the classification reason id - an exception will be thrown if the id cannot be found
|
||||
reasonManager.findReasonById(classificationReasonId);
|
||||
classificationReasons.add(classificationReasonId);
|
||||
}
|
||||
properties.put(PROP_CLASSIFICATION_REASONS, classificationReasons);
|
||||
final Map<QName, Serializable> properties = createPropertiesMap(classificationAspectProperties, content);
|
||||
|
||||
// Add aspect
|
||||
authenticationUtil.runAs(new RunAsWork<Void>()
|
||||
@@ -152,6 +111,75 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
||||
}, authenticationUtil.getAdminUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the properties contained in the {@link ClassificationAspectProperties}.
|
||||
*
|
||||
* @param classificationAspectProperties The DTO containing properties to be stored on the aspect.
|
||||
*/
|
||||
protected void validateProperties(ClassificationAspectProperties classificationAspectProperties)
|
||||
{
|
||||
String classificationLevelId = classificationAspectProperties.getClassificationLevelId();
|
||||
checkNotBlank("classificationLevelId", classificationLevelId);
|
||||
checkNotBlank("classifiedBy", classificationAspectProperties.getClassifiedBy());
|
||||
mandatory("classificationReasonIds", classificationAspectProperties.getClassificationReasonIds());
|
||||
|
||||
if (!securityClearanceService.isCurrentUserClearedForClassification(classificationLevelId))
|
||||
{
|
||||
throw new LevelIdNotFound(classificationLevelId);
|
||||
}
|
||||
|
||||
for (String classificationReasonId : classificationAspectProperties.getClassificationReasonIds())
|
||||
{
|
||||
// Check the classification reason id - an exception will be thrown if the id cannot be found
|
||||
reasonManager.findReasonById(classificationReasonId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the node is suitable for classifying.
|
||||
*
|
||||
* @param content The node to be classified.
|
||||
*/
|
||||
protected void validateContent(NodeRef content)
|
||||
{
|
||||
mandatory("content", content);
|
||||
|
||||
if (!dictionaryService.isSubClass(nodeService.getType(content), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
throw new InvalidNode(content, "The supplied node is not a content node.");
|
||||
}
|
||||
if (nodeService.hasAspect(content, QuickShareModel.ASPECT_QSHARE))
|
||||
{
|
||||
throw new IllegalStateException("A shared content cannot be classified.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a map suitable for storing against the aspect from the data transfer object.
|
||||
*
|
||||
* @param propertiesDTO The properties data transfer object.
|
||||
* @param content The node to be classified.
|
||||
* @return A map from {@link QName QNames} to values.
|
||||
*/
|
||||
protected Map<QName, Serializable> createPropertiesMap(
|
||||
ClassificationAspectProperties propertiesDTO, NodeRef content)
|
||||
{
|
||||
final Map<QName, Serializable> propertiesMap = new HashMap<>();
|
||||
|
||||
if (nodeService.getProperty(content, PROP_INITIAL_CLASSIFICATION) == null)
|
||||
{
|
||||
propertiesMap.put(PROP_INITIAL_CLASSIFICATION, propertiesDTO.getClassificationLevelId());
|
||||
}
|
||||
propertiesMap.put(PROP_CURRENT_CLASSIFICATION, propertiesDTO.getClassificationLevelId());
|
||||
propertiesMap.put(PROP_CLASSIFICATION_AGENCY, propertiesDTO.getClassificationAgency());
|
||||
propertiesMap.put(PROP_CLASSIFIED_BY, propertiesDTO.getClassifiedBy());
|
||||
|
||||
HashSet<String> classificationReasons = new HashSet<>(propertiesDTO.getClassificationReasonIds());
|
||||
propertiesMap.put(PROP_CLASSIFICATION_REASONS, classificationReasons);
|
||||
|
||||
return propertiesMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#hasClearance(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -187,16 +215,9 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#editClassifiedContent(java.lang.String, java.lang.String, java.lang.String, java.util.Set, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void editClassifiedContent(String classificationLevelId, String classifiedBy, String classificationAgency,
|
||||
Set<String> classificationReasonIds, NodeRef content)
|
||||
public void editClassifiedContent(ClassificationAspectProperties classificationAspectProperties, NodeRef content)
|
||||
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode
|
||||
{
|
||||
checkNotBlank("classificationLevelId", classificationLevelId);
|
||||
checkNotBlank("classifiedBy", classifiedBy);
|
||||
// classificationAgency can be blank
|
||||
mandatory("classificationReasonIds", classificationReasonIds);
|
||||
mandatory("content", content);
|
||||
|
||||
classifyContent(classificationLevelId, classifiedBy, classificationAgency, classificationReasonIds, content);
|
||||
classifyContent(classificationAspectProperties, content);
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -78,13 +79,10 @@ public abstract class ClassifyContentBase extends AbstractRmWebScript
|
||||
* Abstract method which does the action of either
|
||||
* classifying a content or editing a classified content
|
||||
*
|
||||
* @param classificationLevelId The security clearance needed to access the content.
|
||||
* @param classifiedBy Free-form text identifying who edited the classified content.
|
||||
* @param classificationAgency The name of the agency responsible for editing the classified content.
|
||||
* @param classificationReasonIds A non-empty set of ids of reasons for editing the classified content in this way.
|
||||
* @param classificationAspectProperties The properties to use when classifying the content.
|
||||
* @param document The classified content which will be edited.
|
||||
*/
|
||||
protected abstract void doClassifyAction(String classificationLevelId, String classifiedBy, String classificationAgency, Set<String> classificationReasonIds, NodeRef document);
|
||||
protected abstract void doClassifyAction(ClassificationAspectProperties classificationAspectProperties, NodeRef document);
|
||||
|
||||
/**
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
@@ -99,9 +97,16 @@ public abstract class ClassifyContentBase extends AbstractRmWebScript
|
||||
String classifiedBy = getStringValueFromJSONObject(jsonObject, CLASSIFIED_BY);
|
||||
String classificationAgency = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AGENCY, false, false);
|
||||
Set<String> classificationReasonIds = getClassificationReasonIds(jsonObject);
|
||||
|
||||
ClassificationAspectProperties propertiesDTO = new ClassificationAspectProperties();
|
||||
propertiesDTO.setClassificationLevelId(classificationLevelId);
|
||||
propertiesDTO.setClassifiedBy(classifiedBy);
|
||||
propertiesDTO.setClassificationAgency(classificationAgency);
|
||||
propertiesDTO.setClassificationReasonIds(classificationReasonIds);
|
||||
|
||||
NodeRef document = parseRequestForNodeRef(req);
|
||||
|
||||
doClassifyAction(classificationLevelId, classifiedBy, classificationAgency, classificationReasonIds, document);
|
||||
doClassifyAction(propertiesDTO, document);
|
||||
|
||||
Map<String, Object> model = new HashMap<>(1);
|
||||
model.put(SUCCESS, true);
|
||||
|
@@ -18,8 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.script.classification;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
@@ -34,8 +33,8 @@ public class ClassifyContentPost extends ClassifyContentBase
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase#doClassifyAction(java.lang.String, java.lang.String, java.lang.String, java.util.Set, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void doClassifyAction(String classificationLevelId, String classifiedBy, String classificationAgency, Set<String> classificationReasonIds, NodeRef document)
|
||||
protected void doClassifyAction(ClassificationAspectProperties classificationAspectProperties, NodeRef document)
|
||||
{
|
||||
getContentClassificationService().classifyContent(classificationLevelId, classifiedBy, classificationAgency, classificationReasonIds, document);
|
||||
getContentClassificationService().classifyContent(classificationAspectProperties, document);
|
||||
}
|
||||
}
|
@@ -18,8 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.script.classification;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
@@ -34,8 +33,8 @@ public class ClassifyContentPut extends ClassifyContentBase
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase#doClassifyAction(java.lang.String, java.lang.String, java.lang.String, java.util.Set, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void doClassifyAction(String classificationLevelId, String classifiedBy, String classificationAgency, Set<String> classificationReasonIds, NodeRef document)
|
||||
protected void doClassifyAction(ClassificationAspectProperties classificationAspectProperties, NodeRef document)
|
||||
{
|
||||
getContentClassificationService().editClassifiedContent(classificationLevelId, classifiedBy, classificationAgency, classificationReasonIds, document);
|
||||
getContentClassificationService().editClassifiedContent(classificationAspectProperties, document);
|
||||
}
|
||||
}
|
@@ -20,6 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration.classificati
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
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.model.ClassifiedContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
@@ -28,8 +29,6 @@ import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Classification level integration test
|
||||
*
|
||||
@@ -46,6 +45,19 @@ public class ClassifyTest extends BaseRMTestCase
|
||||
private static final String CLASSIFIED_BY = "classified by text";
|
||||
private static final String RECORD_NAME = "recordname.txt";
|
||||
|
||||
private ClassificationAspectProperties propertiesDTO;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
propertiesDTO = new ClassificationAspectProperties();
|
||||
propertiesDTO.setClassificationLevelId(CLASSIFICATION_LEVEL);
|
||||
propertiesDTO.setClassifiedBy(CLASSIFIED_BY);
|
||||
propertiesDTO.setClassificationAgency(CLASSIFICATION_AGENCY);
|
||||
propertiesDTO.setClassificationReasonIds(Collections.singleton(CLASSIFICATION_REASON));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given that a record is frozen
|
||||
* And unclassified
|
||||
@@ -68,12 +80,7 @@ public class ClassifyTest extends BaseRMTestCase
|
||||
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(
|
||||
CLASSIFICATION_LEVEL,
|
||||
CLASSIFIED_BY,
|
||||
CLASSIFICATION_AGENCY,
|
||||
Collections.singleton(CLASSIFICATION_REASON),
|
||||
record);
|
||||
contentClassificationService.classifyContent(propertiesDTO, record);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -97,12 +104,7 @@ public class ClassifyTest extends BaseRMTestCase
|
||||
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(
|
||||
CLASSIFICATION_LEVEL,
|
||||
CLASSIFIED_BY,
|
||||
CLASSIFICATION_AGENCY,
|
||||
Collections.singleton(CLASSIFICATION_REASON),
|
||||
record);
|
||||
contentClassificationService.classifyContent(propertiesDTO, record);
|
||||
}
|
||||
|
||||
public void then() throws Exception
|
||||
@@ -151,8 +153,7 @@ public class ClassifyTest extends BaseRMTestCase
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFIED_BY, CLASSIFICATION_AGENCY,
|
||||
Sets.newHashSet(CLASSIFICATION_REASON), record);
|
||||
contentClassificationService.classifyContent(propertiesDTO, record);
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
@@ -202,8 +203,7 @@ public class ClassifyTest extends BaseRMTestCase
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFIED_BY, CLASSIFICATION_AGENCY,
|
||||
Sets.newHashSet(CLASSIFICATION_REASON), record);
|
||||
contentClassificationService.classifyContent(propertiesDTO, record);
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
|
@@ -19,9 +19,12 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -38,6 +41,26 @@ public abstract class BrowseClassificationEnforcementTestBase extends BaseRMTest
|
||||
protected static final String LEVEL1 = "level1";
|
||||
protected static final String LEVEL2 = "level2";
|
||||
protected static final String REASON = "Test Reason 1";
|
||||
/** Classified properties for classification level 1. */
|
||||
protected ClassificationAspectProperties propertiesDTO1;
|
||||
/** Classified properties for classification level 2. */
|
||||
protected ClassificationAspectProperties propertiesDTO2;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
propertiesDTO1 = new ClassificationAspectProperties();
|
||||
propertiesDTO1.setClassificationLevelId(LEVEL1);
|
||||
propertiesDTO1.setClassifiedBy(generate());
|
||||
propertiesDTO1.setClassificationAgency(generate());
|
||||
propertiesDTO1.setClassificationReasonIds(Collections.singleton(REASON));
|
||||
propertiesDTO2 = new ClassificationAspectProperties();
|
||||
propertiesDTO2.setClassificationLevelId(LEVEL2);
|
||||
propertiesDTO2.setClassifiedBy(generate());
|
||||
propertiesDTO2.setClassificationAgency(generate());
|
||||
propertiesDTO2.setClassificationReasonIds(Collections.singleton(REASON));
|
||||
}
|
||||
|
||||
protected List<ChildAssociationRef> browse(NodeRef folder, String userName)
|
||||
{
|
||||
|
@@ -18,14 +18,15 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.repo.site.SiteModel.SITE_MANAGER;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.AccessDeniedException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -39,6 +40,22 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public class ClassificationEnforcementPreMethodInvocationTest extends BaseRMTestCase
|
||||
{
|
||||
private static final String LEVEL1 = "level1";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
|
||||
private ClassificationAspectProperties propertiesDTO;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
propertiesDTO = new ClassificationAspectProperties();
|
||||
propertiesDTO.setClassificationLevelId(LEVEL1);
|
||||
propertiesDTO.setClassifiedBy(generate());
|
||||
propertiesDTO.setClassificationAgency(generate());
|
||||
propertiesDTO.setClassificationReasonIds(Collections.singleton(REASON));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest()
|
||||
*/
|
||||
@@ -63,8 +80,6 @@ public class ClassificationEnforcementPreMethodInvocationTest extends BaseRMTest
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String testUser;
|
||||
private static final String LEVEL1 = "level1";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
private NodeRef folder1;
|
||||
private NodeRef folder2;
|
||||
private NodeRef doc;
|
||||
@@ -83,7 +98,7 @@ public class ClassificationEnforcementPreMethodInvocationTest extends BaseRMTest
|
||||
folder2 = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef();
|
||||
doc = fileFolderService.create(folder1, generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc);
|
||||
contentClassificationService.classifyContent(propertiesDTO, doc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,7 +19,6 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.repo.site.SiteModel.SITE_MANAGER;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
@@ -80,7 +79,7 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific
|
||||
doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, doc1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,8 +171,8 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific
|
||||
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, doc1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, doc2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,8 +266,8 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific
|
||||
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, doc1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, doc2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static org.alfresco.repo.site.SiteModel.SITE_MANAGER;
|
||||
import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
|
||||
@@ -83,7 +82,7 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific
|
||||
doc1 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, doc1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,8 +173,8 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific
|
||||
doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, doc1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, doc2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,8 +265,8 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific
|
||||
doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, doc1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, doc2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,7 +19,6 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_ADMIN;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
@@ -74,7 +73,7 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat
|
||||
record1 = utils.createRecord(folder, generate());
|
||||
record2 = utils.createRecord(folder, generate());
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, record1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,8 +168,8 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat
|
||||
record2 = utils.createRecord(folder, generate());
|
||||
record3 = utils.createRecord(folder, generate());
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, record1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, record2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,8 +266,8 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat
|
||||
record2 = utils.createRecord(folder, generate());
|
||||
record3 = utils.createRecord(folder, generate());
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, record1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, record2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_ADMIN;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
@@ -265,8 +264,8 @@ public class RecordSearchClassificationEnforcementTest extends SearchClassificat
|
||||
record2 = utils.createRecord(folder, searchQuery + generate());
|
||||
record3 = utils.createRecord(folder, searchQuery + generate());
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, record1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, record2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,13 +19,14 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_USER;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -42,6 +43,18 @@ public class RelationshipClassificationEnforcementTest extends BaseRMTestCase
|
||||
private static final String LEVEL1 = "level1";
|
||||
private static final String LEVEL3 = "level3";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
private ClassificationAspectProperties propertiesDTO;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
propertiesDTO = new ClassificationAspectProperties();
|
||||
propertiesDTO.setClassificationLevelId(LEVEL1);
|
||||
propertiesDTO.setClassifiedBy(generate());
|
||||
propertiesDTO.setClassificationAgency(generate());
|
||||
propertiesDTO.setClassificationReasonIds(Collections.singleton(REASON));
|
||||
}
|
||||
|
||||
public void testRelationshipClassification()
|
||||
{
|
||||
@@ -94,7 +107,7 @@ public class RelationshipClassificationEnforcementTest extends BaseRMTestCase
|
||||
{
|
||||
filePlanPermissionService.setPermission(category, myUser, FILING);
|
||||
securityClearanceService.setUserSecurityClearance(myUser, LEVEL3);
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(propertiesDTO, record1);
|
||||
relationshipService.addRelationship(CUSTOM_REF_RENDITION.getLocalName(), record1, record2);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_ADMIN;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails.QUERY;
|
||||
@@ -96,9 +95,9 @@ public class SavedSearchClassificationEnforcementTest extends SearchClassificati
|
||||
searchParameters.setIncludeUndeclaredRecords(true);
|
||||
rmSearchService.saveSearch(siteId, savedSearchName, generate(), searchQuery + "*", searchParameters, true);
|
||||
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record3);
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record5);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, record1);
|
||||
contentClassificationService.classifyContent(propertiesDTO2, record3);
|
||||
contentClassificationService.classifyContent(propertiesDTO1, record5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,9 +19,12 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
@@ -37,6 +40,26 @@ public abstract class SearchClassificationEnforcementTestBase extends BaseRMTest
|
||||
protected static final String LEVEL1 = "level1";
|
||||
protected static final String LEVEL2 = "level2";
|
||||
protected static final String REASON = "Test Reason 1";
|
||||
/** Classified properties for classification level 1. */
|
||||
protected ClassificationAspectProperties propertiesDTO1;
|
||||
/** Classified properties for classification level 2. */
|
||||
protected ClassificationAspectProperties propertiesDTO2;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
propertiesDTO1 = new ClassificationAspectProperties();
|
||||
propertiesDTO1.setClassificationLevelId(LEVEL1);
|
||||
propertiesDTO1.setClassifiedBy(generate());
|
||||
propertiesDTO1.setClassificationAgency(generate());
|
||||
propertiesDTO1.setClassificationReasonIds(Collections.singleton(REASON));
|
||||
propertiesDTO2 = new ClassificationAspectProperties();
|
||||
propertiesDTO2.setClassificationLevelId(LEVEL2);
|
||||
propertiesDTO2.setClassifiedBy(generate());
|
||||
propertiesDTO2.setClassificationAgency(generate());
|
||||
propertiesDTO2.setClassificationReasonIds(Collections.singleton(REASON));
|
||||
}
|
||||
|
||||
protected abstract List<NodeRef> search(String searchQuery);
|
||||
|
||||
|
@@ -18,10 +18,12 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_USER;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
@@ -35,6 +37,18 @@ public class RM2260Test extends BaseRMTestCase
|
||||
{
|
||||
private static final String LEVEL = "level1";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
private ClassificationAspectProperties propertiesDTO;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
propertiesDTO = new ClassificationAspectProperties();
|
||||
propertiesDTO.setClassificationLevelId(LEVEL);
|
||||
propertiesDTO.setClassifiedBy(generate());
|
||||
propertiesDTO.setClassificationAgency(generate());
|
||||
propertiesDTO.setClassificationReasonIds(Collections.singleton(REASON));
|
||||
}
|
||||
|
||||
public void testClassifiyingContentAsNonAdminUser()
|
||||
{
|
||||
@@ -86,7 +100,7 @@ public class RM2260Test extends BaseRMTestCase
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
contentClassificationService.classifyContent(LEVEL, generate(), generate(), newHashSet(REASON), record);
|
||||
contentClassificationService.classifyContent(propertiesDTO, record);
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
|
@@ -18,13 +18,14 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager.UNCLASSIFIED_ID;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.jscript.app.JSONConversionComponent.IS_CLASSIFIED;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.jscript.app.JSONConversionComponent;
|
||||
@@ -45,6 +46,26 @@ public class JSONConversionComponentTest extends BaseRMTestCase
|
||||
private ContentClassificationService contentClassificationService;
|
||||
|
||||
private NodeRef record;
|
||||
/** Classification properties for classification level 1. */
|
||||
private ClassificationAspectProperties level1PropertiesDTO;
|
||||
/** Classification properties for unclassified content. */
|
||||
private ClassificationAspectProperties unclassifiedPropertiesDTO;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
level1PropertiesDTO = new ClassificationAspectProperties();
|
||||
level1PropertiesDTO.setClassificationLevelId(LEVEL1);
|
||||
level1PropertiesDTO.setClassifiedBy(generate());
|
||||
level1PropertiesDTO.setClassificationAgency(generate());
|
||||
level1PropertiesDTO.setClassificationReasonIds(Collections.singleton(REASON1));
|
||||
unclassifiedPropertiesDTO = new ClassificationAspectProperties();
|
||||
unclassifiedPropertiesDTO.setClassificationLevelId(UNCLASSIFIED_ID);
|
||||
unclassifiedPropertiesDTO.setClassifiedBy(generate());
|
||||
unclassifiedPropertiesDTO.setClassificationAgency(generate());
|
||||
unclassifiedPropertiesDTO.setClassificationReasonIds(Collections.singleton(REASON1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initServices()
|
||||
@@ -92,7 +113,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON1), record);
|
||||
contentClassificationService.classifyContent(level1PropertiesDTO, record);
|
||||
jsonString = converter.toJSON(record, true);
|
||||
}
|
||||
|
||||
@@ -131,7 +152,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), generate(), newHashSet(REASON1), record);
|
||||
contentClassificationService.classifyContent(unclassifiedPropertiesDTO, record);
|
||||
jsonString = converter.toJSON(record, true);
|
||||
}
|
||||
|
||||
@@ -206,7 +227,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON1), file);
|
||||
contentClassificationService.classifyContent(level1PropertiesDTO, file);
|
||||
jsonString = converter.toJSON(file, true);
|
||||
}
|
||||
|
||||
@@ -243,7 +264,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), generate(), newHashSet(REASON1), file);
|
||||
contentClassificationService.classifyContent(unclassifiedPropertiesDTO, file);
|
||||
jsonString = converter.toJSON(file, true);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateNodeRef;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateText;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -37,6 +36,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.QuickShareModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode;
|
||||
@@ -57,9 +58,6 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ContentClassificationServiceImpl}.
|
||||
*
|
||||
@@ -78,6 +76,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
|
||||
@Mock DictionaryService mockDictionaryService;
|
||||
@Mock SecurityClearanceService mockSecurityClearanceService;
|
||||
@Mock AuthenticationUtil mockAuthenticationUtil;
|
||||
@Mock ClassificationAspectProperties mockPropertiesDTO;
|
||||
@Captor ArgumentCaptor<Map<QName, Serializable>> propertiesCaptor;
|
||||
|
||||
@Before public void setUp()
|
||||
@@ -103,10 +102,14 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
|
||||
when(mockDictionaryService.isSubClass(mockNodeService.getType(content), ContentModel.TYPE_CONTENT)).thenReturn(true);
|
||||
when(mockNodeService.hasAspect(content, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false);
|
||||
when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(true);
|
||||
// Set up the mock DTO.
|
||||
when(mockPropertiesDTO.getClassificationLevelId()).thenReturn("levelId1");
|
||||
when(mockPropertiesDTO.getClassifiedBy()).thenReturn("classifiedBy");
|
||||
when(mockPropertiesDTO.getClassificationAgency()).thenReturn("classificationAgency");
|
||||
when(mockPropertiesDTO.getClassificationReasonIds()).thenReturn(Sets.newHashSet("reasonId1", "reasonId2"));
|
||||
|
||||
// Call the method under test
|
||||
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency",
|
||||
Sets.newHashSet("reasonId1", "reasonId2"), content);
|
||||
contentClassificationServiceImpl.classifyContent(mockPropertiesDTO, content);
|
||||
|
||||
verify(mockNodeService).addAspect(eq(content), eq(ClassifiedContentModel.ASPECT_CLASSIFIED),
|
||||
propertiesCaptor.capture());
|
||||
@@ -128,28 +131,26 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
|
||||
|
||||
/** Classify a folder using the <code>classifyContent</code> method and check that an exception is raised. */
|
||||
@Test(expected = InvalidNode.class)
|
||||
public void classifyContent_notContent()
|
||||
public void validateContent_notContent()
|
||||
{
|
||||
// Create a folder node.
|
||||
NodeRef notAPieceOfContent = new NodeRef("not://a/piece/of/content/");
|
||||
when(mockNodeService.getType(notAPieceOfContent)).thenReturn(ContentModel.TYPE_FOLDER);
|
||||
|
||||
// Call the method under test.
|
||||
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency",
|
||||
Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent);
|
||||
contentClassificationServiceImpl.validateContent(notAPieceOfContent);
|
||||
}
|
||||
|
||||
/** Classify a piece of content that has already been shared */
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void classifySharedContent()
|
||||
public void validateContent_sharedContent()
|
||||
{
|
||||
NodeRef sharedContent = generateNodeRef(mockNodeService);
|
||||
when(mockDictionaryService.isSubClass(mockNodeService.getType(sharedContent), ContentModel.TYPE_CONTENT)).thenReturn(true);
|
||||
when(mockNodeService.hasAspect(sharedContent, QuickShareModel.ASPECT_QSHARE)).thenReturn(true);
|
||||
|
||||
// Call the method under test.
|
||||
contentClassificationServiceImpl.classifyContent(generateText(), generateText(), generateText(),
|
||||
newHashSet(generateText(), generateText()), sharedContent);
|
||||
contentClassificationServiceImpl.validateContent(sharedContent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,15 +160,16 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
|
||||
@Test(expected = LevelIdNotFound.class)
|
||||
public void classifyContent_notFound()
|
||||
{
|
||||
// Create a classified piece of content.
|
||||
NodeRef classifiedContent = new NodeRef("classified://content/");
|
||||
when(mockDictionaryService.isSubClass(mockNodeService.getType(classifiedContent), ContentModel.TYPE_CONTENT)).thenReturn(true);
|
||||
when(mockNodeService.hasAspect(classifiedContent, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false);
|
||||
// The user doesn't have level 1 clearance.
|
||||
when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(false);
|
||||
// Set up the mock DTO.
|
||||
when(mockPropertiesDTO.getClassificationLevelId()).thenReturn("levelId1");
|
||||
when(mockPropertiesDTO.getClassifiedBy()).thenReturn("classifiedBy");
|
||||
when(mockPropertiesDTO.getClassificationAgency()).thenReturn("classificationAgency");
|
||||
when(mockPropertiesDTO.getClassificationReasonIds()).thenReturn(Sets.newHashSet("reasonId1", "reasonId2"));
|
||||
|
||||
// Call the method under test.
|
||||
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy","classificationAgency",
|
||||
Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent);
|
||||
contentClassificationServiceImpl.validateProperties(mockPropertiesDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.script.classification;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_AGENCY;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_LEVEL_ID;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_REASONS;
|
||||
@@ -29,11 +28,14 @@ import static org.alfresco.util.WebScriptUtils.putValuetoJSONObject;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationReasonManager;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
|
||||
@@ -41,6 +43,8 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTes
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
@@ -74,13 +78,13 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest
|
||||
|
||||
/** Mocked content classification service */
|
||||
private @Mock ContentClassificationService mockedContentClassificationService;
|
||||
|
||||
/** Mocked classification level manager */
|
||||
private @Mock ClassificationLevelManager mockedClassificationLevelManager;
|
||||
|
||||
/** Mocked classification reason manager */
|
||||
private @Mock ClassificationReasonManager mockedClassificationReasonManager;
|
||||
|
||||
/** Captor for the classification aspect properties. */
|
||||
private @Captor ArgumentCaptor<ClassificationAspectProperties> propertiesDTOCaptor;
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript()
|
||||
*/
|
||||
@@ -120,7 +124,14 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest
|
||||
assertEquals(getStringValueFromJSONObject(json, SUCCESS), Boolean.TRUE.toString());
|
||||
|
||||
// Verify that the classify content method was called
|
||||
verify(mockedContentClassificationService, times(1)).classifyContent(LEVEL_ID, BY, AGENCY, newHashSet(REASON1_ID, REASON2_ID), record);
|
||||
verify(mockedContentClassificationService, times(1)).classifyContent(propertiesDTOCaptor.capture(), eq(record));
|
||||
|
||||
// Check the values in the DTO.
|
||||
ClassificationAspectProperties propertiesDTO = propertiesDTOCaptor.getValue();
|
||||
assertEquals(LEVEL_ID, propertiesDTO.getClassificationLevelId());
|
||||
assertEquals(BY, propertiesDTO.getClassifiedBy());
|
||||
assertEquals(AGENCY, propertiesDTO.getClassificationAgency());
|
||||
assertEquals(Sets.newHashSet(REASON1_ID, REASON2_ID), propertiesDTO.getClassificationReasonIds());
|
||||
}
|
||||
|
||||
@Test public void classifyingWithBlankClassifiedByShouldReturn4xxResponse() throws Exception
|
||||
|
Reference in New Issue
Block a user