* @param throwBadRequest (vs. NOT_FOUND)
* @param throwOnWarning (vs.ignore warning)
* @return
*/
public ActionReporter executeCommand(Subject subject, String command, ParameterMap parameters, Status status, boolean includeFailureMessage, boolean throwOnWarning, boolean managed) {
RestActionReporter ar = ResourceUtil.runCommand(command, parameters, subject, managed);
ExitCode code = ar.getActionExitCode();
if (code.equals(ExitCode.FAILURE) || (code.equals(ExitCode.WARNING) && throwOnWarning)) {
Throwable t = ar.getFailureCause();
if (t instanceof SecurityException) {
throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
}
if (includeFailureMessage) {
throw new WebApplicationException(Response.status(status).entity(ar.getCombinedMessage()).build());
} else {
throw new WebApplicationException(status);
}
}
return ar;