RM-2120: Add error handling (and test) as suggested by Neil during + review RM-46

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@104157 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Webster
2015-05-14 10:58:19 +00:00
parent edb4c206c5
commit a9f57ea03b
2 changed files with 33 additions and 1 deletions

View File

@@ -18,11 +18,13 @@
*/
package org.alfresco.module.org_alfresco_module_rm.script.classification;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException;
import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance;
import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService;
import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import java.util.HashMap;
@@ -63,8 +65,17 @@ public class UserSecurityClearancePut extends AbstractRmWebScript
{
String username = req.getParameter(USERNAME);
String clearanceId = req.getParameter(CLEARANCE_ID);
SecurityClearance securityClearance;
SecurityClearance securityClearance = securityClearanceService.setUserSecurityClearance(username, clearanceId);
try
{
securityClearance = securityClearanceService.setUserSecurityClearance(username,
clearanceId);
}
catch (ClassificationServiceException.LevelIdNotFound exception)
{
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to find clearance level");
}
Map<String, Object> model = new HashMap<>();
model.put(ITEM, securityClearance);