r208 - in trunk/src/main: java/org/chorem/bow/action resources webapp/jsp/inc
Author: vbriand Date: 2011-02-18 10:04:26 +0100 (Fri, 18 Feb 2011) New Revision: 208 Url: http://chorem.org/repositories/revision/bow/208 Log: Renamed AddClickAction to RedirectToUrlAction Added: trunk/src/main/java/org/chorem/bow/action/RedirectToUrlAction.java Removed: trunk/src/main/java/org/chorem/bow/action/AddClickAction.java Modified: trunk/src/main/resources/struts.xml trunk/src/main/webapp/jsp/inc/bookmark.jsp Deleted: trunk/src/main/java/org/chorem/bow/action/AddClickAction.java =================================================================== --- trunk/src/main/java/org/chorem/bow/action/AddClickAction.java 2011-02-18 08:35:57 UTC (rev 207) +++ trunk/src/main/java/org/chorem/bow/action/AddClickAction.java 2011-02-18 09:04:26 UTC (rev 208) @@ -1,76 +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.BowBookmark; -import org.nuiton.wikitty.WikittyProxy; - -public class AddClickAction extends BowBaseAction { - - private static final long serialVersionUID = 8579081104294143087L; - protected String bookmarkId; - protected String link; - - /** - * @return the bookmarkId - */ - public String getBookmarkId() { - return bookmarkId; - } - /** - * @param bookmarkId the bookmarkId to set - */ - 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; - } - - public String execute() { - String result = ERROR; - if (bookmarkId != null && !bookmarkId.isEmpty()) { - WikittyProxy proxy = getBowProxy(); - BowBookmark bookmark = proxy.restore(BowBookmark.class, bookmarkId); - if (bookmark != null) { - bookmark.setClick(bookmark.getClick() + 1); - proxy.store(bookmark); - setLink(bookmark.getLink()); - result = SUCCESS; - } - } - return result; - } - -} \ No newline at end of file Copied: trunk/src/main/java/org/chorem/bow/action/RedirectToUrlAction.java (from rev 206, trunk/src/main/java/org/chorem/bow/action/AddClickAction.java) =================================================================== --- trunk/src/main/java/org/chorem/bow/action/RedirectToUrlAction.java (rev 0) +++ trunk/src/main/java/org/chorem/bow/action/RedirectToUrlAction.java 2011-02-18 09:04:26 UTC (rev 208) @@ -0,0 +1,86 @@ +/* + * #%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.BowBookmark; +import org.nuiton.wikitty.WikittyProxy; + +/** + * Retrieves the bookmark URL (where the user will be redirected) and increments + * the click counter for this bookmark + * + */ +public class RedirectToUrlAction extends BowBaseAction { + + private static final long serialVersionUID = 8579081104294143087L; + + protected String bookmarkId; + protected String link; + + /** + * @return the bookmarkId + */ + public String getBookmarkId() { + return bookmarkId; + } + /** + * @param bookmarkId the bookmarkId to set + */ + 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; + } + + /** + * Increments the click counter and sets the link (retrieved by Struts2) + * where the user will be redirected + */ + public String execute() { + String result = ERROR; + if (bookmarkId != null && !bookmarkId.isEmpty()) { + WikittyProxy proxy = getBowProxy(); + BowBookmark bookmark = proxy.restore(BowBookmark.class, bookmarkId); + if (bookmark != null) { + bookmark.setClick(bookmark.getClick() + 1); + proxy.store(bookmark); + setLink(bookmark.getLink()); + result = SUCCESS; + } + } + return result; + } + +} \ No newline at end of file Property changes on: trunk/src/main/java/org/chorem/bow/action/RedirectToUrlAction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/resources/struts.xml =================================================================== --- trunk/src/main/resources/struts.xml 2011-02-18 08:35:57 UTC (rev 207) +++ trunk/src/main/resources/struts.xml 2011-02-18 09:04:26 UTC (rev 208) @@ -164,7 +164,7 @@ <interceptor-ref name="loginStack" /> <result type="redirect">${redirectTo}</result> </action> - <action name="addClick" class="org.chorem.bow.action.AddClickAction"> + <action name="redirectToUrl" class="org.chorem.bow.action.RedirectToUrlAction"> <interceptor-ref name="loginStack" /> <result name="error" type="redirectAction">home</result> <result type="redirect">${link}</result> Modified: trunk/src/main/webapp/jsp/inc/bookmark.jsp =================================================================== --- trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-02-18 08:35:57 UTC (rev 207) +++ trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-02-18 09:04:26 UTC (rev 208) @@ -68,10 +68,10 @@ <div class="description"> <h3><s:text name="bow.bookmark.description" /> :</h3> <p> - <s:url var="addClick" action="addClick"> + <s:url var="redirectTo" action="redirectToUrl"> <s:param name="bookmarkId"><s:property value="%{#wikittyId}" /></s:param> </s:url> - <s:a title="%{#bookmarkLink}" href="%{addClick}" onclick="window.open(this.href); return false;"><s:property value="%{#bookmarkDescription}" /></s:a> + <s:a title="%{#bookmarkLink}" href="%{redirectTo}" onclick="window.open(this.href); return false;"><s:property value="%{#bookmarkDescription}" /></s:a> </p> <p class="tags"> <strong><s:text name="bow.bookmark.tags" /> :</strong>
participants (1)
-
vbriand@users.chorem.org