mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-2420 (Add edit classification to ClassifyService Java API)
+review RM git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@108910 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -229,6 +229,7 @@
|
|||||||
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.getCurrentClassification=ACL_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.getCurrentClassification=ACL_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.classifyContent=ACL_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.classifyContent=ACL_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.hasClearance=ACL_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.hasClearance=ACL_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.editClassifiedContent=ACL_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.*=ACL_DENY
|
org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.*=ACL_DENY
|
||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -30,6 +30,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
* A service to handle the classification of content.
|
* A service to handle the classification of content.
|
||||||
*
|
*
|
||||||
* @author tpage
|
* @author tpage
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface ContentClassificationService
|
public interface ContentClassificationService
|
||||||
{
|
{
|
||||||
@@ -50,7 +51,7 @@ public interface ContentClassificationService
|
|||||||
* @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way.
|
* @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way.
|
||||||
* @param content The node to classify.
|
* @param content The node to classify.
|
||||||
* @throws LevelIdNotFound If the supplied level id is not found.
|
* @throws LevelIdNotFound If the supplied level id is not found.
|
||||||
* @thorws IllegalArgumentException If the supplied {@code classifiedBy} is {@code null},
|
* @throws IllegalArgumentException If the supplied {@code classifiedBy} is {@code null},
|
||||||
* the empty string or a string consisting only of whitespace.
|
* the empty string or a string consisting only of whitespace.
|
||||||
* @throws ReasonIdNotFound If any of the supplied reason ids are not found.
|
* @throws ReasonIdNotFound If any of the supplied reason ids are not found.
|
||||||
* @throws InvalidNodeRefException If the node could not be found.
|
* @throws InvalidNodeRefException If the node could not be found.
|
||||||
@@ -60,6 +61,25 @@ public interface ContentClassificationService
|
|||||||
Set<String> classificationReasonIds, NodeRef content)
|
Set<String> classificationReasonIds, NodeRef content)
|
||||||
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode;
|
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 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},
|
||||||
|
* the empty string or a string consisting only of whitespace.
|
||||||
|
* @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 content node.
|
||||||
|
*/
|
||||||
|
void editClassifiedContent(String classificationLevelId, String classifiedBy, String classificationAgency,
|
||||||
|
Set<String> classificationReasonIds, NodeRef content)
|
||||||
|
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the node is classified or not. A node classified
|
* Checks if the node is classified or not. A node classified
|
||||||
* as "Unclassified" will be treated as not classified.
|
* as "Unclassified" will be treated as not classified.
|
||||||
|
@@ -32,10 +32,12 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.model.QuickShareModel;
|
import org.alfresco.model.QuickShareModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode;
|
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.LevelIdNotFound;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
|
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
@@ -43,6 +45,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
* A service to handle the classification of content.
|
* A service to handle the classification of content.
|
||||||
*
|
*
|
||||||
* @author tpage
|
* @author tpage
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
||||||
implements ContentClassificationService, ClassifiedContentModel
|
implements ContentClassificationService, ClassifiedContentModel
|
||||||
@@ -63,6 +66,9 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
this.reasonManager = classificationServiceBootstrap.getClassificationReasonManager();
|
this.reasonManager = classificationServiceBootstrap.getClassificationReasonManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#getCurrentClassification(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ClassificationLevel getCurrentClassification(final NodeRef nodeRef)
|
public ClassificationLevel getCurrentClassification(final NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
@@ -84,12 +90,16 @@ 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
|
@Override
|
||||||
public void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency,
|
public void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency,
|
||||||
Set<String> classificationReasonIds, final NodeRef content)
|
Set<String> classificationReasonIds, final NodeRef content)
|
||||||
{
|
{
|
||||||
checkNotBlank("classificationLevelId", classificationLevelId);
|
checkNotBlank("classificationLevelId", classificationLevelId);
|
||||||
checkNotBlank("classifiedBy", classifiedBy);
|
checkNotBlank("classifiedBy", classifiedBy);
|
||||||
|
// classificationAgency can be blank
|
||||||
mandatory("classificationReasonIds", classificationReasonIds);
|
mandatory("classificationReasonIds", classificationReasonIds);
|
||||||
mandatory("content", content);
|
mandatory("content", content);
|
||||||
|
|
||||||
@@ -97,11 +107,6 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
throw new InvalidNode(content, "The supplied node is not a content node.");
|
throw new InvalidNode(content, "The supplied node is not a content node.");
|
||||||
}
|
}
|
||||||
if (nodeService.hasAspect(content, ASPECT_CLASSIFIED))
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
"The content has already been classified. Reclassification is currently not supported.");
|
|
||||||
}
|
|
||||||
if (nodeService.hasAspect(content, QuickShareModel.ASPECT_QSHARE))
|
if (nodeService.hasAspect(content, QuickShareModel.ASPECT_QSHARE))
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("A shared content cannot be classified.");
|
throw new IllegalStateException("A shared content cannot be classified.");
|
||||||
@@ -147,6 +152,9 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
}, authenticationUtil.getAdminUserName());
|
}, authenticationUtil.getAdminUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#hasClearance(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasClearance(NodeRef nodeRef)
|
public boolean hasClearance(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
@@ -174,4 +182,21 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
return isClassified;
|
return isClassified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -64,6 +64,7 @@ import com.google.common.collect.Sets;
|
|||||||
* Unit tests for {@link ContentClassificationServiceImpl}.
|
* Unit tests for {@link ContentClassificationServiceImpl}.
|
||||||
*
|
*
|
||||||
* @author tpage
|
* @author tpage
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class ContentClassificationServiceImplUnitTest implements ClassifiedContentModel
|
public class ContentClassificationServiceImplUnitTest implements ClassifiedContentModel
|
||||||
{
|
{
|
||||||
@@ -138,20 +139,6 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
|
|||||||
Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent);
|
Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Classify a piece of content that has already been classified. */
|
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
|
||||||
public void classifyContent_alreadyClassified()
|
|
||||||
{
|
|
||||||
// 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(true);
|
|
||||||
|
|
||||||
// Call the method under test.
|
|
||||||
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency",
|
|
||||||
Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Classify a piece of content that has already been shared */
|
/** Classify a piece of content that has already been shared */
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test(expected = IllegalStateException.class)
|
||||||
public void classifySharedContent()
|
public void classifySharedContent()
|
||||||
|
Reference in New Issue
Block a user