Search in sources :

Example 1 with GetResultList

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

the class PropertiesBagResource method get.

@GET
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Object get() {
    List<Dom> entities = getEntity();
    if (entities == null) {
        // empty dom list
        return new GetResultList(new ArrayList(), "", new String[][] {}, new OptionsResult(Util.getResourceName(uriInfo)));
    }
    RestActionReporter ar = new RestActionReporter();
    ar.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ar.setActionDescription("property");
    List properties = new ArrayList();
    for (Dom child : entities) {
        Map<String, String> entry = new HashMap<String, String>();
        entry.put("name", child.attribute("name"));
        entry.put("value", child.attribute("value"));
        String description = child.attribute("description");
        if (description != null) {
            entry.put("description", description);
        }
        properties.add(entry);
    }
    Properties extraProperties = new Properties();
    extraProperties.put("properties", properties);
    ar.setExtraProperties(extraProperties);
    return new ActionReportResult("properties", ar, new OptionsResult(Util.getResourceName(uriInfo)));
}
Also used : Dom(org.jvnet.hk2.config.Dom) ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) GetResultList(org.glassfish.admin.rest.results.GetResultList) GetResultList(org.glassfish.admin.rest.results.GetResultList) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 ActionReportResult (org.glassfish.admin.rest.results.ActionReportResult)1 GetResultList (org.glassfish.admin.rest.results.GetResultList)1 OptionsResult (org.glassfish.admin.rest.results.OptionsResult)1 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)1 Dom (org.jvnet.hk2.config.Dom)1