mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2045 Add validation that the node is a content node.
This is needed as the API method is specifically for content nodes. We will deal with record nodes later, and possible folder nodes much later. +review RM-25 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@102157 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,8 +21,10 @@ package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.InvalidNode;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.ReasonIdNotFound;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
@@ -58,7 +60,10 @@ public interface ClassificationService
|
||||
* @param document 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.
|
||||
*/
|
||||
void addClassificationToDocument(String classificationLevelId, String classificationAuthority,
|
||||
Set<String> classificationReasonIds, NodeRef document) throws LevelIdNotFound, ReasonIdNotFound;
|
||||
Set<String> classificationReasonIds, NodeRef document) throws LevelIdNotFound, ReasonIdNotFound,
|
||||
InvalidNodeRefException, InvalidNode;
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Generic class for any runtime exception thrown within the {@link ClassificationService}.
|
||||
@@ -87,4 +88,15 @@ public class ClassificationServiceException extends AlfrescoRuntimeException
|
||||
super("Could not find classification reason with id " + reasonId);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidNode extends ClassificationServiceException
|
||||
{
|
||||
/** serial version uid */
|
||||
private static final long serialVersionUID = -4485335425932302477L;
|
||||
|
||||
public InvalidNode(NodeRef nodeRef, String message)
|
||||
{
|
||||
super("Operation not permitted on node " + nodeRef + ", error message: " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.InvalidNode;
|
||||
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.ReasonIdNotFound;
|
||||
@@ -224,6 +226,11 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
|
||||
mandatory("classificationReasonIds", classificationReasonIds);
|
||||
mandatory("document", document);
|
||||
|
||||
if (!nodeService.getType(document).equals(ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
throw new InvalidNode(document, "The supplied node is not a content node.");
|
||||
}
|
||||
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
checkClassificationLevelId(classificationLevelId);
|
||||
|
||||
|
Reference in New Issue
Block a user