Permalink
Browse files

[HHQ-4061] getControlActions() also throws a PermissionException, so …

…put into a try/catch block
  • Loading branch information...
1 parent fb793c6 commit 1987a19034fa9bbc897284408d173124e21281a7 pnguyen committed Jun 22, 2010
Showing with 17 additions and 18 deletions.
  1. +17 −18 hqu/hqapi1/app/ControlController.groovy
@@ -105,29 +105,28 @@ class ControlController extends ApiController {
failureXml = getFailureXML(ErrorCode.INVALID_PARAMETERS,
"No action given")
} else {
-
- def actions = resource.getControlActions(user)
- if (!actions.contains(action)) {
- failureXml = getFailureXML(ErrorCode.INVALID_PARAMETERS,
+ try {
+ def actions = resource.getControlActions(user)
+ if (!actions.contains(action)) {
+ failureXml = getFailureXML(ErrorCode.INVALID_PARAMETERS,
"Resource type " + resource.prototype.name +
" does not support action " + action +
". Possible values: " + actions)
- } else {
- try {
+ } else {
resource.runAction(user, action, arguments)
- } catch (org.hyperic.hq.product.PluginException e) {
- failureXml = getFailureXML(ErrorCode.NOT_SUPPORTED,
- "Resource id " + resourceId +
- " does not support action " + action)
- } catch (PermissionException e) {
- failureXml = getFailureXML(ErrorCode.PERMISSION_DENIED)
- } catch (GroupNotCompatibleException e) {
- failureXml = getFailureXML(ErrorCode.NOT_SUPPORTED,
- "Control actions not supported for mixed groups")
- } catch (Exception e) {
- failureXml = getFailureXML(ErrorCode.UNEXPECTED_ERROR,
- "Unexpected error: " + e.getMessage())
}
+ } catch (org.hyperic.hq.product.PluginException e) {
+ failureXml = getFailureXML(ErrorCode.NOT_SUPPORTED,
+ "Resource id " + resourceId +
+ " does not support action " + action)
+ } catch (PermissionException e) {
+ failureXml = getFailureXML(ErrorCode.PERMISSION_DENIED)
+ } catch (GroupNotCompatibleException e) {
+ failureXml = getFailureXML(ErrorCode.NOT_SUPPORTED,
+ "Control actions not supported for mixed groups")
+ } catch (Exception e) {
+ failureXml = getFailureXML(ErrorCode.UNEXPECTED_ERROR,
+ "Unexpected error: " + e.getMessage())
}
}

0 comments on commit 1987a19

Please sign in to comment.