Author: bbrossaud Date: 2010-06-01 09:59:09 +0200 (Tue, 01 Jun 2010) New Revision: 48 Url: http://chorem.org/repositories/revision/bow/48 Log: fullText works now Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java trunk/src/main/java/org/chorem/bow/ControllerServlet.java Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java =================================================================== --- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 16:04:07 UTC (rev 47) +++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 07:59:09 UTC (rev 48) @@ -238,8 +238,13 @@ Set<String> tags = bookmark.getTags(); String name = bookmark.getDescription(); for (String word : fullText) { - if (tags != null && tags.contains(word)) { - delete = false; + if (tags != null) { + for (String tag : tags) { + if (tag.contains(word)) { + delete = false; + break; + } + } } if (name.contains(word)) { delete = false; Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 16:04:07 UTC (rev 47) +++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 07:59:09 UTC (rev 48) @@ -366,16 +366,7 @@ proxy.store(bookmark); } } - String searchLine = request.getParameter("searchLine"); - String fullText = request.getParameter("fullTextLine"); - if (fullText == null) { - fullText = ""; - } - if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); - } else { - response.sendRedirect("bow?action=home"); - } + redirectToTheGoodPage(request, response); } protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response, User user) @@ -388,16 +379,7 @@ proxy.delete(bookmarkId); } } - String searchLine = request.getParameter("searchLine"); - String fullText = request.getParameter("fullTextLine"); - if (fullText == null) { - fullText = ""; - } - if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); - } else { - response.sendRedirect("bow?action=home"); - } + redirectToTheGoodPage(request, response); } protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response, User user) @@ -414,16 +396,7 @@ } } } - String searchLine = request.getParameter("searchLine"); - String fullText = request.getParameter("fullTextLine"); - if (fullText == null) { - fullText = ""; - } - if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); - } else { - response.sendRedirect("bow?action=home"); - } + redirectToTheGoodPage(request, response); } @@ -454,16 +427,7 @@ tokenActions.setPermanentToken(""); } } - String searchLine = request.getParameter("searchLine"); - String fullText = request.getParameter("fullTextLine"); - if (fullText == null) { - fullText = ""; - } - if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); - } else { - response.sendRedirect("bow?action=home"); - } + redirectToTheGoodPage(request, response); } /* @param request servlet request @@ -473,12 +437,7 @@ protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { addUrl(request, user); - String searchLine = request.getParameter("searchLine"); - if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine); - } else { - response.sendRedirect("bow?action=home"); - } + redirectToTheGoodPage(request, response); } protected void addUrl(HttpServletRequest request, User user) { @@ -552,10 +511,6 @@ addSortDescending(Bookmark.FQ_FIELD_CLICK); List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user BookmarkActions bookmarkActions = createBookmarkActions(request, bookList); - String searchLine = bookmarkActions.getSearchLine(); - if (searchLine.isEmpty()) { - bookmarkActions.emptySearchline(); - } request.setAttribute("bookmarkActions", bookmarkActions); } @@ -572,10 +527,14 @@ bookmarkActions.createTagClougByBookmarks(); bookmarkActions.defineTValues(); } else { - bookmarkActions.addTags(searchLine); // add the new tags - String tag = request.getParameter("addTag"); - if (tag != null && !tag.isEmpty()) { - bookmarkActions.addTag(tag); + if (searchLine != null && searchLine.isEmpty()) { + bookmarkActions.emptySearchline(); + } else { + bookmarkActions.addTags(searchLine); // add the new tags + String tag = request.getParameter("addTag"); + if (tag != null && !tag.isEmpty()) { + bookmarkActions.addTag(tag); + } } bookmarkActions.createTagCloud(); // create the tags cloud with the new informations } @@ -737,12 +696,7 @@ } } } - String searchLine = request.getParameter("searchLine"); - if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine); - } else { - response.sendRedirect("bow?action=home"); - } + redirectToTheGoodPage(request, response); } protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList) @@ -815,12 +769,7 @@ } } } - String searchLine = request.getParameter("searchLine"); - if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine); - } else { - response.sendRedirect("bow?action=home"); - } + redirectToTheGoodPage(request, response); } protected void actionFullText(HttpServletRequest request, User user) { @@ -828,7 +777,20 @@ Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); BookmarkActions bookmarkActions = createBookmarkActions(request, bookList); - log.debug(bookmarkActions.getBookmarks().size()); request.setAttribute("bookmarkActions", bookmarkActions); } + + protected void redirectToTheGoodPage(HttpServletRequest request, HttpServletResponse response) + throws IOException { + String searchLine = request.getParameter("searchLine"); + String fullText = request.getParameter("fullTextLine"); + if (fullText == null) { + fullText = ""; + } + if (searchLine != null) { + response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); + } else { + response.sendRedirect("bow?action=home"); + } + } }