@Override
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   if (isCommentFormSanitized(request) && isStringXSSSecured(request.getParameter("comment"))) {
     HttpSession session = request.getSession();
     ServletContext context = session.getServletContext();
     Catalog catalog = (Catalog) context.getAttribute("catalog");
     Comment comment = generateCommentFromRequest(request);
     if (catalog.addComment(comment)) {
       logger.info(
           "Comentado el articulo: "
               + comment.getRecordIdAsString()
               + " por: "
               + comment.getNickname());
       request.setAttribute("info", "Comentario insertado con exito!");
       request.setAttribute("commented", comment.getRecordIdAsString());
       gotoNamedResource(recordInfoServlet, request, response);
     } else {
       request.setAttribute("info", "Algo falla en nuestro sistema! Intentalo mas tarde...");
       logger.warn("Error insertando un nuevo comentario: " + comment.getIdAsString());
     }
   } else {
     gotoURL(frontPage, request, response);
   }
 }
  public String postComment() {
    Comment comment = (Comment) FrameworkUtils.resolveVariable("comment"); // $NON-NLS-1$
    if (comment.save()) {
      FrameworkUtils.flashMessage(
          "confirmation",
          Translation.get().getValue("commentPostConfirmation")); // $NON-NLS-1$ //$NON-NLS-2$

      return "xsp-success"; //$NON-NLS-1$
    }
    return "xsp-failure"; //$NON-NLS-1$
  }
