Esempio n. 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;
    }
  }