r85 - in trunk/src/main: java/org/chorem/bow resources webapp
Author: bbrossaud Date: 2010-07-15 17:36:42 +0200 (Thu, 15 Jul 2010) New Revision: 85 Url: http://chorem.org/repositories/revision/bow/85 Log: addition admin page and fullText use wikitty engine Added: trunk/src/main/webapp/admin.jsp Modified: trunk/src/main/java/org/chorem/bow/BowConfig.java trunk/src/main/java/org/chorem/bow/BowProxy.java trunk/src/main/java/org/chorem/bow/ControllerServlet.java trunk/src/main/java/org/chorem/bow/UserMigration.java trunk/src/main/resources/bow.properties trunk/src/main/webapp/bookmarkHome.jsp trunk/src/main/webapp/bookmarkSearch.jsp Modified: trunk/src/main/java/org/chorem/bow/BowConfig.java =================================================================== --- trunk/src/main/java/org/chorem/bow/BowConfig.java 2010-07-15 09:14:24 UTC (rev 84) +++ trunk/src/main/java/org/chorem/bow/BowConfig.java 2010-07-15 15:36:42 UTC (rev 85) @@ -19,10 +19,13 @@ import static org.nuiton.i18n.I18n._; import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.lang.UnhandledException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.StringUtil; /** * @@ -104,6 +107,11 @@ return getOption(Option.BOW_ADDRESSFROM.key); } + public String[] getAdmins() { + String str = getOption(Option.BOW_ADMINS.key); + return StringUtil.split(str, ","); + } + /** * Set {@code solr} and {@code jms} system configuration. * @@ -136,6 +144,8 @@ null, String.class, false, false), BOW_ADDRESSFROM("bow.addressFrom", _("bow.config.bow.addressFrom.description"), null, String.class, false, false), + BOW_ADMINS("bow.admins", _("bow.config.bow.admins.description"), + null, String.class, false, false), DATA_DIR("solr.data.dir", _("bow.config.data.dir.description"), System.getProperty("user.home") + "/.bow/solr", String.class, false, false); public final String key; Modified: trunk/src/main/java/org/chorem/bow/BowProxy.java =================================================================== --- trunk/src/main/java/org/chorem/bow/BowProxy.java 2010-07-15 09:14:24 UTC (rev 84) +++ trunk/src/main/java/org/chorem/bow/BowProxy.java 2010-07-15 15:36:42 UTC (rev 85) @@ -25,7 +25,6 @@ import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.WikittyService; import org.nuiton.wikitty.WikittyServiceCached; -import org.nuiton.wikitty.WikittyServiceNotifier; import org.nuiton.wikitty.jdbc.WikittyServiceJDBC; /** @@ -47,6 +46,9 @@ if (instance == null) { BowConfig config = BowConfig.getInstance(); instance = new BowProxy(config); + /* + * Fixe me when wikitty will integrate this function + */ WikittyExtensionMigration.migrationRegistry.put(User.EXT_USER, new UserMigration()); } return instance; Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-07-15 09:14:24 UTC (rev 84) +++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-07-15 15:36:42 UTC (rev 85) @@ -227,12 +227,23 @@ log.debug("Going to actionPreferences"); } request.getRequestDispatcher("preferences.jsp").forward(request, response); + } else if (action.equals("admin") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionAdmin"); + } + request.getRequestDispatcher("admin.jsp").forward(request, response); } else if (action.equals("changePreferences") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionChangePreferences"); } this.actionChangePreferences(request, session, user); request.getRequestDispatcher("preferences.jsp").forward(request, response); + } else if (action.equals("reIndexation") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionReIndexation"); + } + this.actionReIndexation(request, session, user); + request.getRequestDispatcher("admin.jsp").forward(request, response); } else { if (user != null) { request.getRequestDispatcher("error.jsp").forward(request, response); @@ -643,9 +654,7 @@ if (bookList != null) { bookmarkActions.setBookmarks(bookList); } - if (fullText != null && !fullText.isEmpty()) { - bookmarkActions.fullText(fullText); - } else { + if (fullText == null || fullText.isEmpty()) { if (searchLine != null && searchLine.isEmpty()) { bookmarkActions.emptySearchline(); } else { @@ -686,6 +695,7 @@ session.setAttribute("preference", preference); initializeToken(session, login); actionHome(request, login); + checkAdmin(email, session); sendMail(email, password); request.getRequestDispatcher("main.jsp").forward(request, response); } @@ -710,6 +720,7 @@ Preference preference = proxy.restore(Preference.class, login.getWikittyId()); session.setAttribute("preference", preference); initializeToken(session, login); + checkAdmin(email, session); actionHome(request, login); request.getRequestDispatcher("main.jsp").forward(request, response); @@ -720,6 +731,19 @@ } } + protected void checkAdmin(String login, HttpSession session) { + String[] admins = BowConfig.getInstance().getAdmins(); + if (admins != null) { + for (int count = 0; count < admins.length; ++count) { + if (login.equals(admins[count])) { + session.setAttribute("admin", true); + return; + } + } + } + session.setAttribute("admin", false); + } + /* @param session HttpSession session * @throws ServletException if a servlet error occurs * @description retrieve tokens or create there if the user are just @@ -936,8 +960,17 @@ * @description retrieve bookmark for the full text research */ protected void actionFullText(HttpServletRequest request, User user) { + String fullText = request.getParameter("fullTextLine"); WikittyProxy proxy = BowProxy.getInstance(); - Criteria criteria = getBookmarkListCriteriaByUser(user, null); + Criteria criteria = null; + if (fullText != null && !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 result = proxy.findAllByCriteria(Bookmark.class, criteria); BookmarkActions bookmarkActions = createBookmarkActions(request, result, null); request.setAttribute("bookmarkActions", bookmarkActions); @@ -1102,4 +1135,9 @@ request.getRequestDispatcher("forgotPassword.jsp").forward(request, response); } } + + private void actionReIndexation(HttpServletRequest request, HttpSession session, User user) { + WikittyProxy proxy = BowProxy.getInstance(); + proxy.getWikittyService().syncEngin(proxy.getSecurityToken()); + } } Modified: trunk/src/main/java/org/chorem/bow/UserMigration.java =================================================================== --- trunk/src/main/java/org/chorem/bow/UserMigration.java 2010-07-15 09:14:24 UTC (rev 84) +++ trunk/src/main/java/org/chorem/bow/UserMigration.java 2010-07-15 15:36:42 UTC (rev 85) @@ -1,7 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.chorem.bow; import java.security.NoSuchAlgorithmException; Modified: trunk/src/main/resources/bow.properties =================================================================== --- trunk/src/main/resources/bow.properties 2010-07-15 09:14:24 UTC (rev 84) +++ trunk/src/main/resources/bow.properties 2010-07-15 15:36:42 UTC (rev 85) @@ -2,3 +2,4 @@ bow.url=http://localhost:8080/bow/ bow.smtpServer=smtp bow.addressFrom=bow@chorem.org +bow.admins=brossa_b@epitech.net Added: trunk/src/main/webapp/admin.jsp =================================================================== --- trunk/src/main/webapp/admin.jsp (rev 0) +++ trunk/src/main/webapp/admin.jsp 2010-07-15 15:36:42 UTC (rev 85) @@ -0,0 +1,61 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + +<%@page import="org.chorem.bow.Preference" %> +<%@page import="org.chorem.bow.User" %> + +<% + User user = (User) session.getAttribute("user"); + Preference preference = (Preference) session.getAttribute("preference"); + if (user != null && preference != null) { + String url = (String) request.getAttribute("bowUrl"); + String version = (String) request.getAttribute("version"); + String check = preference.getColors(); + if (check == null) { + preference.setColors(""); + } + check = preference.getSearchEngineUrlResults(); + if (check == null) { + preference.setSearchEngineUrlResults(""); + } + check = preference.getSearchEngineUrlSuggestions(); + if (check == null) { + preference.setSearchEngineUrlSuggestions(""); + } +%> + +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta name="description" content="Bookmark On the Web" /> + <title>Bow</title> + <link rel="stylesheet" type="text/css" href="./css/connexion.css" /> + </head> + + <body> + <div id="headback"> + <div id="head"> + <div id="headleft"> + <a class="logo" href="bow">bow</a> + </div> + </div> + </div> + <div id="mainbodyback"> + <div id="mainbody"> + + <div id="content"> + <br /><br /> + <a href="bow?action=reIndexation">All data re-indexation</a> + <br /><br /> + <a href="bow?action=home">Return to the home page</a> + <br /><br /> + </div> + + </div> + <jsp:include page="footer.jsp" flush="true" > + <jsp:param name="bowUrl" value="<%=url%>" /> + <jsp:param name="version" value="<%=version%>" /> + </jsp:include> + </div> + </body> +</html> +<%}%> Modified: trunk/src/main/webapp/bookmarkHome.jsp =================================================================== --- trunk/src/main/webapp/bookmarkHome.jsp 2010-07-15 09:14:24 UTC (rev 84) +++ trunk/src/main/webapp/bookmarkHome.jsp 2010-07-15 15:36:42 UTC (rev 85) @@ -14,6 +14,10 @@ <% TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions"); + Boolean admin = (Boolean) session.getAttribute("admin"); + if (admin == null) { + admin = false; + } if (tokenActions != null && bookmarkActions != null) { String temporaryToken = tokenActions.getTemporaryToken(); String permanentToken = tokenActions.getPermanentToken(); @@ -126,9 +130,12 @@ </div> <div id="colonneD"> <ul class="droite"> + <%if (admin == true) {%> + <li><a href="bow?action=admin">Admin</a></li> + <%}%> <li><a href="bow?action=preferences">Preferences</a></li> - <li><a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');if%20(nameAndTags!=(document.title+'|')){var%20link='<%=url%>bow?action=addUrl&token=<%=temporaryToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Temporary token</a></li> - <li><a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');if%20(nameAndTags!=(document.title+'|')){var%20link='<%=url%>bow?action=addUrl&token=<%=permanentToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Current permanent token</a></li> + <li><a title="Add this link to your favourites to bookmark others in the future. This link is just available while you are connected on the site!" href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');if%20(nameAndTags!=(document.title+'|')){var%20link='<%=url%>bow?action=addUrl&token=<%=temporaryToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Temporary bookmark addition link</a></li> + <li><a title="Add this link to your favourites to bookmark others in the future. This link is always available!" href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');if%20(nameAndTags!=(document.title+'|')){var%20link='<%=url%>bow?action=addUrl&token=<%=permanentToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Permanent bookmark addition link</a></li> </ul> <div id="nuage"> <jsp:include page="tagsCloud.jsp" flush="true" /> Modified: trunk/src/main/webapp/bookmarkSearch.jsp =================================================================== --- trunk/src/main/webapp/bookmarkSearch.jsp 2010-07-15 09:14:24 UTC (rev 84) +++ trunk/src/main/webapp/bookmarkSearch.jsp 2010-07-15 15:36:42 UTC (rev 85) @@ -14,6 +14,10 @@ <% TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions"); + Boolean admin = (Boolean) session.getAttribute("admin"); + if (admin == null) { + admin = false; + } if (tokenActions != null && bookmarkActions != null) { String temporaryToken = tokenActions.getTemporaryToken(); String permanentToken = tokenActions.getPermanentToken(); @@ -108,9 +112,12 @@ <div id="colonneD"> <ul class="droite"> + <%if (admin == true) {%> + <li><a href="bow?action=admin">Admin</a></li> + <%}%> <li><a href="bow?action=preferences">Preferences</a></li> - <li><a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=temporaryToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Temporary token</a></li> - <li><a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=permanentToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Current permanent token</a></li> + <li><a title="Add this link to your favourites to bookmark others in the future. This link is just available while you are connected on the site!" href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=temporaryToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Temporary bookmark addition link</a></li> + <li><a title="Add this link to your favourites to bookmark others in the future. This link is always available!" href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=permanentToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Permanent bookmark addition link</a></li> </ul> <div id="nuage"> <jsp:include page="tagsCloud.jsp" flush="true">
participants (1)
-
bbrossaudï¼ users.chorem.org