This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository bow. See http://git.chorem.org/bow.git commit 92b801d849e62c3aecf5412a20166e11e6bb121e Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Sat Jul 18 00:12:38 2015 +0200 add support to filter on specific BowBookmark wikittyId (listId) useful to show bookmark after editing or for atom link --- .../main/java/org/chorem/bow/BookmarkUtils.java | 13 ++++++--- bow-ui/src/main/java/org/chorem/bow/BowUtils.java | 34 ++++++++++++++++++---- .../java/org/chorem/bow/action/AtomAction.java | 2 +- .../java/org/chorem/bow/action/BowBaseAction.java | 11 +++++++ .../action/bookmark/DeleteSearchResultsAction.java | 6 ++-- .../org/chorem/bow/action/bookmark/HomeAction.java | 3 +- 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java b/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java index e615c74..690d348 100644 --- a/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java +++ b/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java @@ -31,6 +31,8 @@ import org.nuiton.util.StringUtil; import java.util.Date; import java.util.Set; import java.util.HashSet; +import java.util.List; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -69,13 +71,16 @@ public class BookmarkUtils { } public static WikittyQuery getBookmarkListCriteriaByUser(BowUser user, - String tagLine, - String fullTextLine, - String order, - int first) { + List<String> listId, String tagLine, String fullTextLine, + String order, int first) { + WikittyQueryMaker search = new WikittyQueryMaker().and(); addEqUser(search, user.getWikittyId()); + if (CollectionUtils.isNotEmpty(listId)) { + search.containsOne(Element.ID, listId); + } + if (StringUtils.isNotBlank(fullTextLine)) { search.keyword(fullTextLine); } diff --git a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java index 1abf130..b4dd42a 100644 --- a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java +++ b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java @@ -28,9 +28,11 @@ import org.nuiton.util.StringUtil; import java.util.Arrays; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.UUID; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.collections4.CollectionUtils; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; @@ -141,20 +143,40 @@ public class BowUtils { * @return the page where the user will be redirected */ public static String redirectTo(String tagLine, String fullTextLine) { + String result = redirectTo(null, tagLine, fullTextLine); + return result; + } + + /** + * Redirects the user either on the home page or on the search page + * + * @param listId list of bookmark id + * @param tagLine search line + * @param fullTextLine full text search + * @return the page where the user will be redirected + */ + public static String redirectTo(List<String> listId, String tagLine, String fullTextLine) { String result = "home.action"; + + boolean listIdNotEmpty = CollectionUtils.isNotEmpty(listId); boolean tagLineNotBlank = StringUtils.isNotBlank(tagLine); boolean fullTextLineNotBlank = StringUtils.isNotBlank(fullTextLine); - if (tagLineNotBlank || fullTextLineNotBlank) { + if (listIdNotEmpty || tagLineNotBlank || fullTextLineNotBlank) { result += "?"; - if (tagLineNotBlank) { - result += "tagLine=" + tagLine; + String sep = ""; + if (listIdNotEmpty) { + for (String id : listId) { + result += sep + "listId=" + id; + sep = "&"; + } } - if (tagLineNotBlank && fullTextLineNotBlank) { - result += "&"; + if (tagLineNotBlank) { + result += sep + "tagLine=" + tagLine; + sep = "&"; } if (fullTextLineNotBlank) { - result += "fullTextLine=" + fullTextLine; + result += sep + "fullTextLine=" + fullTextLine; } } return result; diff --git a/bow-ui/src/main/java/org/chorem/bow/action/AtomAction.java b/bow-ui/src/main/java/org/chorem/bow/action/AtomAction.java index 7c6803c..fcfd311 100644 --- a/bow-ui/src/main/java/org/chorem/bow/action/AtomAction.java +++ b/bow-ui/src/main/java/org/chorem/bow/action/AtomAction.java @@ -97,7 +97,7 @@ public class AtomAction extends BowBaseAction { BowProxy proxy = session.getProxy(); WikittyQuery criteria = BookmarkUtils.getBookmarkListCriteriaByUser( - user, tagLine, fullTextLine, "descDate", 0); + user, listId, tagLine, fullTextLine, "descDate", 0); criteria.setLimit(count); WikittyQueryResult<String> bookmarksId = proxy.findAllByQuery(criteria); bookmarks = proxy.restore(BowBookmark.class, bookmarksId.getAll(), "WikittyAuthorisation.owner"); diff --git a/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java b/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java index 65ec010..f15856c 100644 --- a/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java +++ b/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java @@ -62,6 +62,9 @@ public class BowBaseAction extends BaseAction implements SessionAware { /** Configuration, default null for lazy loading */ protected transient BowConfig config; + /** des identifiants de bookmark a recherche explicitemnet */ + protected List<String> listId; + /** Les tags a recherche separer par un espace */ protected String tagLine; @@ -100,6 +103,14 @@ public class BowBaseAction extends BaseAction implements SessionAware { this.session = session; } + public List<String> getListId() { + return listId; + } + + public void setListId(List<String> listId) { + this.listId = listId; + } + /** @return the tagLine */ public String getTagLine() { return tagLine; diff --git a/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java b/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java index db0f67c..fd7f466 100644 --- a/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java +++ b/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java @@ -52,10 +52,10 @@ public class DeleteSearchResultsAction extends BowBaseAction { // potentiellement des bookmarks qui ne nous appartiennent pas, // dans ce cas, ne faudrait-il pas seulement ce supprimer des // reader/write/admin ? - // FIXME tchemit 20110829 J'ai mis en dernier paramètre 0 car ça ne compilait pô mais je sais pas si c'est le bon!... WikittyQuery criteria = BookmarkUtils.getBookmarkListCriteriaByUser( - user, tagLine, fullTextLine, null, 0); - + user, listId, tagLine, fullTextLine, null, 0); + criteria.setLimit(Integer.MAX_VALUE); + BowProxy proxy = getBowProxy(); List<String> ids = proxy.findAllByQuery(criteria).getAll(); diff --git a/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java b/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java index 56dab4c..7161053 100644 --- a/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java +++ b/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java @@ -21,6 +21,7 @@ package org.chorem.bow.action.bookmark; import com.opensymphony.xwork2.ActionContext; +import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -93,7 +94,7 @@ public class HomeAction extends BowBaseAction { BowProxy proxy = session.getProxy(); WikittyQuery criteria = BookmarkUtils.getBookmarkListCriteriaByUser( - user, tagLine, fullTextLine, order, first); + user, listId, tagLine, fullTextLine, order, first); WikittyQueryResult<BowBookmark> result = proxy.findAllByQuery(BowBookmark.class, criteria); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.