RM-2045 Fix references to "document" to refer to "content".

We can use the same API to classify documents and records.

+review RM-25

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@102160 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tom Page
2015-04-20 09:04:01 +00:00
parent 17ca9d431f
commit bf04115229
5 changed files with 31 additions and 34 deletions

View File

@@ -52,18 +52,18 @@ public interface ClassificationService
List<ClassificationReason> getClassificationReasons();
/**
* Classify a document.
* Classify a piece of content.
*
* @param classificationLevelId The security clearance needed to access the document.
* @param classificationAuthority The name of the authority responsible for the classification of this document.
* @param classificationReasonIds A non-empty set of ids of reasons for classifying the document in this way.
* @param document The node to classify.
* @param classificationLevelId The security clearance needed to access the content.
* @param classificationAuthority The name of the authority 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 content The node to classify.
* @throws LevelIdNotFound If the supplied level id is not found.
* @throws ReasonIdNotFound If any of the supplied reason ids are not found.
* @throws InvalidNodeRefException If the node could not be found.
* @throws InvalidNode If the supplied node is not a document node.
* @throws InvalidNode If the supplied node is not a content node.
*/
void addClassificationToDocument(String classificationLevelId, String classificationAuthority,
Set<String> classificationReasonIds, NodeRef document) throws LevelIdNotFound, ReasonIdNotFound,
void classifyContent(String classificationLevelId, String classificationAuthority,
Set<String> classificationReasonIds, NodeRef content) throws LevelIdNotFound, ReasonIdNotFound,
InvalidNodeRefException, InvalidNode;
}

View File

@@ -218,24 +218,24 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
}
@Override
public void addClassificationToDocument(String classificationLevelId, String classificationAuthority,
Set<String> classificationReasonIds, NodeRef document)
public void classifyContent(String classificationLevelId, String classificationAuthority,
Set<String> classificationReasonIds, NodeRef content)
{
mandatory("classificationLevelId", classificationLevelId);
mandatory("classificationAuthority", classificationAuthority);
mandatory("classificationReasonIds", classificationReasonIds);
mandatory("document", document);
mandatory("content", content);
if (!nodeService.getType(document).equals(ContentModel.TYPE_CONTENT))
if (!nodeService.getType(content).equals(ContentModel.TYPE_CONTENT))
{
throw new InvalidNode(document, "The supplied node is not a content node.");
throw new InvalidNode(content, "The supplied node is not a content node.");
}
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
checkClassificationLevelId(classificationLevelId);
// Initial classification id
if (nodeService.getProperty(document, PROP_INITIAL_CLASSIFICATION) == null)
if (nodeService.getProperty(content, PROP_INITIAL_CLASSIFICATION) == null)
{
properties.put(PROP_INITIAL_CLASSIFICATION, classificationLevelId);
}
@@ -256,7 +256,7 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
properties.put(PROP_CLASSIFICATION_REASONS, classificationReasons);
// Add aspect
nodeService.addAspect(document, ASPECT_CLASSIFIED, properties);
nodeService.addAspect(content, ASPECT_CLASSIFIED, properties);
}
/**

View File

@@ -83,7 +83,7 @@ public class ClassifyContentPost extends AbstractRmWebScript
Set<String> classificationReasonIds = getClassificationReasonIds(jsonObject);
NodeRef document = parseRequestForNodeRef(req);
getClassificationService().addClassificationToDocument(classificationLevelId, classificationAuthority, classificationReasonIds, document);
getClassificationService().classifyContent(classificationLevelId, classificationAuthority, classificationReasonIds, document);
Map<String, Object> model = new HashMap<String, Object>(1);
model.put(SUCCESS, true);

View File

@@ -260,8 +260,8 @@ public class ClassificationServiceImplUnitTest
assertEquals("Expected an empty list when the target level is not found.", 0, actual.size());
}
/** Classify a document with a couple of reasons and check the NodeService is called correctly. */
@Test public void addClassificationToDocument_success()
/** Classify a piece of content with a couple of reasons and check the NodeService is called correctly. */
@Test public void classifyContent_success()
{
// Create a level and two reasons.
ClassificationLevel level = new ClassificationLevel("levelId1", "displayLabelKey");
@@ -271,15 +271,15 @@ public class ClassificationServiceImplUnitTest
doReturn(level).when(mockLevelManager).findLevelById("levelId1");
doReturn(reason1).when(mockReasonManager).findReasonById("reasonId1");
doReturn(reason2).when(mockReasonManager).findReasonById("reasonId2");
// Create a document node.
NodeRef document = new NodeRef("fake://document/");
doReturn(ContentModel.TYPE_CONTENT).when(mockNodeService).getType(document);
// Create a content node.
NodeRef content = new NodeRef("fake://content/");
doReturn(ContentModel.TYPE_CONTENT).when(mockNodeService).getType(content);
// Call the method under test.
classificationServiceImpl.addClassificationToDocument("levelId1", "classificationAuthority",
Sets.newHashSet("reasonId1", "reasonId2"), document);
classificationServiceImpl.classifyContent("levelId1", "classificationAuthority",
Sets.newHashSet("reasonId1", "reasonId2"), content);
verify(mockNodeService).addAspect(eq(document), eq(ClassifiedContentModel.ASPECT_CLASSIFIED),
verify(mockNodeService).addAspect(eq(content), eq(ClassifiedContentModel.ASPECT_CLASSIFIED),
propertiesCaptor.capture());
// Check the properties that were received.
Map<QName, Serializable> properties = propertiesCaptor.getValue();
@@ -295,19 +295,16 @@ public class ClassificationServiceImplUnitTest
assertEquals("Unexpected set of reasons.", expectedReasonIds, properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_REASONS));
}
/**
* Classify a folder using the <code>addClassificationToDocument</code> method and check that an exception is
* raised.
*/
/** Classify a folder using the <code>classifyContent</code> method and check that an exception is raised. */
@Test(expected = InvalidNode.class)
public void addClassificationToDocument_notDocument()
public void classifyContent_notContent()
{
// Create a folder node.
NodeRef notADocument = new NodeRef("not://a/document/");
doReturn(ContentModel.TYPE_FOLDER).when(mockNodeService).getType(notADocument);
NodeRef notAPieceOfContent = new NodeRef("not://a/piece/of/content/");
doReturn(ContentModel.TYPE_FOLDER).when(mockNodeService).getType(notAPieceOfContent);
// Call the method under test.
classificationServiceImpl.addClassificationToDocument("levelId1", "classificationAuthority",
Sets.newHashSet("reasonId1", "reasonId2"), notADocument);
classificationServiceImpl.classifyContent("levelId1", "classificationAuthority",
Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent);
}
}

View File

@@ -116,7 +116,7 @@ public class ClassifyContentPostTest extends BaseWebScriptUnitTest
assertEquals(getStringValueFromJSONObject(json, SUCCESS), Boolean.TRUE.toString());
// Verify that the classify content method was called
verify(mockedClassificationService, times(1)).addClassificationToDocument(LEVEL_ID, AUTHORITY, newHashSet(REASON1_ID, REASON2_ID), record);
verify(mockedClassificationService, times(1)).classifyContent(LEVEL_ID, AUTHORITY, newHashSet(REASON1_ID, REASON2_ID), record);
}
/**