Skip to content

Commit

Permalink
[HHQ-4061] getControlActions() also throws a PermissionException, so …
Browse files Browse the repository at this point in the history
…put into a try/catch block
  • Loading branch information
pnguyen committed Jun 22, 2010
1 parent fb793c6 commit 1987a19
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions hqu/hqapi1/app/ControlController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down

0 comments on commit 1987a19

Please sign in to comment.