Bow-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
August 2011
- 3 participants
- 38 discussions
r319 - in trunk/bow-ui/src/main/webapp/WEB-INF: . decorators jsp jsp/inc
by bpoussin@users.chorem.org 21 Aug '11
by bpoussin@users.chorem.org 21 Aug '11
21 Aug '11
Author: bpoussin
Date: 2011-08-21 20:31:08 +0200 (Sun, 21 Aug 2011)
New Revision: 319
Url: http://chorem.org/repositories/revision/bow/319
Log:
Evolution #438: Refactore source code and simplify all
- move jsp page to WEB-INF dir for more security
Added:
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/footer.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/header.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/rightMenu.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/tagsCloud.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/permanentXml.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/suggestions.jsp
trunk/bow-ui/src/main/webapp/WEB-INF/jsp/temporaryXml.jsp
Modified:
trunk/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp
Modified: trunk/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp 2011-08-21 18:30:58 UTC (rev 318)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -62,15 +62,15 @@
<body id="page-home">
<div id="wrap">
<div id="page">
- <%@include file="/jsp/inc/header.jsp" %>
+ <%@include file="/WEB-INF/jsp/inc/header.jsp" %>
<div id="main">
<decorator:body />
</div>
<s:if test="%{#session.BowSession.user != null}">
- <jsp:include page="/jsp/inc/rightMenu.jsp" />
+ <jsp:include page="/WEB-INF/jsp/inc/rightMenu.jsp" />
</s:if>
</div>
</div>
- <%@include file="/jsp/inc/footer.jsp" %>
+ <%@include file="/WEB-INF/jsp/inc/footer.jsp" %>
</body>
</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/admin.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,58 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <head>
+ <s:url var="css" value="/css/bookmark.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div id="content">
+ <div class="menu clearfix">
+ <h2><s:text name="bow.admin.panel" /></h2>
+ </div>
+ <div class="formFrame fond">
+ <br /><br />
+
+ <s:if test="#session.BowSession.isAdmin()">
+ <ul id="adminActions">
+ <li><s:a action="reIndexation"><s:text name="bow.admin.dataReindexation" /></s:a></li>
+ <li><s:a action="migrateData?versionFrom=0.4&versionTo=0.5"><s:text name="bow.admin.dataMigration04to05" /></s:a></li>
+ <li><s:a action="migrateData?versionFrom=0.6&versionTo=1.1"><s:text name="bow.admin.dataMigration05to06" /></s:a></li>
+ <li><s:a action="home" id="homePage"><s:text name="bow.admin.home" /></s:a></li>
+ </ul>
+ </s:if>
+ <s:else>
+ <h2><s:text name="bow.admin.forbidden" /></h2>
+ </s:else>
+ </div>
+ </div>
+ </body>
+</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/editBookmark.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,61 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <head>
+ <s:url var="css" value="/css/bookmark.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div id="content">
+ <div class="menu clearfix">
+ <h2><s:text name="popup.addurl.title" /></h2>
+ </div>
+ <div class="formFrame fond">
+ <s:form id="popupAddUrlForm" action="addUrl" method="post">
+ <s:hidden name="tagLine" value="%{tagLine}" />
+ <s:hidden name="fullTextLine" value="%{fullTextLine}" />
+ <s:hidden name="bookmarkId" value="%{bookmark.wikittyId}"/>
+ <s:textfield name="link" labelSeparator=" " key="popup.addurl.link"
+ value="%{bookmark.link}" />
+ <s:textarea name="name" labelSeparator=" " key="popup.addurl.name"
+ value="%{bookmark.description}" />
+ <s:textfield name="privateAlias" labelSeparator=" " key="popup.addurl.alias.private"
+ value="%{bookmark.privateAlias}" />
+ <s:textfield name="publicAlias" labelSeparator=" " key="popup.addurl.alias.public"
+ value="%{bookmark.publicAlias}" />
+ <s:textfield name="tags" labelSeparator=" " key="popup.addurl.tags"
+ value="%{@org.chorem.bow.BookmarkUtils@getBookmarkTagsString(bookmark)}" />
+ <s:submit key="popup.commons.submit" name="submit" />
+ </s:form>
+ </div>
+ </div>
+ </body>
+</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/error.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,48 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <head>
+ <s:url var="css" value="/css/connexion.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div id="main">
+ <div id="msg">
+ <div id="actionmessageHeader">
+ <s:actionmessage />
+ </div>
+ <div id="actionerrorHeader">
+ <s:actionerror />
+ </div>
+ </div>
+ </div>
+ </body>
+</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/forgotPassword.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,51 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <head>
+ <title><s:text name="bow.forgotpwd.title" /></title>
+ <s:url var="css" value="/css/connexion.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div id="content">
+ <div id="formFrame fond">
+ <h1><s:text name="bow.forgotpwd.title" /></h1>
+ <s:form action="forgotPassword">
+ <p>
+ <s:textfield key="bow.login.email" name="email" labelposition="top" labelSeparator=" :" />
+ <s:submit key="bow.forgotpwd.submit" name="submit" />
+ </p>
+ </s:form>
+ <s:a action="login_input" id="loginLink"><s:text name="bow.login.title" /></s:a>
+ </div>
+ </div>
+ </body>
+</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/home.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,75 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+
+ <head>
+ <title><s:text name="bow.search.title" /></title>
+ <s:url var="css" value="/css/bookmark.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div class="menu clearfix">
+ <h2>
+ <s:text name="bow.search.found" />
+ <s:property value="%{searchResult.bookmarkCount}"/>
+ </h2>
+
+ <s:set name="bookmarksToDelete" value="%{searchResult.bookmarkCount}" />
+ <s:if test="%{#bookmarksToDelete > 0}">
+ <s:url var="deleteSearchResults" action="deleteSearchResults" escapeAmp="false">
+ <s:param name="tagLine"><s:property value="searchResult.tagLine" /></s:param>
+ <s:param name="fullTextLine"><s:property value="searchResult.fullTextLine" /></s:param>
+ </s:url>
+ <s:a id="deleteSearchResultsButton" title="delete all" href="" onclick="deleteConfirmation('%{deleteSearchResults}', %{#bookmarksToDelete}); return(false);"></s:a>
+ </s:if>
+ <s:form action="home" method="get" theme="simple">
+ <label for="order"><s:text name="bow.search.orderby" /></label>
+ <s:select id="order" name="order" list="possibleOrder"/>
+ <s:submit key="bow.search.submit" name="submit" />
+ <s:hidden name="tagLine" value="%{searchResult.tagLine}" />
+ <s:hidden name="fullTextLine" value="%{searchResult.fullTextLine}" />
+ </s:form>
+ </div>
+ <div class="content">
+ <s:if test="searchResult.bookmarks.empty">
+ <p class="nobookmarks"><s:text name="bow.bookmarks.noBookmarks" /></p>
+ </s:if>
+ <s:else>
+ <s:iterator value="searchResult.bookmarks" var="bookmark">
+ <s:set name="bookmark" value="bookmark"/>
+ <jsp:include page="inc/bookmark.jsp" flush="true">
+ <jsp:param name="tagLine" value="%{searchResult.tagLine}" />
+ <jsp:param name="fullTextLine" value="%{searchResult.fullTextLine}" />
+ </jsp:include>
+ </s:iterator>
+ </s:else>
+ </div>
+ </body>
+</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/inc/bookmark.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,84 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
+<%@taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<div class="bookmark"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+
+ <div class="bookmarkhead">
+ <p class="date"><s:property value="#bookmark.creationDate"/></p>
+ <s:a cssClass="alias" href="%{config.aliasUrl + #bookmark.wikittyId}.action"
+ title="%{#bookmark.link}" target="_blank">
+ a:<s:property value="%{#bookmark.privateAlias}" />
+ </s:a>
+ <s:if test="%{!#bookmark.publicAlias.empty}">
+ <s:a cssClass="alias" href="%{config.aliasUrl + #bookmark.publicAlias}.action"
+ title="%{#bookmark.link}" target="_blank">
+ <s:property value="%{#bookmark.publicAlias}" />
+ </s:a>
+ </s:if>
+ <s:url var="editBookmark" action="editBookmark" escapeAmp="true">
+ <s:param name="id"><s:property value="%{#bookmark.wikittyId}" /></s:param>
+ <s:param name="tagLine"><s:property value="%{tagLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{fullTextLine}" /></s:param>
+ </s:url>
+ <s:a cssClass="edit" href="%{editBookmark}"/>
+
+ <s:url var="removeBookmark" action="removeBookmark" escapeAmp="true">
+ <s:param name="bookmarkId"><s:property value="%{#bookmark.wikittyId}" /></s:param>
+ <s:param name="tagLine"><s:property value="%{tagLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{fullTextLine}" /></s:param>
+ </s:url>
+ <s:a cssClass="supprim" href="%{removeBookmark}"
+ onclick="return deleteConfirmation('%{#removeBookmark}','%{#bookmark.link}');"></s:a>
+ </div>
+
+ <div class="bookmarkcontenu">
+ <s:a title="%{#bookmark.link}" href="alias/%{#bookmark.wikittyId}.action" target="_blank">
+ <div class="screenshot"></div>
+ </s:a>
+ <div class="click"><s:property value="%{#bookmark.click}" /></div>
+ <div class="description">
+ <h3><s:text name="bow.bookmark.description" /> :</h3>
+ <p>
+ <s:property value="%{#bookmark.description}"/>
+ </p>
+ <p class="tags">
+ <strong><s:text name="bow.bookmark.tags" /> :</strong>
+ <s:iterator value="#bookmark.labels" var="tag">
+ <s:url var="search" action="home">
+ <s:param name="tagLine" value="%{tagLine}"/>
+ <s:param name="addTag" value="%{#tag}"/>
+ <s:param name="fullTextLine" value="%{fullTextLine}"/>
+ </s:url>
+ <s:a href="%{search}" cssClass="tag"><s:property value="%{#tag}"/></s:a>
+ </s:iterator>
+ </p>
+ </div>
+ </div>
+
+</div>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/footer.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/inc/footer.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/footer.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/footer.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,47 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+<div id="footer"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <p>
+ <a shape="rect" href="http://www.chorem.org/projects/show/bow">bow</a>
+ <a shape="rect" href="http://www.chorem.org/projects/bow/files"></a> -
+ <a shape="rect" href="http://www.gnu.org/licenses/agpl.html"><s:text name="bow.footer.license" /></a> -
+ <span title="Copyright">©2011</span>
+ <a shape="rect" href="http://www.codelutin.com">Code Lutin</a> -
+ <a shape="rect" href="http://www.chorem.org/projects/bow/issues"><s:text name="bow.footer.bugreport" /></a> -
+ <a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users"><s:text name="bow.footer.userSupport" /></a> -
+ <s:url var="localeEN">
+ <s:param name="request_locale">en_GB</s:param>
+ </s:url>
+ <s:url var="localeFR">
+ <s:param name="request_locale">fr_FR</s:param>
+ </s:url>
+ <s:a href="%{localeEN}"><s:text name="bow.action.locale.english" /></s:a> -
+ <s:a href="%{localeFR}"><s:text name="bow.action.locale.french" /></s:a>
+ </p>
+</div>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/header.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/inc/header.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/header.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/header.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,71 @@
+<%--
+#%L
+ bow
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+--%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+<div id="header"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <div>
+ <s:if test="%{#session.BowSession.user != null}">
+ <s:url var="homeToken" action="home">
+ <s:param name="token"><s:property value="%{#session.BowSession.getPermanentToken()}" /></s:param>
+ </s:url>
+ <s:a cssClass="logo" href="%{homeToken}">bow</s:a>
+ </s:if>
+ <s:else>
+ <s:a cssClass="logo" action="home">bow</s:a>
+ </s:else>
+ </div>
+ <s:if test="%{#session.BowSession.user != null}">
+ <div class="recherche right">
+ <h3>Recherche</h3>
+ <div class="input">
+ <s:form action="home" theme="simple">
+ <s:textfield name="tagLine" labelSeparator="" />
+ <s:submit key="bow.rightMenu.search.tags" name="submit" />
+ </s:form>
+ </div>
+ <div class="input">
+ <s:form action="home" theme="simple">
+ <s:textfield name="fullTextLine" labelSeparator="" />
+ <s:submit key="bow.rightMenu.fullTextSearch" name="submit" />
+ </s:form>
+ </div>
+ <div class="input">
+ <s:form action="openSearchResult" theme="simple">
+ <s:textfield name="searchLine" labelSeparator="" />
+ <s:submit key="bow.rightMenu.externSearchEngine" name="submit" />
+ </s:form>
+ </div>
+ </div>
+ </s:if>
+ <div id="msg">
+ <span id="actionmessageHeader">
+ <s:actionmessage />
+ </span>
+ <span id="actionerrorHeader">
+ <s:actionerror />
+ </span>
+ </div>
+</div>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/rightMenu.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/inc/rightMenu.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/rightMenu.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/rightMenu.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,73 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<%@taglib prefix="s" uri="/struts-tags" %>
+<%@taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<sj:dialog id="editBookmark"
+ title="Ajout/Modification d'un bookmark"
+ modal="true"
+ autoOpen="false" />
+
+<div id="logoutDiv" xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <s:form action="logout" theme="simple">
+ <div class="input">
+ <s:submit key="bow.rightMenu.logout" name="submit" />
+ </div>
+ </s:form>
+ <a href="http://maven-site.chorem.org/bow/" class="help" target="_blank">
+ <s:text name="bow.rightMenu.help" />
+ </a>
+</div>
+
+<div id="side" xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <div id="colonneD">
+ <ul class="droite">
+ <s:if test="bowSession.admin">
+ <li><s:a action="admin"><s:text name="bow.rightMenu.admin" /></s:a></li>
+ </s:if>
+ <li><s:a action="preferences"><s:text name="bow.preferences.title" /></s:a></li>
+ <li>
+ <s:url var="editBookmark" action="editBookmark" escapeAmp="true">
+ <s:param name="tagLine"><s:property value="%{tagLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{fullTextLine}" /></s:param>
+ </s:url>
+ <s:a href="%{editBookmark}">
+ <s:text name="bow.rightMenu.addUrl.link" />
+ </s:a>
+ </li>
+ </ul>
+ <!--div id="nuage"-->
+ <jsp:include page="tagsCloud.jsp" flush="true">
+ <jsp:param name="tagLine" value="%{tagLine}" />
+ <jsp:param name="fullTextLine" value="%{fullTextLine}"/>
+ </jsp:include>
+ <!--/div-->
+ <div class="colonnebas">
+ <img src="img/piedmenu.jpg" width="401" height="77" alt="Pied de menu" />
+ </div>
+ </div>
+</div>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/tagsCloud.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/inc/tagsCloud.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/tagsCloud.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/inc/tagsCloud.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,42 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+<div id="nuage"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <s:iterator value="%{searchResult.tagsCloud}" status="tagStatus" var="tag">
+ <s:url var="search" action="home" escapeAmp="true">
+ <s:param name="tagLine" value="%{tagLine}"/>
+ <s:param name="addTag" value="%{#tag.topicName}"/>
+ <s:param name="fullTextLine" value="%{fullTextLine}"/>
+ </s:url>
+ <!-- -->
+ <s:a href="%{search}" title="%{#tag.count} results" cssClass="tag"
+ cssStyle="font-size: %{searchResult.getFont(#tag.count)}px">
+ <s:property value="%{#tag.topicName}" />
+ </s:a>
+ </s:iterator>
+</div>
\ No newline at end of file
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/login.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,52 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
+
+<html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <head>
+ <title><s:text name="bow.login.title" /></title>
+ <s:url var="css" value="/css/connexion.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div id="content">
+ <div id="formFrame" class="fond">
+ <h1><s:text name="bow.login.title" /></h1>
+ <br/>
+ <br/>
+ <s:actionerror />
+ <s:form action="login">
+ <s:textfield key="bow.login.email" name="email" labelposition="top" labelSeparator=" :" />
+ <s:password key="bow.login.password" name="password" labelposition="top" labelSeparator=" :" />
+ <s:submit key="bow.login.submit" name="submit" />
+ </s:form>
+ <s:a action="register_input" id="registerLink"><s:text name="bow.register.title" /></s:a><br />
+ <s:a action="forgotPassword_input" id="forgotPwd"><s:text name="bow.forgotpwd.title" /></s:a>
+ </div>
+ </div>
+ </body>
+</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/permanentXml.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/permanentXml.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/permanentXml.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/permanentXml.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,43 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/xml" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
+<%@page import="org.chorem.bow.BowConfig" %>
+
+<%
+String url = BowConfig.getBowUrl();
+%>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
+ xmlns:moz="http://www.mozilla.org/2006/browser/search/"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <ShortName>Bow (permanent)</ShortName>
+ <Description>bookmarkSearch</Description>
+ <InputEncoding>inputEncoding</InputEncoding>
+ <Image width="16" height="16" type="image/ico"><%=url%>img/bow.gif</Image>
+ <s:set var="token" value="#session.BowSession.getPermanentToken()" />
+ <Url type="text/html" method="GET" template="<%=url%>openSearchResult.action?token=${token}&searchLine={searchTerms}" />
+ <Url type="application/x-suggestions+json" method="GET" template="<%=url%>openSearchSuggestion.action?token=${token}&searchLine={searchTerms}" />
+ <moz:SearchForm><%=url%></moz:SearchForm>
+</OpenSearchDescription>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp (from rev 316, trunk/bow-ui/src/main/webapp/jsp/preferences.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,188 @@
+<%--
+#%L
+bow
+
+$Id$
+$HeadURL$
+%%
+Copyright (C) 2010 CodeLutin
+%%
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+#L%
+--%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+<html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+<head>
+ <title><s:text name="bow.preferences.title"/></title>
+ <s:url var="css" value="/css/bookmark.css"/>
+ <link href="${css}" rel="stylesheet" type="text/css"/>
+ <s:head/>
+</head>
+<body>
+<div id="content">
+ <div class="menu clearfix">
+ <h2><s:text name="bow.preferences.title"/></h2>
+ </div>
+ <s:actionerror/>
+
+ <div class="formFrame fond">
+ <s:set var="permanentToken" value="bowSession.getPermanentToken()" />
+ <s:set var="temporaryToken" value="bowSession.getTemporaryToken()" />
+ <ul>
+ <li>
+ <s:a title="%{getText('bow.rightMenu.bookmark.temporaryLinkDescription')}"
+ 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='%{config.bowUrl}addUrl.action?token=%{temporaryToken}&link='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">
+ <s:text name="bow.rightMenu.bookmark.temporaryLink" />
+ </s:a>
+ </li>
+ <li>
+ <s:a title="%{getText('bow.rightMenu.bookmark.permanentLinkDescription')}"
+ 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='%{config.bowUrl}addUrl.action?token=%{permanentToken}&link='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">
+ <s:text name="bow.rightMenu.bookmark.permanentLink" />
+ </s:a>
+ </li>
+ <li>
+ <a href="extensions/bow4chromium.crx">
+ <img src="img/chromium.png" alt="Chromium" class="extensionIcon" />
+ <s:text name="bow.rightMenu.chromiumExtension" />
+ </a>
+ </li>
+ <li>
+ <strong><s:text name="bow.rightMenu.token.permanent"/> :</strong>
+ <s:property value="%{#permanentToken}"/>
+ </li>
+ <li>
+ <strong><s:text name="bow.rightMenu.token.temporary"/> :</strong>
+ <s:property value="%{#temporaryToken}"/>
+ </li>
+ </ul>
+
+ <s:url var="regenPermToken" action="generateToken"/>
+ <s:a href="%{regenPermToken}" id="regenPermToken">
+ <s:text name="bow.preferences.regenPermToken"/>
+ </s:a>
+ </div>
+
+ <div class="formFrame fond">
+ <h3><s:text name="bow.preferences.userInfo"/></h3>
+ <br/>
+ <s:form action="updateUserPref" theme="simple">
+ <s:text name="bow.login.email"/><br/>
+ <s:textfield name="email"
+ labelposition="top"/><br/>
+
+ <s:text name="bow.preferences.currentPassword"/><br/>
+ <s:password name="currentPassword"
+ labelposition="top"/><br/>
+
+ <s:text name="bow.preferences.newPassword"/><br/>
+ <s:password name="newPassword"
+ labelposition="top"/><br/>
+
+ <s:text name="bow.preferences.confirmNewPassword"/><br/>
+ <s:password name="confirmNewPassword"
+ labelposition="top"/><br/>
+ <s:hidden name="update" value="user"/>
+ <s:submit key="bow.preferences.submit" name="submit"/>
+ </s:form>
+ </div>
+ <div class="formFrame fond">
+ <h3><s:text name="bow.preferences.siteLook"/></h3>
+ <br/>
+ <s:form action="updateSitePref" theme="simple">
+ <s:text name="bow.preferences.tagsNb"/><br/>
+ <s:textfield name="tagsNb" labelposition="top"/><br/>
+
+ <s:text name="bow.preferences.bookmarksHomePage"/><br/>
+ <s:textfield name="bookmarksHomePage" labelposition="top"/><br/>
+
+ <s:text name="bow.preferences.searchEngineUrlSuggestions"/><br/>
+ <s:textfield name="searchEngineUrlSuggestions"
+ labelposition="top"/><br/>
+
+ <s:text name="bow.preferences.searchEngineUrlResults"/><br/>
+ <s:textfield name="searchEngineUrlResults"
+ size="50"
+ labelposition="top"/><br/>
+
+ <s:hidden name="update" value="site"/>
+ <s:submit key="bow.preferences.submit" name="submit"/>
+ </s:form>
+ </div>
+
+ <div class="menu clearfix">
+ <h2><s:text name="bow.preferences.tagsManagement"/></h2>
+ </div>
+
+ <div class="formFrame fond">
+ <h3><s:text name="bow.preferences.labels"/>(<s:property value="labels.size()"/>)</h3>
+ <br/>
+ <s:form id="labelsForm" action="adminlabels" method="post" theme="simple">
+ <div class="list">
+ <s:checkboxlist name="selectedLabels" list="labels"
+ listKey="topicName" listValue="%{topicName+'('+count+')'}"/>
+ </div>
+ <div class="action">
+ <s:text name="bow.preferences.labels.name.field"/><s:textfield name="newLabel" />
+ <s:submit name="rename" key="bow.preferences.labels.rename.submit" />
+ <s:submit name="delete" key="bow.preferences.labels.delete.submit" />
+ </div>
+ </s:form>
+ </div>
+
+ <div class="menu clearfix">
+ <h2><s:text name="bow.preferences.importExport"/></h2>
+ </div>
+
+ <div class="formFrame fond">
+ <s:a action="exportBookmarks"><s:text name="bow.preferences.export.bookmarks"/></s:a>
+ <br/>
+
+ <h3><s:text name="bow.preferences.import.bookmarks"/></h3>
+ <br/>
+ <s:form action="importBookmarks" method="post" enctype="multipart/form-data" theme="simple">
+ <s:file name="upfile" labelSeparator=""/>
+ <s:hidden name="tagLine" value="%{tagLine}"/>
+ <s:hidden name="fullTextLine" value="%{fullTextLine}"/>
+ <s:submit key="bow.preferences.import.submit" name="submit"/>
+ </s:form>
+ <br/><br/>
+
+ <s:if test="bookmarksImportDate != null">
+ <s:iterator value="bookmarksImportDate">
+ <s:set name="date" value="%{key}"/>
+ <s:set name="nb" value="%{value}"/>
+ <s:date name="%{stringToDate(#date)}" var="dateString"/>
+ <div class="deleteImport">
+ <span><s:property value="dateString"/> (<s:property value="#nb"/> bookmarks)</span>
+ <s:url var="deleteImport" action="deleteImport">
+ <s:param name="date" value="#date"/>
+ </s:url>
+ <s:a cssClass="deleteImportButton" href="%{deleteImport}"
+ onclick="return deleteConfirmation('%{deleteImport}','%{nb}','%{dateString}');">
+ </s:a>
+ </div>
+ </s:iterator>
+ </s:if>
+ <s:else>
+ <span><s:text name="bow.preferences.noImportedBookmarks"/></span>
+ </s:else>
+ </div>
+
+</div>
+</body>
+</html>
\ No newline at end of file
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/register.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,54 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <head>
+ <title><s:text name="bow.register.title" /></title>
+ <s:url var="css" value="/css/connexion.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div id="content">
+ <div id="formFrame" class="fond">
+ <h1><s:text name="bow.register.title" /></h1>
+ <s:form action="register">
+ <s:actionerror />
+ <p>
+ <s:textfield key="bow.login.email" name="email" labelposition="top" labelSeparator=" :" />
+ <s:password key="bow.login.password" name="password" labelposition="top" labelSeparator=" :" />
+ <s:password key="bow.login.repeatPassword" name="repeatPassword" labelposition="top" labelSeparator=" :" />
+ <s:submit key="bow.register.submit" name="submit" />
+ </p>
+ </s:form>
+ <s:a action="login_input" id="loginLink"><s:text name="bow.login.title" /></s:a>
+ </div>
+ </div>
+ </body>
+</html>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/suggestions.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/suggestions.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/suggestions.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/suggestions.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,44 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@page import="org.chorem.bow.OpenSearchActions" %>
+<%@page import="org.nuiton.wikitty.search.FacetTopic" %>
+<%@page import="org.chorem.bow.action.OpenSearchSuggestionAction"%>
+<%@page import="java.util.List" %>
+
+<%
+OpenSearchSuggestionAction action = OpenSearchSuggestionAction.getAction();
+OpenSearchActions osa = action.getOpenSearchActions();
+if (osa != null) {
+ String[] word = osa.getSearch();
+ if (word != null) {
+ List<FacetTopic> suggestions = osa.getSuggestionList();
+ if (suggestions != null) {
+%>
+<%=osa.getJsonResult()%>
+<%
+ }
+ }
+}
+%>
Copied: trunk/bow-ui/src/main/webapp/WEB-INF/jsp/temporaryXml.jsp (from rev 313, trunk/bow-ui/src/main/webapp/jsp/temporaryXml.jsp)
===================================================================
--- trunk/bow-ui/src/main/webapp/WEB-INF/jsp/temporaryXml.jsp (rev 0)
+++ trunk/bow-ui/src/main/webapp/WEB-INF/jsp/temporaryXml.jsp 2011-08-21 18:31:08 UTC (rev 319)
@@ -0,0 +1,43 @@
+<%--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/xml" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
+<%@page import="org.chorem.bow.BowConfig" %>
+
+<%
+String url = BowConfig.getBowUrl();
+%>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
+ xmlns:moz="http://www.mozilla.org/2006/browser/search/"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page">
+ <ShortName>Bow (temporary)</ShortName>
+ <Description>bookmarkSearch</Description>
+ <InputEncoding>inputEncoding</InputEncoding>
+ <Image width="16" height="16" type="image/ico"><%=url%>img/bow.gif</Image>
+ <s:set var="token" value="%{#session.BowSession.getTemporaryToken()}" />
+ <Url type="text/html" method="GET" template="<%=url%>openSearchResult.action?token=${token}&searchLine={searchTerms}" />
+ <Url type="application/x-suggestions+json" method="GET" template="<%=url%>openSearchSuggestion.action?token=${token}&search={searchTerms}" />
+ <moz:SearchForm><%=url%></moz:SearchForm>
+</OpenSearchDescription>
1
0
Author: bpoussin
Date: 2011-08-21 20:30:58 +0200 (Sun, 21 Aug 2011)
New Revision: 318
Url: http://chorem.org/repositories/revision/bow/318
Log:
Evolution #438: Refactore source code and simplify all
- move jsp page to WEB-INF dir for more security
Removed:
trunk/bow-ui/src/main/webapp/jsp/
1
0
r317 - in trunk/bow-ui/src/main: java/org/chorem/bow java/org/chorem/bow/action java/org/chorem/bow/action/opensearch resources/i18n xmi
by bpoussin@users.chorem.org 21 Aug '11
by bpoussin@users.chorem.org 21 Aug '11
21 Aug '11
Author: bpoussin
Date: 2011-08-21 20:16:39 +0200 (Sun, 21 Aug 2011)
New Revision: 317
Url: http://chorem.org/repositories/revision/bow/317
Log:
Evolution #430: Permit search prefix configurable for each user
- move open search action in new package
- refactore open search action to simplify prefix search
- add support of suggest for alias
- add support for user configuration prefix (backend)
Added:
trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/
trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java
Removed:
trunk/bow-ui/src/main/java/org/chorem/bow/SuggestionsComparator.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
Modified:
trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java
trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java
trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java
trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties
trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties
trunk/bow-ui/src/main/xmi/bow.zargo
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -248,4 +248,130 @@
return config.getOption(BowConfigOption.BOW_ADMINS.key + ".password." + admin);
}
+ /**
+ * Retourne le separateur choisi par l'utilisateur entre les prefix d'action
+ * et la chaine.
+ *
+ * @return
+ */
+ public static String getPrefixSeparator() {
+ return getPrefixSeparator(getConfig());
+ }
+
+ /**
+ * Retourne le separateur choisi par l'utilisateur entre les prefix d'action
+ * et la chaine.
+ *
+ * @return
+ */
+ public static String getPrefixSeparator(ApplicationConfig config) {
+ return config.getOption(BowConfigOption.OPEN_SEARCH_PREFIX_SEPARATOR.key);
+ }
+
+ /**
+ * Retourne le prefix par defaut a utiliser si l'utilisateur a mis le
+ * separateur de prefix mais sans prefix
+ * @return
+ */
+ public static String getDefaultPrefix() {
+ return getDefaultPrefix(getConfig());
+ }
+
+ /**
+ * Retourne le prefix par defaut a utiliser si l'utilisateur a mis le
+ * separateur de prefix mais sans prefix
+ * @return
+ */
+ public static String getDefaultPrefix(ApplicationConfig config) {
+ return config.getOption(BowConfigOption.OPEN_SEARCH_DEFAULT_PREFIX.key);
+ }
+
+ /**
+ * Indique l'action par defaut a faire, si l'utilisateur n'indique ni
+ * prefix ni separateur de prefix
+ * @return
+ */
+ public static String getDefaultAction() {
+ return getDefaultAction(getConfig());
+ }
+
+ /**
+ * Indique l'action par defaut a faire, si l'utilisateur n'indique ni
+ * prefix ni separateur de prefix
+ * @return
+ */
+ public static String getDefaultAction(ApplicationConfig config) {
+ return config.getOption(BowConfigOption.OPEN_SEARCH_DEFAULT_ACTION.key);
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur les tags
+ * @return
+ */
+ public static String getTagSearchPrefix() {
+ return getTagSearchPrefix(getConfig());
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur les tags
+ * @return
+ */
+ public static String getTagSearchPrefix(ApplicationConfig config) {
+ return config.getOption(BowConfigOption.OPEN_SEARCH_TAG_SEARCH_PREFIX.key);
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur fulltext
+ * dans bow
+ * @return
+ */
+ public static String getFullTextSearchPrefix() {
+ return getFullTextSearchPrefix(getConfig());
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur fulltext
+ * dans bow
+ * @return
+ */
+ public static String getFullTextSearchPrefix(ApplicationConfig config) {
+ return config.getOption(BowConfigOption.OPEN_SEARCH_FULLTEXT_SEARCH_PREFIX.key);
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur les alias
+ * prive et une rediection automatique vers cette page
+ * @return
+ */
+ public static String getAliasPrefix() {
+ return getAliasPrefix(getConfig());
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur les alias
+ * prive et une rediection automatique vers cette page
+ * @return
+ */
+ public static String getAliasPrefix(ApplicationConfig config) {
+ return config.getOption(BowConfigOption.OPEN_SEARCH_ALIAS_PREFIX.key);
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur le web
+ * via le moteur de recherche configurer
+ * @return
+ */
+ public static String getWebSearchPrefix() {
+ return getWebSearchPrefix(getConfig());
+ }
+
+ /**
+ * le prefix pour indiquer que l'on souhaite une recherche sur le web
+ * via le moteur de recherche configurer
+ * @return
+ */
+ public static String getWebSearchPrefix(ApplicationConfig config) {
+ return config.getOption(BowConfigOption.OPEN_SEARCH_WEB_SEARCH_PREFIX.key);
+ }
+
}
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -49,10 +49,6 @@
"alias.url",
_("bow.config.alias.url.description"),
"alias/", String.class, false, false),
- SEARCH_ENGINE(
- "search.engine",
- _("bow.config.search.engine.description"),
- null, String.class, false, false),
BOW_SMTPSERVER(
"bow.smtpServer",
_("bow.config.bow.smtpServer.description"),
@@ -64,7 +60,39 @@
BOW_ADMINS(
"bow.admins",
_("bow.config.bow.admins.description"),
- null, String.class, false, false);
+ null, String.class, false, false),
+ SEARCH_ENGINE(
+ "search.engine",
+ _("bow.config.search.engine.description"),
+ null, String.class, false, false),
+ OPEN_SEARCH_DEFAULT_ACTION(
+ "opensearch.default.action",
+ _("bow.config.opensearch.default.action.description"),
+ "w", String.class, false, false),
+ OPEN_SEARCH_PREFIX_SEPARATOR(
+ "opensearch.prefix.separator",
+ _("bow.config.opensearch.prefix.separator.description"),
+ ":", String.class, false, false),
+ OPEN_SEARCH_DEFAULT_PREFIX(
+ "opensearch.default.prefix",
+ _("bow.config.opensearch.default.prefix.description"),
+ "t", String.class, false, false),
+ OPEN_SEARCH_TAG_SEARCH_PREFIX(
+ "opensearch.tag.search.prefix",
+ _("bow.config.opensearch.tag.search.prefix.description"),
+ "t", String.class, false, false),
+ OPEN_SEARCH_FULLTEXT_SEARCH_PREFIX(
+ "opensearch.fulltext.search.prefix",
+ _("bow.config.opensearch.fulltext.search.prefix.description"),
+ "f", String.class, false, false),
+ OPEN_SEARCH_WEB_SEARCH_PREFIX(
+ "opensearch.web.search.prefix",
+ _("bow.config.opensearch.web.search.prefix.description"),
+ "w", String.class, false, false),
+ OPEN_SEARCH_ALIAS_PREFIX(
+ "opensearch.alias.prefix",
+ _("bow.config.opensearch.alias.prefix.description"),
+ "a", String.class, false, false);
public String key;
public String description;
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -28,9 +28,9 @@
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.wikitty.entities.Wikitty;
/**
* Classe utilisee pour stocker les objets utils en session utilisateur
@@ -130,6 +130,24 @@
if (preference.getSearchEngineUrlSuggestions() == null) {
preference.setSearchEngineUrlSuggestions(""); // TODO add default value in config
}
+ if (StringUtils.isBlank(preference.getPrefixSeparator())) {
+ preference.setPrefixSeparator(BowConfig.getPrefixSeparator());
+ }
+ if (StringUtils.isBlank(preference.getTagSearchPrefix())) {
+ preference.setPrefixSeparator(BowConfig.getTagSearchPrefix());
+ }
+ if (StringUtils.isBlank(preference.getFullTextSearchPrefix())) {
+ preference.setFullTextSearchPrefix(BowConfig.getFullTextSearchPrefix());
+ }
+ if (StringUtils.isBlank(preference.getWebSearchPrefix())) {
+ preference.setWebSearchPrefix(BowConfig.getWebSearchPrefix());
+ }
+ if (StringUtils.isBlank(preference.getAliasPrefix())) {
+ preference.setAliasPrefix(BowConfig.getAliasPrefix());
+ }
+ if (StringUtils.isBlank(preference.getDefaultAction())) {
+ preference.setDefaultAction(BowConfig.getDefaultAction());
+ }
}
public String getPermanentToken() {
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/SuggestionsComparator.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/SuggestionsComparator.java 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/SuggestionsComparator.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -1,47 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow;
-
-import java.util.Comparator;
-import org.nuiton.wikitty.search.FacetTopic;
-
-/**
- *
- * @author bbrossaud
- */
-public class SuggestionsComparator implements Comparator<FacetTopic> {
-
- @Override
- public int compare(FacetTopic o1, FacetTopic o2) {
- int result = 0;
-
- if (o1.getCount() < o2.getCount()) {
- result = 1;
- }
- else if (o1.getCount() > o2.getCount()) {
- result = -1;
- }
- return result;
- }
-}
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -44,6 +44,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(AliasAction.class);
+ private static final long serialVersionUID = 1L;
protected String redirectTo = "/";
protected String alias;
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -1,140 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.struts2.interceptor.ServletResponseAware;
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowConfig;
-import org.chorem.bow.BowUtils;
-import org.chorem.bow.BowUser;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * Traite toutes les demandes faite via l'opensearch
- * a:, :, t:, ...
- *
- * @author poussin
- */
-public class OpenSearchResultAction extends BowBaseAction implements ServletResponseAware {
- private static final long serialVersionUID = -1691325797986483856L;
-
- protected String token;
- protected String redirectTo;
- protected HttpServletResponse response;
- protected String searchLine;
-
- public String getSearchLine() {
- return searchLine;
- }
-
- public void setSearchLine(String searchLine) {
- this.searchLine = searchLine;
- }
-
- /**
- * @return the token
- */
- public String getToken() {
- return token;
- }
-
- /**
- * @param token the token to set
- */
- public void setToken(String token) {
- this.token = token;
- }
-
- /**
- * @return the redirectTo
- */
- public String getRedirectTo() {
- return redirectTo;
- }
-
- @Override
- public void setServletResponse(HttpServletResponse response) {
- this.response = response;
- }
-
- @Override
- public String execute() {
- BowUser user = getBowSession().getUser();
-
- if (searchLine != null && searchLine.matches("^http://[^ ]*")) {
- redirectTo = searchLine;
- } else if (searchLine != null
- && (searchLine.startsWith(":") || searchLine.startsWith("t:"))) {
-
- // Search on tags
- int index = searchLine.indexOf(":");
- searchLine = searchLine.substring(index + 1); //Suppresses first ":"
-
- redirectTo = BowUtils.redirectTo(searchLine, null);
- } else if (searchLine != null && searchLine.startsWith("f:")) {
- // Fulltext search in bow
- String fullText = searchLine.substring(2);
- redirectTo = BowUtils.redirectTo(null, fullText);
- } else if (searchLine != null && searchLine.startsWith("a:")) {
- // Redirects to the requested alias
- String privateAlias = searchLine.substring(2);
- WikittyProxy proxy = getBowProxy();
- Criteria criteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId())
- .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PRIVATEALIAS, privateAlias)
- .criteria();
- String bookmarkId = proxy.findIdByCriteria(criteria);
- // si on retrouve l'alias prive on l'utilise,
- // sinon on espere qu'il existe un alias public portant ce nom
- if (bookmarkId != null) {
- redirectTo = BowConfig.getAliasUrl() + bookmarkId + ".action";
- if (log.isDebugEnabled()) {
- log.debug("Private alias found, redirect to: " + redirectTo);
- }
- } else {
- redirectTo = BowConfig.getAliasUrl() + privateAlias + ".action";
- if (log.isDebugEnabled()) {
- log.debug("Private alias not found, redirect to: " + redirectTo);
- }
- }
- } else {
- // Search on the chosen search engine
- BowUser pref = getBowSession().getUser();
-
- String searchEngineURL = pref.getSearchEngineUrlResults();
- if (StringUtils.isEmpty(searchEngineURL)) {
- searchEngineURL = BowConfig.getSearchEngine();
- }
- searchEngineURL = searchEngineURL.replace("{searchTerms}", searchLine);
- searchEngineURL = response.encodeRedirectURL(searchEngineURL);
- redirectTo = searchEngineURL;
- }
- return SUCCESS;
- }
-}
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -1,176 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import com.opensymphony.xwork2.ActionContext;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.io.input.ReaderInputStream;
-import org.apache.commons.lang.StringUtils;
-import org.chorem.bow.BookmarkUtils;
-
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.OpenSearchActions;
-import org.chorem.bow.BowUser;
-import org.chorem.bow.BowUtils;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.search.FacetTopic;
-import org.nuiton.wikitty.search.PagedResult;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.entities.Wikitty;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * Retourne les suggestions pour l'opensearch en fonction de ce qui a ete deja
- * saisi
- *
- * @author poussin
- */
-public class OpenSearchSuggestionAction extends BowBaseAction {
-
- private static final long serialVersionUID = 3973618635494129146L;
-
- static public OpenSearchSuggestionAction getAction() {
- Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY);
- return (OpenSearchSuggestionAction) action;
- }
-
- /** le token utilise pour faire l'appel (permanent ou temporaire) */
- protected String token;
- protected String searchLine;
- protected InputStream inputStream;
-
- public InputStream getInputStream() {
- return inputStream;
- }
-
- public String getToken() {
- return token;
- }
-
- public void setToken(String token) {
- this.token = token;
- }
-
- public String getSearchLine() {
- return searchLine;
- }
-
- public void setSearchLine(String searchLine) {
- this.searchLine = searchLine;
- }
-
- @Override
- public String execute() {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Start opensearch suggest for '%s'", searchLine));
- }
-
- // preparation de la reponse. Un toString sur une liste retourne
- // la bonne syntaxe pour une reponse json :) si on triche un peu
- // en ajoutant des '' pour les chaines
- List json = new ArrayList();
- List<String> completions = new ArrayList<String>();
- List<String> descriptions = new ArrayList<String>();
- List<String> queryUrls = new ArrayList<String>();
-
- json.add("'" + searchLine + "'");
- json.add(completions);
- json.add(descriptions);
- json.add(queryUrls);
-
- if (searchLine != null) {
- BowUser user = getBowSession().getUser();
- WikittyProxy proxy = getBowProxy();
-
- // on ajoute * a la fin du dernier tag, car il n'est peut-etre pas fini
- String searchLineStar = searchLine + "*";
-
- // on recupere le dernier tag en train d'etre ecrit
- String lastTag;
- if (searchLine.contains(" ")) {
- lastTag = StringUtils.substringAfterLast(searchLine, " ");
- } else {
- lastTag = searchLine;
- }
-
- Set<String> searchLineList = BowUtils.getWords(searchLineStar);
-
- Search search = BookmarkUtils.addEqUser(Search.query(), user.getWikittyId());
- search.exteq(BowBookmark.EXT_WIKITTYLABEL);
- search.contains(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, searchLineList);
-
- Criteria criteria= search
- .criteria()
- .setEndIndex(0) // on ne veut aucun resultat, c'est la facet dont on a besoin
- .setFacetMinCount(1) // on demande meme les labels avec 1 seul item
- .setFacetLimit(Integer.MAX_VALUE) // ne ne met pas -1 pour qu'il soit trie par ordre de count
- .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
-
- PagedResult<Wikitty> result = proxy.findAllByCriteria(criteria);
- // lorsqu'on demande tout (facetLimit(-1)), les topics sont trie
- // alphabetiquement pas besoin de les retrier
- List<FacetTopic> topics = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
- if (log.isTraceEnabled()) {
- log.trace("all topics: %s" + topics);
- }
-
- // on en retourne un suggestion que le meme nombre de tag qu'il souhaite
- // voir affiche
- int count = user.getTags();
- for(FacetTopic t : topics) {
- // on ne met que les topics qui qui commence par lastTag
- String completion = t.getTopicName();
- if (log.isTraceEnabled()) {
- log.trace(String.format("'%s' startsWith '%s' ? ", completion, lastTag));
- }
- if (completion.startsWith(lastTag)) {
- String description = _("%s results",t.getCount());
- String queryUrl = String.format("%shome?token=%s&tagLine=%s",
- getConfig().getBowUrl(),
- token,
- searchLine + StringUtils.removeStart(completion, lastTag));
-
- completions.add("'" + completion + "'");
- descriptions.add("'" + description + "'");
- queryUrls.add("'" + queryUrl + "'");
-
- // on s'arrete si l'on en a assez
- count--;
- if (count <= 0) {
- break;
- }
- }
- }
- }
- if (log.isDebugEnabled()) {
- log.debug(String.format("opensearch suggest result: %s", json));
- }
- inputStream = new ReaderInputStream(new StringReader(json.toString()));
- return SUCCESS;
- }
-}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java (from rev 313, trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -0,0 +1,121 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.opensearch;
+
+import org.apache.commons.lang.StringUtils;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.action.BowBaseAction;
+
+/**
+ * Traite toutes les demandes faite via l'opensearch
+ * a:, :, t:, ...
+ *
+ * Cette classe recherche le prefix et redirige vers la bonne methode execute.
+ * Les classes filles n'ont plus qu'a implanter les methodes
+ *
+ * @author poussin
+ */
+abstract public class OpenSearchBaseAction extends BowBaseAction {
+ private static final long serialVersionUID = 1L;
+
+ /** [in] le token d'identification */
+ protected String token;
+ /** [in] la ligne de recherche soumise par l'utilisateur */
+ protected String searchLine;
+
+ /**
+ * [out] le prefix trouve ou calculer par rapport a searchLine
+ * avoir acces a cette valeur, peut-etre utile dans certaine implantation
+ * de {@link #executeNotSupportedPrefixAction}
+ */
+ protected String prefix;
+
+ public String getSearchLine() {
+ return searchLine;
+ }
+
+ public void setSearchLine(String searchLine) {
+ this.searchLine = searchLine;
+ }
+
+ /**
+ * @return the token
+ */
+ public String getToken() {
+ return token;
+ }
+
+ /**
+ * @param token the token to set
+ */
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ abstract protected String executeTagSearchAction(String query);
+
+ abstract protected String executeFulltextSearchAction(String query);
+
+ abstract protected String executeWebSearchAction(String query);
+
+ abstract protected String executeAliasSearchAction(String privateAlias);
+
+ abstract protected String executeNotSupportedPrefixAction(String query);
+
+ @Override
+ public String execute() {
+ BowUser user = getBowSession().getUser();
+
+ String prefixSeparator = user.getPrefixSeparator();
+ prefix = StringUtils.substringBefore(searchLine, prefixSeparator);
+ String query = StringUtils.substringAfter(searchLine, prefixSeparator);
+
+ if (StringUtils.isEmpty(prefix)) {
+ // on a le separateur mais pas de prefix
+ prefix = user.getDefaultPrefix();
+ } else if (StringUtils.equals(searchLine, query)) {
+ // on a pas de separateur
+ prefix = user.getDefaultAction();
+ }
+
+ String result = SUCCESS;
+ if (StringUtils.equals(prefix, user.getTagSearchPrefix())) {
+ result = executeTagSearchAction(query);
+ } else if (StringUtils.equals(prefix, user.getFullTextSearchPrefix())) {
+ result = executeFulltextSearchAction(query);
+ } else if (StringUtils.equals(prefix, user.getWebSearchPrefix())) {
+ result = executeWebSearchAction(query);
+ } else if (StringUtils.equals(prefix, user.getAliasPrefix())) {
+ result = executeAliasSearchAction(query);
+ } else {
+ result = executeNotSupportedPrefixAction(query);
+ }
+
+ return result;
+ }
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java (from rev 313, trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -0,0 +1,120 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.opensearch;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.interceptor.ServletResponseAware;
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowConfig;
+import org.chorem.bow.BowUtils;
+import org.chorem.bow.BowUser;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Traite toutes les demandes faite via l'opensearch
+ * a:, :, t:, ...
+ *
+ * @author poussin
+ */
+public class OpenSearchResultAction extends OpenSearchBaseAction implements ServletResponseAware {
+ private static final long serialVersionUID = 1L;
+
+ protected String redirectTo;
+ protected HttpServletResponse response;
+
+ /**
+ * @return the redirectTo
+ */
+ public String getRedirectTo() {
+ return redirectTo;
+ }
+
+ @Override
+ public void setServletResponse(HttpServletResponse response) {
+ this.response = response;
+ }
+
+ protected String executeTagSearchAction(String query) {
+ redirectTo = BowUtils.redirectTo(searchLine, null);
+ return SUCCESS;
+ }
+
+ protected String executeFulltextSearchAction(String query) {
+ redirectTo = BowUtils.redirectTo(null, searchLine);
+ return SUCCESS;
+ }
+
+ protected String executeWebSearchAction(String query) {
+ // Search on the chosen search engine
+ BowUser user = getBowSession().getUser();
+
+ String result = user.getSearchEngineUrlResults();
+ if (StringUtils.isEmpty(result)) {
+ result = BowConfig.getSearchEngine();
+ }
+ result = result.replace("{searchTerms}", query);
+ result = response.encodeRedirectURL(result);
+ redirectTo = result;
+ return SUCCESS;
+ }
+
+ protected String executeAliasSearchAction(String privateAlias) {
+ BowUser user = getBowSession().getUser();
+ WikittyProxy proxy = getBowProxy();
+ Criteria criteria = Search.query()
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId())
+ .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PRIVATEALIAS, privateAlias)
+ .criteria();
+ String bookmarkId = proxy.findIdByCriteria(criteria);
+
+ String result;
+ // si on retrouve l'alias prive on l'utilise,
+ // sinon on espere qu'il existe un alias public portant ce nom
+ if (bookmarkId != null) {
+ result = BowConfig.getAliasUrl() + bookmarkId + ".action";
+ if (log.isDebugEnabled()) {
+ log.debug("Private alias found, redirect to: " + result);
+ }
+ } else {
+ result = BowConfig.getAliasUrl() + privateAlias + ".action";
+ if (log.isDebugEnabled()) {
+ log.debug("Private alias not found, redirect to: " + result);
+ }
+ }
+ redirectTo = result;
+ return SUCCESS;
+ }
+
+ @Override
+ protected String executeNotSupportedPrefixAction(String query) {
+ // prefix inconnu, on va sur la home
+ redirectTo = BowUtils.redirectTo(null, null);
+ return SUCCESS;
+ }
+
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java (from rev 315, trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java 2011-08-21 18:16:39 UTC (rev 317)
@@ -0,0 +1,231 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.opensearch;
+
+import com.opensymphony.xwork2.ActionContext;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.io.input.ReaderInputStream;
+import org.apache.commons.lang.StringUtils;
+import org.chorem.bow.BookmarkUtils;
+
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.BowUtils;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.FacetTopic;
+import org.nuiton.wikitty.search.PagedResult;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Retourne les suggestions pour l'opensearch en fonction de ce qui a ete deja
+ * saisi
+ *
+ * @author poussin
+ */
+public class OpenSearchSuggestionAction extends OpenSearchBaseAction {
+ private static final long serialVersionUID = 1L;
+
+ static public OpenSearchSuggestionAction getAction() {
+ Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY);
+ return (OpenSearchSuggestionAction) action;
+ }
+
+ protected InputStream inputStream;
+
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ @Override
+ protected String executeTagSearchAction(String query) {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Start opensearch tag suggest for '%s'", query));
+ }
+
+ // preparation de la reponse. Un toString sur une liste retourne
+ // la bonne syntaxe pour une reponse json :) si on triche un peu
+ // en ajoutant des '' pour les chaines
+ List json = new ArrayList();
+ List<String> completions = new ArrayList<String>();
+ List<String> descriptions = new ArrayList<String>();
+ List<String> queryUrls = new ArrayList<String>();
+
+ json.add("'" + query + "'");
+ json.add(completions);
+ json.add(descriptions);
+ json.add(queryUrls);
+
+ if (query != null) {
+ BowUser user = getBowSession().getUser();
+ WikittyProxy proxy = getBowProxy();
+
+ // on ajoute * a la fin du dernier tag, car il n'est peut-etre pas fini
+ String searchLineStar = query + "*";
+
+ // on recupere le dernier tag en train d'etre ecrit
+ String lastTag;
+ if (query.contains(" ")) {
+ lastTag = StringUtils.substringAfterLast(query, " ");
+ } else {
+ lastTag = query;
+ }
+
+ Set<String> searchLineList = BowUtils.getWords(searchLineStar);
+
+ Search search = BookmarkUtils.addEqUser(Search.query(), user.getWikittyId());
+ search.exteq(BowBookmark.EXT_WIKITTYLABEL);
+ search.contains(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, searchLineList);
+
+ Criteria criteria= search
+ .criteria()
+ .setEndIndex(0) // on ne veut aucun resultat, c'est la facet dont on a besoin
+ .setFacetMinCount(1) // on demande meme les labels avec 1 seul item
+ .setFacetLimit(Integer.MAX_VALUE) // ne ne met pas -1 pour qu'il soit trie par ordre de count
+ .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
+
+ PagedResult<Wikitty> result = proxy.findAllByCriteria(criteria);
+ // lorsqu'on demande tout (facetLimit(-1)), les topics sont trie
+ // alphabetiquement pas besoin de les retrier
+ List<FacetTopic> topics = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
+ if (log.isTraceEnabled()) {
+ log.trace("all topics: %s" + topics);
+ }
+
+ // on en retourne un suggestion que le meme nombre de tag qu'il souhaite
+ // voir affiche
+ int count = user.getTags();
+ for(FacetTopic t : topics) {
+ // on ne met que les topics qui qui commence par lastTag
+ String completion = t.getTopicName();
+ if (log.isTraceEnabled()) {
+ log.trace(String.format("'%s' startsWith '%s' ? ", completion, lastTag));
+ }
+ if (completion.startsWith(lastTag)) {
+ String description = _("%s results",t.getCount());
+ String tags = query + StringUtils.removeStart(completion, lastTag);
+ String queryUrl = getConfig().getBowUrl() + BowUtils.redirectTo(tags, null);
+
+ completions.add("'" + completion + "'");
+ descriptions.add("'" + description + "'");
+ queryUrls.add("'" + queryUrl + "'");
+
+ // on s'arrete si l'on en a assez
+ count--;
+ if (count <= 0) {
+ break;
+ }
+ }
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("opensearch suggest result: %s", json));
+ }
+ inputStream = new ReaderInputStream(new StringReader(json.toString()));
+ return SUCCESS;
+ }
+
+ @Override
+ protected String executeFulltextSearchAction(String query) {
+ return executeNotSupportedPrefixAction(query);
+ }
+
+ @Override
+ protected String executeWebSearchAction(String query) {
+ return executeNotSupportedPrefixAction(query);
+ }
+
+ @Override
+ protected String executeAliasSearchAction(String privateAlias) {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Start opensearch alias suggest for '%s'", privateAlias));
+ }
+
+ // preparation de la reponse. Un toString sur une liste retourne
+ // la bonne syntaxe pour une reponse json :) si on triche un peu
+ // en ajoutant des '' pour les chaines
+ List json = new ArrayList();
+ List<String> completions = new ArrayList<String>();
+ List<String> descriptions = new ArrayList<String>();
+ List<String> queryUrls = new ArrayList<String>();
+
+ json.add("'" + privateAlias + "'");
+ json.add(completions);
+ json.add(descriptions);
+ json.add(queryUrls);
+
+ if (privateAlias != null) {
+ BowUser user = getBowSession().getUser();
+ WikittyProxy proxy = getBowProxy();
+
+ // on ajoute * a la fin, car il n'est peut-etre pas fini
+ String privateAliasStar = privateAlias + "*";
+
+ Search search = BookmarkUtils.addEqUser(Search.query(), user.getWikittyId());
+ search.eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PRIVATEALIAS, privateAliasStar);
+
+ Criteria criteria= search.criteria()
+ .setEndIndex(15); // on recupere que les 15 premiers resultats
+
+ PagedResult<BowBookmark> result = proxy.findAllByCriteria(BowBookmark.class, criteria);
+
+ for(BowBookmark b: result) {
+ String completion = b.getPrivateAlias();
+ String description = b.getDescription();
+ String queryUrl = String.format("%s%s?token=%s",
+ getConfig().getAliasUrl(), completion, token);
+ completions.add("'" + completion + "'");
+ descriptions.add("'" + description + "'");
+ queryUrls.add("'" + queryUrl + "'");
+ }
+
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("opensearch alias suggest result: %s", json));
+ }
+ inputStream = new ReaderInputStream(new StringReader(json.toString()));
+ return SUCCESS;
+ }
+
+ /**
+ * On ne renvoie aucune suggestion
+ *
+ * @param prefix
+ * @param query
+ * @return
+ */
+ @Override
+ protected String executeNotSupportedPrefixAction(String query) {
+ String result = String.format("['%s', [], [], []]", query);
+ inputStream = new ReaderInputStream(new StringReader(result));
+ return SUCCESS;
+ }
+
+
+}
\ No newline at end of file
Modified: trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties
===================================================================
--- trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties 2011-08-21 18:16:39 UTC (rev 317)
@@ -31,6 +31,13 @@
bow.config.bow.url.description=
bow.config.configFileName.description=
bow.config.data.dir.description=
+bow.config.opensearch.alias.prefix.description=
+bow.config.opensearch.default.action.description=
+bow.config.opensearch.default.prefix.description=
+bow.config.opensearch.fulltext.search.prefix.description=
+bow.config.opensearch.prefix.separator.description=
+bow.config.opensearch.tag.search.prefix.description=
+bow.config.opensearch.web.search.prefix.description=
bow.config.search.engine.description=
bow.config.servlet.bow.description=
bow.error.internal=An internal error occurred, please contact an administrator if the problem persists
Modified: trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties
===================================================================
--- trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties 2011-08-21 16:06:25 UTC (rev 316)
+++ trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties 2011-08-21 18:16:39 UTC (rev 317)
@@ -31,6 +31,13 @@
bow.config.bow.url.description=
bow.config.configFileName.description=
bow.config.data.dir.description=
+bow.config.opensearch.alias.prefix.description=
+bow.config.opensearch.default.action.description=
+bow.config.opensearch.default.prefix.description=
+bow.config.opensearch.fulltext.search.prefix.description=
+bow.config.opensearch.prefix.separator.description=
+bow.config.opensearch.tag.search.prefix.description=
+bow.config.opensearch.web.search.prefix.description=
bow.config.search.engine.description=
bow.config.servlet.bow.description=
bow.error.internal=Une erreur interne est survenue, merci de contacter un administrateur si cette erreur persiste
Modified: trunk/bow-ui/src/main/xmi/bow.zargo
===================================================================
(Binary files differ)
1
0
Author: bpoussin
Date: 2011-08-21 18:06:25 +0200 (Sun, 21 Aug 2011)
New Revision: 316
Url: http://chorem.org/repositories/revision/bow/316
Log:
Anomalie #439: add url scriptlet in preference page don't work
Modified:
trunk/bow-ui/src/main/webapp/jsp/preferences.jsp
Modified: trunk/bow-ui/src/main/webapp/jsp/preferences.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/preferences.jsp 2011-08-20 12:14:02 UTC (rev 315)
+++ trunk/bow-ui/src/main/webapp/jsp/preferences.jsp 2011-08-21 16:06:25 UTC (rev 316)
@@ -45,13 +45,13 @@
<ul>
<li>
<s:a title="%{getText('bow.rightMenu.bookmark.temporaryLinkDescription')}"
- 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='%{config.bowUrl}addUrl.action?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);">
+ 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='%{config.bowUrl}addUrl.action?token=%{temporaryToken}&link='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">
<s:text name="bow.rightMenu.bookmark.temporaryLink" />
</s:a>
</li>
<li>
<s:a title="%{getText('bow.rightMenu.bookmark.permanentLinkDescription')}"
- 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='%{config.bowUrl}addUrl.action?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);">
+ 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='%{config.bowUrl}addUrl.action?token=%{permanentToken}&link='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">
<s:text name="bow.rightMenu.bookmark.permanentLink" />
</s:a>
</li>
1
0
r315 - in trunk/bow-ui/src/main: java/org/chorem/bow java/org/chorem/bow/action java/org/chorem/bow/action/bookmark java/org/chorem/bow/action/preference resources resources/i18n
by bpoussin@users.chorem.org 20 Aug '11
by bpoussin@users.chorem.org 20 Aug '11
20 Aug '11
Author: bpoussin
Date: 2011-08-20 14:14:02 +0200 (Sat, 20 Aug 2011)
New Revision: 315
Url: http://chorem.org/repositories/revision/bow/315
Log:
Evolution #438: Refactore source code and simplify all
- gros refactore de opensearch suggest, prend 25ms au lieu de 9s :D et surtout fonctionne ;)
Removed:
trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java
Modified:
trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java
trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties
trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties
trunk/bow-ui/src/main/resources/struts.xml
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-20 12:14:02 UTC (rev 315)
@@ -42,6 +42,11 @@
*/
public static Log log = LogFactory.getLog(BookmarkUtils.class);
+ /**
+ * Ajoute a la recherche tout ce qui est necessaire pour connaitre
+ * toutes les informations que l'utilisateur peut voir, meme s'il n'est
+ * pas le createur de ce bookmark
+ */
static public Search addEqUser(Search search, String userId) {
Search result = search.or();
result = result.eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId);
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java 2011-08-20 12:14:02 UTC (rev 315)
@@ -1,162 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.wikitty.search.FacetTopic;
-
-/**
- *
- * @author bbrossaud
- */
-public class OpenSearchActions {
-
- protected List<BowBookmark> bookmarkList = new ArrayList<BowBookmark>();
- protected List<FacetTopic> suggestions = new ArrayList<FacetTopic>();
- protected String[] search;
-
- public void findSuggestions(Set<String> searchLine) {
- int size = searchLine.size();
- search = searchLine.toArray(new String[size]);
- String word = search[size - 1];
- List<FacetTopic> save = new ArrayList<FacetTopic>(suggestions);
- for (FacetTopic topic : save) {
- String tag = topic.getTopicName();
- if (tag != null) {
- if (tag.indexOf(word) != 0 || searchLine.contains(tag)) {
- suggestions.remove(topic);
- }
- }
- }
- List<BowBookmark> cpy = new ArrayList<BowBookmark>(bookmarkList);
- for (BowBookmark bookmark : cpy) {
- Set<String> tags = bookmark.getLabels();
- boolean delete = true;
- for (FacetTopic topic : suggestions) {
- String name = topic.getTopicName();
- if (tags != null && tags.contains(name)) {
- delete = false;
- break;
- }
- }
- if (delete) {
- bookmarkList.remove(bookmark);
- }
- }
- Collections.sort(suggestions, new SuggestionsComparator());
- }
-
- protected boolean bookmarkHasTag(BowBookmark bookmark, String tag) {
- Set<String> tagList = bookmark.getLabels();
- if (tagList != null) {
- if (tagList.contains(tag)) {
- return true;
- }
- }
- return false;
- }
-
- public void setBookmarkList(List<BowBookmark> bookmarks) {
- if (bookmarks != null) {
- List<BowBookmark> newList = new ArrayList<BowBookmark>(bookmarks);
- bookmarkList = newList;
- }
- }
-
- public String getJsonResult() {
- String str = "[";
-
- str += "\"" + StringUtils.join(search, ' ') + "\",";
- str += getJsonSuggestions();
- str += ",";
- str += getJsonDescription();
- str += "]";
- return str;
- }
-
- public String getJsonSuggestions() {
- String str = "[";
- String srch = "";
- Iterator<FacetTopic> it = suggestions.iterator();
- if (search.length > 1) {
- srch = StringUtils.join(search, ' ', 0, search.length - 1);
- srch += " ";
- }
- while (it.hasNext()) {
- FacetTopic su = it.next();
- str += "\"" + srch + su.getTopicName() + "\"";
- if (it.hasNext()) {
- str += ",";
- }
- }
- if (bookmarkList.size() <= 5 && suggestions.size() > 0) {
- for (BowBookmark bookmark : bookmarkList) {
- str += ",\"" + bookmark.getLink() + "\"";
- }
- }
- str += "]";
- return str;
- }
-
- public String getJsonDescription() {
- String str = "[";
- Iterator<FacetTopic> it = suggestions.iterator();
- while (it.hasNext()) {
- FacetTopic su = it.next();
- str += "\"" + su.getCount() + " results\"";
- if (it.hasNext()) {
- str += ",";
- }
- }
- str += "]";
- return str;
- }
-
- public void setSearch(String[] tab) {
- search = tab;
- }
-
- public void setSuggestionList(List<FacetTopic> list) {
- if (list != null) {
- suggestions = new ArrayList<FacetTopic>(list);
- }
- }
-
- public List<BowBookmark> getBookmarkList() {
- return bookmarkList;
- }
-
- public String[] getSearch() {
- return search;
- }
-
- public List<FacetTopic> getSuggestionList() {
- return suggestions;
- }
-}
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-20 12:14:02 UTC (rev 315)
@@ -24,9 +24,14 @@
package org.chorem.bow.action;
import com.opensymphony.xwork2.ActionContext;
+import java.io.InputStream;
+import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.apache.commons.io.input.ReaderInputStream;
+import org.apache.commons.lang.StringUtils;
+import org.chorem.bow.BookmarkUtils;
import org.chorem.bow.BowBookmark;
import org.chorem.bow.OpenSearchActions;
@@ -36,6 +41,7 @@
import org.nuiton.wikitty.search.FacetTopic;
import org.nuiton.wikitty.search.PagedResult;
import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.entities.Wikitty;
import org.nuiton.wikitty.search.Search;
/**
@@ -53,9 +59,23 @@
return (OpenSearchSuggestionAction) action;
}
- protected OpenSearchActions openSearchActions;
+ /** le token utilise pour faire l'appel (permanent ou temporaire) */
+ protected String token;
protected String searchLine;
+ protected InputStream inputStream;
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
public String getSearchLine() {
return searchLine;
}
@@ -64,47 +84,93 @@
this.searchLine = searchLine;
}
-
- public OpenSearchActions getOpenSearchActions() {
- return openSearchActions;
- }
-
@Override
public String execute() {
- BowUser user = getBowSession().getUser();
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Start opensearch suggest for '%s'", searchLine));
+ }
+ // preparation de la reponse. Un toString sur une liste retourne
+ // la bonne syntaxe pour une reponse json :) si on triche un peu
+ // en ajoutant des '' pour les chaines
+ List json = new ArrayList();
+ List<String> completions = new ArrayList<String>();
+ List<String> descriptions = new ArrayList<String>();
+ List<String> queryUrls = new ArrayList<String>();
+
+ json.add("'" + searchLine + "'");
+ json.add(completions);
+ json.add(descriptions);
+ json.add(queryUrls);
+
if (searchLine != null) {
- openSearchActions = new OpenSearchActions();
+ BowUser user = getBowSession().getUser();
WikittyProxy proxy = getBowProxy();
- Set<String> searchLineList = BowUtils.getWords(searchLine);
+ // on ajoute * a la fin du dernier tag, car il n'est peut-etre pas fini
+ String searchLineStar = searchLine + "*";
+
+ // on recupere le dernier tag en train d'etre ecrit
+ String lastTag;
+ if (searchLine.contains(" ")) {
+ lastTag = StringUtils.substringAfterLast(searchLine, " ");
+ } else {
+ lastTag = searchLine;
+ }
- if (searchLine.charAt(searchLine.length() - 1) == ' ') {
- searchLineList.add(""); //If the user doesn't type anything, we have to propose suggestions
+ Set<String> searchLineList = BowUtils.getWords(searchLineStar);
+
+ Search search = BookmarkUtils.addEqUser(Search.query(), user.getWikittyId());
+ search.exteq(BowBookmark.EXT_WIKITTYLABEL);
+ search.contains(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, searchLineList);
+
+ Criteria criteria= search
+ .criteria()
+ .setEndIndex(0) // on ne veut aucun resultat, c'est la facet dont on a besoin
+ .setFacetMinCount(1) // on demande meme les labels avec 1 seul item
+ .setFacetLimit(Integer.MAX_VALUE) // ne ne met pas -1 pour qu'il soit trie par ordre de count
+ .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
+
+ PagedResult<Wikitty> result = proxy.findAllByCriteria(criteria);
+ // lorsqu'on demande tout (facetLimit(-1)), les topics sont trie
+ // alphabetiquement pas besoin de les retrier
+ List<FacetTopic> topics = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
+ if (log.isTraceEnabled()) {
+ log.trace("all topics: %s" + topics);
}
- Criteria criteria;
- if (searchLineList.size() > 1) {
- List<String> cpy = new ArrayList<String>(searchLineList);
- cpy.remove(cpy.size() - 1);
- criteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId())
- // TODO poussin 20110216 eq n'est sans doute pas bon, plutot un contains ?
- .eq(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, cpy).criteria()
- .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
- } else {
- criteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId()).criteria()
- .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
+ // on en retourne un suggestion que le meme nombre de tag qu'il souhaite
+ // voir affiche
+ int count = user.getTags();
+ for(FacetTopic t : topics) {
+ // on ne met que les topics qui qui commence par lastTag
+ String completion = t.getTopicName();
+ if (log.isTraceEnabled()) {
+ log.trace(String.format("'%s' startsWith '%s' ? ", completion, lastTag));
+ }
+ if (completion.startsWith(lastTag)) {
+ String description = _("%s results",t.getCount());
+ String queryUrl = String.format("%shome?token=%s&tagLine=%s",
+ getConfig().getBowUrl(),
+ token,
+ searchLine + StringUtils.removeStart(completion, lastTag));
+
+ completions.add("'" + completion + "'");
+ descriptions.add("'" + description + "'");
+ queryUrls.add("'" + queryUrl + "'");
+
+ // on s'arrete si l'on en a assez
+ count--;
+ if (count <= 0) {
+ break;
+ }
+ }
}
- PagedResult<BowBookmark> result = proxy.findAllByCriteria(BowBookmark.class, criteria);
- List<BowBookmark> bookList = result.getAll();
- List<FacetTopic> topics = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
-
- openSearchActions.setBookmarkList(bookList);
- openSearchActions.setSuggestionList(topics);
- openSearchActions.findSuggestions(searchLineList);
}
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("opensearch suggest result: %s", json));
+ }
+ inputStream = new ReaderInputStream(new StringReader(json.toString()));
return SUCCESS;
}
}
\ No newline at end of file
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java 2011-08-20 12:14:02 UTC (rev 315)
@@ -24,8 +24,6 @@
package org.chorem.bow.action.bookmark;
import com.opensymphony.xwork2.ActionContext;
-import java.util.Arrays;
-import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java 2011-08-20 12:14:02 UTC (rev 315)
@@ -86,9 +86,10 @@
if (result == SUCCESS) {
user = proxy.store(user);
getBowSession().setUser(user);
- addActionMessage(_("bow.preferences.update.successful"));
+ addActionMessage(_("bow.preferences.update.successful"));
}
} catch (Exception eee) {
+ result = ERROR;
addActionError(_("bow.error.internal"));
log.error("Can't change site preference", eee);
} finally {
Modified: trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties
===================================================================
--- trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties 2011-08-20 12:14:02 UTC (rev 315)
@@ -1,3 +1,4 @@
+%s\ results=
alias=
bow.action.locale.english=English
bow.action.locale.french=Fran\u00E7ais
Modified: trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties
===================================================================
--- trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties 2011-08-20 12:14:02 UTC (rev 315)
@@ -1,3 +1,4 @@
+%s\ results=
alias=
bow.action.locale.english=English
bow.action.locale.french=Fran\u00E7ais
Modified: trunk/bow-ui/src/main/resources/struts.xml
===================================================================
--- trunk/bow-ui/src/main/resources/struts.xml 2011-08-20 12:12:25 UTC (rev 314)
+++ trunk/bow-ui/src/main/resources/struts.xml 2011-08-20 12:14:02 UTC (rev 315)
@@ -158,7 +158,13 @@
<result type="redirect">${redirectTo}</result>
</action>
<action name="openSearchSuggestion" class="org.chorem.bow.action.OpenSearchSuggestionAction">
- <result>/jsp/suggestions.jsp</result>
+<!-- <result>/jsp/suggestions.jsp</result> -->
+ <result type="stream">
+ <param name="contentType">application/x-suggestions+json</param>
+ <param name="inputName">inputStream</param>
+ <param name="contentDisposition">inline</param>
+ <param name="allowCaching">false</param>
+ </result>
</action>
<action name="*Xml">
<result>/jsp/{1}Xml.jsp</result>
1
0
r314 - trunk/bow-ui/src/main/java/org/chorem/bow/action/preference
by bpoussin@users.chorem.org 20 Aug '11
by bpoussin@users.chorem.org 20 Aug '11
20 Aug '11
Author: bpoussin
Date: 2011-08-20 14:12:25 +0200 (Sat, 20 Aug 2011)
New Revision: 314
Url: http://chorem.org/repositories/revision/bow/314
Log:
Evolution #438: Refactore source code and simplify all
- suppression de la dependance a ServletRequest
Modified:
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java 2011-08-20 00:51:36 UTC (rev 313)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java 2011-08-20 12:12:25 UTC (rev 314)
@@ -34,10 +34,8 @@
import java.util.List;
import java.util.Set;
-import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
-import org.apache.struts2.interceptor.ServletResponseAware;
import org.chorem.bow.BowBookmark;
import org.chorem.bow.BookmarkUtils;
import org.chorem.bow.BowUser;
@@ -51,16 +49,11 @@
*
* @author poussin
*/
-public class ExportBookmarksAction extends BowBaseAction implements ServletResponseAware {
+public class ExportBookmarksAction extends BowBaseAction {
private static final long serialVersionUID = 45880214686011946L;
- protected HttpServletResponse response;
+
protected InputStream inputStream;
- @Override
- public void setServletResponse(HttpServletResponse response) {
- this.response = response;
- }
-
public InputStream getInputStream() {
return inputStream;
}
1
0
r313 - in trunk/bow-ui/src/main: java/org/chorem/bow java/org/chorem/bow/action java/org/chorem/bow/action/admin java/org/chorem/bow/action/bookmark java/org/chorem/bow/action/login java/org/chorem/bow/action/preference resources resources/i18n resources/org/chorem/bow/action resources/org/chorem/bow/action/preference webapp/jsp webapp/jsp/inc
by bpoussin@users.chorem.org 20 Aug '11
by bpoussin@users.chorem.org 20 Aug '11
20 Aug '11
Author: bpoussin
Date: 2011-08-20 02:51:36 +0200 (Sat, 20 Aug 2011)
New Revision: 313
Url: http://chorem.org/repositories/revision/bow/313
Log:
Evolution #438: Refactore source code and simplify all
- refactore import/export
- refactore pref action
- repackage des actions
- spliter preferenceAction en plusieurs action (INPUT, user, site, tag, import)
- ajout d'une form pour recherche sur le web
- modif du header des jsp pour utiliser <%-- au lieu de <!--
Added:
trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/
trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/
trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/login/
trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java
trunk/bow-ui/src/main/resources/org/chorem/bow/action/preference/
trunk/bow-ui/src/main/resources/org/chorem/bow/action/preference/UpdateUserAction-validation.xml
Removed:
trunk/bow-ui/src/main/java/org/chorem/bow/action/AddUrlAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteImportAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteSearchResultsAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/EditBookmarkAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/ForgotPasswordAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/GenerateTokenAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/HomeAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/LoginAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/LogoutAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/MigrateDataAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/PreferencesAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/ReIndexationAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/RegisterAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/RemoveBookmarkAction.java
Modified:
trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java
trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java
trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties
trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties
trunk/bow-ui/src/main/resources/struts.xml
trunk/bow-ui/src/main/webapp/jsp/admin.jsp
trunk/bow-ui/src/main/webapp/jsp/editBookmark.jsp
trunk/bow-ui/src/main/webapp/jsp/error.jsp
trunk/bow-ui/src/main/webapp/jsp/forgotPassword.jsp
trunk/bow-ui/src/main/webapp/jsp/home.jsp
trunk/bow-ui/src/main/webapp/jsp/inc/bookmark.jsp
trunk/bow-ui/src/main/webapp/jsp/inc/footer.jsp
trunk/bow-ui/src/main/webapp/jsp/inc/header.jsp
trunk/bow-ui/src/main/webapp/jsp/inc/rightMenu.jsp
trunk/bow-ui/src/main/webapp/jsp/inc/tagsCloud.jsp
trunk/bow-ui/src/main/webapp/jsp/login.jsp
trunk/bow-ui/src/main/webapp/jsp/permanentXml.jsp
trunk/bow-ui/src/main/webapp/jsp/preferences.jsp
trunk/bow-ui/src/main/webapp/jsp/register.jsp
trunk/bow-ui/src/main/webapp/jsp/suggestions.jsp
trunk/bow-ui/src/main/webapp/jsp/temporaryXml.jsp
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -23,11 +23,7 @@
*/
package org.chorem.bow;
-import java.text.ParseException;
import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
@@ -37,9 +33,6 @@
import org.nuiton.util.StringUtil;
import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.search.FacetTopic;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.operators.Element;
import org.nuiton.wikitty.search.Search;
public class BookmarkUtils {
@@ -58,13 +51,8 @@
return search;
}
- static public Criteria getBookmarkListCriteriaByUser(BowUser user) {
- Criteria criteria = getBookmarkListCriteriaByUser(user, null, null, null);
- return criteria;
- }
-
static public Criteria getBookmarkListCriteriaByUser(
- BowUser user, String searchLine, String fullTextLine, String order) {
+ BowUser user, String tagLine, String fullTextLine, String order) {
Search search = Search.query();
BookmarkUtils.addEqUser(search, user.getWikittyId());
@@ -72,8 +60,8 @@
search.keyword(fullTextLine);
}
- if (StringUtils.isNotBlank(searchLine)) {
- Set<String> tags = BowUtils.getWords(searchLine);
+ if (StringUtils.isNotBlank(tagLine)) {
+ Set<String> tags = BowUtils.getWords(tagLine);
search.eq(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, tags);
}
@@ -116,29 +104,6 @@
return criteria;
}
- static public Map<String, Integer> getBookmarksByImportDate(BowSession session, BowUser user) throws ParseException {
- WikittyProxy proxy = session.getProxy();
- Criteria criteria = Search.query()
- .eq(Element.ELT_EXTENSION, BowImport.EXT_BOWIMPORT)
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId()).criteria()
- .addFacetField(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE)
- .setFirstIndex(0).setEndIndex(0);
-
- List<FacetTopic> bookmarksImportDate =
- proxy.findAllByCriteria(BowImport.class, criteria)
- .getTopic(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE);
-
- // Extract imports
- Map<String, Integer> result = new HashMap<String, Integer>();
- for (FacetTopic facet : bookmarksImportDate) {
- String dateAsString = facet.getTopicName();
-
- result.put(dateAsString, facet.getCount());
- }
-
- return result;
- }
-
/**
* @param url String which contains the bookmark url
* @param nameAndTags String which contains the name and the tags of the
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -55,7 +55,7 @@
private static final Log log = LogFactory.getLog(BowSearchResult.class);
/** la ligne contenant les tags a rechercher */
- protected String searchLine;
+ protected String tagLine;
/** la ligne contenant le fulltext a recherche */
protected String fullTextLine;
/** l'ordre souhaite pour l'affichage */
@@ -73,13 +73,13 @@
*
* @param session la session de l'utilisateur sur lequel on peut recuperer
* le proxy et les preferences
- * @param searchLine (optionel) le liste des tags a rechercher
+ * @param tagLine (optionel) le liste des tags a rechercher
* @param fullTextLine (optionel) la chaine fulltext a rechercher
* @param order (optionnel) l'ordre d'affichage du resultat
*/
public BowSearchResult(BowSession session,
- String searchLine, String fullTextLine, String order) {
- this.searchLine = StringUtils.defaultString(searchLine);
+ String tagLine, String fullTextLine, String order) {
+ this.tagLine = StringUtils.defaultString(tagLine);
this.fullTextLine = StringUtils.defaultString(fullTextLine);
this.order = StringUtils.defaultString(order);
@@ -87,7 +87,7 @@
BowProxy proxy = session.getProxy();
Criteria criteria = BookmarkUtils.getBookmarkListCriteriaByUser(
- user, searchLine, fullTextLine, order);
+ user, tagLine, fullTextLine, order);
PagedResult<BowBookmark> result =
proxy.findAllByCriteria(BowBookmark.class, criteria);
@@ -115,7 +115,7 @@
// on ne met pas dans le cloud les tags qui ont servi pour la recherche
List<FacetTopic> save = new ArrayList<FacetTopic>(tagsCloud);
// on recupere les tags dans un set pour optimiser la recherche
- Set<String> tagsSearch = BowUtils.getWords(getSearchLine());
+ Set<String> tagsSearch = BowUtils.getWords(gettagLine());
for(Iterator<FacetTopic> i=tagsCloud.iterator(); i.hasNext();) {
FacetTopic topic = i.next();
@@ -143,8 +143,8 @@
}
}
- public String getSearchLine() {
- return searchLine;
+ public String gettagLine() {
+ return tagLine;
}
public int getFont(int ti) {
@@ -163,7 +163,7 @@
}
public Set<String> getTagsSearch() {
- return BowUtils.getWords(getSearchLine());
+ return BowUtils.getWords(gettagLine());
}
public List<BowBookmark> getBookmarks() {
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -136,21 +136,21 @@
/**
* Redirects the user either on the home page or on the search page
*
- * @param searchLine search line
+ * @param tagLine search line
* @param fullTextLine full text search
* @return the page where the user will be redirected
*/
- static public String redirectTo(String searchLine, String fullTextLine) {
+ static public String redirectTo(String tagLine, String fullTextLine) {
String result = "home.action";
- boolean searchLineNotBlank = StringUtils.isNotBlank(searchLine);
+ boolean tagLineNotBlank = StringUtils.isNotBlank(tagLine);
boolean fullTextLineNotBlank = StringUtils.isNotBlank(fullTextLine);
- if (searchLineNotBlank || fullTextLineNotBlank) {
+ if (tagLineNotBlank || fullTextLineNotBlank) {
result += "?";
- if (searchLineNotBlank) {
- result += "searchLine=" + searchLine;
+ if (tagLineNotBlank) {
+ result += "tagLine=" + tagLine;
}
- if (searchLineNotBlank && fullTextLineNotBlank) {
+ if (tagLineNotBlank && fullTextLineNotBlank) {
result += "&";
}
if (fullTextLineNotBlank) {
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/AddUrlAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/AddUrlAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/AddUrlAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,262 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import org.apache.commons.lang.StringUtils;
-import org.chorem.bow.BookmarkUtils;
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowUser;
-import org.chorem.bow.BowUtils;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.search.PagedResult;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * Ajoute ou modifie un bookmark, soit par le formulaire,
- * soit par un appel javascript
- *
- * @author poussin
- */
-public class AddUrlAction extends BowBaseAction {
-
- private static final long serialVersionUID = 3389170166034184139L;
-
- protected String bookmarkId;
- protected String link;
- protected String name;
- protected String privateAlias;
- protected String publicAlias;
- protected String tags;
- protected String nameAndTags;
- protected String redirectTo;
-
- public String getBookmarkId() {
- return bookmarkId;
- }
-
- public void setBookmarkId(String bookmarkId) {
- this.bookmarkId = bookmarkId;
- }
-
- /**
- * @return the link
- */
- public String getLink() {
- return link;
- }
-
- /**
- * @param link the link to set
- */
- public void setLink(String link) {
- this.link = link;
- }
-
- /**
- * @return the description
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the description to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the privateAlias
- */
- public String getPrivateAlias() {
- return privateAlias;
- }
-
- /**
- * @param alias the privateAlias to set
- */
- public void setPrivateAlias(String alias) {
- this.privateAlias = alias;
- }
-
- public String getPublicAlias() {
- return publicAlias;
- }
-
- public void setPublicAlias(String publicAlias) {
- this.publicAlias = publicAlias;
- }
-
- /**
- * @return the tags
- */
- public String getTags() {
- return tags;
- }
-
- /**
- * @param tags the tags to set
- */
- public void setTags(String tags) {
- this.tags = tags;
- }
-
- /**
- * @return the nameAndTags
- */
- public String getNameAndTags() {
- return nameAndTags;
- }
-
- /**
- * @param nameAndTags the nameAndTags to set
- */
- public void setNameAndTags(String nameAndTags) {
- this.nameAndTags = nameAndTags;
- }
-
- /**
- * @return the redirectTo
- */
- public String getRedirectTo() {
- return redirectTo;
- }
-
- public String execute() {
- try {
- WikittyProxy proxy = getBowProxy();
- BowBookmark bookmark = null;
- BowBookmark bookmarkToModify = null;
-
- BowUser user = getBowSession().getUser();
- String userId = user.getWikittyId();
- if (StringUtils.isNotBlank(bookmarkId)) {
- bookmarkToModify = proxy.restore(BowBookmark.class, bookmarkId);
- }
- if (log.isDebugEnabled()) {
- log.debug("Change old wikitty: " + bookmarkToModify);
- }
-
- // gere le cas d'une mise a jour ou d'un ajout via le formulaire
- if (name != null) {
- // Si l'alias prive souhaite est deja utilise on ne l'accept pas
- // Si l'alias public souhaite est deja utilise on ne l'accept pas
- // TODO sletellier 20110416 : return error message when public or private alias is already used
- Criteria privateAliasCriteria = null;
- Criteria publicAliasCriteria = null;
- if (StringUtils.isNotEmpty(privateAlias)) {
- privateAliasCriteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PRIVATEALIAS, privateAlias)
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
- .criteria().setEndIndex(0);
- }
- if (StringUtils.isNotEmpty(publicAlias)) {
- publicAliasCriteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PUBLICALIAS, publicAlias)
- .criteria().setEndIndex(0);
- }
- PagedResult<String>[] aliasResult = proxy.findAllIdByCriteria(
- privateAliasCriteria, publicAliasCriteria);
-
- if (aliasResult[0] != null && aliasResult[0].getNumFound() > 0) {
- if (bookmarkToModify == null) {
- privateAlias = "";
- } else {
- privateAlias = bookmarkToModify.getPrivateAlias();
- }
- }
- if (aliasResult[1] != null && aliasResult[1].getNumFound() > 0) {
- if (bookmarkToModify == null) {
- publicAlias = "";
- } else {
- publicAlias = bookmarkToModify.getPublicAlias();
- }
- }
-
- if (bookmarkToModify == null) {
- bookmark = BookmarkUtils.createBookmark(
- link, name, tags, user, privateAlias, publicAlias, null);
- } else {
- BookmarkUtils.updateBookmark(
- bookmarkToModify, name, link, tags, privateAlias, publicAlias);
- }
- } else { //This part is for the bookmark addition by script
- if (nameAndTags != null) {
- bookmark = BookmarkUtils.createBookmark(link, nameAndTags, user);
- }
- }
- // si on a reussi a creer le bookmark, on regarde s'il ne faut pas
- // le fusionner avec un deja existant
- if (bookmark != null && !bookmark.getDescription().isEmpty()
- && !bookmark.getOwner().isEmpty()) {
-
- // looking for already bookmark with same url, to fusion them
- String link = bookmark.getLink();
- Criteria criteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_LINK, link)
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
- .criteria();
- BowBookmark oldBookmark =
- proxy.findByCriteria(BowBookmark.class, criteria);
- if(oldBookmark != null) {
- // fusionne les descriptions et les tags
- // par contre on prend le dernier privateAlias prive choisi par
- // l'utilisateur s'il y en a un
- String description = oldBookmark.getDescription();
- if (!StringUtils.isEmpty(bookmark.getDescription())) {
- description += "\n";
- description += BowUtils.formatDate(
- bookmark.getCreationDate()) + ": ";
- description += bookmark.getDescription();
- }
-
- oldBookmark.setDescription(description);
- oldBookmark.addAllLabels(bookmark.getLabels());
- String privateAlias = bookmark.getPrivateAlias();
- if (!StringUtils.isEmpty(privateAlias)) {
- oldBookmark.setPrivateAlias(privateAlias);
- }
-
- bookmark = oldBookmark;
- }
-
- }
-
- if (bookmark != null || bookmarkToModify != null) {
- proxy.store(bookmark, bookmarkToModify); //Stores the bookmark if everything is ok
- addActionMessage(_("bow.bookmark.add.successful"));
- if (log.isDebugEnabled()) {
- log.debug("Adding URL");
- }
- }
- redirectTo = BowUtils.redirectTo(searchLine, fullTextLine);
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return SUCCESS;
- }
-}
\ No newline at end of file
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -23,6 +23,8 @@
*/
package org.chorem.bow.action;
+import java.util.Arrays;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Map;
@@ -48,10 +50,19 @@
public static final String UNTRANSLATED_MARKER = "???";
+ // perhaps use enumeration ?
+ final static protected List<String> possibleOrder = Arrays.asList(
+ "ascName", "descName", "ascClick", "descClick", "ascDate", "descDate");
+
+ public static List<String> getPossibleOrder() {
+ return possibleOrder;
+ }
+
protected BowConfig config = null;
protected Map<String, Object> session;
- protected String searchLine;
+ protected String tagLine;
protected String fullTextLine;
+ protected String order;
public BowConfig getConfig() {
if (config == null) {
@@ -76,17 +87,17 @@
}
/**
- * @return the searchLine
+ * @return the tagLine
*/
- public String getSearchLine() {
- return searchLine;
+ public String getTagLine() {
+ return tagLine;
}
/**
- * @param searchLine the searchLine to set
+ * @param tagLine the tagLine to set
*/
- public void setSearchLine(String searchLine) {
- this.searchLine = searchLine;
+ public void setTagLine(String tagLine) {
+ this.tagLine = tagLine;
}
/**
@@ -102,4 +113,13 @@
public void setFullTextLine(String fullTextLine) {
this.fullTextLine = fullTextLine;
}
+
+ public String getOrder() {
+ return order;
+ }
+
+ public void setOrder(String order) {
+ this.order = order;
+ }
+
}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteImportAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteImportAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteImportAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,87 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import java.util.List;
-
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowImport;
-import org.chorem.bow.BowUser;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Search;
-
-
-/**
- * Supprime un import de bookmark
- *
- * @author poussin
- */
-public class DeleteImportAction extends BowBaseAction {
- private static final long serialVersionUID = 8714394293884265516L;
- protected String date;
-
- /**
- * @return the date
- */
- public String getDate() {
- return date;
- }
- /**
- * @param date the date to set
- */
- public void setDate(String date) {
- this.date = date;
- }
-
- /**
- * Deletes a bookmark import
- */
- public String execute() {
- try {
- if (date != null &&
- 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")) {
- WikittyProxy proxy = getBowProxy();
- BowUser user = getBowSession().getUser();
- Criteria criteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId())
- .eq(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE, date).criteria();
- List<BowImport> bookmarks = proxy.findAllByCriteria(BowImport.class, criteria).getAll();
-
- if (log.isDebugEnabled()) {
- log.debug("Will delete " + bookmarks.size() + " bookmarks");
- }
-
- proxy.delete(bookmarks);
-
- addActionMessage(_("bow.bookmark.import.delete.successful"));
- }
- } catch (Exception e) {
- addActionError(_("bow.error.internal"));
- log.error(e.getMessage(), e);
- }
- return SUCCESS;
- }
-
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteSearchResultsAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteSearchResultsAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteSearchResultsAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,74 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-
-import org.chorem.bow.BookmarkUtils;
-import org.chorem.bow.BowUser;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.WikittyProxy;
-
-/**
- * Supprime des bookmarks qui satisfont le critere de recherche.
- *
- * @author poussin
- */
-public class DeleteSearchResultsAction extends BowBaseAction {
-
- private static final long serialVersionUID = -3903724044644625507L;
-
- /**
- * Deletes the search results
- */
- public String execute() {
- try {
- if (StringUtils.isNotBlank(searchLine)
- || StringUtils.isNotBlank(fullTextLine)) {
- BowUser user = getBowSession().getUser();
- // FIXME poussin 20110817 ATTENTION, la recherche remonte
- // potentiellement des bookmarks qui ne nous appartiennent pas,
- // dans ce cas, ne faudrait-il pas seulement ce supprimer des
- // reader/write/admin ?
- Criteria criteria = BookmarkUtils.getBookmarkListCriteriaByUser(
- user, searchLine, fullTextLine, null);
-
- WikittyProxy proxy = getBowProxy();
- List<String> ids = proxy.findAllIdByCriteria(criteria).getAll();
-
- if (log.isDebugEnabled()) {
- log.debug("Will delete " + ids.size() + " bookmarks");
- }
-
- proxy.delete(ids);
- addActionMessage(_("bow.search.results.deleted"));
- }
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return SUCCESS;
- }
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/EditBookmarkAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/EditBookmarkAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/EditBookmarkAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,75 +0,0 @@
-/*
- * #%L
- * BOW UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowBookmarkImpl;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.search.Search;
-import org.nuiton.wikitty.search.operators.Element;
-
-/**
- * Load a bookmark to display it on modification page, used when javascript
- * is not available on client
- *
- * @author sletellier
- */
-public class EditBookmarkAction extends BowBaseAction {
-
- protected String id;
- protected BowBookmark bookmark;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public BowBookmark getBookmark() {
- if (bookmark == null) {
- bookmark = new BowBookmarkImpl();
- }
- return bookmark;
- }
-
- @Override
- public String execute() throws Exception {
- if (id == null) {
- return SUCCESS;
- }
- try {
- WikittyProxy proxy = getBowProxy();
- Criteria criteria = Search.query()
- .eq(Element.ELT_ID, id).criteria();
- bookmark = proxy.findByCriteria(BowBookmark.class, criteria);
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return SUCCESS;
- }
-}
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,138 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.struts2.interceptor.ServletResponseAware;
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BookmarkUtils;
-import org.chorem.bow.BowUser;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * Export son bookmark au format HTML
- *
- * @author poussin
- */
-public class ExportBookmarksAction extends BowBaseAction implements ServletResponseAware {
- private static final long serialVersionUID = 45880214686011946L;
- protected HttpServletResponse response;
- protected InputStream inputStream;
-
- @Override
- public void setServletResponse(HttpServletResponse response) {
- this.response = response;
- }
-
- public InputStream getInputStream() {
- return inputStream;
- }
-
- /**
- * Export tous les bookmarks au format HTML tel que le fait les navigateurs
- *
- * @param bookmarks List<Bookmarks> bookmarks
- * @param out le flux dans lequel il faut ecrire l'export
- * @return String the html file
- */
- protected void generateExportHtmlBookmark(List<BowBookmark> bookmarks, Writer out) throws IOException {
- out.write("<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
- + "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n"
- + "<DL><p>\n");
- if (bookmarks != null) {
- for (BowBookmark bookmark : bookmarks) {
- if (bookmark != null) {
- out.write("<DT><A HREF=\"");
- out.write(bookmark.getLink() + "\" ");
- Date date = bookmark.getCreationDate();
- if (date != null) {
- long milli = date.getTime();
- String time = String.valueOf(milli / 1000);
- out.write("ADD_DATE=\"" + time + "\" LAST_MODIFIED=\"" + time + "\" ");
- }
- out.write("LAST_CHARSET=\"UTF-8\" ");
- Set<String> tags = bookmark.getLabels();
- if (tags != null && !tags.isEmpty()) {
- out.write("SHORTCUTURL=\""
- + BookmarkUtils.getBookmarkTagsString(bookmark) + "\"");
- }
- out.write(">" + bookmark.getDescription() + "</A>\n");
- }
- }
- }
- out.write("</DL><p>");
- }
-
- /**
- * Exports the bookmarks in HTML format
- */
- @Override
- public String execute() {
- WikittyProxy proxy = getBowProxy();
-
- // get current user
- BowUser user = getBowSession().getUser();
-
- // Get all bookmark for user
- Criteria criteria = Search.query()
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId()).criteria();
- List<BowBookmark> bookmarks = proxy.findAllByCriteria(BowBookmark.class, criteria).getAll();
-
- // Export all
- BufferedWriter out = null;
-
- try {
-
- // Write result in temp file
- File tmp = File.createTempFile("bookmarks", ".tmp.html");
-
- tmp.deleteOnExit();
- out = new BufferedWriter(new FileWriter(tmp));
- generateExportHtmlBookmark(bookmarks, out);
- out.close();
-
- inputStream = new FileInputStream(tmp);
- } catch (IOException eee) {
- log.error("Error when exporting bookmarks to HTML : ", eee);
- } finally {
- IOUtils.closeQuietly(out);
- }
- return SUCCESS;
- }
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/ForgotPasswordAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/ForgotPasswordAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/ForgotPasswordAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,123 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.AddressException;
-
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.commons.lang.StringUtils;
-import org.chorem.bow.BowMail;
-import org.chorem.bow.BowUser;
-import org.nuiton.util.StringUtil;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * Genere un nouveau mot de passe pour l'utilisateur et lui envoie par mail
- * TODO poussin 20110211 il faudrait ajouter une securite pour eviter que
- * quelqu'un s'amuse a demander la modification de password de quelqu'un d'autre
- * toutes les 2s
- * - soit en ne permettant l'envoi qu'une fois par jour
- * - soit ????
- *
- * @author poussin
- */
-public class ForgotPasswordAction extends BowBaseAction {
- private static final long serialVersionUID = -8207951465957204954L;
- protected String email;
-
- /**
- * @return the email
- */
- public String getEmail() {
- return email;
- }
-
- /**
- * @param email the email to set
- */
- public void setEmail(String email) {
- this.email = email;
- }
-
- /**
- * Generates a new password and sends it to the user
- */
- @Override
- public String execute() {
- String result = INPUT;
-
- try {
- if (StringUtils.isNotBlank(email)) {
- email = email.trim();
- WikittyProxy proxy = getBowProxy();
- Criteria criteria = Search.query()
- .eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).criteria();
- BowUser user = proxy.findByCriteria(BowUser.class, criteria);
-
- if (user != null) { //If the email address exists
- String password = "";
- String md5 = "";
-
- password = RandomStringUtils.randomAlphanumeric(20);
- md5 = StringUtil.encodeMD5(password);
- try {
- String mailContent;
-
- mailContent = _("bow.register.mailHi") +
- ",\n\n" + _("bow.register.mailPwd") + ": " +
- password + "\n\n" + _("bow.register.mailEmail") +
- ": " + email + "\n\n";
- BowMail.sendMail(email,
- _("bow.register.mailSubject"),
- mailContent);
-
- //The password is changed only if the mail has been sent
- user.setPassword(md5);
- proxy.store(user);
- } catch (AddressException eee) {
- //If the email address is invalid
- addActionError(_("bow.mail.badFormat"));
- log.error(String.format("Can't send message email to '%s'",
- email), eee);
- } catch (MessagingException eee) {
- addActionError("bow.mail.sendError");
- log.error(String.format("Can't send message email to '%s'",
- email), eee);
- }
- result = SUCCESS;
- } else { //If the email is not associated with an account
- addFieldError("email",
- _("bow.forgotPassword.emailDoesntExist"));
- }
- }
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return result;
- }
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/GenerateTokenAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/GenerateTokenAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/GenerateTokenAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,61 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import org.chorem.bow.BowUser;
-import org.chorem.bow.BowUtils;
-import org.nuiton.wikitty.WikittyProxy;
-
-/**
- * Force la regeneration de token permanent et temporaire
- *
- * @author poussin
- */
-public class GenerateTokenAction extends BowBaseAction {
-
- private static final long serialVersionUID = 1141019772989666309L;
-
- /**
- * Generates a new permanent and temporary token
- */
- @Override
- public String execute() {
- try {
- BowUser user = getBowSession().getUser();
- WikittyProxy proxy = getBowProxy();
-
- String permanentToken = BowUtils.generateToken();
- user.setPermanentToken(permanentToken);
- proxy.store(user);
-
- String temporaryToken = BowUtils.generateToken();
- getBowSession().setTemporaryToken(temporaryToken);
- addActionMessage(_("bow.token.generate.successful"));
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return SUCCESS;
- }
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/HomeAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/HomeAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/HomeAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,119 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import com.opensymphony.xwork2.ActionContext;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.chorem.bow.BowSearchResult;
-import org.chorem.bow.BowSession;
-import org.nuiton.util.TimeLog;
-
-/**
- * Prepare l'affichage de la page d'accueil
- *
- * @author poussin
- */
-public class HomeAction extends BowBaseAction {
-
- private static final Log log = LogFactory.getLog(HomeAction.class);
- private static final TimeLog timeLog = new TimeLog(HomeAction.class);
-
- private static final long serialVersionUID = -3735250067223062719L;
-
- private static final String ALIAS_SERVLET_URL = "aliasServletUrl";
-
- static public HomeAction getAction() {
- Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY);
- return (HomeAction) action;
- }
-
- protected String order;
- protected String addTag;
- final static protected List<String> possibleOrder = Arrays.asList(
- "ascName", "descName", "ascClick", "descClick", "ascDate", "descDate");
-
- protected BowSearchResult searchResult;
-
- public static List<String> getPossibleOrder() {
- return possibleOrder;
- }
-
- public String getOrder() {
- return order;
- }
-
- public void setOrder(String order) {
- this.order = order;
- }
-
- public String getAddTag() {
- return addTag;
- }
-
- public void setAddTag(String addTag) {
- this.addTag = addTag;
- }
-
- public BowSearchResult getSearchResult() {
- return searchResult;
- }
-
- public void setSearchResult(BowSearchResult searchResult) {
- this.searchResult = searchResult;
- }
-
- /**
- * Initializes everything before displaying the home page
- */
- @Override
- public String execute() {
- long start = TimeLog.getTime();
- try {
- // on ajoute les tags qui doivent faire parti de ne nouvelle recherche
- // on restocke dans searchLine pour que la bonne info reapparaisse
- // a l'utilisateur
- searchLine = StringUtils.join(new String[]{searchLine, addTag}, " ").trim();
-
- // si l'ordre souhaite n'existe pas, on utilise l'ordre par defaut
- if (!getPossibleOrder().contains(order)) {
- // default sort order
- // TODO poussin 20110815 rendre configurable par l'utilisateur l'ordre par defaut qu'il prefere
- order = "descClick";
- }
-
- BowSession s = getBowSession();
- searchResult = new BowSearchResult(s, searchLine, fullTextLine, order);
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- timeLog.log(start, "execute");
- return SUCCESS;
- }
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,256 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
-
-import org.chorem.bow.BookmarkUtils;
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowImportHelper;
-import org.chorem.bow.BowUser;
-import org.htmlparser.Node;
-import org.htmlparser.Parser;
-import org.htmlparser.util.NodeList;
-import org.htmlparser.util.ParserException;
-import org.htmlparser.util.SimpleNodeIterator;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.entities.Wikitty;
-
-/**
- * Import un bookmark HTML
- *
- * @author poussin
- */
-public class ImportBookmarksAction extends PreferencesAction {
-
- private static final long serialVersionUID = -5962680416570797028L;
-
- protected File upfile;
- protected String upfileContentType;
- protected String upfileFileName;
-
- /**
- * @return the upfile
- */
- public File getUpfile() {
- return upfile;
- }
-
- /**
- * @param upfile
- * the upfile to set
- */
- public void setUpfile(File upfile) {
- this.upfile = upfile;
- }
-
- /**
- * @return the upfileContentType
- */
- public String getUpfileContentType() {
- return upfileContentType;
- }
-
- /**
- * @param upfileContentType
- * the upfileContentType to set
- */
- public void setUpfileContentType(String upfileContentType) {
- this.upfileContentType = upfileContentType;
- }
-
- /**
- * @return the upfileFileName
- */
- public String getUpfileFileName() {
- return upfileFileName;
- }
-
- /**
- * @param upfileFileName
- * the upfileFileName to set
- */
- public void setUpfileFileName(String upfileFileName) {
- this.upfileFileName = upfileFileName;
- }
-
- /**
- * @param html String html
- * @param name String name
- * @param user User user
- * @return Bookmark the bookmark filled
- */
- protected BowBookmark createBookmarkFromHtml(String html, String name, BowUser user) {
- String link = getUrlFromHtml(html);
- String tags = getTagsFromHtml(html);
- Date date = getDateFromHtml(html);
- BowBookmark bookmark = BookmarkUtils.createBookmark(link, name, tags, user, null, null, date);
- return bookmark;
- }
-
- /**
- * @param html String html
- * @return Date from the html
- */
- protected Date getDateFromHtml(String html) {
- Date date = null;
- if (html != null) {
- Pattern p = Pattern.compile("ADD_DATE=\"([^\"]*)\"");
- Matcher m = p.matcher(html);
- if (m.find()) {
- String str = m.group(1);
- if (str != null && !str.isEmpty()) {
- long time = Long.valueOf(str) * 1000; // the date in ms
- date = new Date(time);
- }
- }
- }
- return date;
- }
-
- /**
- * @param html String html
- * @return url
- */
- protected String getUrlFromHtml(String html) {
- String url = "";
- if (html != null) {
- Pattern p = Pattern.compile("A HREF=\"([^\"]*)\"");
- Matcher m = p.matcher(html);
- if (m.find()) {
- url = m.group(1);
- }
- }
- return url;
- }
-
- protected String getTagsFromHtml(String html) {
- String tags = "";
- if (html != null) {
- Pattern p = Pattern.compile("SHORTCUTURL=\"([^\"]*)\"");
- Matcher m = p.matcher(html);
- if (m.find()) {
- tags = m.group(1);
- }
- }
- return tags;
- }
-
- protected void parseHtmlToBookmarks(NodeList list, BowUser user, Date date,
- List<BowBookmark> bookmarks, Set<String> tagList)
- throws ParserException {
-
- 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 (StringUtils.startsWithIgnoreCase(text, "h3")) { // H3 = folder
- if (StringUtils.isNotBlank(plainText)) {
- tagList.add(plainText); // Adds the folder name to the
- // tagList
- }
- } else if (StringUtils.startsWithIgnoreCase(text, "a href")) { // HREF
- // = new
- // bookmarks
- BowBookmark bookmark = createBookmarkFromHtml(text, plainText, user);
- Wikitty w = getBowProxy().getWikitty(bookmark);
- BowImportHelper.addExtension(w);
- BowImportHelper.setImportDate(w, date);
-
- bookmark.addAllLabels(tagList);
-
- bookmarks.add(bookmark);
- }
- NodeList children = node.getChildren();
-
- if (children != null) {
- parseHtmlToBookmarks(children, user, date, bookmarks,
- // On utilise une nouvelle liste pour les enfants
- // pour eviter que les tags de tous les enfants se
- // retrouve ensemble
- new HashSet<String>(tagList)); // If there is an under node = recursion
- }
- }
- }
-
- @Override
- public String execute() {
-
- log.info("Importing boormarks : " + upfile);
- try {
- BowUser user = getBowSession().getUser();
-
- // Struts limite to html files, is null if not one
- if (upfile != null) {
- WikittyProxy proxy = getBowProxy();
-
- try {
- URL url = upfile.toURI().toURL();
- Parser parser = new Parser(url.openConnection());
- NodeList list = parser.parse(null);
-
- List<BowBookmark> bookmarks = new ArrayList<BowBookmark>();
- parseHtmlToBookmarks(list, user, new Date(), bookmarks,
- new HashSet<String>());
- proxy.store(bookmarks);
-
- addActionMessage(_("bow.bookmark.import.successful"));
- } catch (ParserException eee) {
- log.error(String.format("Can't parse imported file '%s'",
- getUpfileFileName()), eee);
- addActionError(_("bow.bookmark.badFileFormat"));
- } catch (IOException eee) {
- log.error(String.format("Can't read imported file '%s'",
- getUpfileFileName()), eee);
- addActionError(_("bow.error.internal"));
- return ERROR;
- }
- } else {
- addActionError(_("bow.bookmark.badFileFormat"));
- return ERROR;
- }
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- return ERROR;
- }
- return SUCCESS;
- }
-}
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/LoginAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/LoginAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/LoginAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,129 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-package org.chorem.bow.action;
-
-import org.apache.commons.lang.StringUtils;
-
-import org.chorem.bow.BowConfig;
-import org.chorem.bow.BowUser;
-import org.chorem.bow.BowUserImpl;
-import org.nuiton.util.StringUtil;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * authentifie l'utilisateur et place son objet User dans la bow session
- *
- * @author poussin
- */
-public class LoginAction extends BowBaseAction {
-
- private static final long serialVersionUID = 6891064800288772246L;
-
- protected String email;
- protected String password;
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- /**
- * Check password in solr index, if fail try to check password admin in config file
- *
- * @param email non null et non vide email
- * @param password non null et non vide email
- * @return
- */
- protected BowUser checkLogin(String email, String password) {
- BowUser result = null;
-
- WikittyProxy proxy = getBowProxy();
- Criteria criteria = Search.query().eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).
- eq(BowUser.FQ_FIELD_WIKITTYUSER_PASSWORD, password).criteria();
- result = proxy.findByCriteria(BowUser.class, criteria);
-
- if (result == null) {
- // failback: try to authenticate admin with config info
- String configPassword = BowConfig.getAdminPassword(email);
- log.info(String.format("failback password: '%s' configPassword: '%s'",
- password, configPassword));
- if (password.equals(configPassword)) {
- // admin authenticate with config, this is possible when
- // solr index is corrupted or missed. Admin must go to admin
- // page en recreate index
- result = new BowUserImpl();
- result.setLogin(email);
- result.setPassword(configPassword);
- addActionMessage(_("bow.login.admin.failback"));
- log.warn(_("bow.login.admin.failback"));
- } else {
- addActionError(_("bow.login.authenticationFailure"));
- }
- }
- return result;
- }
-
- /**
- * Authenticates the user if his email and password are valid
- */
- @Override
- public String execute() {
- String result = INPUT;
-
- try {
- if (StringUtils.isNotBlank(email)) {
- email = email.trim();
-
- if (StringUtils.isNotEmpty(password)) {
- String md5 = StringUtil.encodeMD5(password);
- BowUser user;
-
- user = checkLogin(email, md5);
- if (user != null) {
- getBowSession().setUser(user);
- result = SUCCESS;
- }
- }
- }
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return result;
- }
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/LogoutAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/LogoutAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/LogoutAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,41 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import org.chorem.bow.BowSession;
-
-/**
- * Invalide la session courante et donc de-authentifie l'utilisateur
- *
- * @author poussin
- */
-public class LogoutAction extends BowBaseAction {
- private static final long serialVersionUID = 4806944250461551896L;
-
- @Override
- public String execute() {
- BowSession.invalidate(session);
- return SUCCESS;
- }
-}
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/MigrateDataAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/MigrateDataAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/MigrateDataAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,94 +0,0 @@
-/*
- * #%L
- * BOW UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.bow.BowMigration04To05;
-import org.chorem.bow.BowMigration06To11;
-import org.chorem.bow.BowSession;
-import org.nuiton.util.VersionUtil;
-import org.nuiton.wikitty.WikittyProxy;
-
-/**
- * Lance la migration des données de la version 0.4 vers 0.5
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public class MigrateDataAction extends BowBaseAction {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(MigrateDataAction.class);
-
- /** Version must be real version, like 0.4, 0.5 or 0.6 */
- protected String versionFrom;
- protected String versionTo;
-
- public void setVersionFrom(String versionFrom) {
- this.versionFrom = versionFrom;
- }
-
- public void setVersionTo(String versionTo) {
- this.versionTo = versionTo;
- }
-
- @Override
- public String execute() {
- try {
- if (StringUtils.isBlank(versionFrom) || StringUtils.isBlank(versionTo)) {
- log.error("Migration action must have to parameter: versionFrom and versionTo");
- } else {
- BowSession session = getBowSession();
- if (session.isAdmin()) { //If is admin
- WikittyProxy proxy = getBowProxy();
-
- if (VersionUtil.equals(versionFrom, "0.4")
- && VersionUtil.equals(versionTo, "0.5")) {
- BowMigration04To05.migrate(proxy);
- addActionMessage(_("bow.admin.dataMigration.success"));
- } else if (VersionUtil.equals(versionFrom, "0.6")
- && VersionUtil.equals(versionTo, "1.1")) {
- BowMigration06To11.migrate(proxy);
- addActionMessage(_("bow.admin.dataMigration.success"));
- } else {
- addActionMessage(String.format(
- "No migration found for %s to %s",
- versionFrom, versionTo));
- }
- }
- }
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return SUCCESS;
- }
-
-}
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchResultAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -47,7 +47,16 @@
protected String token;
protected String redirectTo;
protected HttpServletResponse response;
+ protected String searchLine;
+ public String getSearchLine() {
+ return searchLine;
+ }
+
+ public void setSearchLine(String searchLine) {
+ this.searchLine = searchLine;
+ }
+
/**
* @return the token
*/
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -54,7 +54,17 @@
}
protected OpenSearchActions openSearchActions;
+ protected String searchLine;
+ public String getSearchLine() {
+ return searchLine;
+ }
+
+ public void setSearchLine(String searchLine) {
+ this.searchLine = searchLine;
+ }
+
+
public OpenSearchActions getOpenSearchActions() {
return openSearchActions;
}
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/PreferencesAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/PreferencesAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/PreferencesAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,493 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import org.chorem.bow.BookmarkUtils;
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowPreference;
-import org.chorem.bow.BowProxy;
-import org.chorem.bow.BowUser;
-import com.opensymphony.xwork2.ActionContext;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-import org.chorem.bow.BowSession;
-
-import org.nuiton.util.StringUtil;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.WikittyUtil;
-import org.nuiton.wikitty.entities.Wikitty;
-import org.nuiton.wikitty.entities.WikittyLabel;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.search.FacetTopic;
-import org.nuiton.wikitty.search.PagedResult;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * Change les preferences de l'utilisateur (couleur, password, email, ...)
- *
- * @author poussin
- */
-public class PreferencesAction extends BowBaseAction {
- private static final long serialVersionUID = -58341106356599721L;
-
- static public PreferencesAction getAction() {
- Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY);
- return (PreferencesAction) action;
- }
-
- protected String colors;
- protected String tagsNb;
- protected String bookmarksHomePage;
- protected String searchEngineUrlSuggestions;
- protected String searchEngineUrlResults;
- protected String email;
- protected String newPassword;
- protected String currentPassword;
- protected String confirmNewPassword;
- protected String update;
- protected Map<String, Integer> bookmarksImportDate;
-
- protected List<FacetTopic> labels;
- protected String[] selectedLabels;
- protected String rename;
- protected String delete;
- protected String newLabel;
-
- public String getNewLabel() {
- return newLabel;
- }
-
- public void setNewLabel(String newLabel) {
- this.newLabel = newLabel;
- }
-
- public void setRename(String rename) {
- this.rename = rename;
- }
-
- public String getRename() {
- return rename;
- }
-
- public void setDelete(String delete) {
- this.delete = delete;
- }
-
- public String getDelete() {
- return delete;
- }
-
- /**
- * @return the colors
- */
- public String getColors() {
- return colors;
- }
-
- /**
- * @param colors the colors to set
- */
- public void setColors(String colors) {
- this.colors = colors;
- }
-
- /**
- * @return the tagsNb
- */
- public String getTagsNb() {
- return tagsNb;
- }
-
- /**
- * @param tagsNb the tagsNb to set
- */
- public void setTagsNb(String tagsNb) {
- this.tagsNb = tagsNb;
- }
-
- /**
- * @return the bookmarksHomePage
- */
- public String getBookmarksHomePage() {
- return bookmarksHomePage;
- }
-
- /**
- * @param bookmarksHomePage the bookmarksHomePage to set
- */
- public void setBookmarksHomePage(String bookmarksHomePage) {
- this.bookmarksHomePage = bookmarksHomePage;
- }
-
- /**
- * @return the searchEngineUrlSuggestions
- */
- public String getSearchEngineUrlSuggestions() {
- return searchEngineUrlSuggestions;
- }
-
- /**
- * @param searchEngineUrlSuggestions the searchEngineUrlSuggestions to set
- */
- public void setSearchEngineUrlSuggestions(String searchEngineUrlSuggestions) {
- this.searchEngineUrlSuggestions = searchEngineUrlSuggestions;
- }
-
- /**
- * @return the searchEngineUrlResults
- */
- public String getSearchEngineUrlResults() {
- return searchEngineUrlResults;
- }
-
- /**
- * @param searchEngineUrlResults the searchEngineUrlResults to set
- */
- public void setSearchEngineUrlResults(String searchEngineUrlResults) {
- this.searchEngineUrlResults = searchEngineUrlResults;
- }
-
- /**
- * @return the email
- */
- public String getEmail() {
- return email;
- }
-
- /**
- * @param email the email to set
- */
- public void setEmail(String email) {
- this.email = email;
- }
-
- /**
- * @return the newPassword
- */
- public String getNewPassword() {
- return newPassword;
- }
-
- /**
- * @param newPassword the newPassword to set
- */
- public void setNewPassword(String newPassword) {
- this.newPassword = newPassword;
- }
-
- /**
- * @return the currentPassword
- */
- public String getCurrentPassword() {
- return currentPassword;
- }
-
- /**
- * @param currentPassword the currentPassword to set
- */
- public void setCurrentPassword(String currentPassword) {
- this.currentPassword = currentPassword;
- }
-
- /**
- * @return the confirmNewPassword
- */
- public String getConfirmNewPassword() {
- return confirmNewPassword;
- }
-
- /**
- * @param confirmNewPassword the confirmNewPassword to set
- */
- public void setConfirmNewPassword(String confirmNewPassword) {
- this.confirmNewPassword = confirmNewPassword;
- }
-
- /**
- * @return the update
- */
- public String getUpdate() {
- return update;
- }
-
- /**
- * @param update the update to set
- */
- public void setUpdate(String update) {
- this.update = update;
- }
-
- /**
- * @return the bookmarksImportDate
- */
- public Map<String, Integer> getBookmarksImportDate() {
- return bookmarksImportDate;
- }
-
- /**
- * @param bookmarksImportDate the bookmarksImportDate to set
- */
- public void setBookmarksImportDate(Map<String, Integer> bookmarksImportDate) {
- this.bookmarksImportDate = bookmarksImportDate;
- }
-
- public List<FacetTopic> getLabels() {
- return labels;
- }
-
- public String[] getSelectedLabels() {
- return selectedLabels;
- }
-
- public void setSelectedLabels(String[] selectedLabels) {
- this.selectedLabels = selectedLabels;
- }
-
- /**
- * Date est une date mais au format String qui vient de Solr
- * Elle est de la forme '2011-08-18T00:25:16.028Z'
- * qui n'est pas presentable a l'utilisateur
- * On la remet sous une vrai forme date
- */
- public Date stringToDate(String date) {
- try {
- Date result = WikittyUtil.parseDate(date);
- return result;
-
-// String result = date.replaceAll("[^0-9:-]+", " ").trim();
-// result = result.substring(0, date.lastIndexOf(' '));
- } catch (ParseException eee) {
- return new Date(0);
- }
- }
-
- protected void changePreference(BowPreference preference) {
- preference.setColors(colors);
- if (StringUtils.isNotBlank(tagsNb)) {
- preference.setTags(Integer.valueOf(tagsNb));
- }
- if (StringUtils.isNotBlank(bookmarksHomePage)) {
- preference.setBookmarks(Integer.valueOf(bookmarksHomePage));
- }
- preference.setSearchEngineUrlSuggestions(searchEngineUrlSuggestions);
- preference.setSearchEngineUrlResults(searchEngineUrlResults);
- }
-
- /**
- * Modifie l'email et le password si necessaire. Si la modif est impossible
- * email deja utilise, ou mauvais password, alors la methode return false
- * Si tout ce passe bien, la methode retourne true
- *
- * @param user
- * @return
- */
- protected boolean changeUser(BowUser user) {
- boolean result = true;
-
- if (StringUtils.isNotBlank(email)) {
- Criteria criteria = Search.query().eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).criteria();
- if (log.isDebugEnabled()) {
- log.debug(String.format("Try to find user with email: '%s'", email));
- }
- BowUser find = getBowProxy().findByCriteria(BowUser.class, criteria);
-
- //If this email address isn't already used (or if it hasn't changed)
- if (find == null || find.getLogin().equals(user.getLogin())) {
- email = email.trim();
- user.setLogin(email);
- } else {
- // this email address is already used by someone else
- setEmail(user.getLogin());
-
- // TODO poussin 20110818 addFieldError don't work (no message on web page :(
- // add addActionError to prevent addFieldError that don't work
- addFieldError("email", _("bow.preferences.emailAldyExists"));
- addActionError(_("bow.preferences.emailAldyExists"));
- result = false;
- }
- }
-
- if (result
- && StringUtils.isNotBlank(newPassword)
- && StringUtils.isNotBlank(confirmNewPassword)
- && StringUtils.isNotBlank(currentPassword)) {
- if (newPassword.equals(confirmNewPassword)) {
- currentPassword = StringUtil.encodeMD5(currentPassword);
- if (currentPassword.equals(user.getPassword())) {
- user.setPassword(StringUtil.encodeMD5(newPassword));
- } else {
- // TODO poussin 20110818 addFieldError don't work (no message on web page :(
- // add addActionError to prevent addFieldError that don't work
- addFieldError("currentPassword", _("bow.preferences.badCurrentPassword"));
- addActionError(_("bow.preferences.badCurrentPassword"));
- result = false;
- }
- }
- }
- return result;
- }
-
- /**
- * Charge dans la variable labels tous les labels de l'utilisateur
- * @param proxy
- */
- protected void loadLabels(WikittyProxy proxy) {
- BowUser user = getBowSession().getUser();
- String userId = user.getWikittyId();
-
- Criteria c = Search.query()
- .exteq(BowBookmark.EXT_WIKITTYLABEL)
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
- .criteria().setEndIndex(0) // on ne veut aucun resultat, c'est la facet dont on a besoin
- .setFacetMinCount(1) // on demande meme les labels avec 1 seul item
- .setFacetLimit(-1) // on demande tous les labels
- .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
- PagedResult<Wikitty> result = proxy.findAllByCriteria(c);
- // lorsqu'on demande tout (facetLimit(-1)), les topics sont trie
- // alphabetiquement pas besoin de les retrier
- labels = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
- }
-
- /**
- * Fait les modification demandé par l'utilisateur dans l'interface de
- * preference: renome ou supprime des labels. Si l'utilisateur demande le
- * remplacement de label on indiquant pas de nouveau label, alors la chaine
- * vide est utilisee.
- *
- * @return
- */
- public String adminlabels() {
- String result = SUCCESS;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Selected labels: " + Arrays.toString(selectedLabels));
- log.debug("action delete: " + delete + " rename: " + rename);
- }
-
- List<String> selectedLabelsList = Arrays.asList(selectedLabels);
- boolean isRename = !StringUtils.isEmpty(rename);
-
- BowProxy proxy = getBowProxy();
- BowUser user = getBowSession().getUser();
- String userId = user.getWikittyId();
-
- Criteria c = Search.query()
- .in(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, selectedLabelsList)
- .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
- .criteria();
- PagedResult<WikittyLabel> searchResult =
- proxy.findAllByCriteria(WikittyLabel.class, c);
-
- List<WikittyLabel> toStore = new ArrayList<WikittyLabel>();
- for (WikittyLabel label : searchResult) {
- toStore.add(label);
- Set<String> l = label.getLabels();
- if (l != null) {
- // on fait une copie, car l retourne est non modifiable
- l = new HashSet<String>(l);
- l.removeAll(selectedLabelsList);
- if (isRename) {
- l.add(newLabel);
- }
- label.setLabels(l);
- }
- }
- proxy.store(toStore);
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return result;
-
- }
-
- /**
- * Action executer lorsque l'utilisateur demande la page
- */
- @Override
- public String execute() {
- String result = SUCCESS;
-
- try {
- BowSession session = getBowSession();
- BowProxy proxy = session.getProxy();
- // BowUser extends BowPreference, donc on l'utilise pour tout
- BowUser user = session.getUser();
-
- loadLabels(proxy);
- Map<String,Integer> bookmarksByImportDate =
- BookmarkUtils.getBookmarksByImportDate(session, user);
-
- if (log.isDebugEnabled()) {
- log.debug("bookmarksByImportDate found : " + (bookmarksByImportDate == null ? "null" : bookmarksByImportDate.size()));
- }
- setBookmarksImportDate(bookmarksByImportDate.isEmpty() ? null : bookmarksByImportDate);
-
- if (update != null) {
-
- // modification des preferences du site
- if ("site".equals(update)) { //If the user submitted the form
- changePreference(user);
- user = proxy.store(user);
- getBowSession().setUser(user);
- }
-
- // modification des preferences user (email, password)
- if ("user".equals(update)) {
- if (changeUser(user)) {
- user = proxy.store(user);
- getBowSession().setUser(user);
- result = "update";
- addActionMessage(_("bow.preferences.update.successful"));
- } else {
- result = ERROR;
- }
- }
- }
-
- // reload all time data (otherwize if submit user info, site info disappear)
-
- // If the user didn't submit the form, the fields are filled with
- // the current preferences values
- setEmail(user.getLogin());
- setColors(user.getColors());
- setTagsNb(String.valueOf(user.getTags()));
- setBookmarksHomePage(String.valueOf(user.getBookmarks()));
- setSearchEngineUrlSuggestions(user.getSearchEngineUrlSuggestions());
- setSearchEngineUrlResults(user.getSearchEngineUrlResults());
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return result;
- }
-}
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/ReIndexationAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/ReIndexationAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/ReIndexationAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,54 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import org.chorem.bow.BowSession;
-import org.nuiton.wikitty.WikittyProxy;
-
-/**
- * Lance la reindexation solr
- *
- * @author poussin
- */
-public class ReIndexationAction extends BowBaseAction {
-
- private static final long serialVersionUID = 6226574522402739559L;
-
- @Override
- public String execute() {
- try {
- BowSession session = getBowSession();
- if (session.isAdmin()) { //If is admin
- WikittyProxy proxy = getBowProxy();
-
- proxy.getWikittyService().syncSearchEngine(proxy.getSecurityToken());
- addActionMessage(_("bow.admin.reIndexationDone"));
- }
- } catch (Exception eee) {
- addActionError(("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return SUCCESS;
- }
-}
\ No newline at end of file
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/RegisterAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/RegisterAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/RegisterAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,178 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.AddressException;
-import org.apache.commons.lang.StringUtils;
-
-import org.chorem.bow.BowMail;
-import org.chorem.bow.BowUser;
-import org.chorem.bow.BowUserImpl;
-import org.chorem.bow.BowUtils;
-import org.nuiton.util.StringUtil;
-import org.nuiton.wikitty.search.Criteria;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Search;
-
-/**
- * Enregistre un nouvel utilisateur
- *
- * @author poussin
- */
-public class RegisterAction extends BowBaseAction {
-
- private static final long serialVersionUID = 2204772861770399542L;
-
- protected String email;
- protected String password;
- protected String repeatPassword;
-
- /**
- * @return the email
- */
- public String getEmail() {
- return email;
- }
-
- /**
- * @param email the email to set
- */
- public void setEmail(String email) {
- this.email = email;
- }
-
- /**
- * @return the password
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * @param password the password to set
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /**
- * @return the repeatPassword
- */
- public String getRepeatPassword() {
- return repeatPassword;
- }
-
- /**
- * @param repeatPassword the repeatPassword to set
- */
- public void setRepeatPassword(String repeatPassword) {
- this.repeatPassword = repeatPassword;
- }
-
- /**
- *
- * @param email non null and non blank email
- * @return false if the email address isn't already registered, true
- * otherwise
- */
- protected boolean alreadyRegistered(String email) {
- boolean result = true;
-
- WikittyProxy proxy = getBowProxy();
- //Retrieves user by user name (email)
- Criteria criteria = Search.query()
- .eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).criteria();
-
- result = proxy.findByCriteria(BowUser.class, criteria) != null;
- //If the user doesn't already exist
- if (result) {
- //The email address is already used by someone
- addFieldError("email", _("bow.register.emailAldyUsed"));
- }
- return result;
- }
-
- /**
- * Registers the new user and sends an email to confirm registration
- */
- @Override
- public String execute() {
- String result = INPUT;
-
- try {
- if (StringUtils.isNotBlank(email)) {
- email = email.trim();
- if (StringUtils.isNotBlank(password)) {
- if (!password.equals(repeatPassword)) {
- addActionError(_("bow.register.pwdDontMatch"));
- } else {
- String md5 = StringUtil.encodeMD5(password);
-
- //If the email address isn't already used
- if (!alreadyRegistered(email)) {
- WikittyProxy proxy = getBowProxy();
- BowUserImpl newUser = new BowUserImpl();
- newUser.setPassword(md5);
- newUser.setLogin(email);
- String permanentToken = BowUtils.generateToken();
- newUser.setPermanentToken(permanentToken);
- BowUser login = proxy.store(newUser); //Stores the new user
-
- //If there was an error when storing the user
- if (login == null) {
- addFieldError("email", _("bow.register.invalidLogin"));
- } else {
- getBowSession().setUser(login);
- try {
- String mailContent;
-
- mailContent =
- _("bow.register.mailHi") + ",\n\n" +
- _("bow.register.mailPwd") + ": " + password + "\n\n" +
- _("bow.register.mailEmail") + ": " + email + "\n\n";
- BowMail.sendMail(email, _("bow.register.mailSubject"), mailContent);
- } catch (AddressException eee) {
- //If the email address is invalid
- addActionError(_("bow.mail.badFormat"));
- log.error(String.format("Can't send message email to '%s'",
- email), eee);
- } catch (MessagingException eee) {
- addActionError("bow.mail.sendError");
- log.error(String.format("Can't send message email to '%s'",
- email), eee);
- }
- result = SUCCESS;
- }
- }
- }
- }
- }
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error(eee.getMessage(), eee);
- }
- return result;
- }
-}
Deleted: trunk/bow-ui/src/main/java/org/chorem/bow/action/RemoveBookmarkAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/RemoveBookmarkAction.java 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/RemoveBookmarkAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,82 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow.action;
-
-import org.apache.commons.lang.StringUtils;
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowUtils;
-import org.nuiton.wikitty.WikittyProxy;
-
-/**
- * Supprime un bookmark
- *
- * @author poussin
- */
-public class RemoveBookmarkAction extends BowBaseAction {
-
- private static final long serialVersionUID = 820566716695285561L;
-
- protected String bookmarkId;
- protected String redirectTo;
-
- /**
- * @return the bookmarkId
- */
- public String getBookmarkId() {
- return bookmarkId;
- }
-
- /**
- * @param bookmarkId the bookmarkId to set
- */
- public void setBookmarkId(String bookmarkId) {
- this.bookmarkId = bookmarkId;
- }
-
- /**
- * @return the redirectTo
- */
- public String getRedirectTo() {
- return redirectTo;
- }
-
- /**
- * Removes a bookmark
- */
- @Override
- public String execute() {
- if (StringUtils.isNotEmpty(bookmarkId)) {
- try {
- WikittyProxy proxy = getBowProxy();
- proxy.delete(bookmarkId);
- addActionMessage(_("bow.bookmark.remove.successful"));
- } catch (Exception eee) {
- addActionError(_("bow.error.internal"));
- log.error("Can't do action", eee);
- }
- }
- redirectTo = BowUtils.redirectTo(searchLine, fullTextLine);
- return SUCCESS;
- }
-}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/MigrateDataAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,95 @@
+/*
+ * #%L
+ * BOW UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.admin;
+
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.bow.BowMigration04To05;
+import org.chorem.bow.BowMigration06To11;
+import org.chorem.bow.BowSession;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.util.VersionUtil;
+import org.nuiton.wikitty.WikittyProxy;
+
+/**
+ * Lance la migration des données de la version 0.4 vers 0.5
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class MigrateDataAction extends BowBaseAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(MigrateDataAction.class);
+
+ /** Version must be real version, like 0.4, 0.5 or 0.6 */
+ protected String versionFrom;
+ protected String versionTo;
+
+ public void setVersionFrom(String versionFrom) {
+ this.versionFrom = versionFrom;
+ }
+
+ public void setVersionTo(String versionTo) {
+ this.versionTo = versionTo;
+ }
+
+ @Override
+ public String execute() {
+ try {
+ if (StringUtils.isBlank(versionFrom) || StringUtils.isBlank(versionTo)) {
+ log.error("Migration action must have to parameter: versionFrom and versionTo");
+ } else {
+ BowSession session = getBowSession();
+ if (session.isAdmin()) { //If is admin
+ WikittyProxy proxy = getBowProxy();
+
+ if (VersionUtil.equals(versionFrom, "0.4")
+ && VersionUtil.equals(versionTo, "0.5")) {
+ BowMigration04To05.migrate(proxy);
+ addActionMessage(_("bow.admin.dataMigration.success"));
+ } else if (VersionUtil.equals(versionFrom, "0.6")
+ && VersionUtil.equals(versionTo, "1.1")) {
+ BowMigration06To11.migrate(proxy);
+ addActionMessage(_("bow.admin.dataMigration.success"));
+ } else {
+ addActionMessage(String.format(
+ "No migration found for %s to %s",
+ versionFrom, versionTo));
+ }
+ }
+ }
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return SUCCESS;
+ }
+
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/ReIndexationAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,55 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.admin;
+
+import org.chorem.bow.BowSession;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.wikitty.WikittyProxy;
+
+/**
+ * Lance la reindexation solr
+ *
+ * @author poussin
+ */
+public class ReIndexationAction extends BowBaseAction {
+
+ private static final long serialVersionUID = 6226574522402739559L;
+
+ @Override
+ public String execute() {
+ try {
+ BowSession session = getBowSession();
+ if (session.isAdmin()) { //If is admin
+ WikittyProxy proxy = getBowProxy();
+
+ proxy.getWikittyService().syncSearchEngine(proxy.getSecurityToken());
+ addActionMessage(_("bow.admin.reIndexationDone"));
+ }
+ } catch (Exception eee) {
+ addActionError(("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return SUCCESS;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/AddUrlAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,266 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.bookmark;
+
+import org.apache.commons.lang.StringUtils;
+import org.chorem.bow.BookmarkUtils;
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.BowUtils;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.PagedResult;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Ajoute ou modifie un bookmark, soit par le formulaire,
+ * soit par un appel javascript
+ *
+ * @author poussin
+ */
+public class AddOrUpdateAction extends BowBaseAction {
+
+ private static final long serialVersionUID = 3389170166034184139L;
+
+ protected String bookmarkId;
+ protected String link;
+ protected String name;
+ protected String privateAlias;
+ protected String publicAlias;
+ protected String tags;
+ protected String nameAndTags;
+ protected String redirectTo;
+
+ public String getBookmarkId() {
+ return bookmarkId;
+ }
+
+ public void setBookmarkId(String bookmarkId) {
+ this.bookmarkId = bookmarkId;
+ }
+
+ /**
+ * @return the link
+ */
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * @param link the link to set
+ */
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the description to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the privateAlias
+ */
+ public String getPrivateAlias() {
+ return privateAlias;
+ }
+
+ /**
+ * @param alias the privateAlias to set
+ */
+ public void setPrivateAlias(String alias) {
+ this.privateAlias = alias;
+ }
+
+ public String getPublicAlias() {
+ return publicAlias;
+ }
+
+ public void setPublicAlias(String publicAlias) {
+ this.publicAlias = publicAlias;
+ }
+
+ /**
+ * @return the tags
+ */
+ public String getTags() {
+ return tags;
+ }
+
+ /**
+ * @param tags the tags to set
+ */
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ /**
+ * @return the nameAndTags
+ */
+ public String getNameAndTags() {
+ return nameAndTags;
+ }
+
+ /**
+ * @param nameAndTags the nameAndTags to set
+ */
+ public void setNameAndTags(String nameAndTags) {
+ this.nameAndTags = nameAndTags;
+ }
+
+ /**
+ * @return the redirectTo
+ */
+ public String getRedirectTo() {
+ return redirectTo;
+ }
+
+ @Override
+ public String execute() {
+ String result = SUCCESS;
+ try {
+ WikittyProxy proxy = getBowProxy();
+ BowBookmark bookmark = null;
+ BowBookmark bookmarkToModify = null;
+
+ BowUser user = getBowSession().getUser();
+ String userId = user.getWikittyId();
+ if (StringUtils.isNotBlank(bookmarkId)) {
+ bookmarkToModify = proxy.restore(BowBookmark.class, bookmarkId);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Change old wikitty: " + bookmarkToModify);
+ }
+
+ // gere le cas d'une mise a jour ou d'un ajout via le formulaire
+ if (name != null) {
+ // Si l'alias prive souhaite est deja utilise on ne l'accept pas
+ // Si l'alias public souhaite est deja utilise on ne l'accept pas
+ // TODO sletellier 20110416 : return error message when public or private alias is already used
+ Criteria privateAliasCriteria = null;
+ Criteria publicAliasCriteria = null;
+ if (StringUtils.isNotEmpty(privateAlias)) {
+ privateAliasCriteria = Search.query()
+ .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PRIVATEALIAS, privateAlias)
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
+ .criteria().setEndIndex(0);
+ }
+ if (StringUtils.isNotEmpty(publicAlias)) {
+ publicAliasCriteria = Search.query()
+ .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PUBLICALIAS, publicAlias)
+ .criteria().setEndIndex(0);
+ }
+ PagedResult<String>[] aliasResult = proxy.findAllIdByCriteria(
+ privateAliasCriteria, publicAliasCriteria);
+
+ if (aliasResult[0] != null && aliasResult[0].getNumFound() > 0) {
+ if (bookmarkToModify == null) {
+ privateAlias = "";
+ } else {
+ privateAlias = bookmarkToModify.getPrivateAlias();
+ }
+ }
+ if (aliasResult[1] != null && aliasResult[1].getNumFound() > 0) {
+ if (bookmarkToModify == null) {
+ publicAlias = "";
+ } else {
+ publicAlias = bookmarkToModify.getPublicAlias();
+ }
+ }
+
+ if (bookmarkToModify == null) {
+ bookmark = BookmarkUtils.createBookmark(
+ link, name, tags, user, privateAlias, publicAlias, null);
+ } else {
+ BookmarkUtils.updateBookmark(
+ bookmarkToModify, name, link, tags, privateAlias, publicAlias);
+ }
+ } else { //This part is for the bookmark addition by script
+ if (nameAndTags != null) {
+ bookmark = BookmarkUtils.createBookmark(link, nameAndTags, user);
+ }
+ }
+ // si on a reussi a creer le bookmark, on regarde s'il ne faut pas
+ // le fusionner avec un deja existant
+ if (bookmark != null && !bookmark.getDescription().isEmpty()
+ && !bookmark.getOwner().isEmpty()) {
+
+ // looking for already bookmark with same url, to fusion them
+ String link = bookmark.getLink();
+ Criteria criteria = Search.query()
+ .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_LINK, link)
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
+ .criteria();
+ BowBookmark oldBookmark =
+ proxy.findByCriteria(BowBookmark.class, criteria);
+ if(oldBookmark != null) {
+ // fusionne les descriptions et les tags
+ // par contre on prend le dernier privateAlias prive choisi par
+ // l'utilisateur s'il y en a un
+ String description = oldBookmark.getDescription();
+ if (!StringUtils.isEmpty(bookmark.getDescription())) {
+ description += "\n";
+ description += BowUtils.formatDate(
+ bookmark.getCreationDate()) + ": ";
+ description += bookmark.getDescription();
+ }
+
+ oldBookmark.setDescription(description);
+ oldBookmark.addAllLabels(bookmark.getLabels());
+ String privateAlias = bookmark.getPrivateAlias();
+ if (!StringUtils.isEmpty(privateAlias)) {
+ oldBookmark.setPrivateAlias(privateAlias);
+ }
+
+ bookmark = oldBookmark;
+ }
+
+ }
+
+ if (bookmark != null || bookmarkToModify != null) {
+ proxy.store(bookmark, bookmarkToModify); //Stores the bookmark if everything is ok
+ addActionMessage(_("bow.bookmark.add.successful"));
+ if (log.isDebugEnabled()) {
+ log.debug("Adding URL");
+ }
+ }
+ redirectTo = BowUtils.redirectTo(tagLine, fullTextLine);
+ } catch (Exception eee) {
+ result = ERROR;
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return result;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java (from rev 309, trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteSearchResultsAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,75 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.bookmark;
+
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+
+import org.chorem.bow.BookmarkUtils;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+
+/**
+ * Supprime des bookmarks qui satisfont le critere de recherche.
+ *
+ * @author poussin
+ */
+public class DeleteSearchResultsAction extends BowBaseAction {
+
+ private static final long serialVersionUID = -3903724044644625507L;
+
+ /**
+ * Deletes the search results
+ */
+ public String execute() {
+ try {
+ if (StringUtils.isNotBlank(tagLine)
+ || StringUtils.isNotBlank(fullTextLine)) {
+ BowUser user = getBowSession().getUser();
+ // FIXME poussin 20110817 ATTENTION, la recherche remonte
+ // potentiellement des bookmarks qui ne nous appartiennent pas,
+ // dans ce cas, ne faudrait-il pas seulement ce supprimer des
+ // reader/write/admin ?
+ Criteria criteria = BookmarkUtils.getBookmarkListCriteriaByUser(
+ user, tagLine, fullTextLine, null);
+
+ WikittyProxy proxy = getBowProxy();
+ List<String> ids = proxy.findAllIdByCriteria(criteria).getAll();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will delete " + ids.size() + " bookmarks");
+ }
+
+ proxy.delete(ids);
+ addActionMessage(_("bow.search.results.deleted"));
+ }
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return SUCCESS;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/EditBookmarkAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,76 @@
+/*
+ * #%L
+ * BOW UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.bookmark;
+
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowBookmarkImpl;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.Search;
+import org.nuiton.wikitty.search.operators.Element;
+
+/**
+ * Load a bookmark to display it on modification page
+ *
+ * @author sletellier
+ */
+public class EditAction extends BowBaseAction {
+ private static final long serialVersionUID = 1L;
+
+ protected String id;
+ protected BowBookmark bookmark;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public BowBookmark getBookmark() {
+ if (bookmark == null) {
+ bookmark = new BowBookmarkImpl();
+ }
+ return bookmark;
+ }
+
+ @Override
+ public String execute() throws Exception {
+ if (id == null) {
+ return SUCCESS;
+ }
+ try {
+ WikittyProxy proxy = getBowProxy();
+ Criteria criteria = Search.query()
+ .eq(Element.ELT_ID, id).criteria();
+ bookmark = proxy.findByCriteria(BowBookmark.class, criteria);
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return SUCCESS;
+ }
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/HomeAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,110 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.bookmark;
+
+import com.opensymphony.xwork2.ActionContext;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.chorem.bow.BowSearchResult;
+import org.chorem.bow.BowSession;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.util.TimeLog;
+
+/**
+ * Prepare l'affichage de la page d'accueil
+ *
+ * @author poussin
+ */
+public class HomeAction extends BowBaseAction {
+
+ private static final Log log = LogFactory.getLog(HomeAction.class);
+ private static final TimeLog timeLog = new TimeLog(HomeAction.class);
+
+ private static final long serialVersionUID = -3735250067223062719L;
+
+ static public HomeAction getAction() {
+ Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY);
+ return (HomeAction) action;
+ }
+
+ protected String addTag;
+
+ protected BowSearchResult searchResult;
+
+ public String getAddTag() {
+ return addTag;
+ }
+
+ public void setAddTag(String addTag) {
+ this.addTag = addTag;
+ }
+
+ public BowSearchResult getSearchResult() {
+ return searchResult;
+ }
+
+ public void setSearchResult(BowSearchResult searchResult) {
+ this.searchResult = searchResult;
+ }
+
+ /**
+ * Load all data necessary form Home page
+ */
+ protected void load() {
+ // on ajoute les tags qui doivent faire parti de ne nouvelle recherche
+ // on restocke dans tagLine pour que la bonne info reapparaisse
+ // a l'utilisateur
+ tagLine = StringUtils.join(new String[]{tagLine, addTag}, " ").trim();
+
+ // si l'ordre souhaite n'existe pas, on utilise l'ordre par defaut
+ if (!getPossibleOrder().contains(order)) {
+ // default sort order
+ // TODO poussin 20110815 rendre configurable par l'utilisateur l'ordre par defaut qu'il prefere
+ order = "descClick";
+ }
+
+ BowSession session = getBowSession();
+ searchResult = new BowSearchResult(session, tagLine, fullTextLine, order);
+ }
+
+ /**
+ * Initializes everything before displaying the home page
+ */
+ @Override
+ public String execute() {
+ long start = TimeLog.getTime();
+ try {
+ load();
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ timeLog.log(start, "execute");
+ return SUCCESS;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/RemoveBookmarkAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,82 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.bookmark;
+
+import org.apache.commons.lang.StringUtils;
+import org.chorem.bow.BowUtils;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.wikitty.WikittyProxy;
+
+/**
+ * Supprime un bookmark
+ *
+ * @author poussin
+ */
+public class RemoveAction extends BowBaseAction {
+
+ private static final long serialVersionUID = 820566716695285561L;
+
+ protected String bookmarkId;
+ protected String redirectTo;
+
+ /**
+ * @return the bookmarkId
+ */
+ public String getBookmarkId() {
+ return bookmarkId;
+ }
+
+ /**
+ * @param bookmarkId the bookmarkId to set
+ */
+ public void setBookmarkId(String bookmarkId) {
+ this.bookmarkId = bookmarkId;
+ }
+
+ /**
+ * @return the redirectTo
+ */
+ public String getRedirectTo() {
+ return redirectTo;
+ }
+
+ /**
+ * Removes a bookmark
+ */
+ @Override
+ public String execute() {
+ if (StringUtils.isNotEmpty(bookmarkId)) {
+ try {
+ WikittyProxy proxy = getBowProxy();
+ proxy.delete(bookmarkId);
+ addActionMessage(_("bow.bookmark.remove.successful"));
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error("Can't do action", eee);
+ }
+ }
+ redirectTo = BowUtils.redirectTo(tagLine, fullTextLine);
+ return SUCCESS;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/ForgotPasswordAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,124 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.login;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+
+import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang.StringUtils;
+import org.chorem.bow.BowMail;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Genere un nouveau mot de passe pour l'utilisateur et lui envoie par mail
+ * TODO poussin 20110211 il faudrait ajouter une securite pour eviter que
+ * quelqu'un s'amuse a demander la modification de password de quelqu'un d'autre
+ * toutes les 2s
+ * - soit en ne permettant l'envoi qu'une fois par jour
+ * - soit ????
+ *
+ * @author poussin
+ */
+public class ForgotPasswordAction extends BowBaseAction {
+ private static final long serialVersionUID = -8207951465957204954L;
+ protected String email;
+
+ /**
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param email the email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * Generates a new password and sends it to the user
+ */
+ @Override
+ public String execute() {
+ String result = INPUT;
+
+ try {
+ if (StringUtils.isNotBlank(email)) {
+ email = email.trim();
+ WikittyProxy proxy = getBowProxy();
+ Criteria criteria = Search.query()
+ .eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).criteria();
+ BowUser user = proxy.findByCriteria(BowUser.class, criteria);
+
+ if (user != null) { //If the email address exists
+ String password = "";
+ String md5 = "";
+
+ password = RandomStringUtils.randomAlphanumeric(20);
+ md5 = StringUtil.encodeMD5(password);
+ try {
+ String mailContent;
+
+ mailContent = _("bow.register.mailHi") +
+ ",\n\n" + _("bow.register.mailPwd") + ": " +
+ password + "\n\n" + _("bow.register.mailEmail") +
+ ": " + email + "\n\n";
+ BowMail.sendMail(email,
+ _("bow.register.mailSubject"),
+ mailContent);
+
+ //The password is changed only if the mail has been sent
+ user.setPassword(md5);
+ proxy.store(user);
+ } catch (AddressException eee) {
+ //If the email address is invalid
+ addActionError(_("bow.mail.badFormat"));
+ log.error(String.format("Can't send message email to '%s'",
+ email), eee);
+ } catch (MessagingException eee) {
+ addActionError("bow.mail.sendError");
+ log.error(String.format("Can't send message email to '%s'",
+ email), eee);
+ }
+ result = SUCCESS;
+ } else { //If the email is not associated with an account
+ addFieldError("email",
+ _("bow.forgotPassword.emailDoesntExist"));
+ }
+ }
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return result;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/LoginAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,130 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package org.chorem.bow.action.login;
+
+import org.apache.commons.lang.StringUtils;
+
+import org.chorem.bow.BowConfig;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.BowUserImpl;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * authentifie l'utilisateur et place son objet User dans la bow session
+ *
+ * @author poussin
+ */
+public class LoginAction extends BowBaseAction {
+
+ private static final long serialVersionUID = 6891064800288772246L;
+
+ protected String email;
+ protected String password;
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * Check password in solr index, if fail try to check password admin in config file
+ *
+ * @param email non null et non vide email
+ * @param password non null et non vide email
+ * @return
+ */
+ protected BowUser checkLogin(String email, String password) {
+ BowUser result = null;
+
+ WikittyProxy proxy = getBowProxy();
+ Criteria criteria = Search.query().eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).
+ eq(BowUser.FQ_FIELD_WIKITTYUSER_PASSWORD, password).criteria();
+ result = proxy.findByCriteria(BowUser.class, criteria);
+
+ if (result == null) {
+ // failback: try to authenticate admin with config info
+ String configPassword = BowConfig.getAdminPassword(email);
+ log.info(String.format("failback password: '%s' configPassword: '%s'",
+ password, configPassword));
+ if (password.equals(configPassword)) {
+ // admin authenticate with config, this is possible when
+ // solr index is corrupted or missed. Admin must go to admin
+ // page en recreate index
+ result = new BowUserImpl();
+ result.setLogin(email);
+ result.setPassword(configPassword);
+ addActionMessage(_("bow.login.admin.failback"));
+ log.warn(_("bow.login.admin.failback"));
+ } else {
+ addActionError(_("bow.login.authenticationFailure"));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Authenticates the user if his email and password are valid
+ */
+ @Override
+ public String execute() {
+ String result = INPUT;
+
+ try {
+ if (StringUtils.isNotBlank(email)) {
+ email = email.trim();
+
+ if (StringUtils.isNotEmpty(password)) {
+ String md5 = StringUtil.encodeMD5(password);
+ BowUser user;
+
+ user = checkLogin(email, md5);
+ if (user != null) {
+ getBowSession().setUser(user);
+ result = SUCCESS;
+ }
+ }
+ }
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return result;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/LogoutAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,42 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.login;
+
+import org.chorem.bow.BowSession;
+import org.chorem.bow.action.BowBaseAction;
+
+/**
+ * Invalide la session courante et donc de-authentifie l'utilisateur
+ *
+ * @author poussin
+ */
+public class LogoutAction extends BowBaseAction {
+ private static final long serialVersionUID = 4806944250461551896L;
+
+ @Override
+ public String execute() {
+ BowSession.invalidate(session);
+ return SUCCESS;
+ }
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/RegisterAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,179 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.login;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import org.apache.commons.lang.StringUtils;
+
+import org.chorem.bow.BowMail;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.BowUserImpl;
+import org.chorem.bow.BowUtils;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Enregistre un nouvel utilisateur
+ *
+ * @author poussin
+ */
+public class RegisterAction extends BowBaseAction {
+
+ private static final long serialVersionUID = 2204772861770399542L;
+
+ protected String email;
+ protected String password;
+ protected String repeatPassword;
+
+ /**
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param email the email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * @return the repeatPassword
+ */
+ public String getRepeatPassword() {
+ return repeatPassword;
+ }
+
+ /**
+ * @param repeatPassword the repeatPassword to set
+ */
+ public void setRepeatPassword(String repeatPassword) {
+ this.repeatPassword = repeatPassword;
+ }
+
+ /**
+ *
+ * @param email non null and non blank email
+ * @return false if the email address isn't already registered, true
+ * otherwise
+ */
+ protected boolean alreadyRegistered(String email) {
+ boolean result = true;
+
+ WikittyProxy proxy = getBowProxy();
+ //Retrieves user by user name (email)
+ Criteria criteria = Search.query()
+ .eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).criteria();
+
+ result = proxy.findByCriteria(BowUser.class, criteria) != null;
+ //If the user doesn't already exist
+ if (result) {
+ //The email address is already used by someone
+ addFieldError("email", _("bow.register.emailAldyUsed"));
+ }
+ return result;
+ }
+
+ /**
+ * Registers the new user and sends an email to confirm registration
+ */
+ @Override
+ public String execute() {
+ String result = INPUT;
+
+ try {
+ if (StringUtils.isNotBlank(email)) {
+ email = email.trim();
+ if (StringUtils.isNotBlank(password)) {
+ if (!password.equals(repeatPassword)) {
+ addActionError(_("bow.register.pwdDontMatch"));
+ } else {
+ String md5 = StringUtil.encodeMD5(password);
+
+ //If the email address isn't already used
+ if (!alreadyRegistered(email)) {
+ WikittyProxy proxy = getBowProxy();
+ BowUserImpl newUser = new BowUserImpl();
+ newUser.setPassword(md5);
+ newUser.setLogin(email);
+ String permanentToken = BowUtils.generateToken();
+ newUser.setPermanentToken(permanentToken);
+ BowUser login = proxy.store(newUser); //Stores the new user
+
+ //If there was an error when storing the user
+ if (login == null) {
+ addFieldError("email", _("bow.register.invalidLogin"));
+ } else {
+ getBowSession().setUser(login);
+ try {
+ String mailContent;
+
+ mailContent =
+ _("bow.register.mailHi") + ",\n\n" +
+ _("bow.register.mailPwd") + ": " + password + "\n\n" +
+ _("bow.register.mailEmail") + ": " + email + "\n\n";
+ BowMail.sendMail(email, _("bow.register.mailSubject"), mailContent);
+ } catch (AddressException eee) {
+ //If the email address is invalid
+ addActionError(_("bow.mail.badFormat"));
+ log.error(String.format("Can't send message email to '%s'",
+ email), eee);
+ } catch (MessagingException eee) {
+ addActionError("bow.mail.sendError");
+ log.error(String.format("Can't send message email to '%s'",
+ email), eee);
+ }
+ result = SUCCESS;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ }
+ return result;
+ }
+}
Added: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,93 @@
+package org.chorem.bow.action.preference;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowProxy;
+import org.chorem.bow.BowUser;
+import org.nuiton.wikitty.entities.WikittyLabel;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.PagedResult;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class AdminTagAction extends PreferenceBaseAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(AdminTagAction.class);
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ACTION STRUTS
+ *
+ * Fait les modification demandé par l'utilisateur dans l'interface de
+ * preference: renome ou supprime des labels. Si l'utilisateur demande le
+ * remplacement de label on indiquant pas de nouveau label, alors la chaine
+ * vide est utilisee.
+ *
+ * @return
+ */
+ @Override
+ public String execute() {
+ String result = SUCCESS;
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Selected labels: " + Arrays.toString(selectedLabels));
+ log.debug("action delete: " + delete + " rename: " + rename);
+ }
+
+ List<String> selectedLabelsList = Arrays.asList(selectedLabels);
+ boolean isRename = StringUtils.isNotEmpty(rename);
+
+ BowProxy proxy = getBowProxy();
+ BowUser user = getBowSession().getUser();
+ String userId = user.getWikittyId();
+
+ Criteria c = Search.query()
+ .in(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, selectedLabelsList)
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
+ .criteria();
+ PagedResult<WikittyLabel> searchResult =
+ proxy.findAllByCriteria(WikittyLabel.class, c);
+
+ List<WikittyLabel> toStore = new ArrayList<WikittyLabel>();
+ for (WikittyLabel label : searchResult) {
+ toStore.add(label);
+ Set<String> l = label.getLabels();
+ if (l != null) {
+ // on fait une copie, car l retourne est non modifiable
+ l = new HashSet<String>(l);
+ l.removeAll(selectedLabelsList);
+ if (isRename) {
+ l.add(newLabel);
+ }
+ label.setLabels(l);
+ }
+ }
+ proxy.store(toStore);
+
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ } finally {
+ // on recharge les data apres l'action pour l'affichage
+ load();
+ }
+ return result;
+
+ }
+
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java (from rev 306, trunk/bow-ui/src/main/java/org/chorem/bow/action/DeleteImportAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,95 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.preference;
+
+import java.util.List;
+
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowImport;
+import org.chorem.bow.BowUser;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Search;
+
+
+/**
+ * Supprime un import de bookmark
+ *
+ * @author poussin
+ */
+public class DeleteImportAction extends PreferenceBaseAction {
+ private static final long serialVersionUID = 8714394293884265516L;
+ protected String date;
+
+ /**
+ * @return the date
+ */
+ public String getDate() {
+ return date;
+ }
+ /**
+ * @param date the date to set
+ */
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ /**
+ * Deletes a bookmark import
+ */
+ public String execute() {
+ String result = SUCCESS;
+ try {
+ if (date != null &&
+ // XXX poussin 20110818 y'a-t-il vraiment une utilite a checker
+ // que la date verifie le pattern ?
+ // car on pire on ne retrouve rien et donc on ne supprime rien
+ 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")) {
+ WikittyProxy proxy = getBowProxy();
+ BowUser user = getBowSession().getUser();
+ Criteria criteria = Search.query()
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId())
+ .eq(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE, date).criteria();
+ List<BowImport> bookmarks = proxy.findAllByCriteria(BowImport.class, criteria).getAll();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will delete " + bookmarks.size() + " bookmarks");
+ }
+
+ proxy.delete(bookmarks);
+
+ addActionMessage(_("bow.bookmark.import.delete.successful"));
+ }
+ } catch (Exception e) {
+ result = ERROR;
+ addActionError(_("bow.error.internal"));
+ log.error(e.getMessage(), e);
+ } finally {
+ // on recharge les data apres l'action pour l'affichage
+ load();
+ }
+ return result;
+ }
+
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java (from rev 310, trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,139 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.preference;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.struts2.interceptor.ServletResponseAware;
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BookmarkUtils;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.action.BowBaseAction;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Export son bookmark au format HTML
+ *
+ * @author poussin
+ */
+public class ExportBookmarksAction extends BowBaseAction implements ServletResponseAware {
+ private static final long serialVersionUID = 45880214686011946L;
+ protected HttpServletResponse response;
+ protected InputStream inputStream;
+
+ @Override
+ public void setServletResponse(HttpServletResponse response) {
+ this.response = response;
+ }
+
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ /**
+ * Export tous les bookmarks au format HTML tel que le fait les navigateurs
+ *
+ * @param bookmarks List<Bookmarks> bookmarks
+ * @param out le flux dans lequel il faut ecrire l'export
+ * @return String the html file
+ */
+ protected void generateExportHtmlBookmark(List<BowBookmark> bookmarks, Writer out) throws IOException {
+ out.write("<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
+ + "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n"
+ + "<DL><p>\n");
+ if (bookmarks != null) {
+ for (BowBookmark bookmark : bookmarks) {
+ if (bookmark != null) {
+ out.write("<DT><A HREF=\"");
+ out.write(bookmark.getLink() + "\" ");
+ Date date = bookmark.getCreationDate();
+ if (date != null) {
+ long milli = date.getTime();
+ String time = String.valueOf(milli / 1000);
+ out.write("ADD_DATE=\"" + time + "\" LAST_MODIFIED=\"" + time + "\" ");
+ }
+ out.write("LAST_CHARSET=\"UTF-8\" ");
+ Set<String> tags = bookmark.getLabels();
+ if (tags != null && !tags.isEmpty()) {
+ out.write("SHORTCUTURL=\""
+ + BookmarkUtils.getBookmarkTagsString(bookmark) + "\"");
+ }
+ out.write(">" + bookmark.getDescription() + "</A>\n");
+ }
+ }
+ }
+ out.write("</DL><p>");
+ }
+
+ /**
+ * Exports the bookmarks in HTML format
+ */
+ @Override
+ public String execute() {
+ WikittyProxy proxy = getBowProxy();
+
+ // get current user
+ BowUser user = getBowSession().getUser();
+
+ // Get all bookmark for user
+ Criteria criteria = Search.query()
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId()).criteria();
+ List<BowBookmark> bookmarks = proxy.findAllByCriteria(BowBookmark.class, criteria).getAll();
+
+ // Export all
+ BufferedWriter out = null;
+
+ try {
+
+ // Write result in temp file
+ File tmp = File.createTempFile("bookmarks", ".tmp.html");
+
+ tmp.deleteOnExit();
+ out = new BufferedWriter(new FileWriter(tmp));
+ generateExportHtmlBookmark(bookmarks, out);
+ out.close();
+
+ inputStream = new FileInputStream(tmp);
+ } catch (IOException eee) {
+ log.error("Error when exporting bookmarks to HTML : ", eee);
+ } finally {
+ IOUtils.closeQuietly(out);
+ }
+ return SUCCESS;
+ }
+}
\ No newline at end of file
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java (from rev 312, trunk/bow-ui/src/main/java/org/chorem/bow/action/GenerateTokenAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,46 @@
+package org.chorem.bow.action.preference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.bow.BowProxy;
+import org.chorem.bow.BowUser;
+import org.chorem.bow.BowUtils;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class GenerateTokenAction extends PreferenceBaseAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(GenerateTokenAction.class);
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String execute() {
+ try {
+ BowUser user = getBowSession().getUser();
+ BowProxy proxy = getBowProxy();
+
+ String permanentToken = BowUtils.generateToken();
+ user.setPermanentToken(permanentToken);
+ proxy.store(user);
+
+ String temporaryToken = BowUtils.generateToken();
+ getBowSession().setTemporaryToken(temporaryToken);
+ addActionMessage(_("bow.token.generate.successful"));
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error("Can't regenerate token", eee);
+ } finally {
+ // on recharge les data apres l'action pour l'affichage
+ load();
+ }
+ return SUCCESS;
+ }
+
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java (from rev 310, trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,260 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.preference;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
+
+import org.chorem.bow.BookmarkUtils;
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowImportHelper;
+import org.chorem.bow.BowUser;
+import org.htmlparser.Node;
+import org.htmlparser.Parser;
+import org.htmlparser.util.NodeList;
+import org.htmlparser.util.ParserException;
+import org.htmlparser.util.SimpleNodeIterator;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.entities.Wikitty;
+
+/**
+ * Import un bookmark HTML
+ *
+ * @author poussin
+ */
+public class ImportBookmarksAction extends PreferenceBaseAction {
+
+ private static final long serialVersionUID = -5962680416570797028L;
+
+ protected File upfile;
+ protected String upfileContentType;
+ protected String upfileFileName;
+
+ /**
+ * @return the upfile
+ */
+ public File getUpfile() {
+ return upfile;
+ }
+
+ /**
+ * @param upfile
+ * the upfile to set
+ */
+ public void setUpfile(File upfile) {
+ this.upfile = upfile;
+ }
+
+ /**
+ * @return the upfileContentType
+ */
+ public String getUpfileContentType() {
+ return upfileContentType;
+ }
+
+ /**
+ * @param upfileContentType
+ * the upfileContentType to set
+ */
+ public void setUpfileContentType(String upfileContentType) {
+ this.upfileContentType = upfileContentType;
+ }
+
+ /**
+ * @return the upfileFileName
+ */
+ public String getUpfileFileName() {
+ return upfileFileName;
+ }
+
+ /**
+ * @param upfileFileName
+ * the upfileFileName to set
+ */
+ public void setUpfileFileName(String upfileFileName) {
+ this.upfileFileName = upfileFileName;
+ }
+
+ /**
+ * @param html String html
+ * @param name String name
+ * @param user User user
+ * @return Bookmark the bookmark filled
+ */
+ protected BowBookmark createBookmarkFromHtml(String html, String name, BowUser user) {
+ String link = getUrlFromHtml(html);
+ String tags = getTagsFromHtml(html);
+ Date date = getDateFromHtml(html);
+ BowBookmark bookmark = BookmarkUtils.createBookmark(link, name, tags, user, null, null, date);
+ return bookmark;
+ }
+
+ /**
+ * @param html String html
+ * @return Date from the html
+ */
+ protected Date getDateFromHtml(String html) {
+ Date date = null;
+ if (html != null) {
+ Pattern p = Pattern.compile("ADD_DATE=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ String str = m.group(1);
+ if (str != null && !str.isEmpty()) {
+ long time = Long.valueOf(str) * 1000; // the date in ms
+ date = new Date(time);
+ }
+ }
+ }
+ return date;
+ }
+
+ /**
+ * @param html String html
+ * @return url
+ */
+ protected String getUrlFromHtml(String html) {
+ String url = "";
+ if (html != null) {
+ Pattern p = Pattern.compile("A HREF=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ url = m.group(1);
+ }
+ }
+ return url;
+ }
+
+ protected String getTagsFromHtml(String html) {
+ String tags = "";
+ if (html != null) {
+ Pattern p = Pattern.compile("SHORTCUTURL=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ tags = m.group(1);
+ }
+ }
+ return tags;
+ }
+
+ protected void parseHtmlToBookmarks(NodeList list, BowUser user, Date date,
+ List<BowBookmark> bookmarks, Set<String> tagList)
+ throws ParserException {
+
+ 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 (StringUtils.startsWithIgnoreCase(text, "h3")) { // H3 = folder
+ if (StringUtils.isNotBlank(plainText)) {
+ tagList.add(plainText); // Adds the folder name to the
+ // tagList
+ }
+ } else if (StringUtils.startsWithIgnoreCase(text, "a href")) { // HREF
+ // = new
+ // bookmarks
+ BowBookmark bookmark = createBookmarkFromHtml(text, plainText, user);
+ Wikitty w = getBowProxy().getWikitty(bookmark);
+ BowImportHelper.addExtension(w);
+ BowImportHelper.setImportDate(w, date);
+
+ bookmark.addAllLabels(tagList);
+
+ bookmarks.add(bookmark);
+ }
+ NodeList children = node.getChildren();
+
+ if (children != null) {
+ parseHtmlToBookmarks(children, user, date, bookmarks,
+ // On utilise une nouvelle liste pour les enfants
+ // pour eviter que les tags de tous les enfants se
+ // retrouve ensemble
+ new HashSet<String>(tagList)); // If there is an under node = recursion
+ }
+ }
+ }
+
+ @Override
+ public String execute() {
+ String result = SUCCESS;
+ log.info("Importing boormarks : " + upfile);
+ try {
+ BowUser user = getBowSession().getUser();
+
+ // Struts limite to html files, is null if not one
+ if (upfile != null) {
+ WikittyProxy proxy = getBowProxy();
+
+ try {
+ URL url = upfile.toURI().toURL();
+ Parser parser = new Parser(url.openConnection());
+ NodeList list = parser.parse(null);
+
+ List<BowBookmark> bookmarks = new ArrayList<BowBookmark>();
+ parseHtmlToBookmarks(list, user, new Date(), bookmarks,
+ new HashSet<String>());
+ proxy.store(bookmarks);
+
+ addActionMessage(_("bow.bookmark.import.successful"));
+ } catch (ParserException eee) {
+ result = ERROR;
+ log.error(String.format("Can't parse imported file '%s'",
+ getUpfileFileName()), eee);
+ addActionError(_("bow.bookmark.badFileFormat"));
+ } catch (IOException eee) {
+ result = ERROR;
+ log.error(String.format("Can't read imported file '%s'",
+ getUpfileFileName()), eee);
+ addActionError(_("bow.error.internal"));
+ }
+ } else {
+ addActionError(_("bow.bookmark.badFileFormat"));
+ result = ERROR;
+ }
+ } catch (Exception eee) {
+ result = ERROR;
+ addActionError(_("bow.error.internal"));
+ log.error(eee.getMessage(), eee);
+ } finally {
+ // on recharge les data apres l'action pour l'affichage
+ load();
+ }
+ return result;
+ }
+}
Copied: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java (from rev 309, trunk/bow-ui/src/main/java/org/chorem/bow/action/PreferencesAction.java)
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,421 @@
+/*
+ * #%L
+ * bow
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.bow.action.preference;
+
+import org.chorem.bow.BowBookmark;
+import org.chorem.bow.BowProxy;
+import org.chorem.bow.BowUser;
+import com.opensymphony.xwork2.ActionContext;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.chorem.bow.BowImport;
+import org.chorem.bow.BowSession;
+import org.chorem.bow.action.BowBaseAction;
+
+import org.nuiton.wikitty.WikittyUtil;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.FacetTopic;
+import org.nuiton.wikitty.search.PagedResult;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Change les preferences de l'utilisateur (couleur, password, email, ...)
+ *
+ * @author poussin
+ */
+public class PreferenceBaseAction extends BowBaseAction {
+ private static final long serialVersionUID = -58341106356599721L;
+
+ static public PreferenceBaseAction getAction() {
+ Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY);
+ return (PreferenceBaseAction) action;
+ }
+
+ /** la liste des differentes data que l'on peut charger */
+ protected enum PreferenceType{USER_PREF, SITE_PREF, LABELS, IMPORTS};
+
+ protected String colors;
+ protected String tagsNb;
+ protected String bookmarksHomePage;
+ protected String searchEngineUrlSuggestions;
+ protected String searchEngineUrlResults;
+ protected String email;
+ protected String newPassword;
+ protected String currentPassword;
+ protected String confirmNewPassword;
+ protected String update;
+ protected Map<String, Integer> bookmarksImportDate;
+
+ protected List<FacetTopic> labels;
+ protected String[] selectedLabels;
+ protected String rename;
+ protected String delete;
+ protected String newLabel;
+
+ public String getNewLabel() {
+ return newLabel;
+ }
+
+ public void setNewLabel(String newLabel) {
+ this.newLabel = newLabel;
+ }
+
+ public void setRename(String rename) {
+ this.rename = rename;
+ }
+
+ public String getRename() {
+ return rename;
+ }
+
+ public void setDelete(String delete) {
+ this.delete = delete;
+ }
+
+ public String getDelete() {
+ return delete;
+ }
+
+ /**
+ * @return the colors
+ */
+ public String getColors() {
+ return colors;
+ }
+
+ /**
+ * @param colors the colors to set
+ */
+ public void setColors(String colors) {
+ this.colors = colors;
+ }
+
+ /**
+ * @return the tagsNb
+ */
+ public String getTagsNb() {
+ return tagsNb;
+ }
+
+ /**
+ * @param tagsNb the tagsNb to set
+ */
+ public void setTagsNb(String tagsNb) {
+ this.tagsNb = tagsNb;
+ }
+
+ /**
+ * @return the bookmarksHomePage
+ */
+ public String getBookmarksHomePage() {
+ return bookmarksHomePage;
+ }
+
+ /**
+ * @param bookmarksHomePage the bookmarksHomePage to set
+ */
+ public void setBookmarksHomePage(String bookmarksHomePage) {
+ this.bookmarksHomePage = bookmarksHomePage;
+ }
+
+ /**
+ * @return the searchEngineUrlSuggestions
+ */
+ public String getSearchEngineUrlSuggestions() {
+ return searchEngineUrlSuggestions;
+ }
+
+ /**
+ * @param searchEngineUrlSuggestions the searchEngineUrlSuggestions to set
+ */
+ public void setSearchEngineUrlSuggestions(String searchEngineUrlSuggestions) {
+ this.searchEngineUrlSuggestions = searchEngineUrlSuggestions;
+ }
+
+ /**
+ * @return the searchEngineUrlResults
+ */
+ public String getSearchEngineUrlResults() {
+ return searchEngineUrlResults;
+ }
+
+ /**
+ * @param searchEngineUrlResults the searchEngineUrlResults to set
+ */
+ public void setSearchEngineUrlResults(String searchEngineUrlResults) {
+ this.searchEngineUrlResults = searchEngineUrlResults;
+ }
+
+ /**
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param email the email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * @return the newPassword
+ */
+ public String getNewPassword() {
+ return newPassword;
+ }
+
+ /**
+ * @param newPassword the newPassword to set
+ */
+ public void setNewPassword(String newPassword) {
+ this.newPassword = newPassword;
+ }
+
+ /**
+ * @return the currentPassword
+ */
+ public String getCurrentPassword() {
+ return currentPassword;
+ }
+
+ /**
+ * @param currentPassword the currentPassword to set
+ */
+ public void setCurrentPassword(String currentPassword) {
+ this.currentPassword = currentPassword;
+ }
+
+ /**
+ * @return the confirmNewPassword
+ */
+ public String getConfirmNewPassword() {
+ return confirmNewPassword;
+ }
+
+ /**
+ * @param confirmNewPassword the confirmNewPassword to set
+ */
+ public void setConfirmNewPassword(String confirmNewPassword) {
+ this.confirmNewPassword = confirmNewPassword;
+ }
+
+ /**
+ * @return the update
+ */
+ public String getUpdate() {
+ return update;
+ }
+
+ /**
+ * @param update the update to set
+ */
+ public void setUpdate(String update) {
+ this.update = update;
+ }
+
+ /**
+ * @return the bookmarksImportDate
+ */
+ public Map<String, Integer> getBookmarksImportDate() {
+ return bookmarksImportDate;
+ }
+
+ /**
+ * @param bookmarksImportDate the bookmarksImportDate to set
+ */
+ public void setBookmarksImportDate(Map<String, Integer> bookmarksImportDate) {
+ this.bookmarksImportDate = bookmarksImportDate;
+ }
+
+ public List<FacetTopic> getLabels() {
+ return labels;
+ }
+
+ public String[] getSelectedLabels() {
+ return selectedLabels;
+ }
+
+ public void setSelectedLabels(String[] selectedLabels) {
+ this.selectedLabels = selectedLabels;
+ }
+
+ /**
+ * Date est une date mais au format String qui vient de Solr
+ * Elle est de la forme '2011-08-18T00:25:16.028Z'
+ * qui n'est pas presentable a l'utilisateur
+ * On la remet sous une vrai forme date
+ *
+ * Cette methode est utilise dans la JSP de rendu
+ */
+ public Date stringToDate(String date) {
+ try {
+ Date result = WikittyUtil.parseDate(date);
+ return result;
+ } catch (ParseException eee) {
+ return new Date(0);
+ }
+ }
+
+ /**
+ * Load les données sauf celle que l'on demande d'exclure du load
+ * @param exclude
+ */
+ protected void load(PreferenceType ... exclude) {
+ PreferenceType[] list = PreferenceType.values();
+ for (PreferenceType type : exclude) {
+ list[type.ordinal()] = null;
+ }
+
+ for (PreferenceType type : list) {
+ if (type != null) {
+ switch(type) {
+ case USER_PREF:
+ loadUserPref();
+ break;
+ case SITE_PREF:
+ loadSitePref();
+ break;
+ case LABELS:
+ loadLabels();
+ break;
+ case IMPORTS:
+ loadImport();
+ break;
+ default:
+ // do nothing
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * charge les info de l'utilisateur qu'il peut modifier
+ */
+ protected void loadUserPref() {
+ BowSession session = getBowSession();
+ BowUser user = session.getUser();
+
+ setEmail(user.getLogin());
+ }
+
+ /**
+ * Charge les preferences utilisateur pour le site
+ */
+ protected void loadSitePref() {
+ BowSession session = getBowSession();
+ BowUser user = session.getUser();
+
+ setColors(user.getColors());
+ setTagsNb(String.valueOf(user.getTags()));
+ setBookmarksHomePage(String.valueOf(user.getBookmarks()));
+ setSearchEngineUrlSuggestions(user.getSearchEngineUrlSuggestions());
+ setSearchEngineUrlResults(user.getSearchEngineUrlResults());
+ }
+
+ /**
+ * Charge la liste des imports que l'utilisateur a fait
+ */
+ protected void loadImport() {
+ BowSession session = getBowSession();
+ BowProxy proxy = session.getProxy();
+ BowUser user = session.getUser();
+
+ Criteria criteria = Search.query()
+ .exteq(BowImport.EXT_BOWIMPORT)
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId()).criteria()
+ .addFacetField(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE)
+ .setFirstIndex(0).setEndIndex(0);
+
+ List<FacetTopic> bookmarksImportDate =
+ proxy.findAllByCriteria(BowImport.class, criteria)
+ .getTopic(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE);
+
+ // Extract imports
+ Map<String, Integer> result = new HashMap<String, Integer>();
+ for (FacetTopic facet : bookmarksImportDate) {
+ String dateAsString = facet.getTopicName();
+ int count = facet.getCount();
+ result.put(dateAsString, count);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("bookmarksByImportDate found : "
+ + (result == null ? "null" : result.size()));
+ }
+ setBookmarksImportDate(result.isEmpty() ? null : result);
+ }
+
+ /**
+ * Charge dans la variable labels tous les labels de l'utilisateur
+ * @param proxy
+ */
+ protected void loadLabels() {
+ BowSession session = getBowSession();
+ BowProxy proxy = session.getProxy();
+ BowUser user = session.getUser();
+ String userId = user.getWikittyId();
+
+ Criteria c = Search.query()
+ .exteq(BowBookmark.EXT_WIKITTYLABEL)
+ .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId)
+ .criteria().setEndIndex(0) // on ne veut aucun resultat, c'est la facet dont on a besoin
+ .setFacetMinCount(1) // on demande meme les labels avec 1 seul item
+ .setFacetLimit(-1) // on demande tous les labels
+ .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
+ PagedResult<Wikitty> result = proxy.findAllByCriteria(c);
+ // lorsqu'on demande tout (facetLimit(-1)), les topics sont trie
+ // alphabetiquement pas besoin de les retrier
+ labels = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS);
+ }
+
+ /**
+ * ACTION STRUTS
+ *
+ * Action executer lorsque l'utilisateur demande la page. Prepare toutes
+ * les données pour la page JSP
+ */
+ @Override
+ public String input() {
+ String result = SUCCESS;
+
+ try {
+ // load all data
+ load();
+ } catch (Exception eee) {
+ result = ERROR;
+ addActionError(_("bow.error.internal"));
+ log.error("Can't load data preference", eee);
+ }
+ return result;
+ }
+}
Added: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,63 @@
+package org.chorem.bow.action.preference;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.bow.BowProxy;
+import org.chorem.bow.BowSession;
+import org.chorem.bow.BowUser;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class UpdateSiteAction extends PreferenceBaseAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(UpdateSiteAction.class);
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ACTION STRUTS
+ *
+ * Action executer lorsque l'utilisateur demande la page
+ */
+ @Override
+ public String execute() {
+ String result = SUCCESS;
+
+ try {
+ BowSession session = getBowSession();
+ BowProxy proxy = session.getProxy();
+ BowUser preference = session.getUser();
+
+ preference.setColors(colors);
+ if (StringUtils.isNotBlank(tagsNb)) {
+ preference.setTags(Integer.valueOf(tagsNb));
+ }
+ if (StringUtils.isNotBlank(bookmarksHomePage)) {
+ preference.setBookmarks(Integer.valueOf(bookmarksHomePage));
+ }
+ preference.setSearchEngineUrlSuggestions(searchEngineUrlSuggestions);
+ preference.setSearchEngineUrlResults(searchEngineUrlResults);
+
+ preference = proxy.store(preference);
+ getBowSession().setUser(preference);
+ } catch (Exception eee) {
+ result = ERROR;
+ addActionError(_("bow.error.internal"));
+ log.error("Can't change site preference", eee);
+ } finally {
+ // on recharge les data apres l'action pour l'affichage
+ // sauf celle du site qui sont deja les bonnes
+ load(PreferenceType.SITE_PREF);
+ }
+ return result;
+ }
+
+
+}
Added: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java (rev 0)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,103 @@
+package org.chorem.bow.action.preference;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.bow.BowProxy;
+import org.chorem.bow.BowSession;
+import org.chorem.bow.BowUser;
+import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class UpdateUserAction extends PreferenceBaseAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(UpdateUserAction.class);
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ACTION STRUTS
+ *
+ * Modifie l'email et le password si necessaire. Si la modif est impossible
+ * email deja utilise, ou mauvais password, alors la methode return ERROR
+ * Si tout ce passe bien, la methode retourne SUCCES
+ *
+ * @param user
+ * @return
+ */
+ @Override
+ public String execute() {
+ String result = SUCCESS;
+
+ try {
+ BowSession session = getBowSession();
+ BowProxy proxy = session.getProxy();
+ BowUser user = session.getUser();
+
+ if (StringUtils.isNotBlank(email)) {
+ Criteria criteria = Search.query().eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).criteria();
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Try to find user with email: '%s'", email));
+ }
+ BowUser find = getBowProxy().findByCriteria(BowUser.class, criteria);
+
+ //If this email address isn't already used (or if it hasn't changed)
+ if (find == null || find.getLogin().equals(user.getLogin())) {
+ email = email.trim();
+ user.setLogin(email);
+ } else {
+ // this email address is already used by someone else
+ setEmail(user.getLogin());
+
+ // TODO poussin 20110818 addFieldError don't work (no message on web page :(
+ // add addActionError to prevent addFieldError that don't work
+ addFieldError("email", _("bow.preferences.emailAldyExists"));
+ addActionError(_("bow.preferences.emailAldyExists"));
+ result = ERROR;
+ }
+ }
+
+ if (result == SUCCESS
+ && StringUtils.isNotBlank(newPassword)
+ && StringUtils.isNotBlank(confirmNewPassword)
+ && StringUtils.isNotBlank(currentPassword)) {
+ if (newPassword.equals(confirmNewPassword)) {
+ currentPassword = StringUtil.encodeMD5(currentPassword);
+ if (currentPassword.equals(user.getPassword())) {
+ user.setPassword(StringUtil.encodeMD5(newPassword));
+ } else {
+ // TODO poussin 20110818 addFieldError don't work (no message on web page :(
+ // add addActionError to prevent addFieldError that don't work
+ addFieldError("currentPassword", _("bow.preferences.badCurrentPassword"));
+ addActionError(_("bow.preferences.badCurrentPassword"));
+ result = ERROR;
+ }
+ }
+ }
+ if (result == SUCCESS) {
+ user = proxy.store(user);
+ getBowSession().setUser(user);
+ addActionMessage(_("bow.preferences.update.successful"));
+ }
+ } catch (Exception eee) {
+ addActionError(_("bow.error.internal"));
+ log.error("Can't change site preference", eee);
+ } finally {
+ // on recharge les data apres l'action pour l'affichage
+ // sauf celle du user qui sont deja les bonnes
+ load(PreferenceType.USER_PREF);
+ }
+
+ return result;
+ }
+
+}
Modified: trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties
===================================================================
--- trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties 2011-08-20 00:51:36 UTC (rev 313)
@@ -108,6 +108,7 @@
bow.rightMenu.bookmark.temporaryLinkDescription=Add this link to your favourites to bookmark others in the future. This link is only available while you are connected on the site\!
bow.rightMenu.chromiumExtension=Chromium extension
bow.rightMenu.extensions=Extensions
+bow.rightMenu.externSearchEngine=Web search
bow.rightMenu.find.submit=Find
bow.rightMenu.fullTextSearch=Full text search
bow.rightMenu.help=Help
Modified: trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties
===================================================================
--- trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties 2011-08-20 00:51:36 UTC (rev 313)
@@ -108,6 +108,7 @@
bow.rightMenu.bookmark.temporaryLinkDescription=Ajoutez ce lien \u00E0 vos favoris pour pouvoir bookmarker vos liens dans le futur. Ce lien est seulement disponible tant que vous \u00EAtes connect\u00E9 sur le site \!
bow.rightMenu.chromiumExtension=Extension pour chromium
bow.rightMenu.extensions=Extensions
+bow.rightMenu.externSearchEngine=Recherche Web
bow.rightMenu.find.submit=Rechercher
bow.rightMenu.fullTextSearch=Recherche full text
bow.rightMenu.help=Aide
Copied: trunk/bow-ui/src/main/resources/org/chorem/bow/action/preference/UpdateUserAction-validation.xml (from rev 306, trunk/bow-ui/src/main/resources/org/chorem/bow/action/RegisterAction-validation.xml)
===================================================================
--- trunk/bow-ui/src/main/resources/org/chorem/bow/action/preference/UpdateUserAction-validation.xml (rev 0)
+++ trunk/bow-ui/src/main/resources/org/chorem/bow/action/preference/UpdateUserAction-validation.xml 2011-08-20 00:51:36 UTC (rev 313)
@@ -0,0 +1,53 @@
+<!--
+ #%L
+ bow
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+ <field name="email">
+ <field-validator type="requiredstring">
+ <message key="bow.login.email.required" />
+ </field-validator>
+ <field-validator type="regex">
+ <param name="expression">^[a-z0-9!#$%&'*+/=?^_`{|}~-]+((\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)?)+@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?$</param>
+ <message key="bow.login.email.wrongformat" />
+ </field-validator>
+ </field>
+ <field name="password">
+ <field-validator type="requiredstring">
+ <message key="bow.login.password.required" />
+ </field-validator>
+ </field>
+ <field name="repeatPassword">
+ <field-validator type="requiredstring">
+ <message key="bow.login.repeatPassword.required" />
+ </field-validator>
+ </field>
+
+ <validator type="expression">
+ <param name="expression">password.equals(repeatPassword)</param>
+ <message key="bow.register.pwdDontMatch" />
+ </validator>
+</validators>
Modified: trunk/bow-ui/src/main/resources/struts.xml
===================================================================
--- trunk/bow-ui/src/main/resources/struts.xml 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/resources/struts.xml 2011-08-20 00:51:36 UTC (rev 313)
@@ -104,70 +104,62 @@
</package>
<package name="login" extends="loginArea">
- <action name="register_*" method="{1}" class="org.chorem.bow.action.RegisterAction">
+ <action name="register_*" method="{1}" class="org.chorem.bow.action.login.RegisterAction">
<result name="input">/jsp/register.jsp</result>
<result type="redirectAction">home</result>
</action>
- <action name="forgotPassword_*" method="{1}" class="org.chorem.bow.action.ForgotPasswordAction">
+ <action name="forgotPassword_*" method="{1}" class="org.chorem.bow.action.login.ForgotPasswordAction">
<result name="input">/jsp/forgotPassword.jsp</result>
<result type="redirectAction">login_input</result>
</action>
- <action name="login_*" method="{1}" class="org.chorem.bow.action.LoginAction">
+ <action name="login_*" method="{1}" class="org.chorem.bow.action.login.LoginAction">
<result name="input">/jsp/login.jsp</result>
<result name="login" type="redirectAction">home</result>
<result type="redirectAction">home</result>
</action>
- <action name="logout" class="org.chorem.bow.action.LogoutAction">
+ <action name="logout" class="org.chorem.bow.action.login.LogoutAction">
<result type="redirectAction">login_input</result>
</action>
</package>
<package name="bookmark" extends="restrictedArea">
- <action name="importBookmarks" class="org.chorem.bow.action.ImportBookmarksAction">
- <result type="redirectAction">preferences</result>
- <result name="error">/jsp/preferences.jsp</result>
+ <action name="home" class="org.chorem.bow.action.bookmark.HomeAction">
+ <result name="error">/jsp/home.jsp</result>
+ <result>/jsp/home.jsp</result>
</action>
- <action name="exportBookmarks" class="org.chorem.bow.action.ExportBookmarksAction">
- <result type="stream">
- <param name="contentType">application/octet-stream</param>
- <param name="inputName">inputStream</param>
- <param name="contentDisposition">attachment;filename="bookmarks.html"</param>
- </result>
- </action>
- <action name="removeBookmark" class="org.chorem.bow.action.RemoveBookmarkAction">
+ <action name="removeBookmark" class="org.chorem.bow.action.bookmark.RemoveAction">
+ <result name="error" type="redirect">${redirectTo}</result>
<result type="redirect">${redirectTo}</result>
</action>
- <action name="deleteImport" class="org.chorem.bow.action.DeleteImportAction">
- <result type="redirectAction">preferences</result>
+ <action name="editBookmark" class="org.chorem.bow.action.bookmark.EditAction">
+ <result name="error">/jsp/editBookmark.jsp</result>
+ <result>/jsp/editBookmark.jsp</result>
</action>
- <action name="addUrl" class="org.chorem.bow.action.AddUrlAction">
+ <action name="addUrl" class="org.chorem.bow.action.bookmark.AddOrUpdateAction">
+ <result name="error">/jsp/editBookmark.jsp</result>
<result type="redirect">${redirectTo}</result>
</action>
- <action name="editBookmark" class="org.chorem.bow.action.EditBookmarkAction">
- <result>/jsp/editBookmark.jsp</result>
+ <action name="deleteSearchResults" class="org.chorem.bow.action.bookmark.DeleteSearchResultsAction">
+ <result name="error" type="redirectAction">home</result>
+ <result type="redirectAction">home</result>
</action>
</package>
<!-- Fragment: en prevision de faire un peu d'ajax si l'utilisateur le souhaite -->
<package name="fragment" namespace="/fragment" extends="restrictedArea">
- <action name="editBookmark" class="org.chorem.bow.action.EditBookmarkAction">
+ <action name="editBookmark" class="org.chorem.bow.action.bookmark.EditAction">
+ <result name="error">/jsp/editBookmark.jsp</result>
<result>/jsp/editBookmark.jsp</result>
</action>
</package>
<package name="search" extends="restrictedArea">
- <action name="home" class="org.chorem.bow.action.HomeAction">
- <result>/jsp/home.jsp</result>
- </action>
<action name="openSearchResult" class="org.chorem.bow.action.OpenSearchResultAction">
<result type="redirect">${redirectTo}</result>
</action>
<action name="openSearchSuggestion" class="org.chorem.bow.action.OpenSearchSuggestionAction">
<result>/jsp/suggestions.jsp</result>
</action>
- <action name="deleteSearchResults" class="org.chorem.bow.action.DeleteSearchResultsAction">
- <result type="redirectAction">home</result>
- </action>
<action name="*Xml">
<result>/jsp/{1}Xml.jsp</result>
</action>
@@ -177,19 +169,50 @@
<action name="locale" class="org.chorem.bow.action.LocaleAction">
<result type="redirect">/jsp/login.jsp</result>
</action>
- <action name="regenPermToken" class="org.chorem.bow.action.GenerateTokenAction">
- <result type="redirectAction">preferences</result>
+
+ <action name="preferences" class="org.chorem.bow.action.preference.PreferenceBaseAction" method="input">
+ <result name="error">/jsp/preferences.jsp</result>
+ <result>/jsp/preferences.jsp</result>
</action>
+
+ <action name="generateToken" class="org.chorem.bow.action.preference.GenerateTokenAction">
+ <result name="error">/jsp/preferences.jsp</result>
+ <result>/jsp/preferences.jsp</result>
+ </action>
- <action name="adminlabels" class="org.chorem.bow.action.PreferencesAction" method="adminlabels">
- <result type="redirectAction">preferences</result>
+ <action name="updateUserPref" class="org.chorem.bow.action.preference.UpdateUserAction">
+ <result name="error">/jsp/preferences.jsp</result>
+ <result>/jsp/preferences.jsp</result>
</action>
- <action name="preferences" class="org.chorem.bow.action.PreferencesAction">
- <result name="update" type="redirectAction">preferences</result>
+ <action name="updateSitePref" class="org.chorem.bow.action.preference.UpdateSiteAction">
<result name="error">/jsp/preferences.jsp</result>
<result>/jsp/preferences.jsp</result>
</action>
+
+ <action name="adminlabels" class="org.chorem.bow.action.preference.AdminTagAction">
+ <result name="error">/jsp/preferences.jsp</result>
+ <result>/jsp/preferences.jsp</result>
+ </action>
+
+ <action name="deleteImport" class="org.chorem.bow.action.preference.DeleteImportAction">
+ <result name="error">/jsp/preferences.jsp</result>
+ <result>/jsp/preferences.jsp</result>
+ </action>
+
+ <action name="importBookmarks" class="org.chorem.bow.action.preference.ImportBookmarksAction">
+ <result name="error">/jsp/preferences.jsp</result>
+ <result>/jsp/preferences.jsp</result>
+ </action>
+
+ <action name="exportBookmarks" class="org.chorem.bow.action.preference.ExportBookmarksAction">
+ <result name="error">/jsp/preferences.jsp</result>
+ <result type="stream">
+ <param name="contentType">text/html</param>
+ <param name="inputName">inputStream</param>
+ <param name="contentDisposition">attachment;filename="bookmarks.html"</param>
+ </result>
+ </action>
</package>
<package name="admin" extends="restrictedArea">
@@ -197,10 +220,12 @@
<result name="error">/jsp/login.jsp</result>
<result>/jsp/admin.jsp</result>
</action>
- <action name="reIndexation" class="org.chorem.bow.action.ReIndexationAction">
+ <action name="reIndexation" class="org.chorem.bow.action.admin.ReIndexationAction">
+ <result name="error">/jsp/admin.jsp</result>
<result>/jsp/admin.jsp</result>
</action>
- <action name="migrateData" class="org.chorem.bow.action.MigrateDataAction">
+ <action name="migrateData" class="org.chorem.bow.action.admin.MigrateDataAction">
+ <result name="error">/jsp/admin.jsp</result>
<result>/jsp/admin.jsp</result>
</action>
</package>
Modified: trunk/bow-ui/src/main/webapp/jsp/admin.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/admin.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/admin.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,9 +20,10 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
+
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
xmlns:jsp="http://java.sun.com/JSP/Page"
Modified: trunk/bow-ui/src/main/webapp/jsp/editBookmark.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/editBookmark.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/editBookmark.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
@@ -40,7 +40,7 @@
</div>
<div class="formFrame fond">
<s:form id="popupAddUrlForm" action="addUrl" method="post">
- <s:hidden name="searchLine" value="%{searchLine}" />
+ <s:hidden name="tagLine" value="%{tagLine}" />
<s:hidden name="fullTextLine" value="%{fullTextLine}" />
<s:hidden name="bookmarkId" value="%{bookmark.wikittyId}"/>
<s:textfield name="link" labelSeparator=" " key="popup.addurl.link"
Modified: trunk/bow-ui/src/main/webapp/jsp/error.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/error.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/error.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
Modified: trunk/bow-ui/src/main/webapp/jsp/forgotPassword.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/forgotPassword.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/forgotPassword.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,31 +20,32 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
+
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<head>
- <title><s:text name="bow.forgotpwd.title" /></title>
- <s:url var="css" value="/css/connexion.css" />
- <link href="${css}" rel="stylesheet" type="text/css" />
- <s:head />
+ <title><s:text name="bow.forgotpwd.title" /></title>
+ <s:url var="css" value="/css/connexion.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
</head>
<body>
- <div id="content">
- <div id="formFrame fond">
- <h1><s:text name="bow.forgotpwd.title" /></h1>
- <s:form action="forgotPassword">
- <p>
- <s:textfield key="bow.login.email" name="email" labelposition="top" labelSeparator=" :" />
- <s:submit key="bow.forgotpwd.submit" name="submit" />
- </p>
- </s:form>
- <s:a action="login_input" id="loginLink"><s:text name="bow.login.title" /></s:a>
- </div>
- </div>
+ <div id="content">
+ <div id="formFrame fond">
+ <h1><s:text name="bow.forgotpwd.title" /></h1>
+ <s:form action="forgotPassword">
+ <p>
+ <s:textfield key="bow.login.email" name="email" labelposition="top" labelSeparator=" :" />
+ <s:submit key="bow.forgotpwd.submit" name="submit" />
+ </p>
+ </s:form>
+ <s:a action="login_input" id="loginLink"><s:text name="bow.login.title" /></s:a>
+ </div>
+ </div>
</body>
</html>
Modified: trunk/bow-ui/src/main/webapp/jsp/home.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/home.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/home.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,15 +20,9 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
-<%@page import="org.chorem.bow.BowBookmark" %>
-<%@page import="java.text.SimpleDateFormat" %>
-<%@page import="java.util.List" %>
-<%@page import="org.chorem.bow.BowSearchResult"%>
-<%@page import="org.chorem.bow.action.HomeAction"%>
-<%@page import="org.chorem.bow.BowConfig"%>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
@@ -50,7 +44,7 @@
<s:set name="bookmarksToDelete" value="%{searchResult.bookmarkCount}" />
<s:if test="%{#bookmarksToDelete > 0}">
<s:url var="deleteSearchResults" action="deleteSearchResults" escapeAmp="false">
- <s:param name="searchLine"><s:property value="searchResult.searchLine" /></s:param>
+ <s:param name="tagLine"><s:property value="searchResult.tagLine" /></s:param>
<s:param name="fullTextLine"><s:property value="searchResult.fullTextLine" /></s:param>
</s:url>
<s:a id="deleteSearchResultsButton" title="delete all" href="" onclick="deleteConfirmation('%{deleteSearchResults}', %{#bookmarksToDelete}); return(false);"></s:a>
@@ -59,7 +53,7 @@
<label for="order"><s:text name="bow.search.orderby" /></label>
<s:select id="order" name="order" list="possibleOrder"/>
<s:submit key="bow.search.submit" name="submit" />
- <s:hidden name="searchLine" value="%{searchResult.searchLine}" />
+ <s:hidden name="tagLine" value="%{searchResult.tagLine}" />
<s:hidden name="fullTextLine" value="%{searchResult.fullTextLine}" />
</s:form>
</div>
@@ -71,7 +65,7 @@
<s:iterator value="searchResult.bookmarks" var="bookmark">
<s:set name="bookmark" value="bookmark"/>
<jsp:include page="inc/bookmark.jsp" flush="true">
- <jsp:param name="searchLine" value="%{searchResult.searchLine}" />
+ <jsp:param name="tagLine" value="%{searchResult.tagLine}" />
<jsp:param name="fullTextLine" value="%{searchResult.fullTextLine}" />
</jsp:include>
</s:iterator>
Modified: trunk/bow-ui/src/main/webapp/jsp/inc/bookmark.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/inc/bookmark.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/inc/bookmark.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="sj" uri="/struts-jquery-tags" %>
@@ -31,26 +31,26 @@
<div class="bookmarkhead">
<p class="date"><s:property value="#bookmark.creationDate"/></p>
- <s:a cssClass="alias" href="%{config.servletAliasUrl + #bookmark.wikittyId}.action"
+ <s:a cssClass="alias" href="%{config.aliasUrl + #bookmark.wikittyId}.action"
title="%{#bookmark.link}" target="_blank">
a:<s:property value="%{#bookmark.privateAlias}" />
</s:a>
<s:if test="%{!#bookmark.publicAlias.empty}">
- <s:a cssClass="alias" href="%{config.servletAliasUrl + #bookmark.publicAlias}.action"
+ <s:a cssClass="alias" href="%{config.aliasUrl + #bookmark.publicAlias}.action"
title="%{#bookmark.link}" target="_blank">
<s:property value="%{#bookmark.publicAlias}" />
</s:a>
</s:if>
<s:url var="editBookmark" action="editBookmark" escapeAmp="true">
<s:param name="id"><s:property value="%{#bookmark.wikittyId}" /></s:param>
- <s:param name="searchLine"><s:property value="%{searchLine}" /></s:param>
+ <s:param name="tagLine"><s:property value="%{tagLine}" /></s:param>
<s:param name="fullTextLine"><s:property value="%{fullTextLine}" /></s:param>
</s:url>
<s:a cssClass="edit" href="%{editBookmark}"/>
<s:url var="removeBookmark" action="removeBookmark" escapeAmp="true">
<s:param name="bookmarkId"><s:property value="%{#bookmark.wikittyId}" /></s:param>
- <s:param name="searchLine"><s:property value="%{searchLine}" /></s:param>
+ <s:param name="tagLine"><s:property value="%{tagLine}" /></s:param>
<s:param name="fullTextLine"><s:property value="%{fullTextLine}" /></s:param>
</s:url>
<s:a cssClass="supprim" href="%{removeBookmark}"
@@ -71,7 +71,7 @@
<strong><s:text name="bow.bookmark.tags" /> :</strong>
<s:iterator value="#bookmark.labels" var="tag">
<s:url var="search" action="home">
- <s:param name="searchLine" value="%{searchLine}"/>
+ <s:param name="tagLine" value="%{tagLine}"/>
<s:param name="addTag" value="%{#tag}"/>
<s:param name="fullTextLine" value="%{fullTextLine}"/>
</s:url>
Modified: trunk/bow-ui/src/main/webapp/jsp/inc/footer.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/inc/footer.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/inc/footer.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
Modified: trunk/bow-ui/src/main/webapp/jsp/inc/header.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/inc/header.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/inc/header.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
$Id$
@@ -19,9 +19,10 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
--->
+--%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
+
<div id="header"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
xmlns:jsp="http://java.sun.com/JSP/Page">
@@ -41,7 +42,7 @@
<h3>Recherche</h3>
<div class="input">
<s:form action="home" theme="simple">
- <s:textfield name="searchLine" labelSeparator="" />
+ <s:textfield name="tagLine" labelSeparator="" />
<s:submit key="bow.rightMenu.search.tags" name="submit" />
</s:form>
</div>
@@ -51,6 +52,12 @@
<s:submit key="bow.rightMenu.fullTextSearch" name="submit" />
</s:form>
</div>
+ <div class="input">
+ <s:form action="openSearchResult" theme="simple">
+ <s:textfield name="searchLine" labelSeparator="" />
+ <s:submit key="bow.rightMenu.externSearchEngine" name="submit" />
+ </s:form>
+ </div>
</div>
</s:if>
<div id="msg">
Modified: trunk/bow-ui/src/main/webapp/jsp/inc/rightMenu.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/inc/rightMenu.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/inc/rightMenu.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="sj" uri="/struts-jquery-tags" %>
@@ -52,7 +52,7 @@
<li><s:a action="preferences"><s:text name="bow.preferences.title" /></s:a></li>
<li>
<s:url var="editBookmark" action="editBookmark" escapeAmp="true">
- <s:param name="searchLine"><s:property value="%{searchLine}" /></s:param>
+ <s:param name="tagLine"><s:property value="%{tagLine}" /></s:param>
<s:param name="fullTextLine"><s:property value="%{fullTextLine}" /></s:param>
</s:url>
<s:a href="%{editBookmark}">
@@ -62,7 +62,7 @@
</ul>
<!--div id="nuage"-->
<jsp:include page="tagsCloud.jsp" flush="true">
- <jsp:param name="searchLine" value="%{searchLine}" />
+ <jsp:param name="tagLine" value="%{tagLine}" />
<jsp:param name="fullTextLine" value="%{fullTextLine}"/>
</jsp:include>
<!--/div-->
Modified: trunk/bow-ui/src/main/webapp/jsp/inc/tagsCloud.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/inc/tagsCloud.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/inc/tagsCloud.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
@@ -29,7 +29,7 @@
xmlns:jsp="http://java.sun.com/JSP/Page">
<s:iterator value="%{searchResult.tagsCloud}" status="tagStatus" var="tag">
<s:url var="search" action="home" escapeAmp="true">
- <s:param name="searchLine" value="%{searchLine}"/>
+ <s:param name="tagLine" value="%{tagLine}"/>
<s:param name="addTag" value="%{#tag.topicName}"/>
<s:param name="fullTextLine" value="%{fullTextLine}"/>
</s:url>
Modified: trunk/bow-ui/src/main/webapp/jsp/login.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/login.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/login.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
Modified: trunk/bow-ui/src/main/webapp/jsp/permanentXml.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/permanentXml.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/permanentXml.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/xml" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@page import="org.chorem.bow.BowConfig" %>
Modified: trunk/bow-ui/src/main/webapp/jsp/preferences.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/preferences.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/preferences.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
--->
+--%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
@@ -71,7 +71,7 @@
</li>
</ul>
- <s:url var="regenPermToken" action="regenPermToken"/>
+ <s:url var="regenPermToken" action="generateToken"/>
<s:a href="%{regenPermToken}" id="regenPermToken">
<s:text name="bow.preferences.regenPermToken"/>
</s:a>
@@ -80,7 +80,7 @@
<div class="formFrame fond">
<h3><s:text name="bow.preferences.userInfo"/></h3>
<br/>
- <s:form action="preferences" theme="simple">
+ <s:form action="updateUserPref" theme="simple">
<s:text name="bow.login.email"/><br/>
<s:textfield name="email"
labelposition="top"/><br/>
@@ -103,7 +103,7 @@
<div class="formFrame fond">
<h3><s:text name="bow.preferences.siteLook"/></h3>
<br/>
- <s:form action="preferences" theme="simple">
+ <s:form action="updateSitePref" theme="simple">
<s:text name="bow.preferences.tagsNb"/><br/>
<s:textfield name="tagsNb" labelposition="top"/><br/>
@@ -156,7 +156,7 @@
<br/>
<s:form action="importBookmarks" method="post" enctype="multipart/form-data" theme="simple">
<s:file name="upfile" labelSeparator=""/>
- <s:hidden name="searchLine" value="%{searchLine}"/>
+ <s:hidden name="tagLine" value="%{tagLine}"/>
<s:hidden name="fullTextLine" value="%{fullTextLine}"/>
<s:submit key="bow.preferences.import.submit" name="submit"/>
</s:form>
Modified: trunk/bow-ui/src/main/webapp/jsp/register.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/register.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/register.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,9 +20,10 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
+
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
xmlns:jsp="http://java.sun.com/JSP/Page"
Modified: trunk/bow-ui/src/main/webapp/jsp/suggestions.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/suggestions.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/suggestions.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="org.chorem.bow.OpenSearchActions" %>
<%@page import="org.nuiton.wikitty.search.FacetTopic" %>
Modified: trunk/bow-ui/src/main/webapp/jsp/temporaryXml.jsp
===================================================================
--- trunk/bow-ui/src/main/webapp/jsp/temporaryXml.jsp 2011-08-19 16:31:32 UTC (rev 312)
+++ trunk/bow-ui/src/main/webapp/jsp/temporaryXml.jsp 2011-08-20 00:51:36 UTC (rev 313)
@@ -1,4 +1,4 @@
-<!--
+<%--
#%L
bow
@@ -20,7 +20,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
- -->
+ --%>
<%@page contentType="text/xml" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@page import="org.chorem.bow.BowConfig" %>
1
0
Author: tchemit
Date: 2011-08-19 18:31:32 +0200 (Fri, 19 Aug 2011)
New Revision: 312
Url: http://chorem.org/repositories/revision/bow/312
Log:
Update mavenpom4redmine to 3.0.2.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-18 15:00:54 UTC (rev 311)
+++ trunk/pom.xml 2011-08-19 16:31:32 UTC (rev 312)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.0.1</version>
+ <version>3.0.2</version>
</parent>
<groupId>org.chorem</groupId>
1
0
Author: bpoussin
Date: 2011-08-18 17:00:54 +0200 (Thu, 18 Aug 2011)
New Revision: 311
Url: http://chorem.org/repositories/revision/bow/311
Log:
Evolution #438: Refactore source code and simplify all
... continue
Modified:
trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java 2011-08-18 14:53:22 UTC (rev 310)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/OpenSearchActions.java 2011-08-18 15:00:54 UTC (rev 311)
@@ -41,7 +41,7 @@
protected List<FacetTopic> suggestions = new ArrayList<FacetTopic>();
protected String[] search;
- public void findSuggestions(List<String> searchLine) {
+ public void findSuggestions(Set<String> searchLine) {
int size = searchLine.size();
search = searchLine.toArray(new String[size]);
String word = search[size - 1];
1
0
r310 - in trunk/bow-ui/src/main/java/org/chorem/bow: . action
by bpoussin@users.chorem.org 18 Aug '11
by bpoussin@users.chorem.org 18 Aug '11
18 Aug '11
Author: bpoussin
Date: 2011-08-18 16:53:22 +0200 (Thu, 18 Aug 2011)
New Revision: 310
Url: http://chorem.org/repositories/revision/bow/310
Log:
Evolution #438: Refactore source code and simplify all
- move import/export sspecifique method from BookmarkUtils to specifique action
- add normalizeXXXX method in BowUtils to help to convert object to right object to storage
- remove many not use any more method
Modified:
trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java
trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java
trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-18 10:15:48 UTC (rev 309)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-18 14:53:22 UTC (rev 310)
@@ -29,8 +29,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
@@ -75,7 +73,7 @@
}
if (StringUtils.isNotBlank(searchLine)) {
- List<String> tags = BowUtils.getWords(searchLine);
+ Set<String> tags = BowUtils.getWords(searchLine);
search.eq(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, tags);
}
@@ -142,101 +140,6 @@
}
/**
- * @param html String html
- * @param name String name
- * @param user User user
- * @return Bookmark the bookmark filled
- */
- public static BowBookmark createBookmarkFromHtml(String html, String name, BowUser user) {
- String link = getUrlFromHtml(html);
- String tags = getTagsFromHtml(html);
- Date date = getDateFromHtml(html);
- BowBookmark bookmark = createBookmark(link, name, tags, user, null, null, date);
- return bookmark;
- }
-
- /**
- * @param html String html
- * @return Date from the html
- */
- public static Date getDateFromHtml(String html) {
- Date date = null;
- if (html != null) {
- Pattern p = Pattern.compile("ADD_DATE=\"([^\"]*)\"");
- Matcher m = p.matcher(html);
- if (m.find()) {
- String str = m.group(1);
- if (str != null && !str.isEmpty()) {
- long time = Long.valueOf(str) * 1000; // the date in ms
- date = new Date(time);
- }
- }
- }
- return date;
- }
-
- /**
- * @param bookmarks List<Bookmarks> bookmarks
- * @return String the html file
- */
- public static String getExportHtmlBookmark(List<BowBookmark> bookmarks) {
- String export;
- export = "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
- + "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n"
- + "<DL><p>\n";
- if (bookmarks != null) {
- for (BowBookmark bookmark : bookmarks) {
- if (bookmark != null) {
- export += "<DT><A HREF=\"";
- export += bookmark.getLink() + "\" ";
- Date date = bookmark.getCreationDate();
- if (date != null) {
- long milli = date.getTime();
- String time = String.valueOf(milli / 1000);
- export += "ADD_DATE=\"" + time + "\" LAST_MODIFIED=\"" + time + "\" ";
- }
- export += "LAST_CHARSET=\"UTF-8\" ";
- Set<String> tags = bookmark.getLabels();
- if (tags != null && !tags.isEmpty()) {
- export += "SHORTCUTURL=\"" + getBookmarkTagsString(bookmark) + "\"";
- }
- export += ">" + bookmark.getDescription() + "</A>\n";
- }
- }
- }
- export += "</DL><p>";
- return export;
- }
-
- /**
- * @param html String html
- * @return url
- */
- public static String getUrlFromHtml(String html) {
- String url = "";
- if (html != null) {
- Pattern p = Pattern.compile("A HREF=\"([^\"]*)\"");
- Matcher m = p.matcher(html);
- if (m.find()) {
- url = m.group(1);
- }
- }
- return url;
- }
-
- public static String getTagsFromHtml(String html) {
- String tags = "";
- if (html != null) {
- Pattern p = Pattern.compile("SHORTCUTURL=\"([^\"]*)\"");
- Matcher m = p.matcher(html);
- if (m.find()) {
- tags = m.group(1);
- }
- }
- return tags;
- }
-
- /**
* @param url String which contains the bookmark url
* @param nameAndTags String which contains the name and the tags of the
* bookmark separated by '|' ==> name|tag1 tag2...
@@ -245,53 +148,25 @@
*/
public static BowBookmark createBookmark(String url, String nameAndTags, BowUser user) {
- BowBookmark bookmark = new BowBookmarkImpl();
+ // on recherche les tags qui doivent etre apres le dernier |
+ // ce qu'il y a devant est la description qui peut elle aussi contenir
+ // des |
- int nameIndex = nameAndTags.indexOf('|'); // get the index name of the website
+ // on s'assure que la chaine est non null, et en enleve les blanc en trop
+ String name = BowUtils.normalizeString(nameAndTags);
+ String tags = ""; // par defaut on a pas de tag
+
+ int nameIndex = name.lastIndexOf('|');
if (nameIndex > 0) {
- String name = nameAndTags.substring(0, nameIndex); // get the website name
- if (!name.isEmpty()) {
- name = name.trim();
- bookmark.setDescription(name); // set the description (website name)
- }
+ // il faut faire tags avant name, car on change name ensuite
+ tags = name.substring(nameIndex + 1);
+ name = name.substring(0, nameIndex); // get the website description
}
- String tags = nameAndTags;
- if (nameIndex >= 0) {
- tags = nameAndTags.substring(nameIndex + 1); // get tags, +1 because of '|'
- }
- addTagsToBookmark(BowUtils.getWords(tags), bookmark);
- addUrlToBookmark(url, bookmark);
- bookmark.setClick(0);
- bookmark.setOwner(user.getWikittyId());
- bookmark.addReader(user.getWikittyId()); // only owner can read it
- bookmark.setCreationDate(new Date()); // set the date
+ BowBookmark bookmark = createBookmark(url, name, tags, user, "", "", null);
+
return bookmark;
}
- public static void addUrlToBookmark(String url, BowBookmark bookmark) {
- if (url != null && !url.isEmpty()) {
- String link = url.trim();
- if (! link.matches("[a-z]+://.+") ) {
- link = "http://" + link;
- }
- bookmark.setLink(link);
- } else {
- bookmark.setLink("");
- }
- }
-
- public static void addTagsToBookmark(List<String> tagList, BowBookmark bookmark) {
- if (tagList != null) {
- for (String tag : tagList) {
- if (StringUtils.isNotEmpty(tag)) {
- // on peut ajouter plusieurs fois le meme tag, car on les
- // stocke dans un Set
- bookmark.addLabels(tag);
- }
- }
- }
- }
-
/**
* Create new Bookmark
*
@@ -307,64 +182,33 @@
BowUser user, String privateAlias, String publicAlias, Date date) {
BowBookmark bookmark = new BowBookmarkImpl();
- if (name != null) {
- name = name.trim();
- bookmark.setDescription(name);
- } else {
- bookmark.setDescription("");
- }
- addTagsToBookmark(BowUtils.getWords(tags), bookmark);
+ bookmark.setDescription(BowUtils.normalizeString(name));
+
+ bookmark.addAllLabels(BowUtils.getWords(tags));
+ bookmark.setLink(BowUtils.normalizeUrl(url));
- addUrlToBookmark(url, bookmark);
-
bookmark.setClick(0);
bookmark.setOwner(user.getWikittyId());
bookmark.addReader(user.getWikittyId()); // only owner can read it
- if (date == null) {
- date = new Date();
- }
- bookmark.setCreationDate(date); // set the date
- if (privateAlias != null) {
- privateAlias = privateAlias.trim();
- bookmark.setPrivateAlias(privateAlias);
- } else {
- bookmark.setPrivateAlias("");
- }
- if (publicAlias != null) {
- publicAlias = publicAlias.trim();
- bookmark.setPublicAlias(publicAlias);
- } else {
- bookmark.setPublicAlias("");
- }
+ bookmark.setCreationDate(BowUtils.normalizeDate(date));
+
+ bookmark.setPrivateAlias(BowUtils.normalizeString(privateAlias));
+ bookmark.setPublicAlias(BowUtils.normalizeString(publicAlias));
+
return bookmark;
}
- public static void updateBookmarkName(BowBookmark bookmark, String name) {
- if (name != null) {
- name = name.trim();
- bookmark.setDescription(name);
- }
- }
-
public static void updateBookmark(BowBookmark bookmark, String name,
String link, String tags, String privateAlias, String publicAlias) {
- if (name != null) {
- name = name.trim();
- bookmark.setDescription(name);
- }
- addUrlToBookmark(link, bookmark);
- bookmark.clearLabels();
- addTagsToBookmark(BowUtils.getWords(tags), bookmark);
- if (privateAlias != null) {
- privateAlias = privateAlias.trim();
- }
- bookmark.setPrivateAlias(privateAlias);
- if (publicAlias != null) {
- publicAlias = publicAlias.trim();
- }
- bookmark.setPublicAlias(publicAlias);
+ bookmark.setDescription(BowUtils.normalizeString(name));
+
+ bookmark.setLink(BowUtils.normalizeUrl(link));
+ bookmark.setLabels(BowUtils.getWords(tags));
+
+ bookmark.setPrivateAlias(BowUtils.normalizeString(privateAlias));
+ bookmark.setPublicAlias(BowUtils.normalizeString(publicAlias));
}
public static String getBookmarkTagsString(BowBookmark bookmark) {
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java 2011-08-18 10:15:48 UTC (rev 309)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java 2011-08-18 14:53:22 UTC (rev 310)
@@ -114,9 +114,8 @@
// on ne met pas dans le cloud les tags qui ont servi pour la recherche
List<FacetTopic> save = new ArrayList<FacetTopic>(tagsCloud);
- // on met dans un Set pour optimiser la recherche
- Set<String> tagsSearch =
- new HashSet<String>(BowUtils.getWords(getSearchLine()));
+ // on recupere les tags dans un set pour optimiser la recherche
+ Set<String> tagsSearch = BowUtils.getWords(getSearchLine());
for(Iterator<FacetTopic> i=tagsCloud.iterator(); i.hasNext();) {
FacetTopic topic = i.next();
@@ -163,7 +162,7 @@
return tagsCloud;
}
- public List<String> getTagsSearch() {
+ public Set<String> getTagsSearch() {
return BowUtils.getWords(getSearchLine());
}
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java 2011-08-18 10:15:48 UTC (rev 309)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java 2011-08-18 14:53:22 UTC (rev 310)
@@ -25,7 +25,9 @@
import java.util.Arrays;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.nuiton.util.StringUtil;
@@ -34,8 +36,10 @@
import org.nuiton.wikitty.search.Search;
import java.util.UUID;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.time.DateFormatUtils;
+import org.nuiton.util.DateUtil;
public class BowUtils {
@@ -45,17 +49,71 @@
}
/**
+ * Retourne toujours une date valide. Si date est null, on prend la date
+ * du jour
+ *
+ * @param date null or valide date
+ * @return date if date not null, or today date
+ */
+ static public Date normalizeDate(Date date) {
+ Date result = date;
+ if (result == null) {
+ result = new Date();
+ }
+ return result;
+ }
+
+ /**
+ * Supprime les blancs de debut et de fin, et retourne une chaine vide si s
+ * est null
+ *
+ * @param s null or string
+ * @return empty string or string without blank at begin and end
+ */
+ static public String normalizeString(String s) {
+ String result = StringUtils.defaultIfBlank(s, "");
+ result = result.trim();
+ return result;
+ }
+
+ /**
+ * Normalise l'url, si elle est null ou vide retourne une chaine vide.
+ * Si elle ne commence pas par un protocol (ex: ftp://) alors on ajoute
+ * automatiquement http://
+ *
+ * @param url l'url a normaliser
+ * @return l'url normalisee
+ */
+ public static String normalizeUrl(String url) {
+ String result = "";
+ if (StringUtils.isNotBlank(url)) {
+ result = url.trim();
+ if (! result.matches("[a-z]+://.+") ) {
+ result = "http://" + result;
+ }
+ }
+ return result;
+ }
+
+ /**
* Donne la liste des mots de la chaine passee en parametre.
- * Si tags est null ou vide, le tableau retourne sera vide
+ * Si tags est null ou vide, le 'set' retourne sera vide.
*
+ * La liste retournee ne doit jamais contenir de chaine null ou vide.
+ *
* @param tags
* @return
*/
- static public List<String> getWords(String tags) {
+ static public Set<String> getWords(String tags) {
String [] words = StringUtils.split(tags);
words = ArrayUtils.nullToEmpty(words);
- List<String> result = Arrays.asList(words);
+ Set<String> result = new HashSet<String>(Arrays.asList(words));
+
+ // on s'assure que la liste ne retourne jamais de chaine null ou vide.
+ result.remove("");
+ result.remove(null);
+
return result;
}
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java 2011-08-18 10:15:48 UTC (rev 309)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/ExportBookmarksAction.java 2011-08-18 14:53:22 UTC (rev 310)
@@ -29,7 +29,10 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Writer;
+import java.util.Date;
import java.util.List;
+import java.util.Set;
import javax.servlet.http.HttpServletResponse;
@@ -62,6 +65,41 @@
}
/**
+ * Export tous les bookmarks au format HTML tel que le fait les navigateurs
+ *
+ * @param bookmarks List<Bookmarks> bookmarks
+ * @param out le flux dans lequel il faut ecrire l'export
+ * @return String the html file
+ */
+ protected void generateExportHtmlBookmark(List<BowBookmark> bookmarks, Writer out) throws IOException {
+ out.write("<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
+ + "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n"
+ + "<DL><p>\n");
+ if (bookmarks != null) {
+ for (BowBookmark bookmark : bookmarks) {
+ if (bookmark != null) {
+ out.write("<DT><A HREF=\"");
+ out.write(bookmark.getLink() + "\" ");
+ Date date = bookmark.getCreationDate();
+ if (date != null) {
+ long milli = date.getTime();
+ String time = String.valueOf(milli / 1000);
+ out.write("ADD_DATE=\"" + time + "\" LAST_MODIFIED=\"" + time + "\" ");
+ }
+ out.write("LAST_CHARSET=\"UTF-8\" ");
+ Set<String> tags = bookmark.getLabels();
+ if (tags != null && !tags.isEmpty()) {
+ out.write("SHORTCUTURL=\""
+ + BookmarkUtils.getBookmarkTagsString(bookmark) + "\"");
+ }
+ out.write(">" + bookmark.getDescription() + "</A>\n");
+ }
+ }
+ }
+ out.write("</DL><p>");
+ }
+
+ /**
* Exports the bookmarks in HTML format
*/
@Override
@@ -77,7 +115,6 @@
List<BowBookmark> bookmarks = proxy.findAllByCriteria(BowBookmark.class, criteria).getAll();
// Export all
- String export = BookmarkUtils.getExportHtmlBookmark(bookmarks);
BufferedWriter out = null;
try {
@@ -87,11 +124,12 @@
tmp.deleteOnExit();
out = new BufferedWriter(new FileWriter(tmp));
- out.write(export);
+ generateExportHtmlBookmark(bookmarks, out);
+ out.close();
inputStream = new FileInputStream(tmp);
- } catch (IOException e) {
- log.error("Error when exporting bookmarks to HTML : " + e.getMessage(), e);
+ } catch (IOException eee) {
+ log.error("Error when exporting bookmarks to HTML : ", eee);
} finally {
IOUtils.closeQuietly(out);
}
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-08-18 10:15:48 UTC (rev 309)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-08-18 14:53:22 UTC (rev 310)
@@ -28,7 +28,12 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
import org.chorem.bow.BookmarkUtils;
import org.chorem.bow.BowBookmark;
@@ -100,11 +105,72 @@
this.upfileFileName = upfileFileName;
}
+ /**
+ * @param html String html
+ * @param name String name
+ * @param user User user
+ * @return Bookmark the bookmark filled
+ */
+ protected BowBookmark createBookmarkFromHtml(String html, String name, BowUser user) {
+ String link = getUrlFromHtml(html);
+ String tags = getTagsFromHtml(html);
+ Date date = getDateFromHtml(html);
+ BowBookmark bookmark = BookmarkUtils.createBookmark(link, name, tags, user, null, null, date);
+ return bookmark;
+ }
+
+ /**
+ * @param html String html
+ * @return Date from the html
+ */
+ protected Date getDateFromHtml(String html) {
+ Date date = null;
+ if (html != null) {
+ Pattern p = Pattern.compile("ADD_DATE=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ String str = m.group(1);
+ if (str != null && !str.isEmpty()) {
+ long time = Long.valueOf(str) * 1000; // the date in ms
+ date = new Date(time);
+ }
+ }
+ }
+ return date;
+ }
+
+ /**
+ * @param html String html
+ * @return url
+ */
+ protected String getUrlFromHtml(String html) {
+ String url = "";
+ if (html != null) {
+ Pattern p = Pattern.compile("A HREF=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ url = m.group(1);
+ }
+ }
+ return url;
+ }
+
+ protected String getTagsFromHtml(String html) {
+ String tags = "";
+ if (html != null) {
+ Pattern p = Pattern.compile("SHORTCUTURL=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ tags = m.group(1);
+ }
+ }
+ return tags;
+ }
+
protected void parseHtmlToBookmarks(NodeList list, BowUser user, Date date,
- List<BowBookmark> bookmarks, List<String> tagList)
+ List<BowBookmark> bookmarks, Set<String> tagList)
throws ParserException {
- boolean isFolder = false;
SimpleNodeIterator it = list.elements();
while (it.hasMoreNodes()) {
@@ -115,21 +181,20 @@
String text = node.getText(); // The text in the head ==>
// <text></toto>
- if (text != null && text.startsWith("H3")) { // H3 = folder
- if (plainText != null && !plainText.isEmpty()) {
+ if (StringUtils.startsWithIgnoreCase(text, "h3")) { // H3 = folder
+ if (StringUtils.isNotBlank(plainText)) {
tagList.add(plainText); // Adds the folder name to the
// tagList
- isFolder = true;
}
- } else if (text != null && text.startsWith("A HREF")) { // HREF
+ } else if (StringUtils.startsWithIgnoreCase(text, "a href")) { // HREF
// = new
// bookmarks
- BowBookmark bookmark = BookmarkUtils
- .createBookmarkFromHtml(text, plainText, user);
+ BowBookmark bookmark = createBookmarkFromHtml(text, plainText, user);
Wikitty w = getBowProxy().getWikitty(bookmark);
BowImportHelper.addExtension(w);
BowImportHelper.setImportDate(w, date);
- BookmarkUtils.addTagsToBookmark(tagList, bookmark);
+
+ bookmark.addAllLabels(tagList);
bookmarks.add(bookmark);
}
@@ -137,16 +202,12 @@
if (children != null) {
parseHtmlToBookmarks(children, user, date, bookmarks,
- tagList); // If there is an under node = recursion
+ // On utilise une nouvelle liste pour les enfants
+ // pour eviter que les tags de tous les enfants se
+ // retrouve ensemble
+ new HashSet<String>(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);
- }
- }
}
@Override
@@ -167,7 +228,7 @@
List<BowBookmark> bookmarks = new ArrayList<BowBookmark>();
parseHtmlToBookmarks(list, user, new Date(), bookmarks,
- new ArrayList<String>());
+ new HashSet<String>());
proxy.store(bookmarks);
addActionMessage(_("bow.bookmark.import.successful"));
Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java
===================================================================
--- trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-18 10:15:48 UTC (rev 309)
+++ trunk/bow-ui/src/main/java/org/chorem/bow/action/OpenSearchSuggestionAction.java 2011-08-18 14:53:22 UTC (rev 310)
@@ -26,6 +26,7 @@
import com.opensymphony.xwork2.ActionContext;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.chorem.bow.BowBookmark;
import org.chorem.bow.OpenSearchActions;
@@ -66,7 +67,7 @@
openSearchActions = new OpenSearchActions();
WikittyProxy proxy = getBowProxy();
- List<String> searchLineList = BowUtils.getWords(searchLine);
+ Set<String> searchLineList = BowUtils.getWords(searchLine);
if (searchLine.charAt(searchLine.length() - 1) == ' ') {
searchLineList.add(""); //If the user doesn't type anything, we have to propose suggestions
1
0