Exemplo n.º 1
0
  /**
   * Constructor used for {@link HttpMethod#POST} requests, which receive a JSON payload.
   *
   * @param pMap map containing requests parameters
   * @param pInitParams optional processing parameters (obtained as query parameters or from within
   *     the JSON request)
   */
  public JmxRequest(Map<String, ?> pMap, ProcessingParameters pInitParams) {
    this(
        RequestType.getTypeByName((String) pMap.get("type")),
        HttpMethod.POST,
        EscapeUtil.parsePath((String) pMap.get("path")),
        pInitParams);

    Map target = (Map) pMap.get("target");
    if (target != null) {
      targetConfig = new ProxyTargetConfig(target);
    }
  }
Exemplo n.º 2
0
  /**
   * Convert this request to a JSON object, which can be used as a part of a return value.
   *
   * @return JSON object representing this base request object
   */
  public JSONObject toJSON() {
    JSONObject ret = new JSONObject();
    ret.put("type", type.getName());

    if (targetConfig != null) {
      ret.put("target", targetConfig.toJSON());
    }
    if (pathParts != null) {
      try {
        ret.put("path", getPath());
      } catch (UnsupportedOperationException exp) {
        // Happens when request doesnt support paths
      }
    }
    return ret;
  }