use of com.sun.enterprise.admin.report.ActionReporter in project Payara by payara.
the class GetGroupNamesCommand method execute.
@Override
public void execute(AdminCommandContext context) {
Config tmp = null;
try {
tmp = configs.getConfigByName(target);
} catch (Exception ex) {
}
if (tmp != null) {
config = tmp;
}
if (tmp == null) {
Server targetServer = domain.getServerNamed(target);
if (targetServer != null) {
config = domain.getConfigNamed(targetServer.getConfigRef());
}
com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
config = domain.getConfigNamed(cluster.getConfigRef());
}
}
ActionReporter report = (ActionReporter) context.getActionReport();
try {
String[] list = getGroupNames(realmName, userName);
List<String> ret = Arrays.asList(list);
report.setActionExitCode(ExitCode.SUCCESS);
Properties props = new Properties();
props.put("groups", ret);
report.setExtraProperties(props);
report.setMessage("" + ret);
} catch (NoSuchRealmException | BadRealmException | InvalidOperationException | NoSuchUserException ex) {
report.setFailureCause(ex);
report.setActionExitCode(ExitCode.FAILURE);
}
}
use of com.sun.enterprise.admin.report.ActionReporter in project Payara by payara.
the class ActionReportResultXmlProvider method getContent.
@Override
public String getContent(ActionReportResult proxy) {
ActionReporter ar = proxy.getActionReport();
ActionReportXmlProvider provider = new ActionReportXmlProvider();
return provider.getContent(ar);
}
use of com.sun.enterprise.admin.report.ActionReporter in project Payara by payara.
the class ActionReportJsonProvider method processReport.
/**
* Converts an ActionReport into a JsonObject
* @param ar
* @return
* @throws JsonException
*/
protected JsonObject processReport(ActionReporter ar) throws JsonException {
JsonObjectBuilder result = Json.createObjectBuilder();
if (ar instanceof RestActionReporter) {
result.add("message", ((RestActionReporter) ar).getCombinedMessage());
} else {
String message = decodeEol(ar.getMessage());
if (message != null) {
result.add("message", message);
}
}
String desc = ar.getActionDescription();
if (desc != null) {
result.add("command", ar.getActionDescription());
} else {
result.add("command", JsonValue.NULL);
}
result.add("exit_code", ar.getActionExitCode().toString());
Properties properties = ar.getTopMessagePart().getProps();
if ((properties != null) && (!properties.isEmpty())) {
JsonObject propBuilder = Json.createObjectBuilder((Map) properties).build();
result.add("properties", propBuilder);
}
Properties extraProperties = ar.getExtraProperties();
if ((extraProperties != null) && (!extraProperties.isEmpty())) {
result.add("extraProperties", getExtraProperties(extraProperties));
}
List<MessagePart> children = ar.getTopMessagePart().getChildren();
if ((children != null) && (!children.isEmpty())) {
result.add("children", processChildren(children));
}
List<ActionReporter> subReports = ar.getSubActionsReport();
if ((subReports != null) && (!subReports.isEmpty())) {
result.add("subReports", processSubReports(subReports));
}
return result.build();
}
use of com.sun.enterprise.admin.report.ActionReporter in project Payara by payara.
the class AdminCommandStateJsonProvider method processState.
public JsonObject processState(AdminCommandState state) throws JsonException {
JsonObjectBuilder result = Json.createObjectBuilder();
result.add("state", state.getState().name());
result.add("id", state.getId());
result.add("empty-payload", state.isOutboundPayloadEmpty());
ActionReporter ar = (ActionReporter) state.getActionReport();
addActionReporter(ar, result);
return result.build();
}
Aggregations