示例#3
0
  public List<Comment> getCommentByStatusId(String statusId) {
    List<Comment> list = new LinkedList<Comment>();
    Connection conn = null;
    PreparedStatement pStmt = null;
    String sql = "select cid, ctext from comment where sid = ?";
    ResultSet rs = null;
    Comment c = null;

    try {
      conn = DB.getConn();
      pStmt = DB.getpStmt(conn, sql);
      pStmt.setString(1, statusId);
      rs = pStmt.executeQuery();
      while (rs.next()) {
        c = new Comment();
        c.setCid(rs.getString("cid"));
        c.setCtext(rs.getString("ctext"));
        c.setSid(statusId);
        list.add(c);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      if (rs != null) {
        try {
          rs.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
      if (pStmt != null) {
        try {
          pStmt.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
      if (conn != null) {
        try {
          conn.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
    return list;
  }
示例#4
0
  @RequestMapping(value = "/insertcomment", method = RequestMethod.POST)
  public String InsertComent(
      @RequestParam("comicId") String comicId,
      @RequestParam("comment") String comment,
      HttpSession httpSession) {

    System.out.println("comment:" + comment);
    User user = (User) httpSession.getAttribute("user");
    if (user != null) {

      Comment c = new Comment();
      c.setComicId(comicService.GetComic(comicId));
      c.setCommentDes(comment);
      c.setDateTime(new Date());
      c.setUserId(user);
      comicService.InsertComment(c);
    }
    return "redirect:/comic/comiclist/" + comicId;
  }
示例#5
0
 @ResponseBody
 @RequestMapping(value = "/insertcommentback")
 public String InsertComentBack(
     @RequestParam("comment") String comment,
     @RequestParam("commentId") int commentId,
     @RequestParam("toId") String toId,
     HttpSession httpSession) {
   User user = (User) httpSession.getAttribute("user");
   if (user != null) {
     CommentSub cs = new CommentSub();
     Comment c = comicService.GetComent(commentId);
     c.setDateTime(new Date());
     cs.setCommentId(c);
     cs.setCommentDes(comment);
     cs.setToId(comicService.GetUser(toId));
     cs.setUpDate(new Date());
     cs.setFromId(user);
     comicService.InsertCommentBack(cs);
     comicService.UpdateComment(c);
     return "";
   }
   return null;
 }
示例#6
0
  @Transactional
  public void updateComment(Comment myComment) {
    Comment itemFromDbs = this.getCommentbyId(myComment.getId());
    if (itemFromDbs != null) {

      itemFromDbs.setContent(myComment.getContent());
      itemFromDbs.setArticleId(myComment.getArticleId());
      entityManager.persist(itemFromDbs);
    }
  }
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof AtyViewHolder) {
      ((AtyViewHolder) holder).atysItem.tvName.setText(aty.getUsername());
      //        mViewHolder.atysItem.tvJoined.setText(atysList.getJoincount());
      // fill html data
      ((AtyViewHolder) holder).atysItem.tvTime.setText(dateFormat(aty.getPubtime()));
      ((AtyViewHolder) holder).atysItem.tvTitle.setText(aty.getTitle());
      ((AtyViewHolder) holder).atysItem.tvAddress.setText(aty.getPlace());
      // ((AtyViewHolder) holder).atysItem.tvBeginTime.setText(aty.getTime());
      ((AtyViewHolder) holder).atysItem.tvJoined.setText(aty.getJoincount());
      String picture1 = aty.getPicturefir();
      String picture2 = aty.getPicturesec();
      String faceUrl = aty.getUserface();
      if (faceUrl != null && faceUrl.length() > 0) {
        Bitmap faceImage = AppCache.getImage(faceUrl);
        if (faceImage != null) {
          ((AtyViewHolder) holder).atysItem.ivFace.setImageBitmap(faceImage);
        }
      } else {
        ((AtyViewHolder) holder).atysItem.ivFace.setImageBitmap(null);
      }
      WindowManager windowManager = activity.getWindowManager();
      Display display = windowManager.getDefaultDisplay();
      int width = display.getWidth() - 7;
      int height = display.getHeight();
      layoutParams = new LinearLayout.LayoutParams(width, height * 2 / 5);
      Bitmap pic1Image = AppCache.getImage(picture1);

      if (pic1Image != null) {
        ((AtyViewHolder) holder).atysItem.imageContains.removeAllViews();
        ImageView imageView = new ImageView(activity);
        imageView.setLayoutParams(layoutParams);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setImageBitmap(pic1Image);
        if (pic1Image != null) {
          ((AtyViewHolder) holder).atysItem.imageContains.addView(imageView);
        }
      }
      Bitmap pic2Image = AppCache.getImage(picture2);
      if (pic2Image != null) {
        ImageView imageView = new ImageView(activity);
        imageView.setLayoutParams(layoutParams);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setImageBitmap(pic2Image);
        if (pic1Image != null) {
          ((AtyViewHolder) holder).atysItem.imageContains.addView(imageView);
        }
      }

    } else if (holder instanceof CommentViewHolder) {

      Log.d("position", String.valueOf(position));
      Comment comment = comments.get(position - 1);
      ((CommentViewHolder) holder).tvName.setText(comment.getUsername());
      ((CommentViewHolder) holder).tvContent.setText(comment.getContent());
      ((CommentViewHolder) holder).tvPubtime.setText(comment.getPubtime());
      String faceUrl = comment.getUserface();
      if (faceUrl != null && faceUrl.length() > 0) {
        Bitmap faceImage = AppCache.getImage(faceUrl);
        if (faceImage != null) {
          ((CommentViewHolder) holder).ivFace.setImageBitmap(faceImage);
        }
      } else {
        ((CommentViewHolder) holder).ivFace.setImageBitmap(null);
      }
    }
  }
示例#8
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    HttpSession session = request.getSession();
    String username = (String) session.getAttribute("username");
    String curCategId = (String) session.getAttribute("curCategId");

    response.setContentType("text/html;charset=UTF-8");

    String action = request.getParameter("action");
    PrintWriter out = response.getWriter();

    System.out.println("Action = " + action);

    if (action.equalsIgnoreCase("showCategory")) {
      ArrayList<Category> categories = new ArrayList<Category>(joinOp.GetCategByUsername(username));

      out.println("<div class='kategori'>");
      out.println("<div id='categoryAll' onclick='showTaskList(0);'>All</div>");
      out.println("</div>");

      for (Category categ : categories) {
        out.println("<div class='kategori'>");
        out.println(
            "<div id='category"
                + categ.getId_category()
                + "'"
                + "onclick='showTaskList("
                + categ.getId_category()
                + ");'>"
                + categ.getName()
                + "</div>");
        if (username.equals(categ.getCateg_creator())) {
          out.println(
              "<div class='removeCategory' id='removeCateg"
                  + categ.getId_category()
                  + "' onclick='return removeCategory("
                  + categ.getId_category()
                  + ");'>x</div>");
        }
        out.println("</div>");
      }

    } else if (action.equalsIgnoreCase("addCategory")) {
      String categName = request.getParameter("name");
      String[] authUsers = request.getParameter("authUsers").split(",");

      categoryOp.InsertNewCategory(new Category("", categName, username));

      String newCategId = categoryOp.FetchIdByName(categName);
      caurelationOp.InsertCaurelation(new Caurelation("", newCategId, username));
      ucrelationOp.InsertUcrelation(new Ucrelation("", username, newCategId));

      if (authUsers.length != 0) {
        for (String authUser : authUsers) {
          if (userOp.ListAllUsernames().contains(authUser)) {
            ucrelationOp.InsertUcrelation(new Ucrelation("", authUser.trim(), newCategId));
            caurelationOp.InsertCaurelation(new Caurelation("", newCategId, authUser));
          }
        }
      }

    } else if (action.equalsIgnoreCase("removeCategory")) {
      String categId = request.getParameter("code");
      ArrayList<String> taskIds = new ArrayList<String>(taskOp.FetchIdsByCategId(categId));

      for (String taskId : taskIds) {
        ttrelationOp.DeleteByTaskId(taskId);
        utrelationOp.DeleteByTaskId(taskId);
        tarelationOp.DeleteTarelationByTaskId(taskId);
        commentOp.DeleteCommentByTaskId(taskId);
        taskOp.DeleteById(taskId);
      }

      ucrelationOp.DeleteByCategId(categId, username);
      caurelationOp.DeleteCaurelationByCategId(categId);
      categoryOp.DeleteCategoryById(categId);

    } else if (action.equalsIgnoreCase("showTaskList")) {
      String categId = request.getParameter("code");

      session.setAttribute("curCategId", categId);

      ArrayList<Task> tasks =
          new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(username, categId));
      ArrayList<String> tags;
      int i = 0;
      for (Task task : tasks) {
        i = 0;
        out.println("<div class='listTugas'>");
        out.println(
            "<a class='listname' id='task"
                + task.getId_task()
                + "'"
                + "onclick='showRinci("
                + task.getId_task()
                + ");'>"
                + task.getName()
                + "</a>");
        out.println("<div class='listdeadline'>Deadline: " + task.getDeadline() + "</div>");

        tags = new ArrayList<String>(joinOp.GetTagNamesByTaskId(task.getId_task()));
        out.println("<div class='listtag'>Tag: ");

        while (i < tags.size()) {
          out.print(tags.get(i));
          i++;
          if (i < tags.size()) {
            out.print(", ");
          }
        }
        out.println("</div>");

        out.println("<div class='liststatus' id='statusTask'>");
        if (task.getStatus().equals("T")) {
          out.println(
              "<input type='checkbox' id='checkboxTask"
                  + task.getId_task()
                  + "' onclick='changeTaskStatus("
                  + task.getId_task()
                  + ", this.checked);' checked>");
        } else if (task.getStatus().equals("F")) {
          out.println(
              "<input type='checkbox' id='checkboxTask"
                  + task.getId_task()
                  + "' onclick='changeTaskStatus("
                  + task.getId_task()
                  + ", this.checked);'>");
        }

        out.println("Done</div>");

        if (username.equals(taskOp.FetchCreatorById(task.getId_task()))) {
          out.println(
              "<div class='removeTask'><input type='submit' id='removeTaskBtn"
                  + task.getId_task()
                  + "' onclick='removeTask("
                  + curCategId
                  + ","
                  + task.getId_task()
                  + ");' value='Remove Task'/></div>");
        }
        out.println("</div>");
      }

      if (caurelationOp.FetchAuthUsersByCategId(categId).contains(username)) {
        out.println("<a onclick='showBuat();' class='addTask'>+task</a>");
      }
    } else if (action.equalsIgnoreCase("showTaskDetail")) {
      String taskId = request.getParameter("code");
      Task task = taskOp.SelectById(taskId);

      out.println("<div id='taskdetail'>");
      // NAME
      out.println("<div id='taskdetail_name'>" + task.getName() + "</div><br>");
      // STATUS
      out.println("<br><div>=======================================================</div>");
      if (task.getStatus().equalsIgnoreCase("T")) {
        out.println(
            "<div id='taskdetail_status'><em>Status : </em>Done "
                + "<input type='checkbox' onclick='changeTaskStatus("
                + task.getId_task()
                + ", this.checked);' checked/>"
                + "</div>");
      } else {
        out.println(
            "<div id='taskdetail_status'>Status : Done "
                + "<input type='checkbox' onclick='changeTaskStatus("
                + task.getId_task()
                + ", this.checked);'/>"
                + "</div>");
      }
      // ATTACHMENT
      ArrayList<Attachment> attachments = joinOp.GetAttachmentFromId_task(task.getId_task());
      int extensionIdx;
      String extension, filename;
      out.println("<br><div>=======================================================</div>");
      out.println("<div><em>Attachment: </em></div>");
      out.println("<div id='taskdetail_attachment'>");
      for (Attachment item : attachments) {
        extensionIdx = item.getPath().lastIndexOf('.');
        if (extensionIdx > 0) {
          filename = item.getPath().substring(item.getPath().lastIndexOf('/') + 1);
          extension = item.getPath().substring(extensionIdx + 1);
          System.out.println(item.getPath() + " has extension " + extension);
          // jika gambar
          if (extension.equalsIgnoreCase("jpg")
              || extension.equalsIgnoreCase("png")
              || extension.equalsIgnoreCase("gif")) {
            System.out.println(filename);
            out.println("<img src='" + item.getPath() + "' height=\"100\" width=\"100\"/><br>");
            out.println("<a href='" + item.getPath() + "'>" + filename + "</a><br>");
            // jika video
          } else if (extension.equalsIgnoreCase("mp4")
              || extension.equalsIgnoreCase("webm")
              || extension.equalsIgnoreCase("ogg")) {
            out.println("<video width=\"320\" height=\"240\" controls>");
            out.println("<source src='" + item.getPath() + "' type='video/" + extension + "'>");
            out.println("</video><br>");
            out.println("<a href='" + item.getPath() + "'>" + filename + "</a><br>");
          } else {
            out.println("<a href='" + item.getPath() + "'>" + filename + "</a><br>");
          }
        }
      }
      out.println("</div>");
      // DEADLINE
      out.println("<br><div>=======================================================</div>");
      out.println(
          "<div id='taskdetail_deadline'><em>Deadline: </em>" + task.getDeadline() + "</div>");
      // ASSIGNEE
      out.println("<br><div>=======================================================</div>");
      ArrayList<String> assignees = utrelationOp.FetchAssigneeByTaskId(task.getId_task());
      out.println("<div id='taskdetail_assignee'><em>Assignee: </em>");
      int i = 0;
      while (i < assignees.size()) {
        out.println(
            "<a href='profile.jsp?userprofile="
                + assignees.get(i)
                + "'>"
                + assignees.get(i)
                + "</a>");
        i++;
        if (i < assignees.size()) {
          out.print("; ");
        }
      }
      out.println("</div>");
      // KOMENTAR
      out.println("<br><div>=======================================================</div>");
      out.println("<div><em>Comment: </em></div>");
      User user;
      String[] timesplit;
      ArrayList<Comment> comments = commentOp.FetchCommentByTaskId(task.getId_task());
      out.println("<div id='ctotal'>" + comments.size() + " comment(s)</div>");
      out.println("<div id='taskdetail_comment'>");
      out.println("<div id='commentlist'>");
      for (Comment item : comments) {
        out.println("<div id='comment" + item.getId_comment() + "'>");
        user = userOp.SelectUserInfoByUsername(item.getUsername());
        timesplit = item.getTimestamp().split(":");
        System.out.println("LALALALALA" + timesplit.length);
        out.println(
            "<img class='cavatar' src='"
                + user.getAvatar()
                + "' style='width:30px; height:30px;'/>");
        out.println(
            "<div class='ctimestamp'>"
                + timesplit[3]
                + ":"
                + timesplit[4]
                + " - "
                + timesplit[2]
                + "/"
                + timesplit[1]
                + "</div>");
        out.println("<div class='ccontent'>" + item.getContent() + "</div>");
        if (username.equals(user.getUsername())) {
          out.println(
              "<input type='button' value='Delete' class='cdelete' onclick='delComment("
                  + item.getId_comment()
                  + ");'/>");
        }
        out.println("</div>");
      }
      out.println("</div>");
      out.println("<div id='commentbox'>");
      out.println("<textarea id='cbox'></textarea></br>");
      out.println("<input type='button' value='Submit' onclick='addComment(" + taskId + ");'/>");
      out.println("</div>");
      out.println("</div>");
      // TAG
      out.println("<br><div>=======================================================</div>");
      ArrayList<Tag> tags = joinOp.GetTagFromId_task(task.getId_task());
      out.println("<div id='taskdetail_tag'><em>Tag: </em>");
      i = 0;
      while (i < tags.size()) {
        out.println(tags.get(i).getName());
        i++;
        if (i < tags.size()) {
          out.print("; ");
        }
      }
      out.println("</div>");
      if (utrelationOp.IsTaskEditable(username, taskId)) {
        out.println(
            "<input type='button' value='Edit task' onclick='editTaskDetail("
                + task.getId_task()
                + ");'/>");
      }
      out.println("<input type='button' value='Back' onclick='restore2();'/>");
      out.println("</div>");
    } else if (action.equalsIgnoreCase("editTaskDetail")) {
      String taskId = request.getParameter("code");
      Task task = taskOp.SelectById(taskId);
      out.println("<div id='editdetail'>");
      out.println("<form>");
      out.println("<big style='font-size: 20pt;'>" + task.getName() + "</big><br/>");
      out.println(
          "<br/>Deadline: <input type='date' id='editDeadline' name='editDeadline' value='"
              + task.getDeadline()
              + "'><br/>");
      out.println(
          "<br/><div class='assignee'>Assignee: <input type='text' id='editAssignee'"
              + "name='editAssignee' value='");

      ArrayList<String> authUsers =
          new ArrayList<String>(utrelationOp.FetchAssigneeByTaskId(taskId));
      int i = 0;
      while (i < authUsers.size()) {
        out.print(authUsers.get(i));
        i++;
        if (i < authUsers.size()) {
          out.print(",");
        }
      }

      out.print(
          "' onkeyup=\"multiAutocomp(this, 'getAllUser.jsp');\" onfocusin='multiAutocompClearAll();'></div><br/>");

      out.println("<div class='tag'>Tag: <input type='text' id='editTag' name='editTag' value='");

      ArrayList<String> tags = new ArrayList<String>(joinOp.GetTagNamesByTaskId(task.getId_task()));
      i = 0;
      while (i < tags.size()) {
        out.print(tags.get(i));
        i++;
        if (i < tags.size()) {
          out.print(",");
        }
      }

      out.print(
          "' onkeyup=\"multiAutocomp(this, 'getAllTag.jsp');\" onfocusin='multiAutocompClearAll();'></div><br/>");

      out.println("</form><br/>");

      if (username.equals(taskOp.FetchCreatorById(task.getId_task()))) {
        out.println(
            "<input type='button' id='editremove' onclick='removeTask("
                + curCategId
                + ", "
                + task.getId_task()
                + ");' class='button' value='Remove Task'/><br>");
      } else if (utrelationOp.FetchAssigneeByTaskId(task.getId_task()).contains(username)) {
        out.println(
            "<input type='button' id='editremove' onclick='removeReference("
                + curCategId
                + ", "
                + task.getId_task()
                + ");' class='button' value='Remove me from this task'/><br>");
      }
      out.println(
          "<input type='button' id='editsave' onclick='saveTaskDetail("
              + task.getId_task()
              + ");' class='button' value='Save'/>");
      out.println(
          "<input type='button' id='editback' onclick='restore4();' class='button' value='Back'/>");
      out.println("</div>");
    } else if (action.equalsIgnoreCase("changeTaskStatus")) {
      String taskId = request.getParameter("code");
      String newStatus = request.getParameter("chkYesNo");

      if (newStatus.equals("0")) {
        taskOp.UpdateStatusWithId("F", taskId);
      } else if (newStatus.equals("1")) {
        taskOp.UpdateStatusWithId("T", taskId);
      }

      out.println("<div>");
      if (newStatus.equals("0")) {
        out.println(
            "<input type='checkbox' id='checkboxTask"
                + taskId
                + "' "
                + "onclick='changeTaskStatus("
                + taskId
                + ", this.checked);' checked>");
      } else if (newStatus.equals("1")) {
        out.println(
            "<input type='checkbox' id='checkboxTask"
                + taskId
                + "' "
                + "onclick='changeTaskStatus("
                + taskId
                + ", this.checked);'>");
      }
      out.println("Done</div>");

    } else if (action.equalsIgnoreCase("saveTaskDetail")) {
      String taskId = request.getParameter("code");
      String deadline = request.getParameter("newDeadline");
      String[] assignees = request.getParameter("newAssignees").split(",");
      String[] tags = request.getParameter("newTags").split(",");

      ArrayList<String> oldAssignees =
          new ArrayList<String>(utrelationOp.FetchAssigneeByTaskId(taskId));
      ArrayList<String> oldTagIds = new ArrayList<String>(joinOp.GetTagsIdByTaskId(taskId));

      taskOp.UpdateDeadlineById(deadline, taskId);
      for (String oldAssignee : oldAssignees) {
        utrelationOp.DeleteByTaskIdAndUsername(taskId, oldAssignee);
      }

      for (String oldTagId : oldTagIds) {
        ttrelationOp.DeleteByTagId(oldTagId);
      }

      for (String assignee : assignees) {
        if (userOp.ListAllUsernames().contains(assignee.trim())) {
          utrelationOp.InsertUtrelation(new Utrelation("", taskId, assignee.trim()));
          if (ucrelationOp.CheckIfUcrelationExists(assignee.trim(), curCategId) == 0) {
            ucrelationOp.InsertUcrelation(new Ucrelation("", assignee.trim(), curCategId));
          }
        }
      }

      for (String tag : tags) {
        if (tagOp.CheckIfTagExists(tag.trim()) == 0) {
          tagOp.InsertTag(tag.trim());
        }
        ttrelationOp.InsertTtrelation(new Ttrelation("", taskId, tagOp.SelectIdByName(tag.trim())));
      }

      ArrayList<Task> temp;
      for (String oldAssignee : oldAssignees) {
        temp = new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(oldAssignee, curCategId));
        if (temp.isEmpty()) {
          ucrelationOp.DeleteByCategId(curCategId, oldAssignee);
        }
      }

      for (String oldTagId : oldTagIds) {
        if (joinOp.CheckTtrelationByTagId(oldTagId) == 0) {
          tagOp.DeleteById(oldTagId);
        }
      }
    } else if (action.equalsIgnoreCase("addTask")) {
      String[] assignees = request.getParameter("newTaskAssignee").split(",");
      String[] tags = request.getParameter("newTaskTags").split(",");
      String name = request.getParameter("newTaskName");

    } else if (action.equalsIgnoreCase("removeTask")) {
      String taskId = request.getParameter("code");
      tarelationOp.DeleteTarelationByTaskId(taskId);
      ttrelationOp.DeleteByTaskId(taskId);
      commentOp.DeleteCommentByTaskId(taskId);
      utrelationOp.DeleteByTaskId(taskId);
      taskOp.DeleteById(taskId);

      ArrayList<String> allUsers = new ArrayList<String>(userOp.ListAllUsernames());
      ArrayList<Task> temp;
      for (String user : allUsers) {
        if (!user.equals(username)) {
          temp = new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(user, curCategId));
          if (temp.isEmpty()) {
            ucrelationOp.DeleteByCategId(curCategId, username);
          }
        }
      }
    } else if (action.equalsIgnoreCase("removeReference")) {
      String taskId = request.getParameter("code");

      utrelationOp.DeleteByTaskId(taskId);
      ArrayList<Task> temp =
          new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(username, curCategId));
      if (temp.isEmpty()) {
        ucrelationOp.DeleteByCategId(curCategId, username);
      }

    } else if (action.equalsIgnoreCase("addComment")) {
      String idtask = request.getParameter("it");
      String content = request.getParameter("c");

      DateFormat dateFormat = new SimpleDateFormat("yyyy:MM:dd:HH:mm");
      Date date = new Date();
      String timestamp = dateFormat.format(date).toString();

      String avatar = userOp.SelectUserInfoByUsername(username).getAvatar();

      commentOp.InsertComment(idtask, username, dateFormat.format(date).toString(), content);
      String idcomment = commentOp.GetIdByOtherAttributes(idtask, username, content);

      String message = avatar + ":" + timestamp + ":" + content + ":" + idcomment;
      out.println(message);
    } else if (action.equalsIgnoreCase("delComment")) {
      String idcomment = request.getParameter("ic");

      commentOp.DeleteCommentByCommentId(idcomment);
      out.println(idcomment);
    } else {
      System.out.println("No command existed");
    }

    out.close();
  }