Пример #1
0
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  @Path("select")
  public String getUserData(String json) {
    JSONObject jObj = null;
    try {
      jObj = new JSONObject(json);
      Integer userID = Integer.parseInt(jObj.getString("userID"));
      User user = dbManager.getUserbyAccountId(userID);

      jObj.put("middle_name", user.getMiddleName());
      jObj.put("last_name", user.getLastName());
      jObj.put("street", user.getStreet());
      jObj.put("house_number", user.getHouseNumber());
      jObj.put("city", user.getCity());
      jObj.put("postal_code", user.getPostalCode());
      jObj.put("country", user.getCountry());
      Account account = user.getAccountId();
      jObj.put("email", account.getUserName());

    } catch (JSONException ex) {
      Logger.getLogger(ChangeAccount.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      return jObj.toString();
    }
  }