r58 - in trunk: . src/main/java/org/chorem/bow
Author: bbrossaud Date: 2010-06-02 16:14:19 +0200 (Wed, 02 Jun 2010) New Revision: 58 Url: http://chorem.org/repositories/revision/bow/58 Log: added new comments Modified: trunk/TODO.txt trunk/src/main/java/org/chorem/bow/BowProxy.java trunk/src/main/java/org/chorem/bow/ControllerServlet.java trunk/src/main/java/org/chorem/bow/Suggestion.java Modified: trunk/TODO.txt =================================================================== --- trunk/TODO.txt 2010-06-02 10:32:07 UTC (rev 57) +++ trunk/TODO.txt 2010-06-02 14:14:19 UTC (rev 58) @@ -20,7 +20,7 @@ ===> champ recherche fulltext -===> class bokkmarkFile = Id proprietaire, list<userID> writer, list<userId> reader; +===> class bookmarkFile = Id proprietaire, list<userID> writer, list<userId> reader; ===> class bookmark = idBookmarkFile a la place de UserID; Modified: trunk/src/main/java/org/chorem/bow/BowProxy.java =================================================================== --- trunk/src/main/java/org/chorem/bow/BowProxy.java 2010-06-02 10:32:07 UTC (rev 57) +++ trunk/src/main/java/org/chorem/bow/BowProxy.java 2010-06-02 14:14:19 UTC (rev 58) @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.WikittyService; -//import org.nuiton.wikitty.WikittyServiceCached; import org.nuiton.wikitty.WikittyServiceCached; import org.nuiton.wikitty.jdbc.WikittyServiceJDBC; @@ -52,10 +51,7 @@ protected BowProxy(BowConfig config) { WikittyService ws = new WikittyServiceJDBC(config.getFlatOptions()); - // FIXME activate next line, when new wikitty version released ans tested ws = new WikittyServiceCached(ws); setWikittyService(ws); } - - } Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-02 10:32:07 UTC (rev 57) +++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-02 14:14:19 UTC (rev 58) @@ -78,10 +78,12 @@ request.setAttribute("bowUrl", url); HttpSession session = request.getSession(true); User user = (User) session.getAttribute("user"); + String token = request.getParameter("token"); // token or not if (token != null && !token.isEmpty()) { - user = checkToken(token, session); + user = checkToken(token, session); // retrieve user by token } + String action = request.getParameter("action"); if (action != null) { if (action.equals("register")) { @@ -226,6 +228,14 @@ } } + + /* @param request servlet request + * @param response servlet response + * @param user the user + * @param token the permanent or temporary token + * @throws ServletException if a servlet error occurs + * @description set the openSearch result + */ protected void actionOpenSearchResult(HttpServletRequest request, HttpServletResponse response, User user, String token) throws IOException, ServletException { String searchLine = request.getParameter("searchLine"); @@ -235,7 +245,7 @@ WikittyProxy proxy = BowProxy.getInstance(); Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine); criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); - PagedResult result = proxy.findAllByCriteria(Bookmark.class, criteria); + PagedResult result = proxy.findAllByCriteria(Bookmark.class, criteria);// retrieve bookmarks by search BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine); request.setAttribute("bookmarkActions", bookmarkActions); request.setAttribute("token", token); @@ -243,6 +253,12 @@ } } + /* @param request servlet request + * @param response servlet response + * @param user the user + * @throws ServletException if a servlet error occurs + * @description set the openSearch suggestions + */ protected void actionOpenSearchSuggestion(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { if (user != null) { @@ -253,14 +269,14 @@ String[] words = search.split("\\s+"); List<String> searchLine = new ArrayList<String>(Arrays.asList(words)); if (search.charAt(search.length() - 1) == ' ') { - searchLine.add(""); + searchLine.add(""); // if the user types nothing we have to propose suggestions } Criteria criteria = null; if (searchLine.size() > 1) { List<String> cpy = new ArrayList<String>(searchLine); cpy.remove(cpy.size() - 1); criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). - contains(Bookmark.FQ_FIELD_TAGS, cpy).criteria(); + eq(Bookmark.FQ_FIELD_TAGS, cpy).criteria(); } else { criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); } @@ -272,12 +288,24 @@ } } + /* @param request servlet request + * @param response servlet response + * @param session current session + * @throws ServletException if a servlet error occurs + * @description delete the session + */ protected void actionLogout(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, ServletException { session.invalidate(); request.getRequestDispatcher("login.jsp").forward(request, response); } + /* @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet error occurs + * @description when the user click on the bookmark url, we + * increment the number of click + */ protected void actionAddClick(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String bookmarkId = request.getParameter("bookmarkId"); @@ -295,6 +323,12 @@ } } + /* @param request servlet request + * @param response servlet response + * @param user the user + * @throws ServletException if a servlet error occurs + * @description order the bookmarks by type + */ protected void actionOrderAsc(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { String type = request.getParameter("type"); @@ -318,6 +352,12 @@ } } + /* @param request servlet request + * @param response servlet response + * @param user the user + * @throws ServletException if a servlet error occurs + * @description order the bookmarks by type + */ protected void actionOrderDesc(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { String searchLine = request.getParameter("searchLine"); @@ -341,6 +381,12 @@ } } + /* @param request servlet request + * @param response servlet response + * @param user the user + * @throws ServletException if a servlet error occurs + * @description edit the bookmark + */ protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { String tags = request.getParameter("tags"); @@ -358,6 +404,12 @@ redirectToTheGoodPage(request, response); } + /* @param request servlet request + * @param response servlet response + * @param user the user + * @throws ServletException if a servlet error occurs + * @description remove the bookmark + */ protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { String bookmarkId = request.getParameter("bookmarkId"); @@ -371,6 +423,12 @@ redirectToTheGoodPage(request, response); } + /* @param request servlet request + * @param response servlet response + * @param user the user + * @throws ServletException if a servlet error occurs + * @description delete the bookmark tag + */ protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { String bookmarkId = request.getParameter("bookmarkId"); @@ -389,9 +447,12 @@ } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs + /* @param request servlet request + * @param response servlet response + * @param user User user + * @param session HttpSession session + * @throws ServletException if a servlet error occurs + * @description delete the current token and generate an another */ protected void actionGenerateToken(HttpServletRequest request, HttpServletResponse response, User user, HttpSession session) throws IOException, ServletException, NoSuchAlgorithmException { @@ -421,9 +482,11 @@ redirectToTheGoodPage(request, response); } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs + /* @param request servlet request + * @param response servlet response + * @param user User user + * @throws ServletException if a servlet error occurs + * @description add a new bookmark */ protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { @@ -433,12 +496,12 @@ protected void addUrl(HttpServletRequest request, User user) { String link = request.getParameter("url"); // url of the website - String name = request.getParameter("name"); + String name = request.getParameter("name"); // website name Bookmark bookmark = null; if (name != null) { String tags = request.getParameter("tags"); // tags bookmark = BookmarkActions.createBookmark(link, name, tags, user, null); - } else { + } else { // this part is for the bookmark addition by script String nameAndTags = request.getParameter("nameAndTags"); bookmark = BookmarkActions.createBookmark(link, nameAndTags, user); } @@ -450,6 +513,12 @@ } } } + /* @param token String token + * @param session HttpSession session + * @return User + * @description check if the token is valid and return the + * token owner + */ protected User checkToken(String token, HttpSession session) { if (checkTemporaryToken(token, session) == true) { @@ -478,6 +547,10 @@ return null; } + /* @param token String which contains the MD5 encoding token + * @return null the token doesn't exist + * @return User the token owner + */ protected boolean checkTemporaryToken(String token, HttpSession session) { TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); if (tokenActions != null) { @@ -491,9 +564,12 @@ return false; } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs + /* @param request servlet request + * @param response servlet response + * @param user User user + * @throws ServletException if a servlet error occurs + * @description set the bookmarks and the tagCloud by search + * or tag addition */ protected void actionSearch(HttpServletRequest request, User user) throws IOException, ServletException { @@ -514,6 +590,12 @@ request.setAttribute("bookmarkActions", bookmarkActions); } + /* @param request servlet request + * @param result PageResult result + * @param searchLine String searchLine + * @return bookmarkActions the bookmarkAction + * @description create the tagCLoud by research type + */ protected BookmarkActions createBookmarkActions(HttpServletRequest request, PagedResult result, String searchLine) { String fullText = request.getParameter("fullTextLine"); BookmarkActions bookmarkActions = new BookmarkActions(); @@ -535,9 +617,11 @@ return bookmarkActions; } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs + /* @param request servlet request + * @param response servlet response + * @param session HttpSession session + * @throws ServletException if a servlet error occurs + * @description check if the registration is correct or not */ protected void actionRegister(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, ServletException, NoSuchAlgorithmException { @@ -564,9 +648,11 @@ } } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs + /* @param request servlet request + * @param response servlet response + * @param session HttpSession session + * @throws ServletException if a servlet error occurs + * @description check if the authentication is correct or not */ protected void actionLogin(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, ServletException, NoSuchAlgorithmException { @@ -587,6 +673,11 @@ } } + /* @param session HttpSession session + * @throws ServletException if a servlet error occurs + * @description retrieve tokens or create there if the user are just + * registered + */ protected void initializeToken(HttpSession session, User login) throws NoSuchAlgorithmException { WikittyProxy proxy = BowProxy.getInstance(); @@ -607,10 +698,10 @@ } - /* @param email String which contains the user name (email) - * @param password String which contains the user password - * @return null the user doesn't exist - * @return User the user exists + /* @param email String which contains the user name (email) + * @param password String which contains the user password + * @return null the user doesn't exist + * @return User the user exists */ protected User checkLogin(String email, String password) { if (email != null && password != null) { @@ -626,9 +717,9 @@ } - /* @param email String which contains the user name (email) - * @param password String which contains the user password - * @return bool false if the user doesn't exists or true + /* @param email String which contains the user name (email) + * @param password String which contains the user password + * @return bool false if the user doesn't exists or true */ protected boolean checkRegister(String email, String password) { if (email != null && password != null) { @@ -644,6 +735,10 @@ return true; } + /* @param request servlet request + * @param user User user + * @description initialize all for the home page + */ protected void actionHome(HttpServletRequest request, User user) { WikittyProxy proxy = BowProxy.getInstance(); Criteria criteria = getBookmarkListCriteriaByUser(user, null); @@ -666,6 +761,12 @@ } } + /* @param request servlet request + * @param response servlet response + * @param user User user + * @throws ServletException if a servlet error occurs + * @description import bookmark for an user + */ protected void actionImportBookmarks(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, FileUploadException, ParserException { // Check that we have a file upload request @@ -695,6 +796,12 @@ redirectToTheGoodPage(request, response); } + /* @param list NodeList list + * @param bookmarks List<Bookmark> bookmarks + * @param tagList List<String> tagList + * @throws ParserException if a parser error occurs + * @description parse the html by recursion and retrieve bookmarks + */ protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList) throws ParserException { if (list != null) { @@ -702,14 +809,14 @@ SimpleNodeIterator it = list.elements(); while (it.hasMoreNodes()) { Node node = it.nextNode(); - String plainText = node.toPlainTextString(); - String text = node.getText(); - if (text != null && text.startsWith("H3")) { + String plainText = node.toPlainTextString(); // the text between two heads ==> <toto>plainText</toto> + String text = node.getText(); // the text in the head ==> <text></toto> + if (text != null && text.startsWith("H3")) { // H3 = folder if (plainText != null && !plainText.isEmpty()) { - tagList.add(plainText); + tagList.add(plainText); // add the folder name to the tagList isFolder = true; } - } else if (text != null && text.startsWith("A HREF")) { + } else if (text != null && text.startsWith("A HREF")) { // HREF = new bookmarks Bookmark bookmark = BookmarkActions.createBookmarkFromHtml(text, plainText, user); BookmarkActions.addTagsToBookmark(tagList, bookmark); if (bookmark != null) { @@ -718,10 +825,10 @@ } NodeList children = node.getChildren(); if (children != null) { - parseHtmlToBookmarks(children, user, bookmarks, tagList); + parseHtmlToBookmarks(children, user, bookmarks, tagList); // if there is an under node = recursion } } - if (isFolder == true) { + if (isFolder == true) { // if we find a folder, we have to remove it int index = tagList.size() - 1; if (index > -1) { tagList.remove(index); @@ -730,6 +837,10 @@ } } + /* @param response servlet response + * @param user User user + * @description export bookmarks + */ protected void actionExportBookmarks(HttpServletResponse response, User user) throws IOException { WikittyProxy proxy = BowProxy.getInstance(); @@ -746,6 +857,11 @@ op.close(); } + /* @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet error occurs + * @description add an alias for one bookmark + */ protected void actionAddAlias(HttpServletRequest request, HttpServletResponse response) throws IOException { String alias = request.getParameter("alias"); @@ -767,6 +883,11 @@ redirectToTheGoodPage(request, response); } + /* @param request servlet request + * @param user User user + * @throws ServletException if a servlet error occurs + * @description retrieve bookmark for the full text research + */ protected void actionFullText(HttpServletRequest request, User user) { WikittyProxy proxy = BowProxy.getInstance(); Criteria criteria = getBookmarkListCriteriaByUser(user, null); @@ -775,6 +896,11 @@ request.setAttribute("bookmarkActions", bookmarkActions); } + /* @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet error occurs + * @description choose the good page + */ protected void redirectToTheGoodPage(HttpServletRequest request, HttpServletResponse response) throws IOException { String searchLine = request.getParameter("searchLine"); @@ -789,6 +915,10 @@ } } + /* @param user User user + * @param searchLine String searchLine + * @description return the bookmark criteria by search + */ protected Criteria getBookmarkListCriteriaByUser(User user, String searchLine) { Criteria criteria = null; if (user != null) { Modified: trunk/src/main/java/org/chorem/bow/Suggestion.java =================================================================== --- trunk/src/main/java/org/chorem/bow/Suggestion.java 2010-06-02 10:32:07 UTC (rev 57) +++ trunk/src/main/java/org/chorem/bow/Suggestion.java 2010-06-02 14:14:19 UTC (rev 58) @@ -13,6 +13,10 @@ int nb = 0; String name = ""; + public void increment() { + nb++; + } + public void setNb(int value) { nb = value; }
participants (1)
-
bbrossaudï¼ users.chorem.org