Search in sources :

Example 1 with OptionsResult

use of org.glassfish.admin.rest.results.OptionsResult 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 2 with OptionsResult

use of org.glassfish.admin.rest.results.OptionsResult 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 3 with OptionsResult

use of org.glassfish.admin.rest.results.OptionsResult 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)

Example 4 with OptionsResult

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

the class AbstractAttributeBagResource method get.

/**
 * Gets the attributes.
 *
 * @return a list of the 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(getDescriptionName());
    List attributes = getAllAttributes();
    Properties extraProperties = new Properties();
    extraProperties.put(getPropertiesName(), attributes);
    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) ArrayList(java.util.ArrayList) List(java.util.List) Properties(java.util.Properties) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with OptionsResult

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

the class TemplateListOfResource method buildActionReportResult.

protected ActionReportResult buildActionReportResult() {
    if (entity == null) {
        // wrong resource
        String errorMessage = localStrings.getLocalString("rest.resource.erromessage.noentity", "Resource not found.");
        return ResourceUtil.getActionReportResult(ActionReport.ExitCode.FAILURE, errorMessage, requestHeaders, uriInfo);
    }
    RestActionReporter ar = new RestActionReporter();
    final String typeKey = (decode(getName(uriInfo.getPath(), '/')));
    ar.setActionDescription(typeKey);
    OptionsResult optionsResult = new OptionsResult(Util.getResourceName(uriInfo));
    Map<String, MethodMetaData> mmd = getMethodMetaData();
    optionsResult.putMethodMetaData("GET", mmd.get("GET"));
    optionsResult.putMethodMetaData("POST", mmd.get("POST"));
    ResourceUtil.addMethodMetaData(ar, mmd);
    ar.getExtraProperties().put("childResources", ResourceUtil.getResourceLinks(getEntity(), uriInfo));
    ar.getExtraProperties().put("commands", ResourceUtil.getCommandLinks(getCommandResourcesPaths()));
    // an internal impl detail, so it can wait
    return new ActionReportResult(ar, optionsResult);
}
Also used : ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) MethodMetaData(org.glassfish.admin.rest.provider.MethodMetaData) OptionsResult(org.glassfish.admin.rest.results.OptionsResult)

Aggregations

ActionReportResult (org.glassfish.admin.rest.results.ActionReportResult)16 OptionsResult (org.glassfish.admin.rest.results.OptionsResult)16 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)16 Produces (javax.ws.rs.Produces)7 GET (javax.ws.rs.GET)5 MethodMetaData (org.glassfish.admin.rest.provider.MethodMetaData)5 Properties (java.util.Properties)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Consumes (javax.ws.rs.Consumes)3 ActionReport (org.glassfish.api.ActionReport)3 List (java.util.List)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 PUT (javax.ws.rs.PUT)2 ExitCode (org.glassfish.api.ActionReport.ExitCode)2 ParameterMap (org.glassfish.api.admin.ParameterMap)2 Dom (org.jvnet.hk2.config.Dom)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 Domain (com.sun.enterprise.config.serverbeans.Domain)1