@Override protected Navigation run() throws Exception { // TODO Auto-generated method stub /*UserService service = new UserService(); service.removeUserModel(um.getKey()); return redirect("/");*/ UserService service = new UserService(); JSONObject json = new JSONObject(); UserDto user = new UserDto(); try { json = new JSONObject((String) this.requestScope("data")); user.setAddress(json.getString("address")); user.setAge(json.getInt("age")); // user.setBirthday(Date.parse(json.getString("date")); user.setEmail(json.getString("email")); // user.setKey(null); // user.setImgSrc(json.getString("imgSrc")); user.setName(json.getString("name")); service.removeUserModel(user); } catch (Exception e) { e.printStackTrace(); user.getErrorList().add("Server controller error: " + e.getMessage()); } json.put("user", user.toJSON()); json.put("errorList", user.getErrorList()); response.setContentType("application/json"); response.getWriter().write(json.toString()); return null; }
// private TaskMeta meta = TaskMeta.get(); @Override protected Navigation run() throws Exception { response.setContentType("application/json"); TaskDto dto = new TaskDto(); JSONObject json = null; try { json = new JSONObject((String) this.request.getReader().readLine()); dto.setId(json.getLong("id")); Task task = service.getTask(dto.getId()); if (task.isToday() == true) { dto.getErrorList().add("Error: The task has already been added to Pending Tasks"); } else { dto = this.service.addTaskToday(dto); } } catch (Exception e) { dto.getErrorList().add("Server controller error: " + e.getMessage()); if (json == null) { json = new JSONObject(); } } json.put("errorList", dto.getErrorList()); response.getWriter().write(json.toString()); return null; }