Search in sources :

Example 6 with ActionReportResult

use of org.glassfish.admin.rest.results.ActionReportResult in project Payara by payara.

the class ManagementProxyResource method proxyRequest.

@GET
public ActionReportResult proxyRequest() {
    RestActionReporter ar = new RestActionReporter();
    ar.setActionDescription("Proxied Data");
    ar.setSuccess();
    ActionReportResult result = new ActionReportResult(ar);
    Properties proxiedResponse = new ManagementProxyImpl().proxyRequest(uriInfo, Util.getJerseyClient(), habitat);
    ar.setExtraProperties(proxiedResponse);
    return result;
}
Also used : ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) Properties(java.util.Properties) GET(javax.ws.rs.GET)

Example 7 with ActionReportResult

use of org.glassfish.admin.rest.results.ActionReportResult in project Payara by payara.

the class MonitoredAttributeBagResource method put.

/**
 * Creates new monitored-attributes. This method deletes all of the existing
 * monitored-attributes.
 *
 * @param attributes the list of monitored-attributes to be created.
 * @return a list of the monitored-attributes after the transaction.
 */
@PUT
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ActionReportResult put(List<Map<String, String>> attributes) {
    RestActionReporter ar = new RestActionReporter();
    ar.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ar.setActionDescription("monitored-attribute");
    try {
        setMonitoredAttributes(attributes);
        List monitoredAttributes = getMonitoredAttributes();
        Properties extraProperties = new Properties();
        extraProperties.put("monitoredAttributes", monitoredAttributes);
        ar.setExtraProperties(extraProperties);
    } catch (TransactionFailure ex) {
        ar.setActionExitCode(ActionReport.ExitCode.FAILURE);
        ar.setMessage(ex.getMessage());
    }
    return new ActionReportResult(tagName, ar, new OptionsResult(Util.getResourceName(uriInfo)));
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 8 with ActionReportResult

use of org.glassfish.admin.rest.results.ActionReportResult in project Payara by payara.

the class MonitoredAttributeBagResource method get.

/**
 * Gets the monitored-attributes.
 *
 * @return a list of the monitored-attributes after the transaction.
 */
@GET
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ActionReportResult get() {
    RestActionReporter ar = new RestActionReporter();
    ar.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ar.setActionDescription("monitored-attribute");
    List monitoredAttributes = getMonitoredAttributes();
    Properties extraProperties = new Properties();
    extraProperties.put("monitoredAttributes", monitoredAttributes);
    ar.setExtraProperties(extraProperties);
    return new ActionReportResult(tagName, ar, new OptionsResult(Util.getResourceName(uriInfo)));
}
Also used : ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with ActionReportResult

use of org.glassfish.admin.rest.results.ActionReportResult in project Payara by payara.

the class SystemPropertiesCliResource method get.

@GET
public ActionReportResult get() {
    domain = locatorBridge.getRemoteLocator().getService(Domain.class);
    ParameterMap data = new ParameterMap();
    processCommandParams(data);
    addQueryString(uriInfo.getQueryParameters(), data);
    adjustParameters(data);
    Map<String, Map<String, String>> properties = new TreeMap<String, Map<String, String>>();
    RestActionReporter actionReport = new RestActionReporter();
    getSystemProperties(properties, getEntity(), false);
    actionReport.getExtraProperties().put("systemProperties", new ArrayList(properties.values()));
    if (properties.isEmpty()) {
        // i18n
        actionReport.getTopMessagePart().setMessage("Nothing to list.");
    }
    ActionReportResult results = new ActionReportResult(commandName, actionReport, new OptionsResult());
    return results;
}
Also used : ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) ArrayList(java.util.ArrayList) ParameterMap(org.glassfish.api.admin.ParameterMap) Domain(com.sun.enterprise.config.serverbeans.Domain) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) ParameterMap(org.glassfish.api.admin.ParameterMap) TreeMap(java.util.TreeMap) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) GET(javax.ws.rs.GET)

Example 10 with ActionReportResult

use of org.glassfish.admin.rest.results.ActionReportResult in project Payara by payara.

the class SystemPropertiesCliResource method saveProperties.

protected Response saveProperties(String parent, HashMap<String, String> data) {
    String propertiesString = convertPropertyMapToString(data);
    data = new HashMap<String, String>();
    data.put("DEFAULT", propertiesString);
    data.put("target", (parent == null) ? getParent(uriInfo) : parent);
    RestActionReporter actionReport = ResourceUtil.runCommand("create-system-properties", data, getSubject());
    ActionReport.ExitCode exitCode = actionReport.getActionExitCode();
    ActionReportResult results = new ActionReportResult(commandName, actionReport, new OptionsResult());
    int status = HttpURLConnection.HTTP_OK;
    /*200 - ok*/
    if (exitCode == ActionReport.ExitCode.FAILURE) {
        status = HttpURLConnection.HTTP_INTERNAL_ERROR;
    }
    return Response.status(status).entity(results).build();
}
Also used : ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) ActionReport(org.glassfish.api.ActionReport) OptionsResult(org.glassfish.admin.rest.results.OptionsResult)

Aggregations

ActionReportResult (org.glassfish.admin.rest.results.ActionReportResult)24 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)23 OptionsResult (org.glassfish.admin.rest.results.OptionsResult)13 Produces (javax.ws.rs.Produces)9 GET (javax.ws.rs.GET)7 ArrayList (java.util.ArrayList)5 Consumes (javax.ws.rs.Consumes)5 MethodMetaData (org.glassfish.admin.rest.provider.MethodMetaData)5 ActionReport (org.glassfish.api.ActionReport)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Properties (java.util.Properties)4 Test (org.testng.annotations.Test)3 Domain (com.sun.enterprise.config.serverbeans.Domain)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 POST (javax.ws.rs.POST)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 Response (javax.ws.rs.core.Response)2 ActionReportResultHtmlProvider (org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider)2