Search in sources :

Example 6 with ActionReporter

use of com.sun.enterprise.v3.common.ActionReporter in project Payara by payara.

the class ActionReportResultXmlProvider method getContent.

@Override
public String getContent(ActionReportResult proxy) {
    ActionReporter ar = (ActionReporter) proxy.getActionReport();
    ActionReportXmlProvider provider = new ActionReportXmlProvider();
    return provider.getContent(ar);
}
Also used : ActionReporter(com.sun.enterprise.v3.common.ActionReporter)

Example 7 with ActionReporter

use of com.sun.enterprise.v3.common.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();
}
Also used : ActionReporter(com.sun.enterprise.v3.common.ActionReporter) JsonObjectBuilder(javax.json.JsonObjectBuilder)

Example 8 with ActionReporter

use of com.sun.enterprise.v3.common.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 ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (BadRealmException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (InvalidOperationException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (NoSuchUserException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Config(com.sun.enterprise.config.serverbeans.Config) NoSuchUserException(com.sun.enterprise.security.auth.realm.NoSuchUserException) Properties(java.util.Properties) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) InvalidOperationException(com.sun.enterprise.security.auth.realm.InvalidOperationException) NoSuchUserException(com.sun.enterprise.security.auth.realm.NoSuchUserException) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) InvalidOperationException(com.sun.enterprise.security.auth.realm.InvalidOperationException) ActionReporter(com.sun.enterprise.v3.common.ActionReporter)

Example 9 with ActionReporter

use of com.sun.enterprise.v3.common.ActionReporter in project Payara by payara.

the class GetTokensCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    ActionReporter report = (ActionReporter) context.getActionReport();
    PropertyResolver resolver = new PropertyResolver(domain, target);
    String sep = "";
    String eol = System.getProperty("line.separator");
    StringBuilder output = new StringBuilder();
    Map<String, String> values = new TreeMap<String, String>();
    Properties properties = new Properties();
    properties.put("tokens", values);
    for (String token : tokens) {
        String value = resolver.getPropertyValue(token);
        if ((value == null) && (checkSystemProperties)) {
            value = System.getProperty(token);
        }
        output.append(sep).append(token).append(" = ").append(value);
        sep = eol;
        values.put(token, value);
    }
    report.setMessage(output.toString());
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    report.setExtraProperties(properties);
    return;
}
Also used : ActionReporter(com.sun.enterprise.v3.common.ActionReporter) PropertyResolver(org.glassfish.config.support.PropertyResolver) TreeMap(java.util.TreeMap) Properties(java.util.Properties)

Aggregations

ActionReporter (com.sun.enterprise.v3.common.ActionReporter)8 Properties (java.util.Properties)3 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)3 PlainTextActionReporter (com.sun.enterprise.v3.common.PlainTextActionReporter)2 JsonObjectBuilder (javax.json.JsonObjectBuilder)2 MessagePart (org.glassfish.api.ActionReport.MessagePart)2 ParamsWithPayload (com.sun.enterprise.admin.remote.ParamsWithPayload)1 RestPayloadImpl (com.sun.enterprise.admin.remote.RestPayloadImpl)1 CachedCommandModel (com.sun.enterprise.admin.util.CachedCommandModel)1 Config (com.sun.enterprise.config.serverbeans.Config)1 Server (com.sun.enterprise.config.serverbeans.Server)1 BadRealmException (com.sun.enterprise.security.auth.realm.BadRealmException)1 InvalidOperationException (com.sun.enterprise.security.auth.realm.InvalidOperationException)1 NoSuchRealmException (com.sun.enterprise.security.auth.realm.NoSuchRealmException)1 NoSuchUserException (com.sun.enterprise.security.auth.realm.NoSuchUserException)1 PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)1 TreeMap (java.util.TreeMap)1 JsonObject (javax.json.JsonObject)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 XmlMap (org.glassfish.admin.rest.utils.xml.XmlMap)1