Skip to content

Commit

Permalink
PAYARA-1404 Reload page with alert on failure (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandrex247 authored and smillidge committed Mar 20, 2017
1 parent ee77251 commit c27be54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ public static void getHazelcastClusterMembers(HandlerContext handlerCtx) {
@HandlerInput(name = "rows", type = List.class, required = true),
@HandlerInput(name = "command", type = String.class, required = true)},
output = {
@HandlerOutput(name = "result", type = String.class)
@HandlerOutput(name = "response", type = Map.class)
})
public static void sendAsadminCommandToSelectedInstances(HandlerContext handlerCtx) {
String parentEndpoint = (String) handlerCtx.getInputValue("parentEndpoint");
String endpoint = parentEndpoint.endsWith("/") ? parentEndpoint + "send-asadmin-command" : parentEndpoint
+ "/" + "send-asadmin-command";
List<HashMap> rows = (List<HashMap>) handlerCtx.getInputValue("rows");
String command = (String) handlerCtx.getInputValue("command");

// Check that the text box isn't empty
if (command != null) {
// Get the selected rows
Expand Down Expand Up @@ -156,7 +156,8 @@ public static void sendAsadminCommandToSelectedInstances(HandlerContext handlerC
attrsMap.put("logOutput", "true");

try{
RestUtil.restRequest(endpoint, attrsMap, "POST", handlerCtx, false, true);
Map response = RestUtil.restRequest(endpoint, attrsMap, "POST", handlerCtx, false, false);
handlerCtx.setOutputValue("response", response);
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@

getAllSingleMapRows(TableRowGroup="${tableRowGroup}" Rows="#{requestScope.rows}");
py.sendAsadminCommandToSelectedInstances(parentEndpoint="#{pageSession.parentUrl}",
rows="#{requestScope.rows}", command="#{pageSession.command}");

rows="#{requestScope.rows}", command="#{pageSession.command}",
response="#{pageSession.commandResponse}");

if("#{pageSession.commandResponse.data['exit_code']} = FAILURE") {
prepareAlertMsg(type="error", detail="#{pageSession.commandResponse.data.message}",
summary="An error has occurred");
gf.redirect(page="#{request.contextPath}/hazelcast/hazelcastMembersDomain.jsf?&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
}

py.prepareSuccessfulCommandMsg();
gf.redirect(page="#{request.contextPath}/hazelcast/hazelcastMembersDomain.jsf?&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
/>
Expand Down

0 comments on commit c27be54

Please sign in to comment.