Search in sources :

Example 11 with MethodMetaData

use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.

the class TemplateExecCommand method optionsLegacyFormat.

@OPTIONS
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ActionReportResult optionsLegacyFormat() {
    RestActionReporter ar = new RestActionReporter();
    ar.setExtraProperties(new Properties());
    ar.setActionDescription(commandDisplayName);
    OptionsResult optionsResult = new OptionsResult(resourceName);
    Map<String, MethodMetaData> mmd = new HashMap<String, MethodMetaData>();
    MethodMetaData methodMetaData = ResourceUtil.getMethodMetaData(commandName, getCommandParams(), locatorBridge.getRemoteLocator());
    optionsResult.putMethodMetaData(commandMethod, methodMetaData);
    mmd.put(commandMethod, methodMetaData);
    ResourceUtil.addMethodMetaData(ar, mmd);
    ActionReportResult ret = new ActionReportResult(ar, null, optionsResult);
    ret.setCommandDisplayName(commandDisplayName);
    return ret;
}
Also used : ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) HashMap(java.util.HashMap) MethodMetaData(org.glassfish.admin.rest.provider.MethodMetaData) Properties(java.util.Properties) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) Produces(javax.ws.rs.Produces) OPTIONS(javax.ws.rs.OPTIONS)

Example 12 with MethodMetaData

use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.

the class TemplateListOfResource method getMethodMetaData.

private Map<String, MethodMetaData> getMethodMetaData() {
    Map<String, MethodMetaData> map = new TreeMap<String, MethodMetaData>();
    // GET meta data
    map.put("GET", new MethodMetaData());
    // POST meta data
    String command = getPostCommand();
    if (command != null) {
        MethodMetaData postMethodMetaData = ResourceUtil.getMethodMetaData(command, locatorBridge.getRemoteLocator());
        if (Util.getResourceName(uriInfo).equals("Application")) {
            postMethodMetaData.setIsFileUploadOperation(true);
        }
        map.put("POST", postMethodMetaData);
    }
    return map;
}
Also used : MethodMetaData(org.glassfish.admin.rest.provider.MethodMetaData) TreeMap(java.util.TreeMap)

Example 13 with MethodMetaData

use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.

the class ResourceUtil method addMethodMetaData.

public static void addMethodMetaData(ActionReport ar, Map<String, MethodMetaData> mmd) {
    List<Map> methodMetaData = new ArrayList<Map>();
    MethodMetaData getMetaData = mmd.get("GET");
    methodMetaData.add(new HashMap() {

        {
            put("name", "GET");
        }
    });
    if (getMetaData != null) {
        // are they extra params for a GET command?
        Map<String, Object> getMetaDataMap = new HashMap<String, Object>();
        if (getMetaData.sizeParameterMetaData() > 0) {
            getMetaDataMap.put(MESSAGE_PARAMETERS, buildMethodMetadataMap(getMetaData));
        }
        methodMetaData.add(getMetaDataMap);
    }
    MethodMetaData postMetaData = mmd.get("POST");
    Map<String, Object> postMetaDataMap = new HashMap<String, Object>();
    if (postMetaData != null) {
        postMetaDataMap.put("name", "POST");
        // }
        if (postMetaData.sizeParameterMetaData() > 0) {
            postMetaDataMap.put(MESSAGE_PARAMETERS, buildMethodMetadataMap(postMetaData));
        }
        methodMetaData.add(postMetaDataMap);
    }
    MethodMetaData deleteMetaData = mmd.get("DELETE");
    if (deleteMetaData != null) {
        Map<String, Object> deleteMetaDataMap = new HashMap<String, Object>();
        deleteMetaDataMap.put("name", "DELETE");
        deleteMetaDataMap.put(MESSAGE_PARAMETERS, buildMethodMetadataMap(deleteMetaData));
        methodMetaData.add(deleteMetaDataMap);
    }
    ar.getExtraProperties().put("methods", methodMetaData);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MethodMetaData(org.glassfish.admin.rest.provider.MethodMetaData) Map(java.util.Map) ParameterMap(org.glassfish.api.admin.ParameterMap) HashMap(java.util.HashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) TreeMap(java.util.TreeMap)

Aggregations

MethodMetaData (org.glassfish.admin.rest.provider.MethodMetaData)13 TreeMap (java.util.TreeMap)5 ActionReportResult (org.glassfish.admin.rest.results.ActionReportResult)5 OptionsResult (org.glassfish.admin.rest.results.OptionsResult)5 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)5 HashMap (java.util.HashMap)3 ParameterMetaData (org.glassfish.admin.rest.provider.ParameterMetaData)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 MultiException (org.glassfish.hk2.api.MultiException)2 Attribute (org.jvnet.hk2.config.Attribute)2 Map (java.util.Map)1 OPTIONS (javax.ws.rs.OPTIONS)1 Produces (javax.ws.rs.Produces)1 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)1 Param (org.glassfish.api.Param)1 CommandModel (org.glassfish.api.admin.CommandModel)1 ParameterMap (org.glassfish.api.admin.ParameterMap)1 ConfigBean (org.jvnet.hk2.config.ConfigBean)1