mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-2045 (Java API to add a classification to a document)
* Check the id's of classification reasons and level + review RM-25 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@102125 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,7 +28,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.MissingConfiguration;
|
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.MissingConfiguration;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.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;
|
||||||
@@ -223,6 +225,7 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
mandatory("document", document);
|
mandatory("document", document);
|
||||||
|
|
||||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||||
|
checkClassificationLevelId(classificationLevelId);
|
||||||
|
|
||||||
// Initial classification id
|
// Initial classification id
|
||||||
if (nodeService.getProperty(document, PROP_INITIAL_CLASSIFICATION) == null)
|
if (nodeService.getProperty(document, PROP_INITIAL_CLASSIFICATION) == null)
|
||||||
@@ -240,6 +243,7 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
HashSet<String> classificationReasons = new HashSet<>();
|
HashSet<String> classificationReasons = new HashSet<>();
|
||||||
for (String classificationReasonId : classificationReasonIds)
|
for (String classificationReasonId : classificationReasonIds)
|
||||||
{
|
{
|
||||||
|
checkClassificationReasonId(classificationReasonId);
|
||||||
classificationReasons.add(classificationReasonId);
|
classificationReasons.add(classificationReasonId);
|
||||||
}
|
}
|
||||||
properties.put(PROP_CLASSIFICATION_REASONS, classificationReasons);
|
properties.put(PROP_CLASSIFICATION_REASONS, classificationReasons);
|
||||||
@@ -247,4 +251,26 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
// Add aspect
|
// Add aspect
|
||||||
nodeService.addAspect(document, ASPECT_CLASSIFIED, properties);
|
nodeService.addAspect(document, ASPECT_CLASSIFIED, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to check if a classification level with the given id exists
|
||||||
|
*
|
||||||
|
* @param classificationLevelId {@link String} The id of the classification level
|
||||||
|
* @throws {@link LevelIdNotFound} throws an exception if a classification level with given id does not exist
|
||||||
|
*/
|
||||||
|
private void checkClassificationLevelId(String classificationLevelId) throws LevelIdNotFound
|
||||||
|
{
|
||||||
|
levelManager.findLevelById(classificationLevelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to check if a classification reason with the given id exists
|
||||||
|
*
|
||||||
|
* @param classificationReasonId {@String} The id of the classification reason
|
||||||
|
* @throws {@link ReasonIdNotFound} throws an exception if a classification reason with the given id does not exist
|
||||||
|
*/
|
||||||
|
private void checkClassificationReasonId(String classificationReasonId) throws ReasonIdNotFound
|
||||||
|
{
|
||||||
|
reasonManager.findReasonById(classificationReasonId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user