Beispiel #1
0
  public HttpServletRequest addtagurl(HttpServletRequest req, HttpServletResponse response)
      throws SQLException {
    User user = User.getInstance();
    if (user == null) {
      this.parent.redirect("login", true);
      return req;
    } else {

      String uri = (String) req.getParameter("url");
      String listTag = (String) req.getParameter("list");
      Url url = user.getUrlById(Integer.valueOf(uri));
      String str[] = listTag.split("@");
      for (int i = 0; i < str.length; i++) {
        Tag tag = user.getTagByName(str[i]);
        if (tag == null) {
          // add tag
          tag = new Tag(str[i], user.getuId());
          tag.addTagtoBDD();
          tag.setTid(tag.getTagIdFromBDD());
          user.addOneTag(tag);
        }
        if (!url.hasTag(tag)) {
          TagMap tm = new TagMap(tag, url);
          tm.addTagMaptoBDD(user.getuId());
          tm.setTmId(tm.getIdFromBdd());
          user.addOneMap(tm);
        }
      }
      return req;
    }
  }
Beispiel #2
0
 public HttpServletRequest addvisit(HttpServletRequest req, HttpServletResponse response) {
   User u = User.getInstance();
   if (u == null) {
     this.parent.redirect("login", true);
     return req;
   } else {
     String id = req.getParameter("id");
     Url url = u.getUrlById(Integer.valueOf(id));
     url.addVisit();
     return req;
   }
 }
Beispiel #3
0
 public HttpServletRequest ajoutertagurl(HttpServletRequest req, HttpServletResponse response)
     throws SQLException {
   User user = User.getInstance();
   if (user == null) {
     this.parent.redirect("login", true);
     return req;
   } else {
     String id = req.getParameter("id");
     String tagId = req.getParameter("tagId");
     List<Tag> allTags = user.getAllTag();
     Url url = user.getUrlById(Integer.parseInt(id));
     List<Url> allUrls = new ArrayList<Url>();
     allUrls.add(url);
     req.setAttribute("tagid", tagId);
     req.setAttribute("user", user);
     req.setAttribute("tags", allTags);
     req.setAttribute("urls", allUrls);
     return req;
   }
 }