Examples of JSONTokeniser


Examples of org.servalproject.json.JSONTokeniser

  protected static JSONTokeniser receiveRestfulResponse(HttpURLConnection conn, int[] expected_response_codes) throws IOException, ServalDInterfaceException, MeshMSException
  {
    if (!"application/json".equals(conn.getContentType()))
      throw new ServalDInterfaceException("unexpected HTTP Content-Type: " + conn.getContentType());
    if (conn.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) {
      JSONTokeniser json = new JSONTokeniser(new InputStreamReader(conn.getErrorStream(), "US-ASCII"));
      Status status = decodeRestfulStatus(json);
      throwRestfulResponseExceptions(status, conn.getURL());
      throw new ServalDInterfaceException("unexpected MeshMS status = " + status.meshms_status_code + ", \"" + status.meshms_status_message + "\"");
    }
    for (int code: expected_response_codes) {
      if (conn.getResponseCode() == code) {
        JSONTokeniser json = new JSONTokeniser(new InputStreamReader(conn.getInputStream(), "US-ASCII"));
        return json;
      }
    }
    throw new ServalDInterfaceException("unexpected HTTP response code: " + conn.getResponseCode());
  }
View Full Code Here

Examples of org.servalproject.json.JSONTokeniser

        wr.print("Content-Type: text/plain; charset=utf-8\r\n");
        wr.print("\r\n");
        wr.print(text);
        wr.print("\r\n--" + boundary + "--\r\n");
    wr.close();
    JSONTokeniser json = MeshMSCommon.receiveRestfulResponse(conn, HttpURLConnection.HTTP_CREATED);
    Status status = decodeRestfulStatus(json);
    throwRestfulResponseExceptions(status, conn.getURL());
    return status.meshms_status_code;
  }
View Full Code Here

Examples of org.servalproject.json.JSONTokeniser

  {
    HttpURLConnection conn = connector.newServalDHttpConnection("/restful/meshms/" + sid1.toHex() + "/readall");
    conn.setRequestMethod("POST");
    conn.connect();
    int[] expected_response_codes = { HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED };
    JSONTokeniser json = MeshMSCommon.receiveRestfulResponse(conn, expected_response_codes);
    Status status = decodeRestfulStatus(json);
    throwRestfulResponseExceptions(status, conn.getURL());
    return status.meshms_status_code;
  }
View Full Code Here

Examples of org.servalproject.json.JSONTokeniser

  {
    HttpURLConnection conn = connector.newServalDHttpConnection("/restful/meshms/" + sid1.toHex() + "/" + sid2.toHex() + "/readall");
    conn.setRequestMethod("POST");
    conn.connect();
    int[] expected_response_codes = { HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED };
    JSONTokeniser json = MeshMSCommon.receiveRestfulResponse(conn, expected_response_codes);
    Status status = decodeRestfulStatus(json);
    throwRestfulResponseExceptions(status, conn.getURL());
    return status.meshms_status_code;
  }
View Full Code Here

Examples of org.servalproject.json.JSONTokeniser

  {
    HttpURLConnection conn = connector.newServalDHttpConnection("/restful/meshms/" + sid1.toHex() + "/" + sid2.toHex() + "/recv/" + offset + "/read");
    conn.setRequestMethod("POST");
    conn.connect();
    int[] expected_response_codes = { HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED };
    JSONTokeniser json = MeshMSCommon.receiveRestfulResponse(conn, expected_response_codes);
    Status status = decodeRestfulStatus(json);
    throwRestfulResponseExceptions(status, conn.getURL());
    return status.meshms_status_code;
  }
View Full Code Here

Examples of org.servalproject.json.JSONTokeniser

      }
    }
    if (!conn.getContentType().equals("application/json"))
      throw new ServalDInterfaceException("unexpected HTTP Content-Type: " + conn.getContentType());
    if (status.http_status_code >= 300) {
      JSONTokeniser json = new JSONTokeniser(new InputStreamReader(conn.getErrorStream(), "US-ASCII"));
      decodeRestfulStatus(status, json);
    }
    if (status.http_status_code == HttpURLConnection.HTTP_FORBIDDEN)
      return status;
    if (status.http_status_code == HttpURLConnection.HTTP_NOT_IMPLEMENTED)
View Full Code Here

Examples of org.servalproject.json.JSONTokeniser

  protected static JSONTokeniser receiveRestfulResponse(HttpURLConnection conn, int[] expected_response_codes) throws IOException, ServalDInterfaceException
  {
    Status status = receiveResponse(conn, expected_response_codes);
    if (!conn.getContentType().equals("application/json"))
      throw new ServalDInterfaceException("unexpected HTTP Content-Type: " + conn.getContentType());
    return new JSONTokeniser(new InputStreamReader(status.input_stream, "US-ASCII"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.