r140 - in trunk/src/main: java/org/chorem/bow webapp webapp/css
Author: kmorin Date: 2010-12-20 23:31:55 +0100 (Mon, 20 Dec 2010) New Revision: 140 Url: http://chorem.org/repositories/revision/bow/140 Log: - add password confirmation during registration - remove question mark near logout Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java trunk/src/main/webapp/css/connexion.css trunk/src/main/webapp/login.jsp trunk/src/main/webapp/register.jsp trunk/src/main/webapp/rightMenu.jsp Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-12-20 13:38:14 UTC (rev 139) +++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-12-20 22:31:55 UTC (rev 140) @@ -72,1352 +72,1360 @@ * @author bbrossaud */ public class ControllerServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - private static final Log log = LogFactory.getLog(ControllerServlet.class); - protected String version = ""; - protected String bowServletUrl = ""; + private static final long serialVersionUID = 1L; + private static final Log log = LogFactory.getLog(ControllerServlet.class); + protected String version = ""; + protected String bowServletUrl = ""; - public ControllerServlet() throws Exception { - BowConfig config = BowConfig.getInstance(); - version = config.getVersion(); - bowServletUrl = config.getBowUrl(); - if (bowServletUrl == null) { - throw new Exception("No bow.url=\"SERVER URL\" in bow.properties"); - } - bowServletUrl += config.getServletBow(); - } + public ControllerServlet() throws Exception { + BowConfig config = BowConfig.getInstance(); + version = config.getVersion(); + bowServletUrl = config.getBowUrl(); + if (bowServletUrl == null) { + throw new Exception("No bow.url=\"SERVER URL\" in bow.properties"); + } + bowServletUrl += config.getServletBow(); + } - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - doPost(request, response); - } + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + doPost(request, response); + } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs - */ - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - try { - request.setCharacterEncoding("UTF8"); - request.setAttribute("version", version); - request.setAttribute("bowUrl", bowServletUrl); - HttpSession session = request.getSession(true); - User user = (User) session.getAttribute("user"); + /* @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet error occurs + */ + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + try { + request.setCharacterEncoding("UTF8"); + request.setAttribute("version", version); + request.setAttribute("bowUrl", bowServletUrl); + 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); // retrieve user by token - } + String token = request.getParameter("token"); // token or not + if (token != null && !token.isEmpty()) { + user = checkToken(token, session); // retrieve user by token + } - String action = request.getParameter("action"); - if (action != null) { - if (action.equals("register")) { - if (log.isDebugEnabled()) { - log.debug("Going to actionRegister"); - } - actionRegister(request, response, session); - } else if (action.equals("registration")) { - if (log.isDebugEnabled()) { - log.debug("Going to Register"); - } - request.getRequestDispatcher("register.jsp").forward(request, response); - } else if (action.equals("forgotPassword")) { - if (log.isDebugEnabled()) { - log.debug("Going to forgotPassword"); - } - request.getRequestDispatcher("forgotPassword.jsp").forward(request, response); - } else if (action.equals("login")) { - if (log.isDebugEnabled()) { - log.debug("Going to actionLogin"); - } - actionLogin(request, response, session); - } else if (action.equals("logout")) { - if (log.isDebugEnabled()) { - log.debug("Going to actionLogout"); - } - actionLogout(request, response, session); - } else if (action.equals("home")) { - if (log.isDebugEnabled()) { - log.debug("Going to actionHome.jsp"); - } - actionHome(request, response, session); - } else if (action.equals("addUrl") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionAddUrl"); - } - actionAddUrl(request, response, user); - } else if (action.equals("sendPassword")) { - if (log.isDebugEnabled()) { - log.debug("Going to actionSendPassword"); - } - actionSendPassword(request, response); - } else if (action.equals("modifyBookmark") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionModif"); - } - actionModifyBookmark(request, response, user); - } else if (action.equals("importBookmarks") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionImportBookmarks"); - } - actionImportBookmarks(request, response, user); - } else if (action.equals("exportBookmarks") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionExportBookmarks"); - } - actionExportBookmarks(response, user); - } else if (action.equals("search") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionSearch"); - } - actionSearch(request, user); - request.getRequestDispatcher("search.jsp").forward(request, response); - } else if (action.equals("generateToken") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionGenerateToken"); - } - actionGenerateToken(request, response, user, session); - request.getRequestDispatcher("preferences.jsp").forward(request, response); - } else if (action.equals("deleteTag") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionDeleteTag"); - } - actionDeleteTag(request, response, user); - } else if (action.equals("addAlias") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionAddAlias"); - } - actionAddAlias(request, response); - } else if (action.equals("removeBookmark") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionRemoveBookmark"); - } - actionRemoveBookmark(request, response, user); - } else if (action.equals("editBookmark") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionEditBookmark"); - } - actionEditBookmark(request, response, user); - } else if (action.equals("order") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionOrder"); - } - actionOrder(request, response, user); - request.getRequestDispatcher("search.jsp").forward(request, response); - } else if (action.equals("addClick") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionAddClic"); - } - actionAddClick(request, response); - } else if (action.equals("temporaryXml")) { - if (log.isDebugEnabled()) { - log.debug("Going to temporaryXml.jsp"); - } - request.getRequestDispatcher("temporaryXml.jsp").forward(request, response); - } else if (action.equals("permanentXml")) { - if (log.isDebugEnabled()) { - log.debug("Going to permanentXml.jsp"); - } - request.getRequestDispatcher("permanentXml.jsp").forward(request, response); - } else if (action.equals("openSearchSuggestion") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionOpenSearchSuggestion"); - } - actionOpenSearchSuggestion(request, response, user); - request.getRequestDispatcher("suggestions.jsp").forward(request, response); - } else if (action.equals("openSearchResult") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionOpenSearchResult"); - } - actionOpenSearchResult(request, response, session, user, token); - } else if (action.equals("fullText") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionFullText"); - } - actionFullText(request, user); - request.getRequestDispatcher("search.jsp").forward(request, response); - } else if (action.equals("preferences") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionPreferences"); - } - getBookmarksByImportDate(request, user); - request.getRequestDispatcher("preferences.jsp").forward(request, response); - } else if (action.equals("admin") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionAdmin"); - } - if ((Boolean) session.getAttribute("admin")) { - request.getRequestDispatcher("admin.jsp").forward(request, response); - } else { - request.getRequestDispatcher("login.jsp").forward(request, response); - } - } else if (action.equals("changePreferences") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionChangePreferences"); - } - actionChangePreferences(request, session, user); - request.getRequestDispatcher("preferences.jsp").forward(request, response); - } else if (action.equals("deleteImport") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionDeleteImport"); - } - actionDeleteImport(request, response, user); - //request.getRequestDispatcher("preferences.jsp").forward(request, response); - } else if (action.equals("reIndexation") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionReIndexation"); - } - actionReIndexation(request, session, user); - request.getRequestDispatcher("admin.jsp").forward(request, response); - } else if (action.equals("deleteSearchResults") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionDeleteSearchResults"); - } - actionDeleteSearchResults(request, response, user); - } - else { - if (user != null) { - request.getRequestDispatcher("error.jsp").forward(request, response); - } else { - request.getRequestDispatcher("login.jsp").forward(request, response); - } - } - } else { - request.getRequestDispatcher("login.jsp").forward(request, response); - } - } catch (Exception eee) { - log.error("Can't do action", eee); - request.setAttribute("errorMsgUser", eee.getMessage()); - request.setAttribute("errorMsgTech", eee.toString()); - request.getRequestDispatcher("error.jsp").forward(request, response); - } - } + String action = request.getParameter("action"); + if (action != null) { + if (action.equals("register")) { + if (log.isDebugEnabled()) { + log.debug("Going to actionRegister"); + } + actionRegister(request, response, session); + } else if (action.equals("registration")) { + if (log.isDebugEnabled()) { + log.debug("Going to Register"); + } + request.getRequestDispatcher("register.jsp").forward(request, response); + } else if (action.equals("forgotPassword")) { + if (log.isDebugEnabled()) { + log.debug("Going to forgotPassword"); + } + request.getRequestDispatcher("forgotPassword.jsp").forward(request, response); + } else if (action.equals("login")) { + if (log.isDebugEnabled()) { + log.debug("Going to actionLogin"); + } + actionLogin(request, response, session); + } else if (action.equals("logout")) { + if (log.isDebugEnabled()) { + log.debug("Going to actionLogout"); + } + actionLogout(request, response, session); + } else if (action.equals("home")) { + if (log.isDebugEnabled()) { + log.debug("Going to actionHome.jsp"); + } + actionHome(request, response, session); + } else if (action.equals("addUrl") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionAddUrl"); + } + actionAddUrl(request, response, user); + } else if (action.equals("sendPassword")) { + if (log.isDebugEnabled()) { + log.debug("Going to actionSendPassword"); + } + actionSendPassword(request, response); + } else if (action.equals("modifyBookmark") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionModif"); + } + actionModifyBookmark(request, response, user); + } else if (action.equals("importBookmarks") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionImportBookmarks"); + } + actionImportBookmarks(request, response, user); + } else if (action.equals("exportBookmarks") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionExportBookmarks"); + } + actionExportBookmarks(response, user); + } else if (action.equals("search") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionSearch"); + } + actionSearch(request, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (action.equals("generateToken") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionGenerateToken"); + } + actionGenerateToken(request, response, user, session); + request.getRequestDispatcher("preferences.jsp").forward(request, response); + } else if (action.equals("deleteTag") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionDeleteTag"); + } + actionDeleteTag(request, response, user); + } else if (action.equals("addAlias") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionAddAlias"); + } + actionAddAlias(request, response); + } else if (action.equals("removeBookmark") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionRemoveBookmark"); + } + actionRemoveBookmark(request, response, user); + } else if (action.equals("editBookmark") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionEditBookmark"); + } + actionEditBookmark(request, response, user); + } else if (action.equals("order") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionOrder"); + } + actionOrder(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (action.equals("addClick") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionAddClic"); + } + actionAddClick(request, response); + } else if (action.equals("temporaryXml")) { + if (log.isDebugEnabled()) { + log.debug("Going to temporaryXml.jsp"); + } + request.getRequestDispatcher("temporaryXml.jsp").forward(request, response); + } else if (action.equals("permanentXml")) { + if (log.isDebugEnabled()) { + log.debug("Going to permanentXml.jsp"); + } + request.getRequestDispatcher("permanentXml.jsp").forward(request, response); + } else if (action.equals("openSearchSuggestion") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionOpenSearchSuggestion"); + } + actionOpenSearchSuggestion(request, response, user); + request.getRequestDispatcher("suggestions.jsp").forward(request, response); + } else if (action.equals("openSearchResult") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionOpenSearchResult"); + } + actionOpenSearchResult(request, response, session, user, token); + } else if (action.equals("fullText") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionFullText"); + } + actionFullText(request, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (action.equals("preferences") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionPreferences"); + } + getBookmarksByImportDate(request, user); + request.getRequestDispatcher("preferences.jsp").forward(request, response); + } else if (action.equals("admin") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionAdmin"); + } + if ((Boolean) session.getAttribute("admin")) { + request.getRequestDispatcher("admin.jsp").forward(request, response); + } else { + request.getRequestDispatcher("login.jsp").forward(request, response); + } + } else if (action.equals("changePreferences") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionChangePreferences"); + } + actionChangePreferences(request, session, user); + request.getRequestDispatcher("preferences.jsp").forward(request, response); + } else if (action.equals("deleteImport") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionDeleteImport"); + } + actionDeleteImport(request, response, user); + //request.getRequestDispatcher("preferences.jsp").forward(request, response); + } else if (action.equals("reIndexation") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionReIndexation"); + } + actionReIndexation(request, session, user); + request.getRequestDispatcher("admin.jsp").forward(request, response); + } else if (action.equals("deleteSearchResults") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionDeleteSearchResults"); + } + actionDeleteSearchResults(request, response, user); + } + else { + if (user != null) { + request.getRequestDispatcher("error.jsp").forward(request, response); + } else { + request.getRequestDispatcher("login.jsp").forward(request, response); + } + } + } else { + request.getRequestDispatcher("login.jsp").forward(request, response); + } + } catch (Exception eee) { + log.error("Can't do action", eee); + request.setAttribute("errorMsgUser", eee.getMessage()); + request.setAttribute("errorMsgTech", eee.toString()); + request.getRequestDispatcher("error.jsp").forward(request, response); + } + } - /* @param request servlet request - * @param user user information - * @throws IOException If the redirection fails - * @description Deletes every bookmark imported at a given date - */ - protected void actionDeleteImport(HttpServletRequest request, - HttpServletResponse response, - User user) throws IOException { - String date = request.getParameter("date"); - - if (date != null) { - WikittyProxy proxy = BowProxy.getInstance(); - - if (date.matches("[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{1,3}Z")) { - Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Import.EXT_IMPORT).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). - eq(Import.FQ_FIELD_DATE, date).criteria(); - List<Import> bookmarks = proxy.findAllByCriteria(Import.class, criteria).getAll(); - List<String> ids = new ArrayList<String>(); + /* @param request servlet request + * @param user user information + * @throws IOException If the redirection fails + * @description Deletes every bookmark imported at a given date + */ + protected void actionDeleteImport(HttpServletRequest request, + HttpServletResponse response, + User user) throws IOException { + String date = request.getParameter("date"); - for (Import bookmark : bookmarks) { - ids.add(bookmark.getWikittyId()); - } - proxy.delete(ids); - } - response.sendRedirect("bow?action=preferences"); + if (date != null) { + WikittyProxy proxy = BowProxy.getInstance(); + + if (date.matches("[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{1,3}Z")) { + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Import.EXT_IMPORT).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). + eq(Import.FQ_FIELD_DATE, date).criteria(); + List<Import> bookmarks = proxy.findAllByCriteria(Import.class, criteria).getAll(); + List<String> ids = new ArrayList<String>(); + + for (Import bookmark : bookmarks) { + ids.add(bookmark.getWikittyId()); + } + proxy.delete(ids); + } + response.sendRedirect("bow?action=preferences"); + } } - } - /* @param request servlet request - * @param response servlet response - * @param user user information - * @throws IOException If the redirection fails - * @description Deletes the bookmarks returned after a research - */ - protected void actionDeleteSearchResults(HttpServletRequest request, HttpServletResponse response, User user) throws IOException { - String searchLine = request.getParameter("searchLine"); - String fullText = request.getParameter("fullTextLine"); - - if (searchLine != null && fullText != null) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria; - if (fullText.isEmpty()) { - criteria = getBookmarkListCriteriaByUser(user, searchLine); - } else { - criteria = Search.query().keyword(fullText).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); - } - List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); - List<String> ids = new ArrayList<String>(); - - for (Bookmark bookmark : bookmarks) { - if (searchLine.isEmpty() && bookmark.getTags() == null || !searchLine.isEmpty() || - fullText.isEmpty() && bookmark.getTags() == null || !fullText.isEmpty()) { - ids.add(bookmark.getWikittyId()); - } - } - proxy.delete(ids); + /* @param request servlet request + * @param response servlet response + * @param user user information + * @throws IOException If the redirection fails + * @description Deletes the bookmarks returned after a research + */ + protected void actionDeleteSearchResults(HttpServletRequest request, HttpServletResponse response, User user) throws IOException { + String searchLine = request.getParameter("searchLine"); + String fullText = request.getParameter("fullTextLine"); + + if (searchLine != null && fullText != null) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria; + if (fullText.isEmpty()) { + criteria = getBookmarkListCriteriaByUser(user, searchLine); + } else { + criteria = Search.query().keyword(fullText).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); + } + List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); + List<String> ids = new ArrayList<String>(); + + for (Bookmark bookmark : bookmarks) { + if (searchLine.isEmpty() && bookmark.getTags() == null || !searchLine.isEmpty() || + fullText.isEmpty() && bookmark.getTags() == null || !fullText.isEmpty()) { + ids.add(bookmark.getWikittyId()); + } + } + proxy.delete(ids); + } + response.sendRedirect("bow?action=home"); } - response.sendRedirect("bow?action=home"); - } - - /* @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, HttpSession session, User user, String token) - throws IOException, ServletException, NoSuchAlgorithmException { - String searchLine = request.getParameter("searchLine"); - if (searchLine != null && searchLine.matches("^http://[^ ]*")) { - response.sendRedirect(searchLine); - } else if (searchLine != null - && (searchLine.startsWith(":") || searchLine.startsWith("t:")) ) { - // on fait une recherche sur les tags - int index = searchLine.indexOf(":"); - searchLine = searchLine.substring(index+1); // suppress first ":" + /* @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, HttpSession session, User user, String token) + throws IOException, ServletException, NoSuchAlgorithmException { + String searchLine = request.getParameter("searchLine"); + if (searchLine != null && searchLine.matches("^http://[^ ]*")) { + response.sendRedirect(searchLine); + } else if (searchLine != null + && (searchLine.startsWith(":") || searchLine.startsWith("t:")) ) { + // on fait une recherche sur les tags - session.setAttribute("user", user); - initializeToken(session, user); - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine); - criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); - PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria);// retrieve bookmarks by search - BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine); - request.setAttribute("bookmarkActions", bookmarkActions); - request.setAttribute("token", token); - request.getRequestDispatcher("search.jsp").forward(request, response); - } else if (searchLine != null && searchLine.startsWith("f:")) { - // recherche fulltext dans bow - String fullText = searchLine.substring(2); + int index = searchLine.indexOf(":"); + searchLine = searchLine.substring(index+1); // suppress first ":" - session.setAttribute("user", user); - initializeToken(session, user); - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria; - if (!fullText.isEmpty()) { - criteria = Search.query().keyword(fullText). - eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). - addFacetField(Bookmark.FQ_FIELD_TAGS); + session.setAttribute("user", user); + initializeToken(session, user); + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine); + criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); + PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria);// retrieve bookmarks by search + BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine); + request.setAttribute("bookmarkActions", bookmarkActions); + request.setAttribute("token", token); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (searchLine != null && searchLine.startsWith("f:")) { + // recherche fulltext dans bow + String fullText = searchLine.substring(2); - } else { - criteria = getBookmarkListCriteriaByUser(user, null); - } - PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); - BookmarkActions bookmarkActions = createBookmarkActions(request, result, null); - request.setAttribute("bookmarkActions", bookmarkActions); - request.setAttribute("token", token); - request.getRequestDispatcher("search.jsp").forward(request, response); - } else if (searchLine != null && searchLine.startsWith("a:")) { - // on redirige vers l'alias demande - searchLine = searchLine.substring(2); - response.sendRedirect(BowConfig.getInstance().getAliasUrl() + searchLine); - } else { - // on fait une recherche sur le moteur de recherche configurer - WikittyProxy proxy = BowProxy.getInstance(); - Preference pref = proxy.restore(Preference.class, user.getWikittyId()); + session.setAttribute("user", user); + initializeToken(session, user); + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria; + if (!fullText.isEmpty()) { + criteria = Search.query().keyword(fullText). + eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). + addFacetField(Bookmark.FQ_FIELD_TAGS); - String searchEngineURL = pref.getSearchEngineUrlResults(); - if (searchEngineURL == null || "".equals(searchEngineURL)) { - BowConfig config = BowConfig.getInstance(); - searchEngineURL = config.getSearchEngine(); - } - searchEngineURL = searchEngineURL.replace("{searchTerms}", searchLine); - searchEngineURL = response.encodeRedirectURL(searchEngineURL); + } else { + criteria = getBookmarkListCriteriaByUser(user, null); + } + PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); + BookmarkActions bookmarkActions = createBookmarkActions(request, result, null); + request.setAttribute("bookmarkActions", bookmarkActions); + request.setAttribute("token", token); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (searchLine != null && searchLine.startsWith("a:")) { + // on redirige vers l'alias demande + searchLine = searchLine.substring(2); + response.sendRedirect(BowConfig.getInstance().getAliasUrl() + searchLine); + } else { + // on fait une recherche sur le moteur de recherche configurer + WikittyProxy proxy = BowProxy.getInstance(); + Preference pref = proxy.restore(Preference.class, user.getWikittyId()); - response.sendRedirect(searchEngineURL); - } - } + String searchEngineURL = pref.getSearchEngineUrlResults(); + if (searchEngineURL == null || "".equals(searchEngineURL)) { + BowConfig config = BowConfig.getInstance(); + searchEngineURL = config.getSearchEngine(); + } + searchEngineURL = searchEngineURL.replace("{searchTerms}", searchLine); + searchEngineURL = response.encodeRedirectURL(searchEngineURL); - /* @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) { - String search = request.getParameter("searchLine"); - if (search != null) { - OpenSearchActions openSearchActions = new OpenSearchActions(); - WikittyProxy proxy = BowProxy.getInstance(); - String[] words = search.split("\\s+"); - List<String> searchLine = new ArrayList<String>(Arrays.asList(words)); - if (search.charAt(search.length() - 1) == ' ') { - searchLine.add(""); // if the user types nothing we have to propose suggestions - } - Criteria criteria; - 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()). - eq(Bookmark.FQ_FIELD_TAGS, cpy).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); - } else { - criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). - criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); - } - PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); - List<Bookmark> bookList = result.getAll(); - List<FacetTopic> topics = result.getTopic(Bookmark.FQ_FIELD_TAGS); - openSearchActions.setBookmarkList(bookList); - openSearchActions.setSuggestionList(topics); - openSearchActions.findSuggestions(searchLine); - request.setAttribute("openSearchAction", openSearchActions); - } - } - } + response.sendRedirect(searchEngineURL); + } + } - /* @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 + * @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) { + String search = request.getParameter("searchLine"); + if (search != null) { + OpenSearchActions openSearchActions = new OpenSearchActions(); + WikittyProxy proxy = BowProxy.getInstance(); + String[] words = search.split("\\s+"); + List<String> searchLine = new ArrayList<String>(Arrays.asList(words)); + if (search.charAt(search.length() - 1) == ' ') { + searchLine.add(""); // if the user types nothing we have to propose suggestions + } + Criteria criteria; + 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()). + eq(Bookmark.FQ_FIELD_TAGS, cpy).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); + } else { + criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). + criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); + } + PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); + List<Bookmark> bookList = result.getAll(); + List<FacetTopic> topics = result.getTopic(Bookmark.FQ_FIELD_TAGS); + openSearchActions.setBookmarkList(bookList); + openSearchActions.setSuggestionList(topics); + openSearchActions.findSuggestions(searchLine); + request.setAttribute("openSearchAction", openSearchActions); + } + } + } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs - * @description when the user click on the bookmark bowServletUrl, we - * increment the number of click - */ - protected void actionAddClick(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - String bookmarkId = request.getParameter("bookmarkId"); - if (bookmarkId != null && !bookmarkId.isEmpty()) { - WikittyProxy proxy = BowProxy.getInstance(); - Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); - if (bookmark != null) { - int click = bookmark.getClick(); - ++click; - bookmark.setClick(click); - proxy.store(bookmark); - String link = bookmark.getLink(); - response.sendRedirect(link); - } - } - } + /* @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 - * @param user the user - * @throws ServletException if a servlet error occurs - * @description order the bookmarks by type - */ - protected void actionOrder(HttpServletRequest request, - HttpServletResponse response, - User user) - throws IOException, ServletException { - String type = request.getParameter("type"); - String searchLine = request.getParameter("searchLine"); - Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine); - if (type != null && baseCriteria != null && !type.isEmpty()) { - WikittyProxy proxy = BowProxy.getInstance(); - PagedResult<Bookmark> result = null; - if (type.equals("ascName")) { - Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DESCRIPTION); - result = proxy.findAllByCriteria(Bookmark.class, criteria); - } else if (type.equals("ascDate")) { - Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DATE); - result = proxy.findAllByCriteria(Bookmark.class, criteria); - } else if (type.equals("ascClick")) { - Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_CLICK); - result = proxy.findAllByCriteria(Bookmark.class, criteria); - } else if (type.equals("descName")) { - Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DESCRIPTION); - result = proxy.findAllByCriteria(Bookmark.class, criteria); - } else if (type.equals("descDate")) { - Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DATE); - result = proxy.findAllByCriteria(Bookmark.class, criteria); - } else if (type.equals("descClick")) { - Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); - result = proxy.findAllByCriteria(Bookmark.class, criteria); - } - BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine); - request.setAttribute("bookmarkActions", bookmarkActions); - } - } + /* @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet error occurs + * @description when the user click on the bookmark bowServletUrl, we + * increment the number of click + */ + protected void actionAddClick(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + String bookmarkId = request.getParameter("bookmarkId"); + if (bookmarkId != null && !bookmarkId.isEmpty()) { + WikittyProxy proxy = BowProxy.getInstance(); + Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); + if (bookmark != null) { + int click = bookmark.getClick(); + ++click; + bookmark.setClick(click); + proxy.store(bookmark); + String link = bookmark.getLink(); + response.sendRedirect(link); + } + } + } - /* @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 bookmarkId = request.getParameter("bookmarkId"); - if (bookmarkId != null && !bookmarkId.isEmpty()) { - WikittyProxy proxy = BowProxy.getInstance(); - Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); - if (bookmark != null) { - request.setAttribute("link", bookmark.getLink()); - request.setAttribute("name", bookmark.getDescription()); - request.setAttribute("alias", bookmark.getAlias()); - request.setAttribute("tags", BookmarkActions.getBookmarkTagsString(bookmark)); - request.setAttribute("action", "bow?action=modifyBookmark"); - request.setAttribute("bookmarkId", bookmarkId); - } - } - String searchLine = request.getParameter("searchLine"); - if (searchLine == null) { - initHomePage(request, user); - request.getRequestDispatcher("home.jsp").forward(request, response); - } else { - actionSearch(request, user); - request.getRequestDispatcher("search.jsp").forward(request, response); - } - } + /* @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 actionOrder(HttpServletRequest request, + HttpServletResponse response, + User user) + throws IOException, ServletException { + String type = request.getParameter("type"); + String searchLine = request.getParameter("searchLine"); + Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine); + if (type != null && baseCriteria != null && !type.isEmpty()) { + WikittyProxy proxy = BowProxy.getInstance(); + PagedResult<Bookmark> result = null; + if (type.equals("ascName")) { + Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DESCRIPTION); + result = proxy.findAllByCriteria(Bookmark.class, criteria); + } else if (type.equals("ascDate")) { + Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DATE); + result = proxy.findAllByCriteria(Bookmark.class, criteria); + } else if (type.equals("ascClick")) { + Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_CLICK); + result = proxy.findAllByCriteria(Bookmark.class, criteria); + } else if (type.equals("descName")) { + Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DESCRIPTION); + result = proxy.findAllByCriteria(Bookmark.class, criteria); + } else if (type.equals("descDate")) { + Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DATE); + result = proxy.findAllByCriteria(Bookmark.class, criteria); + } else if (type.equals("descClick")) { + Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); + result = proxy.findAllByCriteria(Bookmark.class, criteria); + } + BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine); + request.setAttribute("bookmarkActions", bookmarkActions); + } + } - /* @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"); - if (bookmarkId != null && !bookmarkId.isEmpty()) { - try { - WikittyProxy proxy = BowProxy.getInstance(); - Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); - if (bookmark != null) { - proxy.delete(bookmarkId); - } - } catch (Exception eee) { - log.error("Can't do action", eee); - } - } - redirectToTheGoodPage(request, response); - } + /* @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 bookmarkId = request.getParameter("bookmarkId"); + if (bookmarkId != null && !bookmarkId.isEmpty()) { + WikittyProxy proxy = BowProxy.getInstance(); + Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); + if (bookmark != null) { + request.setAttribute("link", bookmark.getLink()); + request.setAttribute("name", bookmark.getDescription()); + request.setAttribute("alias", bookmark.getAlias()); + request.setAttribute("tags", BookmarkActions.getBookmarkTagsString(bookmark)); + request.setAttribute("action", "bow?action=modifyBookmark"); + request.setAttribute("bookmarkId", bookmarkId); + } + } + String searchLine = request.getParameter("searchLine"); + if (searchLine == null) { + initHomePage(request, user); + request.getRequestDispatcher("home.jsp").forward(request, response); + } else { + actionSearch(request, user); + request.getRequestDispatcher("search.jsp").forward(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"); - String tag = request.getParameter("deleteTag"); - if (tag != null && bookmarkId != null) { - if (!bookmarkId.isEmpty()) { - WikittyProxy proxy = BowProxy.getInstance(); - Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); - if (bookmark != null) { - bookmark.removeTags(tag); - proxy.store(bookmark); - } - } - } - 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"); + if (bookmarkId != null && !bookmarkId.isEmpty()) { + try { + WikittyProxy proxy = BowProxy.getInstance(); + Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); + if (bookmark != null) { + proxy.delete(bookmarkId); + } + } catch (Exception eee) { + log.error("Can't do action", eee); + } + } + 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"); + String tag = request.getParameter("deleteTag"); + if (tag != null && bookmarkId != null) { + if (!bookmarkId.isEmpty()) { + WikittyProxy proxy = BowProxy.getInstance(); + Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); + if (bookmark != null) { + bookmark.removeTags(tag); + proxy.store(bookmark); + } + } + } + redirectToTheGoodPage(request, response); + } - /* @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 { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, user.getEmail()).criteria(); - Token currentToken = proxy.findByCriteria(Token.class, criteria); - if (currentToken != null) { - String id = currentToken.getWikittyId(); - proxy.delete(id); - } - TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); - if (tokenActions != null) { - String token = tokenActions.generateToken(); // Generate an encoding MD5 token - criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria(); - Token oldToken = proxy.findByCriteria(Token.class, criteria); - if (oldToken == null) { // Check if the token already exists - TokenImpl newToken = new TokenImpl(); - newToken.setToken(token); - newToken.setEmail(user.getEmail()); - proxy.store((Token) newToken); // If the token doesn't exist, it is stored - tokenActions.setPermanentToken(token); - } else { - tokenActions.setPermanentToken(""); - } - } - } + /* @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 { - protected void actionModifyBookmark(HttpServletRequest request, - HttpServletResponse response, - User user) - throws IOException { - String link = request.getParameter("url"); // bowServletUrl of the website - String name = request.getParameter("name"); // website name - String alias = request.getParameter("alias"); - String tags = request.getParameter("tags"); - String id = request.getParameter("bookmarkId"); - WikittyProxy proxy = BowProxy.getInstance(); - Bookmark bookmark = proxy.restore(Bookmark.class, id); - if (bookmark != null) { - if (alias != null && !alias.isEmpty()) { - Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria(); - if (proxy.findByCriteria(Bookmark.class, criteria) != null) { - alias = bookmark.getAlias(); - } - } - BookmarkActions.updateBookmark(bookmark, name, link, tags, alias); - proxy.store(bookmark); - } - redirectToTheGoodPage(request, response); - } + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, user.getEmail()).criteria(); + Token currentToken = proxy.findByCriteria(Token.class, criteria); + if (currentToken != null) { + String id = currentToken.getWikittyId(); + proxy.delete(id); + } + TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); + if (tokenActions != null) { + String token = tokenActions.generateToken(); // Generate an encoding MD5 token + criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria(); + Token oldToken = proxy.findByCriteria(Token.class, criteria); + if (oldToken == null) { // Check if the token already exists + TokenImpl newToken = new TokenImpl(); + newToken.setToken(token); + newToken.setEmail(user.getEmail()); + proxy.store((Token) newToken); // If the token doesn't exist, it is stored + tokenActions.setPermanentToken(token); + } else { + tokenActions.setPermanentToken(""); + } + } + } - /* @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 { - addUrl(request, user); - redirectToTheGoodPage(request, response); - } + protected void actionModifyBookmark(HttpServletRequest request, + HttpServletResponse response, + User user) + throws IOException { + String link = request.getParameter("url"); // bowServletUrl of the website + String name = request.getParameter("name"); // website name + String alias = request.getParameter("alias"); + String tags = request.getParameter("tags"); + String id = request.getParameter("bookmarkId"); + WikittyProxy proxy = BowProxy.getInstance(); + Bookmark bookmark = proxy.restore(Bookmark.class, id); + if (bookmark != null) { + if (alias != null && !alias.isEmpty()) { + Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria(); + if (proxy.findByCriteria(Bookmark.class, criteria) != null) { + alias = bookmark.getAlias(); + } + } + BookmarkActions.updateBookmark(bookmark, name, link, tags, alias); + proxy.store(bookmark); + } + redirectToTheGoodPage(request, response); + } - protected void addUrl(HttpServletRequest request, User user) { - String link = request.getParameter("url"); // bowServletUrl of the website - String name = request.getParameter("name"); // website name - String alias = request.getParameter("alias"); - WikittyProxy proxy = BowProxy.getInstance(); - Bookmark bookmark = null; - if (name != null) { - String tags = request.getParameter("tags"); // tags - if (alias != null && !alias.isEmpty()) { - Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria(); - if (proxy.findByCriteria(Bookmark.class, criteria) != null) { - alias = ""; - } - } - bookmark = BookmarkActions.createBookmark(link, name, tags, user, alias, null); - } else { // this part is for the bookmark addition by script - String nameAndTags = request.getParameter("nameAndTags"); - if (nameAndTags != null) { - bookmark = BookmarkActions.createBookmark(link, nameAndTags, user); - } - } - if (bookmark != null && !bookmark.getDescription().isEmpty() && !bookmark.getEmail().isEmpty()) { - proxy.store(bookmark); // store the bookmark if everything is ok - if (log.isDebugEnabled()) { - log.debug("Adding URL"); - } - } - } - /* @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)) { - User user = (User) session.getAttribute("user"); - return user; - } - User user = checkPermanentToken(token); - return user; - } + /* @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 { + addUrl(request, user); + redirectToTheGoodPage(request, response); + } - /* @param token String which contains the MD5 encoding token - * @return null the token doesn't exist - * @return User the token owner - */ - protected User checkPermanentToken(String token) { - if (token != null) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria(); - Token DbToken = proxy.findByCriteria(Token.class, criteria); - if (DbToken != null) { // check if the token exists - String userEmail = DbToken.getEmail(); // the token owner user name (email) - criteria = Search.query().eq(User.FQ_FIELD_EMAIL, userEmail).criteria(); // retrieve user by token - return proxy.findByCriteria(User.class, criteria); - } - } - return null; - } + protected void addUrl(HttpServletRequest request, User user) { + String link = request.getParameter("url"); // bowServletUrl of the website + String name = request.getParameter("name"); // website name + String alias = request.getParameter("alias"); + WikittyProxy proxy = BowProxy.getInstance(); + Bookmark bookmark = null; + if (name != null) { + String tags = request.getParameter("tags"); // tags + if (alias != null && !alias.isEmpty()) { + Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria(); + if (proxy.findByCriteria(Bookmark.class, criteria) != null) { + alias = ""; + } + } + bookmark = BookmarkActions.createBookmark(link, name, tags, user, alias, null); + } else { // this part is for the bookmark addition by script + String nameAndTags = request.getParameter("nameAndTags"); + if (nameAndTags != null) { + bookmark = BookmarkActions.createBookmark(link, nameAndTags, user); + } + } + if (bookmark != null && !bookmark.getDescription().isEmpty() && !bookmark.getEmail().isEmpty()) { + proxy.store(bookmark); // store the bookmark if everything is ok + if (log.isDebugEnabled()) { + log.debug("Adding URL"); + } + } + } + /* @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)) { + User user = (User) session.getAttribute("user"); + return user; + } + User user = checkPermanentToken(token); + return user; + } - /* @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) { - String temporaryToken = tokenActions.getTemporaryToken(); - if (temporaryToken != null) { - if (temporaryToken.equals(token)) { - return true; - } - } - } - return false; - } + /* @param token String which contains the MD5 encoding token + * @return null the token doesn't exist + * @return User the token owner + */ + protected User checkPermanentToken(String token) { + if (token != null) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria(); + Token DbToken = proxy.findByCriteria(Token.class, criteria); + if (DbToken != null) { // check if the token exists + String userEmail = DbToken.getEmail(); // the token owner user name (email) + criteria = Search.query().eq(User.FQ_FIELD_EMAIL, userEmail).criteria(); // retrieve user by token + return proxy.findByCriteria(User.class, criteria); + } + } + return null; + } - /* @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 { - String searchLine = request.getParameter("searchLine"); - if (searchLine == null) { - searchLine = ""; - } - String fulltext = request.getParameter("fullTextLine"); - if (fulltext != null && !fulltext.isEmpty() && searchLine.isEmpty()) { - actionFullText(request, user); - } else { - String tag = request.getParameter("addTag"); - if (tag != null && !tag.isEmpty()) { - if (searchLine.isEmpty()) { - searchLine = tag; - } else { - searchLine += " " + tag; - } - } - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine); - criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); - PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); // select all bookmarks by user - BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine); - request.setAttribute("bookmarkActions", bookmarkActions); - } - } + /* @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) { + String temporaryToken = tokenActions.getTemporaryToken(); + if (temporaryToken != null) { + if (temporaryToken.equals(token)) { + return true; + } + } + } + return false; + } - /* @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<Bookmark> result, - String searchLine) { - String fullText = request.getParameter("fullTextLine"); - BookmarkActions bookmarkActions = new BookmarkActions(); - bookmarkActions.setFullTextLine(fullText); - List<Bookmark> bookList = result.getAll(); - if (bookList != null) { - bookmarkActions.setBookmarks(bookList); - } - if (fullText == null || fullText.isEmpty()) { - if (searchLine != null && searchLine.isEmpty()) { - bookmarkActions.emptySearchline(); - } else { - bookmarkActions.addTags(searchLine); // add the new tags - } - } - List<FacetTopic> topics = result.getTopic(Bookmark.FQ_FIELD_TAGS); - bookmarkActions.createTagCloud(topics); - return bookmarkActions; - } + /* @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 { + String searchLine = request.getParameter("searchLine"); + if (searchLine == null) { + searchLine = ""; + } + String fulltext = request.getParameter("fullTextLine"); + if (fulltext != null && !fulltext.isEmpty() && searchLine.isEmpty()) { + actionFullText(request, user); + } else { + String tag = request.getParameter("addTag"); + if (tag != null && !tag.isEmpty()) { + if (searchLine.isEmpty()) { + searchLine = tag; + } else { + searchLine += " " + tag; + } + } + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine); + criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); + PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); // select all bookmarks by user + BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine); + request.setAttribute("bookmarkActions", bookmarkActions); + } + } - /* @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, MessagingException { - String email = request.getParameter("email"); - if (email != null) { - email = email.trim(); - String password = request.getParameter("password"); - String md5; - if (password != null) { - md5 = StringUtil.encodeMD5(password); - if (!checkRegister(email, md5, request)) { // check if all is well - WikittyProxy proxy = BowProxy.getInstance(); - UserImpl newUser = new UserImpl(); - newUser.setPassword(md5); - newUser.setEmail(email); - User login = proxy.store((User) newUser); // store the new user - if (login != null) { - initSession(session, login); - initHomePage(request, login); - sendMail(email, password); - request.getRequestDispatcher("home.jsp").forward(request, response); - return ; - } - request.setAttribute("errorMsgUser", "Invalid login, please choose another one"); + /* @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<Bookmark> result, + String searchLine) { + String fullText = request.getParameter("fullTextLine"); + BookmarkActions bookmarkActions = new BookmarkActions(); + bookmarkActions.setFullTextLine(fullText); + List<Bookmark> bookList = result.getAll(); + if (bookList != null) { + bookmarkActions.setBookmarks(bookList); } - } + if (fullText == null || fullText.isEmpty()) { + if (searchLine != null && searchLine.isEmpty()) { + bookmarkActions.emptySearchline(); + } else { + bookmarkActions.addTags(searchLine); // add the new tags + } + } + List<FacetTopic> topics = result.getTopic(Bookmark.FQ_FIELD_TAGS); + bookmarkActions.createTagCloud(topics); + return bookmarkActions; } - request.getRequestDispatcher("register.jsp").forward(request, response); - } - /* @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 { - String email = request.getParameter("email"); - if (email != null) { - email = email.trim(); - String password = request.getParameter("password"); - String md5; - if (password != null) { - md5 = StringUtil.encodeMD5(password); - User login = checkLogin(email, md5, request); // check if the user exists - if (login != null) { - initSession(session, login); - initHomePage(request, login); - request.getRequestDispatcher("home.jsp").forward(request, response); - return; - } - } - } - request.getRequestDispatcher("login.jsp").forward(request, response); - } + /* @param request servlet request + * @param response servlet response + * @param session HttpSessiorn 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, MessagingException { + String email = request.getParameter("email"); + if (email != null) { + email = email.trim(); + String password = request.getParameter("password"); + String repeatPassword = request.getParameter("repeatPassword"); + String md5; - protected void checkAdmin(String login, HttpSession session) { - String[] admins = BowConfig.getInstance().getAdmins(); - if (admins != null) { - for (String admin : admins) { - if (login.equals(admin)) { - session.setAttribute("admin", true); - return; - } - } - } - session.setAttribute("admin", false); - } + if (password == null) { + request.setAttribute("errorMsgUser", "Invalid password, password must not be null "); - /* @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(); - Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, login.getEmail()).criteria(); - Token token = proxy.findByCriteria(Token.class, criteria); - TokenActions tokenActions = new TokenActions(); - if (token == null) { - token = new TokenImpl(); - String newToken = tokenActions.generateToken(); - token.setToken(newToken); - token.setEmail(login.getEmail()); - proxy.store(token); - } - tokenActions.setPermanentToken(token.getToken()); - String temporaryToken = tokenActions.generateToken(); - tokenActions.setTemporaryToken(temporaryToken); - session.setAttribute("tokenActions", tokenActions); - } + } else if (!password.equals(repeatPassword)) { + request.setAttribute("errorMsgUser", "Invalid password, you have not type twice the same password."); + } else { + md5 = StringUtil.encodeMD5(password); + if (!checkRegister(email, md5, request)) { // check if all is well + WikittyProxy proxy = BowProxy.getInstance(); + UserImpl newUser = new UserImpl(); + newUser.setPassword(md5); + newUser.setEmail(email); + User login = proxy.store((User) newUser); // store the new user - /* @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, - HttpServletRequest request) throws NoSuchAlgorithmException { - if (email != null && password != null) { - if (!email.isEmpty() && !password.equals(StringUtil.encodeMD5(""))) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email). - eq(User.FQ_FIELD_PASSWORD, password).criteria(); - User user = proxy.findByCriteria(User.class, criteria); - - if (user == null) { - request.setAttribute("errorMsgUser", "Unknown email or incorrect password"); - } - return user; // retrieve user by user name (email) and password - } - } - request.setAttribute("errorMsgUser", "Please enter your email address and your password"); - return null; - } + if (login != null) { + initSession(session, login); + initHomePage(request, login); + sendMail(email, password); + request.getRequestDispatcher("home.jsp").forward(request, response); + } else { + request.setAttribute("errorMsgUser", "Invalid login, please choose another one"); + } + } + } + request.getRequestDispatcher("register.jsp").forward(request, response); + } + } - /* @param email String which contains the user name (email) - * @param password String which contains the user password - * @return boolean false if the user doesn't exist or true - */ - protected boolean checkRegister(String email, - String password, - HttpServletRequest request) throws NoSuchAlgorithmException { - if (email != null && password != null) { - if (!email.isEmpty() && !password.equals(StringUtil.encodeMD5(""))) { - WikittyProxy proxy = BowProxy.getInstance(); + /* @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 { + String email = request.getParameter("email"); + if (email != null) { + email = email.trim(); + String password = request.getParameter("password"); + String md5; + if (password != null) { + md5 = StringUtil.encodeMD5(password); + User login = checkLogin(email, md5, request); // check if the user exists + if (login != null) { + initSession(session, login); + initHomePage(request, login); + request.getRequestDispatcher("home.jsp").forward(request, response); + return; + } + } + } + request.getRequestDispatcher("login.jsp").forward(request, response); + } - Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria(); // retrieve user by user name (email) - if (proxy.findByCriteria(User.class, criteria) == null) { - return false; - } - request.setAttribute("errorMsgUser", "This email address is already used"); - return true; - } - } - request.setAttribute("errorMsgUser", "Email and password must be correctly filled"); - return true; - } + protected void checkAdmin(String login, HttpSession session) { + String[] admins = BowConfig.getInstance().getAdmins(); + if (admins != null) { + for (String admin : admins) { + if (login.equals(admin)) { + session.setAttribute("admin", true); + return; + } + } + } + session.setAttribute("admin", false); + } - protected void initHomePage(HttpServletRequest request, User user) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = getBookmarkListCriteriaByUser(user, null); - if (criteria != null) { - Criteria sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); - PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, sortCriteria); // select all bookmarks by user - sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10); - List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll(); - BookmarkActions bookmarkActions = createBookmarkActions(request, result, null); - bookmarkActions.setTagSearch(null); - List<Bookmark> bookList = bookmarkActions.getBookmarks(); - if (bookList.size() > 10) { - bookList = bookmarkActions.getBookmarks().subList(0, 10); - bookmarkActions.setBookmarks(bookList); - } - if (lastBookmarks != null) { - bookmarkActions.setLastBookmarks(lastBookmarks); - } - request.setAttribute("bookmarkActions", bookmarkActions); - } - } - - protected void initSession(HttpSession session, User user) throws NoSuchAlgorithmException { - WikittyProxy proxy = BowProxy.getInstance(); - session.setAttribute("user", user); - Preference preference = proxy.restore(Preference.class, user.getWikittyId()); - session.setAttribute("preference", preference); - initializeToken(session, user); - checkAdmin(user.getEmail(), session); - } - - /* @param request servlet request - * @param user User user - * @description initialize all for the home page - */ - protected void actionHome(HttpServletRequest request, - HttpServletResponse response, - HttpSession session) - throws ServletException, IOException, NoSuchAlgorithmException { - User user = (User) session.getAttribute("user"); - if (user == null) { - String token = request.getParameter("token"); - user = checkPermanentToken(token); - if (user != null) { - initSession(session, user); - } - } - if (user != null) { - initHomePage(request, user); - request.getRequestDispatcher("home.jsp").forward(request, response); - } else { - request.getRequestDispatcher("login.jsp").forward(request, response); - } - } + /* @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(); + Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, login.getEmail()).criteria(); + Token token = proxy.findByCriteria(Token.class, criteria); + TokenActions tokenActions = new TokenActions(); + if (token == null) { + token = new TokenImpl(); + String newToken = tokenActions.generateToken(); + token.setToken(newToken); + token.setEmail(login.getEmail()); + proxy.store(token); + } + tokenActions.setPermanentToken(token.getToken()); + String temporaryToken = tokenActions.generateToken(); + tokenActions.setTemporaryToken(temporaryToken); + session.setAttribute("tokenActions", tokenActions); + } - protected void createImportExtension(List<Bookmark> bookmarks) { - if (bookmarks != null && !bookmarks.isEmpty()) { - WikittyProxy proxy = BowProxy.getInstance(); - List<String> ids = new ArrayList<String>(); - for (Bookmark bookmark : bookmarks) { - String id = bookmark.getWikittyId(); - ids.add(id); - } - Date date = new Date(); - List<Import> imports = proxy.restore(Import.class, ids); - for (Import imp : imports) { - imp.setDate(date); - } - proxy.store(imports); - } - } - - protected void getBookmarksByImportDate(HttpServletRequest request, User user) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Import.EXT_IMPORT).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). - addFacetField(Import.FQ_FIELD_DATE); - List<FacetTopic> bookmarksImportDate = proxy.findAllByCriteria(Import.class, criteria).getTopic(Import.FQ_FIELD_DATE); - request.setAttribute("bookmarksImportDate", bookmarksImportDate); - } - - /* @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, ServletException { - // Check that we have a file upload request - boolean isMultipart = ServletFileUpload.isMultipartContent(request); - if (isMultipart) { - // Create a factory for disk-based file items - DiskFileItemFactory factory = new DiskFileItemFactory(); - // Create a new file upload handler - ServletFileUpload upload = new ServletFileUpload(factory); - // Process the uploaded items - // Parse the request - List<?> items = upload.parseRequest(request); - for (Object obj : items) { - FileItem item = (FileItem) obj; - if (!item.isFormField()) { - WikittyProxy proxy = BowProxy.getInstance(); - String content = item.getString(); - try { - Parser parser = new Parser(content); - NodeList list = parser.parse(null); - List<Bookmark> bookmarks = new ArrayList<Bookmark>(); - parseHtmlToBookmarks(list, user, bookmarks, new ArrayList<String>()); - bookmarks = proxy.store(bookmarks); - createImportExtension(bookmarks); - initHomePage(request, user); - request.getRequestDispatcher("home.jsp").forward(request, response); - } - catch (ParserException e) { - request.setAttribute("errorMsgUser", "Bad bookmarks file format, expected Netscape-like bookmarks file"); - request.setAttribute("errorMsgTech", e.getMessage()); - - String searchLine = request.getParameter("searchLine"); - if (searchLine == null) { - initHomePage(request, user); - request.getRequestDispatcher("home.jsp").forward(request, response); - } else { - actionSearch(request, user); - request.getRequestDispatcher("search.jsp").forward(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) { - boolean isFolder = false; - SimpleNodeIterator it = list.elements(); - while (it.hasMoreNodes()) { - Node node = it.nextNode(); - 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); // add the folder name to the tagList - isFolder = true; - } - } 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) { - bookmarks.add(bookmark); - } - } - NodeList children = node.getChildren(); - if (children != null) { - parseHtmlToBookmarks(children, user, bookmarks, tagList); // if there is an under node = recursion - } - } - if (isFolder) { // if we find a folder, we have to remove it - int index = tagList.size() - 1; - if (index > -1) { - tagList.remove(index); - } - } - } - } + /* @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, + HttpServletRequest request) throws NoSuchAlgorithmException { + if (email != null && password != null) { + if (!email.isEmpty() && !password.equals(StringUtil.encodeMD5(""))) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email). + eq(User.FQ_FIELD_PASSWORD, password).criteria(); + User user = proxy.findByCriteria(User.class, criteria); - /* @param response servlet response - * @param user User user - * @description export bookmarks - */ - protected void actionExportBookmarks(HttpServletResponse response, User user) - throws IOException { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); - List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); - String export = BookmarkActions.getExportHtmlBookmark(bookmarks); - byte[] buff = export.getBytes(); - ServletOutputStream op = response.getOutputStream(); - response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"bookmarks.html\""); - response.setContentLength(buff.length); - op.write(buff, 0, buff.length); - op.flush(); - op.close(); - } + if (user == null) { + request.setAttribute("errorMsgUser", "Unknown email or incorrect password"); + } + return user; // retrieve user by user name (email) and password + } + } + request.setAttribute("errorMsgUser", "Please enter your email address and your password"); + return null; + } - /* @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"); - if (alias != null && !alias.isEmpty()) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria(); - List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); - if (bookmarks == null || bookmarks.isEmpty()) { - String id = request.getParameter("bookmarkId"); - if (id != null && !id.isEmpty()) { - Bookmark bookmark = proxy.restore(Bookmark.class, id); - if (bookmark != null) { - bookmark.setAlias(alias); - proxy.store(bookmark); - } - } - } - } - 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) throws IOException, ServletException { - String fullText = request.getParameter("fullTextLine"); - if (fullText == null || fullText.isEmpty()) { - actionSearch(request, user); - } else { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria; - if (!fullText.isEmpty()) { - criteria = Search.query().keyword(fullText). - eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). - addFacetField(Bookmark.FQ_FIELD_TAGS); - - } else { - criteria = getBookmarkListCriteriaByUser(user, null); - } - PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); - BookmarkActions bookmarkActions = createBookmarkActions(request, result, null); - request.setAttribute("bookmarkActions", bookmarkActions); - } - } + /* @param email String which contains the user name (email) + * @param password String which contains the user password + * @return boolean false if the user doesn't exist or true + */ + protected boolean checkRegister(String email, + String password, + HttpServletRequest request) throws NoSuchAlgorithmException { + if (email != null && password != null) { + if (!email.isEmpty() && !password.equals(StringUtil.encodeMD5(""))) { + WikittyProxy proxy = BowProxy.getInstance(); - /* @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"); - 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"); - } - } + Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria(); // retrieve user by user name (email) + if (proxy.findByCriteria(User.class, criteria) == null) { + return false; + } + request.setAttribute("errorMsgUser", "This email address is already used"); + return true; + } + } + request.setAttribute("errorMsgUser", "Email and password must be correctly filled"); + return true; + } - /* @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) { - if (searchLine != null && !searchLine.isEmpty()) { - String[] words = searchLine.split("\\s+"); // put the tags in an array - List<String> tags = new ArrayList<String>(Arrays.asList(words)); - criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). - eq(Bookmark.FQ_FIELD_TAGS, tags).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); - } else { - criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). - criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); - } - } - return criteria; - } + protected void initHomePage(HttpServletRequest request, User user) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = getBookmarkListCriteriaByUser(user, null); + if (criteria != null) { + Criteria sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK); + PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, sortCriteria); // select all bookmarks by user + sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10); + List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll(); + BookmarkActions bookmarkActions = createBookmarkActions(request, result, null); + bookmarkActions.setTagSearch(null); + List<Bookmark> bookList = bookmarkActions.getBookmarks(); + if (bookList.size() > 10) { + bookList = bookmarkActions.getBookmarks().subList(0, 10); + bookmarkActions.setBookmarks(bookList); + } + if (lastBookmarks != null) { + bookmarkActions.setLastBookmarks(lastBookmarks); + } + request.setAttribute("bookmarkActions", bookmarkActions); + } + } - protected Preference changePreference(HttpServletRequest request, HttpSession session) { + protected void initSession(HttpSession session, User user) throws NoSuchAlgorithmException { + WikittyProxy proxy = BowProxy.getInstance(); + session.setAttribute("user", user); + Preference preference = proxy.restore(Preference.class, user.getWikittyId()); + session.setAttribute("preference", preference); + initializeToken(session, user); + checkAdmin(user.getEmail(), session); + } - Preference preference = (Preference) session.getAttribute("preference"); - // Retrieve Preference fields - String colors = request.getParameter("colors"); - String tags = request.getParameter("tagsNb"); - String bookmarks = request.getParameter("bookmarks"); - String searchEngineSuggestions = request.getParameter("searchEngineUrlSuggestions"); - String searchEngineResults = request.getParameter("searchEngineUrlResults"); + /* @param request servlet request + * @param user User user + * @description initialize all for the home page + */ + protected void actionHome(HttpServletRequest request, + HttpServletResponse response, + HttpSession session) + throws ServletException, IOException, NoSuchAlgorithmException { + User user = (User) session.getAttribute("user"); + if (user == null) { + String token = request.getParameter("token"); + user = checkPermanentToken(token); + if (user != null) { + initSession(session, user); + } + } + if (user != null) { + initHomePage(request, user); + request.getRequestDispatcher("home.jsp").forward(request, response); + } else { + request.getRequestDispatcher("login.jsp").forward(request, response); + } + } - preference.setColors(colors); - preference.setTags(Integer.valueOf(tags)); - preference.setBookmarks(Integer.valueOf(bookmarks)); - preference.setSearchEngineUrlSuggestions(searchEngineSuggestions); - preference.setSearchEngineUrlResults(searchEngineResults); + protected void createImportExtension(List<Bookmark> bookmarks) { + if (bookmarks != null && !bookmarks.isEmpty()) { + WikittyProxy proxy = BowProxy.getInstance(); + List<String> ids = new ArrayList<String>(); + for (Bookmark bookmark : bookmarks) { + String id = bookmark.getWikittyId(); + ids.add(id); + } + Date date = new Date(); + List<Import> imports = proxy.restore(Import.class, ids); + for (Import imp : imports) { + imp.setDate(date); + } + proxy.store(imports); + } + } - return preference; - } - - protected User changeUser(HttpServletRequest request, User newUser) - throws NoSuchAlgorithmException { - String email = request.getParameter("email"); - String newPassword = request.getParameter("newPassword"); - String currentPassword = request.getParameter("currentPassword"); - String confirmNewPassword = request.getParameter("confirmNewPassword"); + protected void getBookmarksByImportDate(HttpServletRequest request, User user) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Import.EXT_IMPORT).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). + addFacetField(Import.FQ_FIELD_DATE); + List<FacetTopic> bookmarksImportDate = proxy.findAllByCriteria(Import.class, criteria).getTopic(Import.FQ_FIELD_DATE); + request.setAttribute("bookmarksImportDate", bookmarksImportDate); + } - if (email != null && !email.isEmpty()) { - newUser.setEmail(email); - } - if (newPassword != null && confirmNewPassword != null && currentPassword != null) { - if (!newPassword.isEmpty() && !confirmNewPassword.isEmpty() && !currentPassword.isEmpty()) { - if (newPassword.equals(confirmNewPassword)) { - currentPassword = StringUtil.encodeMD5(currentPassword); - if (currentPassword.equals(newUser.getPassword())) { - String md5 = StringUtil.encodeMD5(newPassword); - newUser.setPassword(md5); - } - } - } - } - return newUser; - } - - protected void actionChangePreferences(HttpServletRequest request, HttpSession session, User user) - throws NoSuchAlgorithmException, AddressException, MessagingException { + /* @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, ServletException { + // Check that we have a file upload request + boolean isMultipart = ServletFileUpload.isMultipartContent(request); + if (isMultipart) { + // Create a factory for disk-based file items + DiskFileItemFactory factory = new DiskFileItemFactory(); + // Create a new file upload handler + ServletFileUpload upload = new ServletFileUpload(factory); + // Process the uploaded items + // Parse the request + List<?> items = upload.parseRequest(request); + for (Object obj : items) { + FileItem item = (FileItem) obj; + if (!item.isFormField()) { + WikittyProxy proxy = BowProxy.getInstance(); + String content = item.getString(); + try { + Parser parser = new Parser(content); + NodeList list = parser.parse(null); + List<Bookmark> bookmarks = new ArrayList<Bookmark>(); + parseHtmlToBookmarks(list, user, bookmarks, new ArrayList<String>()); + bookmarks = proxy.store(bookmarks); + createImportExtension(bookmarks); + initHomePage(request, user); + request.getRequestDispatcher("home.jsp").forward(request, response); + } + catch (ParserException e) { + request.setAttribute("errorMsgUser", "Bad bookmarks file format, expected Netscape-like bookmarks file"); + request.setAttribute("errorMsgTech", e.getMessage()); - WikittyProxy proxy = BowProxy.getInstance(); + String searchLine = request.getParameter("searchLine"); + if (searchLine == null) { + initHomePage(request, user); + request.getRequestDispatcher("home.jsp").forward(request, response); + } else { + actionSearch(request, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } + } + } + } + } + } - Preference preference = changePreference(request, session); - proxy.store(preference); + /* @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) { + boolean isFolder = false; + SimpleNodeIterator it = list.elements(); + while (it.hasMoreNodes()) { + Node node = it.nextNode(); + 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); // add the folder name to the tagList + isFolder = true; + } + } 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) { + bookmarks.add(bookmark); + } + } + NodeList children = node.getChildren(); + if (children != null) { + parseHtmlToBookmarks(children, user, bookmarks, tagList); // if there is an under node = recursion + } + } + if (isFolder) { // if we find a folder, we have to remove it + int index = tagList.size() - 1; + if (index > -1) { + tagList.remove(index); + } + } + } + } - User newUser = proxy.restore(User.class, user.getWikittyId()); - newUser = changeUser(request, newUser); - newUser = proxy.store(newUser); - session.setAttribute("user", newUser); + /* @param response servlet response + * @param user User user + * @description export bookmarks + */ + protected void actionExportBookmarks(HttpServletResponse response, User user) + throws IOException { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); + List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); + String export = BookmarkActions.getExportHtmlBookmark(bookmarks); + byte[] buff = export.getBytes(); + ServletOutputStream op = response.getOutputStream(); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment; filename=\"bookmarks.html\""); + response.setContentLength(buff.length); + op.write(buff, 0, buff.length); + op.flush(); + op.close(); + } - preference = proxy.restore(Preference.class, newUser.getWikittyId()); - session.setAttribute("preference", preference); - } + /* @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"); + if (alias != null && !alias.isEmpty()) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria(); + List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); + if (bookmarks == null || bookmarks.isEmpty()) { + String id = request.getParameter("bookmarkId"); + if (id != null && !id.isEmpty()) { + Bookmark bookmark = proxy.restore(Bookmark.class, id); + if (bookmark != null) { + bookmark.setAlias(alias); + proxy.store(bookmark); + } + } + } + } + redirectToTheGoodPage(request, response); + } - protected void sendMail(String email, String password) - throws AddressException, MessagingException { + /* @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) throws IOException, ServletException { + String fullText = request.getParameter("fullTextLine"); + if (fullText == null || fullText.isEmpty()) { + actionSearch(request, user); + } else { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria; + if (!fullText.isEmpty()) { + criteria = Search.query().keyword(fullText). + eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). + addFacetField(Bookmark.FQ_FIELD_TAGS); - BowConfig config = BowConfig.getInstance(); - String smtpServer = config.getSmtpServer(); - Properties properties = new Properties(); - properties.put("mail.smtp.host", smtpServer); + } else { + criteria = getBookmarkListCriteriaByUser(user, null); + } + PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); + BookmarkActions bookmarkActions = createBookmarkActions(request, result, null); + request.setAttribute("bookmarkActions", bookmarkActions); + } + } - Session session = Session.getDefaultInstance(properties, null); - session.setDebug(true); + /* @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"); + 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"); + } + } - Message msg = new MimeMessage(session); + /* @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) { + if (searchLine != null && !searchLine.isEmpty()) { + String[] words = searchLine.split("\\s+"); // put the tags in an array + List<String> tags = new ArrayList<String>(Arrays.asList(words)); + criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). + eq(Bookmark.FQ_FIELD_TAGS, tags).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); + } else { + criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()). + criteria().addFacetField(Bookmark.FQ_FIELD_TAGS); + } + } + return criteria; + } - InternetAddress toAddress = new InternetAddress(email); - msg.addRecipient(Message.RecipientType.TO, toAddress); + protected Preference changePreference(HttpServletRequest request, HttpSession session) { - String addressFrom = config.getAddressFrom(); - InternetAddress fromAddress = new InternetAddress(addressFrom); - msg.setFrom(fromAddress); + Preference preference = (Preference) session.getAttribute("preference"); + // Retrieve Preference fields + String colors = request.getParameter("colors"); + String tags = request.getParameter("tagsNb"); + String bookmarks = request.getParameter("bookmarks"); + String searchEngineSuggestions = request.getParameter("searchEngineUrlSuggestions"); + String searchEngineResults = request.getParameter("searchEngineUrlResults"); - String messageSubject = "[Bow] New Password"; - msg.setSubject(messageSubject); + preference.setColors(colors); + preference.setTags(Integer.valueOf(tags)); + preference.setBookmarks(Integer.valueOf(bookmarks)); + preference.setSearchEngineUrlSuggestions(searchEngineSuggestions); + preference.setSearchEngineUrlResults(searchEngineResults); - String messageBody = "Hi,\n\n"; - messageBody += "Your new password: " + password + "\n"; - messageBody += "Your email: " + email + "\n\n"; - msg.setContent(messageBody, "text/plain"); + return preference; + } - Transport.send(msg); - } + protected User changeUser(HttpServletRequest request, User newUser) + throws NoSuchAlgorithmException { + String email = request.getParameter("email"); + String newPassword = request.getParameter("newPassword"); + String currentPassword = request.getParameter("currentPassword"); + String confirmNewPassword = request.getParameter("confirmNewPassword"); - protected boolean passwordExists(String password) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(User.FQ_FIELD_PASSWORD, password).criteria(); - List<User> users = proxy.findAllByCriteria(User.class, criteria).getAll(); - if (users != null && users.size() > 0) { - return true; - } - return false; - } + if (email != null && !email.isEmpty()) { + newUser.setEmail(email); + } + if (newPassword != null && confirmNewPassword != null && currentPassword != null) { + if (!newPassword.isEmpty() && !confirmNewPassword.isEmpty() && !currentPassword.isEmpty()) { + if (newPassword.equals(confirmNewPassword)) { + currentPassword = StringUtil.encodeMD5(currentPassword); + if (currentPassword.equals(newUser.getPassword())) { + String md5 = StringUtil.encodeMD5(newPassword); + newUser.setPassword(md5); + } + } + } + } + return newUser; + } - protected void actionSendPassword(HttpServletRequest request, HttpServletResponse response) - throws NoSuchAlgorithmException, AddressException, MessagingException, ServletException, IOException { - String email = request.getParameter("email"); - if (email != null) { - email = email.trim(); - if (!email.isEmpty()) { - WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria(); - User user = proxy.findByCriteria(User.class, criteria); - if (user != null) { - boolean bool = true; - String password = ""; - String md5 = ""; - while (bool) { - password = RandomStringUtils.randomAlphanumeric(20); - md5 = StringUtil.encodeMD5(password); - bool = passwordExists(md5); - } - sendMail(email, password); - user.setPassword(md5); - proxy.store(user); - request.getRequestDispatcher("login.jsp").forward(request, response); - } else { - request.setAttribute("errorMsgUser", "This email address doesn't exist"); - } - } else { - request.setAttribute("errorMsgUser", "Please enter an email address"); - } - } - request.getRequestDispatcher("forgotPassword.jsp").forward(request, response); - } + protected void actionChangePreferences(HttpServletRequest request, HttpSession session, User user) + throws NoSuchAlgorithmException, AddressException, MessagingException { - protected void actionReIndexation(HttpServletRequest request, HttpSession session, User user) { - if ((Boolean) session.getAttribute("admin")) { - WikittyProxy proxy = BowProxy.getInstance(); - proxy.getWikittyService().syncEngin(proxy.getSecurityToken()); + WikittyProxy proxy = BowProxy.getInstance(); + + Preference preference = changePreference(request, session); + proxy.store(preference); + + User newUser = proxy.restore(User.class, user.getWikittyId()); + newUser = changeUser(request, newUser); + newUser = proxy.store(newUser); + session.setAttribute("user", newUser); + + preference = proxy.restore(Preference.class, newUser.getWikittyId()); + session.setAttribute("preference", preference); } - } + + protected void sendMail(String email, String password) + throws AddressException, MessagingException { + + BowConfig config = BowConfig.getInstance(); + String smtpServer = config.getSmtpServer(); + Properties properties = new Properties(); + properties.put("mail.smtp.host", smtpServer); + + Session session = Session.getDefaultInstance(properties, null); + session.setDebug(true); + + Message msg = new MimeMessage(session); + + InternetAddress toAddress = new InternetAddress(email); + msg.addRecipient(Message.RecipientType.TO, toAddress); + + String addressFrom = config.getAddressFrom(); + InternetAddress fromAddress = new InternetAddress(addressFrom); + msg.setFrom(fromAddress); + + String messageSubject = "[Bow] New Password"; + msg.setSubject(messageSubject); + + String messageBody = "Hi,\n\n"; + messageBody += "Your new password: " + password + "\n"; + messageBody += "Your email: " + email + "\n\n"; + msg.setContent(messageBody, "text/plain"); + + Transport.send(msg); + } + + protected boolean passwordExists(String password) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(User.FQ_FIELD_PASSWORD, password).criteria(); + List<User> users = proxy.findAllByCriteria(User.class, criteria).getAll(); + if (users != null && users.size() > 0) { + return true; + } + return false; + } + + protected void actionSendPassword(HttpServletRequest request, HttpServletResponse response) + throws NoSuchAlgorithmException, AddressException, MessagingException, ServletException, IOException { + String email = request.getParameter("email"); + if (email != null) { + email = email.trim(); + if (!email.isEmpty()) { + WikittyProxy proxy = BowProxy.getInstance(); + Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria(); + User user = proxy.findByCriteria(User.class, criteria); + if (user != null) { + boolean bool = true; + String password = ""; + String md5 = ""; + while (bool) { + password = RandomStringUtils.randomAlphanumeric(20); + md5 = StringUtil.encodeMD5(password); + bool = passwordExists(md5); + } + sendMail(email, password); + user.setPassword(md5); + proxy.store(user); + request.getRequestDispatcher("login.jsp").forward(request, response); + } else { + request.setAttribute("errorMsgUser", "This email address doesn't exist"); + } + } else { + request.setAttribute("errorMsgUser", "Please enter an email address"); + } + } + request.getRequestDispatcher("forgotPassword.jsp").forward(request, response); + } + + protected void actionReIndexation(HttpServletRequest request, HttpSession session, User user) { + if ((Boolean) session.getAttribute("admin")) { + WikittyProxy proxy = BowProxy.getInstance(); + proxy.getWikittyService().syncEngin(proxy.getSecurityToken()); + } + } } Modified: trunk/src/main/webapp/css/connexion.css =================================================================== --- trunk/src/main/webapp/css/connexion.css 2010-12-20 13:38:14 UTC (rev 139) +++ trunk/src/main/webapp/css/connexion.css 2010-12-20 22:31:55 UTC (rev 140) @@ -78,14 +78,14 @@ color:#804561; width:225px; position:relative; - margin:20px auto; + margin:15px auto; } -#formFrame form p{ +#formFrame form div{ color:#804561; font-size:16px; font-weight:bold; - padding:15px 0; + padding:10px 0; } #formFrame form input[type="text"], Modified: trunk/src/main/webapp/login.jsp =================================================================== --- trunk/src/main/webapp/login.jsp 2010-12-20 13:38:14 UTC (rev 139) +++ trunk/src/main/webapp/login.jsp 2010-12-20 22:31:55 UTC (rev 140) @@ -31,15 +31,17 @@ <div id="formFrame"> <h1>Login</h1> <form method="post" action="bow?action=login"> - <p> - <label for="email">Email :</label> - <input type="text" name="email" id="email" /> - <br /><br /> + <div> + <label for="email">Email :</label> + <input type="text" name="email" id="email" /> + </div> + <div> <label for="password">Password :</label> <input type="password" name="password" id="password" /> - <br /><br /> + </div> + <div> <input type="submit" value="Login" /> - </p> + </div> </form> <a href="bow?action=registration" id="register">Register</a> <a href="bow?action=forgotPassword" id="forgotPwd">Forgot Your Password?</a> Modified: trunk/src/main/webapp/register.jsp =================================================================== --- trunk/src/main/webapp/register.jsp 2010-12-20 13:38:14 UTC (rev 139) +++ trunk/src/main/webapp/register.jsp 2010-12-20 22:31:55 UTC (rev 140) @@ -31,15 +31,21 @@ <div id="formFrame"> <h1>Register</h1> <form method="post" action="bow?action=register"> - <p> - <label for="email">Email :</label> - <input type="text" name="email" id="email" /> - <br /><br /> - <label for="password">Password :</label> - <input type="password" name="password" id="password" /> - <br /><br /> - <input type="submit" value="Register" /> - </p> + <div> + <label for="email">Email :</label> + <input type="text" name="email" id="email" /> + </div> + <div> + <label for="password">Password :</label> + <input type="password" name="password" id="password" /> + </div> + <div> + <label for="repeatPassword">Repeat the password :</label> + <input type="password" name="repeatPassword" id="repeatPassword" /> + </div> + <div> + <input type="submit" value="Register" /> + </div> </form> <a href="bow" id="register">Login page</a> </div> Modified: trunk/src/main/webapp/rightMenu.jsp =================================================================== --- trunk/src/main/webapp/rightMenu.jsp 2010-12-20 13:38:14 UTC (rev 139) +++ trunk/src/main/webapp/rightMenu.jsp 2010-12-20 22:31:55 UTC (rev 140) @@ -79,7 +79,7 @@ <input type="submit" value="Logout" /> </div> </form> - <a href="#" class="help">Aide</a> + <!--<a href="#" class="help">Aide</a>--> </div> <div id="side"> <div id="colonneD">
participants (1)
-
kmorin@users.chorem.org