Author: tchemit Date: 2012-03-23 22:32:36 +0100 (Fri, 23 Mar 2012) New Revision: 3207 Url: http://chorem.org/repositories/revision/pollen/3207 Log: - add shiro filters - improve access to application context and user session - usage of javascript files to clean pages - clean interceptor stacks Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js Removed: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -23,22 +23,48 @@ */ package org.chorem.pollen.ui; +import com.opensymphony.xwork2.ActionContext; import org.chorem.pollen.PollenConfiguration; import org.chorem.pollen.services.PollenNotifierWorker; import org.nuiton.topia.TopiaContext; +import javax.servlet.ServletContext; +import java.util.Map; + /** * @author tchemit <chemit@codelutin.com> * @since 1.2.6 */ public class PollenApplicationContext { + /** Key to store the single instance of the application context */ + public static final String APPLICATION_CONTEXT_PARAMETER = + "pollenApplicationContext"; + protected PollenConfiguration configuration; protected TopiaContext rootContext; protected PollenNotifierWorker pollenNotifierWorker; + public static PollenApplicationContext get(ActionContext actionContext) { + Map<String, Object> application = actionContext.getApplication(); + PollenApplicationContext applicationContext = + (PollenApplicationContext) application.get(APPLICATION_CONTEXT_PARAMETER); + return applicationContext; + } + + public static PollenApplicationContext get(ServletContext servletContext) { + PollenApplicationContext applicationContext = + (PollenApplicationContext) servletContext.getAttribute(APPLICATION_CONTEXT_PARAMETER); + return applicationContext; + } + + public static void set(ServletContext servletContext, + PollenApplicationContext context) { + servletContext.setAttribute(APPLICATION_CONTEXT_PARAMETER, context); + } + public PollenConfiguration getConfiguration() { return configuration; } Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -34,13 +34,13 @@ import org.chorem.pollen.services.PollenServiceContext; import org.chorem.pollen.services.PollenServiceFactory; import org.chorem.pollen.services.impl.UserService; -import org.chorem.pollen.ui.actions.PollenActionSupport; import org.nuiton.i18n.I18n; import org.nuiton.i18n.init.DefaultI18nInitializer; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaUtil; +import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import java.io.IOException; @@ -77,8 +77,10 @@ i18nInitializer.setMissingKeyReturnNull(true); I18n.init(i18nInitializer, Locale.getDefault()); - PollenApplicationContext applicationContext = new PollenApplicationContext(); - sce.getServletContext().setAttribute(PollenActionSupport.APPLICATION_CONTEXT_PARAMETER, applicationContext); + PollenApplicationContext applicationContext = + new PollenApplicationContext(); + PollenApplicationContext.set(sce.getServletContext(), + applicationContext); // initialize configuration PollenConfiguration configuration = new PollenConfiguration(); @@ -112,8 +114,9 @@ log.info("Application is ending at " + new Date() + "..."); } + ServletContext servletContext = sce.getServletContext(); PollenApplicationContext applicationContext = - (PollenApplicationContext) sce.getServletContext().getAttribute(PollenActionSupport.APPLICATION_CONTEXT_PARAMETER); + PollenApplicationContext.get(servletContext); if (applicationContext != null) { Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -24,10 +24,14 @@ package org.chorem.pollen.ui; import com.google.common.collect.Maps; +import com.opensymphony.xwork2.ActionContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.business.persistence.UserAccount; +import javax.servlet.ServletRequest; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; import java.util.Map; /** @@ -41,6 +45,39 @@ /** Logger. */ private static final Log log = LogFactory.getLog(PollenSession.class); + /** Key to store the {@link PollenSession} instance in the session's map. */ + protected static final String SESSION_PARAMETER = "pollenSession"; + + public static PollenSession get(ServletRequest servletRequest) { + HttpSession httpSession = ((HttpServletRequest) servletRequest).getSession(true); + PollenSession pollenSession = (PollenSession) httpSession.getAttribute(SESSION_PARAMETER); + if (pollenSession == null) { + pollenSession = new PollenSession(); + httpSession.setAttribute(SESSION_PARAMETER, pollenSession); + } + return pollenSession; + } + + public static PollenSession get(ActionContext actionContext) { + + // load it from session + Map<String, Object> strutsSession = + actionContext.getSession(); + PollenSession session = (PollenSession) + strutsSession.get(SESSION_PARAMETER); + + if (session == null) { + + // create an empty session + session = new PollenSession(); + + // and store it in the struts session + strutsSession.put(SESSION_PARAMETER, session); + } + return session; + } + + /** User loggued account (if anonymous, then userAccount is null). */ private UserAccount userAccount; Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -1,37 +0,0 @@ -package org.chorem.pollen.ui; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.shiro.web.filter.authz.AuthorizationFilter; -import org.chorem.pollen.business.persistence.UserAccount; -import org.chorem.pollen.ui.actions.PollenActionSupport; - -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -public class PollenShiroFilter extends AuthorizationFilter { - - private static final Log log = LogFactory.getLog(PollenShiroFilter.class); - - @Override - protected boolean isAccessAllowed(ServletRequest servletRequest, ServletResponse servletResponse, Object mappedValue) { - - PollenSession pollenSession = PollenActionSupport.getPollenSession(servletRequest); - - UserAccount userAccount = pollenSession.getUserAccount(); - - boolean isAccessAllowed = userAccount != null && userAccount.isAdministrator(); - - if (log.isDebugEnabled()) { - if (isAccessAllowed) { - log.debug("granting access to an admin-reserved page"); - } else { - log.debug("illegal access to an admin-reserved page, user will be sent to " + getUnauthorizedUrl()); - } - } - - return isAccessAllowed; - - } - -} Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -25,7 +25,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.ui.actions.PollenActionSupport; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaRuntimeException; @@ -48,7 +47,7 @@ @Override protected TopiaContext beginTransaction(ServletRequest request) throws TopiaRuntimeException { PollenApplicationContext applicationContext = - PollenActionSupport.getPollenApplicationContext(); + PollenApplicationContext.get(request.getServletContext()); TopiaContext rootContext = applicationContext.getRootContext(); try { Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -25,8 +25,6 @@ import com.google.common.collect.Lists; import com.opensymphony.xwork2.ActionContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.struts2.StrutsStatics; import org.chorem.pollen.PollenConfiguration; import org.chorem.pollen.business.persistence.UserAccount; @@ -41,16 +39,13 @@ import org.nuiton.web.filter.TopiaTransactionFilter; import org.nuiton.web.struts2.BaseAction; -import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; import java.net.URL; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; -import java.util.Map; /** * Pollen action support. @@ -67,24 +62,13 @@ private static final long serialVersionUID = 1L; - /** Key to store the {@link PollenSession} instance in the session's map. */ - protected static final String SESSION_PARAMETER = "pollenSession"; - - /** Key to store the single instance of the application context */ - public static final String APPLICATION_CONTEXT_PARAMETER = "pollenApplicationContext"; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(PollenActionSupport.class); - private static DateFormat dateTimeFormat; private DateFormat dateFormat; public static PollenApplicationContext getPollenApplicationContext() { - Map<String, Object> application = getActionContext().getApplication(); PollenApplicationContext applicationContext = - (PollenApplicationContext) application.get(APPLICATION_CONTEXT_PARAMETER); + PollenApplicationContext.get(getActionContext()); return applicationContext; } @@ -111,34 +95,9 @@ return "Index"; } - public static PollenSession getPollenSession(ServletRequest servletRequest) { - HttpSession httpSession = ((HttpServletRequest) servletRequest).getSession(true); - PollenSession pollenSession = (PollenSession) httpSession.getAttribute(SESSION_PARAMETER); - if (pollenSession == null) { - pollenSession = new PollenSession(); - httpSession.setAttribute(SESSION_PARAMETER, pollenSession); - } - return pollenSession; - } - public PollenSession getPollenSession() { if (pollenSession == null) { - - // load it from session - Map<String, Object> strutsSession = - getActionContext().getSession(); - PollenSession session = (PollenSession) - strutsSession.get(SESSION_PARAMETER); - - if (session == null) { - - // create an empty session - session = new PollenSession(); - - // and store it in the struts session - strutsSession.put(SESSION_PARAMETER, session); - } - pollenSession = session; + pollenSession = PollenSession.get(getActionContext()); } return pollenSession; } Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -25,6 +25,7 @@ import com.google.common.base.Preconditions; import com.opensymphony.xwork2.Preparable; +import org.apache.struts2.interceptor.ParameterAware; import org.chorem.pollen.business.persistence.PersonList; import org.chorem.pollen.business.persistence.PollAccount; import org.chorem.pollen.services.exceptions.FavoriteListNotFoundException; @@ -33,16 +34,20 @@ import org.chorem.pollen.services.impl.FavoriteService; import org.chorem.pollen.ui.actions.PollenActionSupport; +import java.util.Map; + /** * Manage a selected favorite lists of a connected user. * * @author tchemit <chemit@codelutin.com> * @since 1.2.6 */ -public class ManageFavoriteList extends PollenActionSupport implements Preparable { +public class ManageFavoriteList extends PollenActionSupport implements Preparable, ParameterAware { private static final long serialVersionUID = 1L; + private Map<String, String[]> parameters; + @Override public String getPageLogo() { return "Creation"; @@ -50,7 +55,7 @@ protected String action; - protected String favoriteListId; +// protected String favoriteListId; protected PersonList favoriteList; @@ -73,26 +78,26 @@ } public String getFavoriteListId() { - return favoriteListId; + return favoriteList.getTopiaId(); } - public void setFavoriteListId(String favoriteListId) { - this.favoriteListId = favoriteListId; - } - public String getAction() { return action; } - public void setAction(String action) { - this.action = action; - } - @Override public void prepare() throws Exception { - Preconditions.checkNotNull(favoriteListId); + String[] favoriteListIds = parameters.get("favoriteListId"); + Preconditions.checkNotNull(favoriteListIds); + Preconditions.checkArgument(favoriteListIds.length == 1); + String favoriteListId = favoriteListIds[0]; + String[] actions = parameters.get("action"); + if (actions != null && actions.length == 1) { + action = actions[0]; + } + FavoriteService service = newService(FavoriteService.class); try { @@ -190,4 +195,8 @@ return pollAccount; } + @Override + public void setParameters(Map<String, String[]> parameters) { + this.parameters = parameters; + } } Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -1,84 +0,0 @@ -/* - * #%L - * Pollen :: UI (strust2) - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit - * %% - * 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.pollen.ui.interceptors; - -import com.google.common.base.Preconditions; -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.interceptor.AbstractInterceptor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.business.persistence.UserAccount; -import org.chorem.pollen.ui.PollenSession; -import org.chorem.pollen.ui.PollenUIUtils; -import org.chorem.pollen.ui.actions.PollenActionSupport; - -/** - * To check if logged user is admin. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.2.6 - */ -public class CheckUserIsAdmin extends AbstractInterceptor { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = LogFactory.getLog(CheckUserIsAdmin.class); - - /** Where to redirect where user is loggued */ - protected String redirectAction; - - public void setRedirectAction(String redirectAction) { - this.redirectAction = redirectAction; - } - - @Override - public String intercept(ActionInvocation invocation) throws Exception { - - PollenActionSupport action = (PollenActionSupport) invocation.getAction(); - - UserAccount user = action.getPollenUserAccount(); - Preconditions.checkNotNull(user, "No user found is session"); - - boolean check = user.isAdministrator(); - - String result = null; - - if (!check) { - - if (log.isInfoEnabled()) { - log.info("User not admin try to acces admin section..."); - } - - if (log.isInfoEnabled()) { - log.info("Will redirect to " + redirectAction); - } - PollenUIUtils.redirect(redirectAction); - - } else { - result = invocation.invoke(); - } - return result; - } -} Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -1,99 +0,0 @@ -/* - * #%L - * Pollen :: UI (strust2) - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit - * %% - * 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.pollen.ui.interceptors; - -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.interceptor.AbstractInterceptor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.ui.PollenSession; -import org.chorem.pollen.ui.PollenUIUtils; -import org.chorem.pollen.ui.actions.PollenActionSupport; - -/** - * To check user is loggued. If not, then redirect to the {@link #loginAction}. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.2.6 - */ -public class CheckUserIsLogguedInterceptor extends AbstractInterceptor { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(CheckUserIsLogguedInterceptor.class); - - /** Where to redirect if user is not authenticated. */ - protected String loginAction; - - /** Where to redirect where user is loggued */ - protected String redirectAction; - - public void setLoginAction(String loginAction) { - this.loginAction = loginAction; - } - - public void setRedirectAction(String redirectAction) { - this.redirectAction = redirectAction; - } - - protected static final String URL_PATTERN = "%s?redirectAction=%s"; - - @Override - public String intercept(ActionInvocation invocation) throws Exception { - - PollenActionSupport action = (PollenActionSupport) invocation.getAction(); - - boolean userLoggued = action.getPollenUserAccount() != null; - - if (!userLoggued && log.isInfoEnabled()) { - log.info("No user loggued!"); - } - - String result = null; - - if (!userLoggued) { - - // redirect to login - - String url = String.format(URL_PATTERN, - loginAction, - redirectAction - ); - if (log.isInfoEnabled()) { - log.info("Will redirect to " + url); - } - PollenUIUtils.redirect(url); - - } else { - - result = invocation.invoke(); - } - - return result; - } - - -} Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -58,7 +58,6 @@ public class PollenFileUploadInterceptor extends FileUploadInterceptor { private static final long serialVersionUID = 1L; - protected final Pattern FILENAME_PATTERN = Pattern.compile("(.+)\\[(.+)\\]"); @Override Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,115 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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.pollen.ui.security; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.shiro.util.StringUtils; +import org.apache.shiro.web.filter.authz.AuthorizationFilter; +import org.apache.shiro.web.util.WebUtils; +import org.chorem.pollen.bean.PollUri; +import org.chorem.pollen.business.persistence.UserAccount; +import org.chorem.pollen.services.DefaultPollenServiceContext; +import org.chorem.pollen.services.PollenServiceContext; +import org.chorem.pollen.services.PollenServiceFactory; +import org.chorem.pollen.ui.PollenApplicationContext; +import org.chorem.pollen.ui.PollenSession; +import org.nuiton.topia.TopiaContext; +import org.nuiton.web.filter.TopiaTransactionFilter; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public abstract class AbstractPollenAuthorization extends AuthorizationFilter { + + public static final Pattern URI_PATTERN = + Pattern.compile("/.*/(.[^/]+)/(.+)"); + + /** Logger. */ + private static final Log log = + LogFactory.getLog(AbstractPollenAuthorization.class); + + protected AbstractPollenAuthorization() { + if (log.isInfoEnabled()) { + log.info("Init - "+this); + } + } + + protected PollUri getPollUri(ServletRequest request) { + String servletPath = ((HttpServletRequest) request).getServletPath(); + Matcher m = URI_PATTERN.matcher(servletPath); + + PollUri result = null; + if (m.find()) { + + String uriId = m.group(2); + result = PollUri.newPollUri(uriId); + + } + return result; + } + + protected UserAccount getPollenUSerAccount(ServletRequest request) { + PollenSession pollenSession = PollenSession.get(request); + + return pollenSession.getUserAccount(); + } + + protected PollenServiceContext getServiceContext(ServletRequest request) { + PollenApplicationContext applicationContext = + PollenApplicationContext.get(request.getServletContext()); + + PollenServiceFactory serviceFactory = new PollenServiceFactory(); + + TopiaContext transaction = + TopiaTransactionFilter.getTransaction(request); + + Locale locale = Locale.getDefault(); + return DefaultPollenServiceContext.newContext( + locale, + transaction, + applicationContext.getConfiguration(), + serviceFactory + ); + } + + @Override + protected final boolean onAccessDenied(ServletRequest request, + ServletResponse response) throws IOException { + String unauthorizedUrl = getUnauthorizedUrl(); + //SHIRO-142 - ensure that redirect _or_ error code occurs - both cannot happen due to response commit: + if (StringUtils.hasText(unauthorizedUrl)) { + WebUtils.issueRedirect(request, response, unauthorizedUrl); + } else { + WebUtils.toHttp(response).sendError(HttpServletResponse.SC_UNAUTHORIZED); + } + return false; + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java (from rev 3202, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java) =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,59 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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.pollen.ui.security; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.business.persistence.UserAccount; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +public class AdminUserRequired extends AbstractPollenAuthorization { + + private static final Log log = + LogFactory.getLog(AdminUserRequired.class); + + @Override + protected boolean isAccessAllowed(ServletRequest request, + ServletResponse response, + Object mappedValue) { + + UserAccount userAccount = getPollenUSerAccount(request); + + boolean isAccessAllowed = userAccount != null && + userAccount.isAdministrator(); + + if (log.isDebugEnabled()) { + if (isAccessAllowed) { + log.debug("granting access to an admin-reserved page"); + } else { + log.debug("illegal access to an admin-reserved page, user will be sent to " + getUnauthorizedUrl()); + } + } + + return isAccessAllowed; + } + +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,48 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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.pollen.ui.security; + +import org.apache.shiro.web.filter.authc.UserFilter; +import org.chorem.pollen.business.persistence.UserAccount; +import org.chorem.pollen.ui.PollenSession; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +public class ConnectedUserRequired extends UserFilter { + + @Override + protected boolean isAccessAllowed(ServletRequest request, + ServletResponse response, + Object mappedValue) { + PollenSession pollenSession = + PollenSession.get(request); + + UserAccount userAccount = pollenSession.getUserAccount(); + + boolean isAccessAllowed = userAccount != null; + return isAccessAllowed; + } + +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,102 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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.pollen.ui.security; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.bean.PollUri; +import org.chorem.pollen.services.PollenServiceContext; +import org.chorem.pollen.services.exceptions.PollNotFoundException; +import org.chorem.pollen.services.exceptions.UnauthorizedPollAccessException; +import org.chorem.pollen.services.impl.PollService; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +public class PollAccessRequired extends AbstractPollenAuthorization { + + private static final Log log = + LogFactory.getLog(PollAccessRequired.class); + + protected final AdminUserRequired adminFilter; + + public PollAccessRequired() { + adminFilter = new AdminUserRequired(); + } + + @Override + protected boolean isAccessAllowed(ServletRequest request, + ServletResponse response, + Object mappedValue) { + + boolean isAccessAllowed; + + if (adminFilter.isAccessAllowed(request, response, mappedValue)) { + + // user is connected ans admin, so + isAccessAllowed = true; + + } else { + + PollUri pollUri = getPollUri(request); + + if (pollUri == null) { + + // no uriId given + isAccessAllowed = false; + + + } else { + PollenServiceContext serviceContext = + getServiceContext(request); + + PollService pollService = + serviceContext.newService(PollService.class); + + try { + pollService.checkPollAccount(pollUri); + isAccessAllowed = true; + + if (log.isDebugEnabled()) { + log.debug("Can access to this poll " + pollUri.getPollId()); + } + } catch (PollNotFoundException e) { + if (log.isDebugEnabled()) { + log.debug("Poll not found!"); + } + isAccessAllowed = false; + } catch (UnauthorizedPollAccessException e) { + if (log.isDebugEnabled()) { + log.debug("User can not access page"); + } + isAccessAllowed = false; + } + + } + } + + return isAccessAllowed; + } + +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,103 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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.pollen.ui.security; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.bean.PollUri; +import org.chorem.pollen.services.PollenServiceContext; +import org.chorem.pollen.services.exceptions.PollNotFoundException; +import org.chorem.pollen.services.exceptions.UnauthorizedPollAccessException; +import org.chorem.pollen.services.impl.PollService; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +public class PollCreatorRequired extends AbstractPollenAuthorization { + + private static final Log log = LogFactory.getLog(PollCreatorRequired.class); + + protected final AdminUserRequired adminFilter; + + public PollCreatorRequired() { + adminFilter = new AdminUserRequired(); + } + + + @Override + protected boolean isAccessAllowed(ServletRequest request, + ServletResponse response, + Object mappedValue) { + + boolean isAccessAllowed; + + if (adminFilter.isAccessAllowed(request, response, mappedValue)) { + + // user is connected ans admin, so + isAccessAllowed = true; + + } else { + + PollUri pollUri = getPollUri(request); + + if (pollUri == null) { + + // no uriId given + isAccessAllowed = false; + + + } else { + PollenServiceContext serviceContext = + getServiceContext(request); + + PollService pollService = + serviceContext.newService(PollService.class); + + try { + pollService.checkPollCreator(pollUri); + isAccessAllowed = true; + + if (log.isDebugEnabled()) { + log.debug("Can access to this poll " + + pollUri.getPollId()); + } + } catch (PollNotFoundException e) { + if (log.isDebugEnabled()) { + log.debug("Poll not found!"); + } + isAccessAllowed = false; + } catch (UnauthorizedPollAccessException e) { + if (log.isDebugEnabled()) { + log.debug("User can not access page"); + } + isAccessAllowed = false; + } + + } + } + + return isAccessAllowed; + } + +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,80 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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.pollen.ui.security; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.bean.PollUri; +import org.chorem.pollen.services.PollenServiceContext; +import org.chorem.pollen.services.exceptions.PollNotFoundException; +import org.chorem.pollen.services.impl.PollService; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +public class PollRequired extends AbstractPollenAuthorization { + + private static final Log log = + LogFactory.getLog(PollRequired.class); + + @Override + protected boolean isAccessAllowed(ServletRequest request, + ServletResponse response, + Object mappedValue) { + + boolean isAccessAllowed; + + PollUri pollUri = getPollUri(request); + + if (pollUri == null) { + + // no uriId given + isAccessAllowed = false; + + } else { + + PollenServiceContext serviceContext = getServiceContext(request); + + PollService pollService = + serviceContext.newService(PollService.class); + + try { + pollService.checkPoll(pollUri); + isAccessAllowed = true; + + if (log.isDebugEnabled()) { + log.debug("Can access to this poll " + pollUri.getPollId()); + } + } catch (PollNotFoundException e) { + if (log.isDebugEnabled()) { + log.debug("Poll not found!"); + } + isAccessAllowed = false; + } + } + + return isAccessAllowed; + } + +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-23 21:32:36 UTC (rev 3207) @@ -32,7 +32,7 @@ <package name="admin" extends="default" namespace="/admin"> - <default-interceptor-ref name="pollenBasicAdminStack"/> + <default-interceptor-ref name="pollenBasicStack"/> <!-- manage users --> <action name="usersList" method="input" @@ -43,7 +43,7 @@ <!-- create user --> <action name="create" method="create" class="org.chorem.pollen.ui.actions.admin.ManageUsers"> - <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/admin/usersList.jsp</result> <result>/WEB-INF/jsp/admin/usersList.jsp</result> </action> @@ -51,7 +51,7 @@ <!-- save user --> <action name="edit" method="edit" class="org.chorem.pollen.ui.actions.admin.ManageUsers"> - <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/admin/usersList.jsp</result> <result>/WEB-INF/jsp/admin/usersList.jsp</result> </action> @@ -59,7 +59,7 @@ <!-- delete user --> <action name="delete" method="delete" class="org.chorem.pollen.ui.actions.admin.ManageUsers"> - <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/admin/usersList.jsp</result> <result>/WEB-INF/jsp/admin/usersList.jsp</result> </action> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-23 21:32:36 UTC (rev 3207) @@ -31,83 +31,79 @@ <package name="json" extends="default" namespace="/json"> - <!-- get pagined users --> - <action name="getUsers" - class="org.chorem.pollen.ui.actions.json.GetUsers"> - <interceptor-ref name="pollenBasicAdminStack"/> - <result type="json"/> - </action> + <default-interceptor-ref name="pollenBasicStack"/> - <!-- get user detail --> - <action name="getUser" - class="org.chorem.pollen.ui.actions.json.GetUser"> - <interceptor-ref name="pollenBasicAdminStack"/> + <action name="get*" + class="org.chorem.pollen.ui.actions.json.Get{1}"> <result type="json"/> </action> + <!----> + <!--<!– get pagined users –>--> + <!--<action name="getUsers"--> + <!--class="org.chorem.pollen.ui.actions.json.GetUsers">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get pagined favorite lists of user --> - <action name="getFavoriteLists" - class="org.chorem.pollen.ui.actions.json.GetFavoriteLists"> - <interceptor-ref name="pollenBasicLogguedStack"/> - <result type="json"/> - </action> + <!--<!– get user detail –>--> + <!--<action name="getUser"--> + <!--class="org.chorem.pollen.ui.actions.json.GetUser">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get selected favorite list of user --> - <action name="getFavoriteList" - class="org.chorem.pollen.ui.actions.json.GetFavoriteList"> - <interceptor-ref name="pollenBasicLogguedStack"/> - <result type="json"/> - </action> + <!--<!– get pagined favorite lists of user –>--> + <!--<action name="getFavoriteLists"--> + <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteLists">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get pagined poll accounts of a given favorite list --> - <action name="getFavoriteListPollAccounts" - class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccounts"> - <interceptor-ref name="pollenBasicLogguedStack"/> - <result type="json"/> - </action> + <!--<!– get selected favorite list of user –>--> + <!--<action name="getFavoriteList"--> + <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteList">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get selected poll account of a given favorite list --> - <action name="getFavoriteListPollAccount" - class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccount"> - <interceptor-ref name="pollenBasicLogguedStack"/> - <result type="json"/> - </action> + <!--<!– get pagined poll accounts of a given favorite list –>--> + <!--<action name="getFavoriteListPollAccounts"--> + <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccounts">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get pagined polls --> - <action name="getPolls" - class="org.chorem.pollen.ui.actions.json.GetPolls"> - <interceptor-ref name="pollenBasicAdminStack"/> - <result type="json"/> - </action> + <!--<!– get selected poll account of a given favorite list –>--> + <!--<action name="getFavoriteListPollAccount"--> + <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccount">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get pagined created polls --> - <action name="getCreatedPolls" - class="org.chorem.pollen.ui.actions.json.GetCreatedPolls"> - <interceptor-ref name="pollenBasicLogguedStack"/> - <result type="json"/> - </action> + <!--<!– get pagined polls –>--> + <!--<action name="getPolls"--> + <!--class="org.chorem.pollen.ui.actions.json.GetPolls">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get pagined invited polls --> - <action name="getInvitedPolls" - class="org.chorem.pollen.ui.actions.json.GetInvitedPolls"> - <interceptor-ref name="pollenBasicLogguedStack"/> - <result type="json"/> - </action> + <!--<!– get pagined created polls –>--> + <!--<action name="getCreatedPolls"--> + <!--class="org.chorem.pollen.ui.actions.json.GetCreatedPolls">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get pagined created polls --> - <action name="getParticipatedPolls" - class="org.chorem.pollen.ui.actions.json.GetParticipatedPolls"> - <interceptor-ref name="pollenBasicLogguedStack"/> - <result type="json"/> - </action> + <!--<!– get pagined invited polls –>--> + <!--<action name="getInvitedPolls"--> + <!--class="org.chorem.pollen.ui.actions.json.GetInvitedPolls">--> + <!--<result type="json"/>--> + <!--</action>--> - <!-- get pagined poll comments --> - <action name="getPollComments" - class="org.chorem.pollen.ui.actions.json.GetPollComments"> - <interceptor-ref name="pollenBasicStack"/> - <result type="json"/> - </action> + <!--<!– get pagined created polls –>--> + <!--<action name="getParticipatedPolls"--> + <!--class="org.chorem.pollen.ui.actions.json.GetParticipatedPolls">--> + <!--<result type="json"/>--> + <!--</action>--> + <!--<!– get pagined poll comments –>--> + <!--<action name="getPollComments"--> + <!--class="org.chorem.pollen.ui.actions.json.GetPollComments">--> + <!--<result type="json"/>--> + <!--</action>--> + </package> </struts> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-23 21:32:36 UTC (rev 3207) @@ -38,6 +38,12 @@ <param name="namespace">/poll</param> <param name="actionName">votefor/${uriId}</param> </result-type> + + <result-type name="redirect2" + class="org.apache.struts2.dispatcher.ServletRedirectResult"> + <param name="location">${redirectUrl}</param> + <param name="prependServletContext">false</param> + </result-type> </result-types> <!-- create poll --> @@ -110,10 +116,7 @@ <action name="clone/*" class="org.chorem.pollen.ui.actions.poll.ClonePoll"> <param name="uriId">{1}</param> - <result type="redirect"> - <param name="location">${redirectUrl}</param> - <param name="prependServletContext">false</param> - </result> + <result type="redirect2"/> </action> <!-- export poll --> @@ -123,7 +126,8 @@ <result type="stream"> <param name="contentCharSet">UTF-8</param> <param name="contentType">application/xml</param> - <param name="contentDisposition">attachment;filename="${filename}" + <param name="contentDisposition"> + attachment;filename="${filename}" </param> <param name="encode">true</param> <param name="bufferSize">4096</param> @@ -141,10 +145,7 @@ <action name="close/*" class="org.chorem.pollen.ui.actions.poll.ClosePoll"> <param name="uriId">{1}</param> - <result type="redirect"> - <param name="location">${redirectUrl}</param> - <param name="prependServletContext">false</param> - </result> + <result type="redirect2"/> </action> <!-- confirm delete poll --> @@ -158,10 +159,7 @@ <action name="delete/*" class="org.chorem.pollen.ui.actions.poll.DeletePoll"> <param name="uriId">{1}</param> - <result type="redirect"> - <param name="location">${redirectUrl}</param> - <param name="prependServletContext">false</param> - </result> + <result type="redirect2"/> </action> <!-- display poll result --> @@ -174,14 +172,14 @@ <!-- display createds polls --> <action name="createdList" class="org.chorem.pollen.ui.actions.poll.CreatedList"> - <interceptor-ref name="pollenBasicLogguedStack"/> + <interceptor-ref name="pollenBasicStack"/> <result>/WEB-INF/jsp/poll/createdList.jsp</result> </action> <!-- display participated polls --> <action name="participatedList" class="org.chorem.pollen.ui.actions.poll.ParticipatedList"> - <interceptor-ref name="pollenBasicLogguedStack"/> + <interceptor-ref name="pollenBasicStack"/> <result>/WEB-INF/jsp/poll/participatedList.jsp</result> </action> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-23 21:32:36 UTC (rev 3207) @@ -66,7 +66,7 @@ <!-- show favorite lists --> <action name="favoriteLists" method="input" class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists"> - <interceptor-ref name="pollenBasicLogguedStack"/> + <interceptor-ref name="pollenBasicStack"/> <result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result> <result>/WEB-INF/jsp/user/favoriteLists.jsp</result> </action> @@ -74,7 +74,7 @@ <!-- create favorite list --> <action name="createFavoriteList" method="create" class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists"> - <interceptor-ref name="pollenParamsPrepareParamsLogguedStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result> <result>/WEB-INF/jsp/user/favoriteLists.jsp</result> </action> @@ -82,7 +82,7 @@ <!-- delete favorite list --> <action name="deleteFavoriteList" method="delete" class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists"> - <interceptor-ref name="pollenParamsPrepareParamsLogguedStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result> <result>/WEB-INF/jsp/user/favoriteLists.jsp</result> </action> @@ -90,14 +90,14 @@ <!-- edit favorite list --> <action name="editFavoriteList" method="input" class="org.chorem.pollen.ui.actions.user.ManageFavoriteList"> - <interceptor-ref name="pollenParamsPrepareParamsLogguedStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> </action> <!-- add poll account to favorite list --> <action name="addPollAccount" method="create" class="org.chorem.pollen.ui.actions.user.ManageFavoriteList"> - <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> <result>/WEB-INF/jsp/user/favoriteList.jsp</result> </action> @@ -105,7 +105,7 @@ <!-- edit poll account to favorite list --> <action name="editPollAccount" method="edit" class="org.chorem.pollen.ui.actions.user.ManageFavoriteList"> - <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> <result>/WEB-INF/jsp/user/favoriteList.jsp</result> </action> @@ -113,7 +113,7 @@ <!-- remove poll account from a favorite list --> <action name="removePollAccount" method="delete" class="org.chorem.pollen.ui.actions.user.ManageFavoriteList"> - <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> <result>/WEB-INF/jsp/user/favoriteList.jsp</result> </action> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties 2012-03-23 21:32:36 UTC (rev 3207) @@ -28,5 +28,5 @@ log4j.appender.console.layout.ConversionPattern=%d [%p] %c %m%n log4j.logger.org.chorem.pollen=INFO -log4j.logger.org.chorem.pollen.ui.PollenShiroFilter=DEBUG +log4j.logger.org.chorem.pollen.ui.PollenShiroIsAdministratorFilter=DEBUG log4j.logger.org.nuiton=INFO Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-23 21:32:36 UTC (rev 3207) @@ -1,8 +1,51 @@ [main] -pollenFilter=org.chorem.pollen.ui.PollenShiroFilter -pollenFilter.unauthorizedUrl=bordel.jsp +connected=org.chorem.pollen.ui.security.ConnectedUserRequired +connected.loginUrl=/security/connected_required +admin=org.chorem.pollen.ui.security.AdminUserRequired +admin.unauthorizedUrl=/security/admin_required + +poll=org.chorem.pollen.ui.security.PollRequired +poll.unauthorizedUrl=/security/poll_required + +pollAccess=org.chorem.pollen.ui.security.PollAccessRequired +pollAccess.unauthorizedUrl=/security/poll_access_required + +pollCreator=org.chorem.pollen.ui.security.PollCreatorRequired +pollCreator.unauthorizedUrl=/security/poll_creator_required + [urls] -/admin/**=pollenFilter +# connected urls +/poll/createdList=connected +/poll/participatedList=connected +/user/favoriteLists=connected +/user/createFavoriteList=connected +/user/deleteFavoriteList=connected +/user/show=connected +/user/edit=connected +/user/editFavoriteList=connected +/json/getFavoriteLists=connected +/json/getFavoriteList=connected +/json/getFavoriteListPollAccounts=connected +/json/getFavoriteListPollAccount=connected +/json/getCreatedPolls=connected +/json/getInvitedPolls=connected +/json/getParticipatedPolls=connected + +# connected and admin urls +/admin/**=connected,admin +/user/addPollAccount=connected,admin +/user/editPollAccount=connected,admin +/user/removePollAccount=connected,admin +/json/getUsers=connected,admin +/json/getUser=connected,admin +/json/getPolls=connected,admin + +# is pollAccount (can vote and see result of a poll) +/poll/votefor/**=poll,pollAccess +/poll/result/**=poll,pollAccess + +# is pollCreator (can admin a poll) +/poll/modification/**=poll,pollCreator \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-23 21:32:36 UTC (rev 3207) @@ -67,17 +67,6 @@ <interceptor name="pollenFileUpload" class="org.chorem.pollen.ui.interceptors.PollenFileUploadInterceptor"/> - <!--<interceptor name="checkUserLoggued"--> - <!--class="org.chorem.pollen.ui.interceptors.CheckUserIsLogguedInterceptor">--> - <!--<param name="loginAction">/notLoggued</param>--> - <!--<param name="redirectAction">/home</param>--> - <!--</interceptor>--> - - <!--<interceptor name="checkUserAdmin"--> - <!--class="org.chorem.pollen.ui.interceptors.CheckUserIsAdmin">--> - <!--<param name="redirectAction">/notAdmin</param>--> - <!--</interceptor>--> - <!-- basic stack --> <interceptor-stack name="pollenBasicStack"> <interceptor-ref name="i18n"/> @@ -87,17 +76,6 @@ </interceptor-ref> </interceptor-stack> - <interceptor-stack name="pollenBasicLogguedStack"> - <!--<interceptor-ref name="checkUserLoggued"/>--> - <interceptor-ref name="pollenBasicStack"/> - </interceptor-stack> - - <interceptor-stack name="pollenBasicAdminStack"> - <!-- interceptor-ref name="checkUserLoggued" /> - <interceptor-ref name="checkUserAdmin"/ --> - <interceptor-ref name="pollenBasicStack"/> - </interceptor-stack> - <!-- params stack with params--> <interceptor-stack name="pollenParamsPrepareParamsStack"> <interceptor-ref name="i18n"/> @@ -134,17 +112,6 @@ </interceptor-ref> </interceptor-stack> - <interceptor-stack name="pollenParamsPrepareParamsLogguedStack"> - <!--<interceptor-ref name="checkUserLoggued"/>--> - <interceptor-ref name="pollenParamsPrepareParamsStack"/> - </interceptor-stack> - - <interceptor-stack name="pollenParamsPrepareParamsAdminStack"> - <!--<interceptor-ref name="checkUserLoggued"/>--> - <!--<interceptor-ref name="checkUserAdmin"/>--> - <interceptor-ref name="pollenParamsPrepareParamsStack"/> - </interceptor-stack> - </interceptors> <!-- must be authenticated to perform any actions --> @@ -193,6 +160,16 @@ </package> + <package name="security" extends="default" namespace="/security"> + + <default-interceptor-ref name="pollenBasicStack"/> + + <action name="*"> + <result>/WEB-INF/jsp/security/{1}.jsp</result> + </action> + + </package> + <include file="config/struts-json.xml"/> <include file="config/struts-admin.xml"/> <include file="config/struts-poll.xml"/> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -27,118 +27,23 @@ <script type="text/javascript" src="<s:url value='/js/gridHelper.js' />"></script> +<script type="text/javascript" + src="<s:url value='/js/usersList.js' />"></script> + <title><s:text name="pollen.title.usersList"/></title> <h1 class="title${pageLogo}"><s:text name="pollen.title.usersList"/></h1> <s:url id="loadUsers" action="getUsers" namespace="/json" escapeAmp="false"/> -<s:url id="loadUser" action="getUser" namespace="/json"/> - <s:set var="user" value="%{#session.pollenSession.userAccount}"/> <script type="text/javascript"> - jQuery(document).ready(function () { - - var action='${action}'; - - if ('${action}' == 'create') { - $('#createForm').show(); - } - if ('${action}' == 'edit') { - $('#editForm').show(); - } - if ('${action}' == 'delete') { - $('#deleteForm').show(); - } - - // listen row selection - $.addRowSelectTopic('users'); - - $.addClearSelectTopic('users', function(){ - if (action !='') { - // come back from action - action=''; - return; - } - $(".userForm").hide(); - }); - - // to create a new row - $.listenRowTopic('users-addRow', function(event) { - - $('#createForm .errorMessage').hide(); - $('#createForm [name="createUser.login"]').val(""); - $('#createForm [name="createUser.email"]').val(""); - $('#createForm [name="createUser.firstName"]').val(""); - $('#createForm [name="createUser.lastName"]').val(""); - $('#createForm [name="createUser.administrator"]').prop('checked',false); - $('#editForm').hide(); - $('#deleteForm').hide(); - $('#createForm').show(); - }); - - // to edit a selected row - $.listenRowTopic('users-editRow', function (event) { - var id = $.getSelectedId('users'); - if(!id) { - - // no user selected - return; - } - $('#editForm .errorMessage').hide(); - jQuery.getJSON("${loadUser}", { "userId":id }, function (result) { - - var user = result.user; - $('#editForm [name="editUser.topiaId"]').val(user.id); - $('#editForm [name="editUser.login"]').val(user.login); - $('#editForm [name="editUser.email"]').val(user.email); - $('#editForm [name="editUser.firstName"]').val(user.firstName); - $('#editForm [name="editUser.lastName"]').val(user.lastName); - $('#editForm [name="editUser.administrator"]').prop('checked',false); - $('#editForm [name="editUser.administrator"]').prop('checked',user.administrator); - $('#editForm').show(); - $('#createForm').hide(); - $('#deleteForm').hide(); - } - ); - }); - - // to delete the selected row - $.listenRowTopic('users-deleteRow', function(event) { - var id = $.getSelectedId('users'); - if(!id) { - - // no user selected - return; - } - - var userId = '${user.topiaId}'; - - if (id == userId) { - - // can not delete connected user - return; - } - $('#deleteForm .errorMessage').hide(); - - jQuery.getJSON("${loadUser}", { "userId":id }, function (result) { - - var user = result.user; - $('#deleteForm [name="deleteUser.topiaId"]').val(user.id); - $('#deleteForm [name="deleteUser.login"]').val(user.login); - $('#deleteForm [name="deleteUser.email"]').val(user.email); - $('#deleteForm [name="deleteUser.firstName"]').val(user.firstName); - $('#deleteForm [name="deleteUser.lastName"]').val(user.lastName); - $('#deleteForm [name="deleteUser.administrator"]').prop('checked',false); - $('#deleteForm [name="deleteUser.administrator"]').prop('checked',user.administrator); - $('#editForm').hide(); - $('#createForm').hide(); - $('#deleteForm').show(); - } - ); - }); + initUsersPage( + '${action}', + '<s:url action="getUser" namespace="/json"/>' + ); }); </script> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -2,8 +2,8 @@ #%L Pollen :: UI (strust2) - $Id: confirmDeletePoll.jsp 3185 2012-03-14 14:43:26Z tchemit $ - $HeadURL: http://svn.chorem.org/svn/pollen/branches/pollen-1.2.6-struts2/pollen-ui-str... $ + $Id$ + $HeadURL$ %% Copyright (C) 2009 - 2012 CodeLutin %% Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,28 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 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" language="java" %> +<html> +<head><title></title></head> +<body>Vous devez être connecter en administrateur pour accéder à cette page.</body> +</html> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,28 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 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" language="java" %> +<html> +<head><title></title></head> +<body>Vous devez être connecter pour accéder à cette page.</body> +</html> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,28 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 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" language="java" %> +<html> +<head><title></title></head> +<body>Vous n'êtes pas autorisé à accéder à cette page de sondage.</body> +</html> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,28 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 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" language="java" %> +<html> +<head><title></title></head> +<body>Seul le créateur du sondage ou un administratuer peut accéder à cette page.</body> +</html> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,28 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 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" language="java" %> +<html> +<head><title></title></head> +<body>Aucun sondage à l'url donné.</body> +</html> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -27,103 +27,33 @@ <script type="text/javascript" src="<s:url value='/js/gridHelper.js' />"></script> +<script type="text/javascript" + src="<s:url value='/js/favoriteList.js' />"></script> + <s:url id="loadPollAccounts" action="getFavoriteListPollAccounts" namespace="/json" escapeAmp="false"> - <s:param name="favoriteListId" value="%{favoriteListId}"/> + <s:param name="favoriteListId" value="%{favoriteList.topiaId}"/> </s:url> -<s:url id="loadPollAccount" action="getFavoriteListPollAccount" - namespace="/json"/> - <script type="text/javascript"> jQuery(document).ready(function () { - var action = '${action}'; - - if ('${action}' == 'create') { - $('#createForm').show(); - } else if ('${action}' == 'edit') { - $('#editForm').show(); - } else if ('${action}' == 'delete') { - $('#deleteForm').show(); - } - - // listen row selection - $.addRowSelectTopic('pollAccounts'); - - $.addClearSelectTopic('pollAccounts', function () { - if (action != '') { - // come back from action - action = ''; - return; - } - $(".pollAccountForm").hide(); - }); - - // to create a new row - $.listenRowTopic('pollAccounts-addRow', function (event) { - $('#createForm [name="createPollAccount.votingId"]').val(""); - $('#createForm [name="createPollAccount.email"]').val(""); - $('#deleteForm').hide(); - $('#editForm').hide(); - $('#createForm').show(); - }); - - // to edit the selected row - $.listenRowTopic('pollAccounts-editRow', function (event) { - var id = $.getSelectedId('pollAccounts'); - if (!id) { - - // no row selected - return; - } - - jQuery.getJSON("${loadPollAccount}", { "pollAccountId":id }, - function (result) { - - var pollAccount = result.pollAccount; - $('#editForm [name="editPollAccount.topiaId"]').val(pollAccount.id); - $('#editForm [name="editPollAccount.votingId"]').val(pollAccount.votingId); - $('#editForm [name="editPollAccount.email"]').val(pollAccount.email); - $('#deleteForm').hide(); - $('#createForm').hide(); - $('#editForm').show(); - } - ); - }); - - // to delete the selected row - $.listenRowTopic('pollAccounts-deleteRow', function (event) { - var id = $.getSelectedId('pollAccounts'); - if (!id) { - - // no row selected - return; - } - - jQuery.getJSON("${loadPollAccount}", { "pollAccountId":id }, - function (result) { - - var pollAccount = result.pollAccount; - $('#deleteForm [name="deletePollAccount.topiaId"]').val(pollAccount.id); - $('#deleteForm [name="deletePollAccount.votingId"]').val(pollAccount.votingId); - $('#deleteForm [name="deletePollAccount.email"]').val(pollAccount.email); - $('#editForm').hide(); - $('#createForm').hide(); - $('#deleteForm').show(); - } - ); - }); + initFavoritePage( + '${action}', + '<s:url action="getFavoriteListPollAccount" namespace="/json"/>' + ); }); </script> <title> - <s:text name="pollen.title.editFavoriteList"/> ${favoriteList.name} + <s:text name="pollen.title.editFavoriteList"/> <s:property + value="favoriteList.name"/> </title> <h1 class="title${pageLogo}"> - <s:text name="pollen.title.editFavoriteList"/> ${favoriteList.name} + <s:text name="pollen.title.editFavoriteList"/> <s:property + value="favoriteList.name"/> </h1> <sjg:grid id="pollAccounts" dataType="json" href="%{loadPollAccounts}" @@ -207,7 +137,8 @@ </fieldset> <br/> - <s:submit action="removePollAccount" key="pollen.action.delete" align="center"/> + <s:submit action="removePollAccount" key="pollen.action.delete" + align="center"/> </s:form> <br/> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-03-23 21:30:45 UTC (rev 3206) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-03-23 21:32:36 UTC (rev 3207) @@ -27,81 +27,27 @@ <script type="text/javascript" src="<s:url value='/js/gridHelper.js' />"></script> +<script type="text/javascript" + src="<s:url value='/js/favoriteLists.js' />"></script> + <title><s:text name="pollen.title.favoriteLists"/></title> <h1 class="title${pageLogo}"><s:text name="pollen.title.favoriteLists"/></h1> <s:url id="loadFavoriteLists" action="getFavoriteLists" namespace="/json"/> -<s:url id="loadFavoriteList" action="getFavoriteList" namespace="/json"/> <script type="text/javascript"> jQuery(document).ready(function () { - var action = '${action}'; - - if ('${action}' == 'create') { - $('#createForm').show(); - } else if ('${action}' == 'delete') { - $('#deleteForm').show(); - } - - // listen row selection - $.addRowSelectTopic('favoriteLists'); - - $.addClearSelectTopic('favoriteLists', function () { - if (action != '') { - // come back from action - action = ''; - return; - } - $(".userForm").hide(); - }); - - // to create a new row - $.listenRowTopic('favoriteLists-addRow', function (event) { - - $('#createForm .errorMessage').hide(); - $('#createForm [name="favoriteList.name"]').val(""); - $('#createForm [name="csvImport"]').val(""); - $('#createForm [name="ldapImport"]').val(""); - $('#deleteForm').hide(); - $('#createForm').show(); - }); - - // to edit a selected row - $.listenRowTopic('favoriteLists-editRow', function (event) { - var id = $.getSelectedId('favoriteLists'); - if (!id) { - // no row selected - return; - } - - $('#editForm [name="favoriteListId"]').val(id); - $('#editForm').submit(); - }); - - // to delete the selected row - $.listenRowTopic('favoriteLists-deleteRow', function (event) { - var id = $.getSelectedId('favoriteLists'); - if (!id) { - // no row selected - return; - } - jQuery.getJSON("${loadFavoriteList}", { favoriteListId:id }, - function (result) { - var user = result.favoriteList; - $('#deleteForm [name="deleteFavoriteList.topiaId"]').val(user.id); - $('#deleteForm [name="deleteFavoriteList.name"]').val(user.name); - $('#createForm').hide(); - $('#deleteForm').show(); - } - ); - }); + initFavoritesPage( + '${action}', + '<s:url action="getFavoriteList" namespace="/json"/>' + ); }); </script> -<sjg:grid id="favoriteLists" dataType="json" href="%{loadFavoriteLists}" +<sjg:grid id="favoriteLists" dataType="json" href='%{loadFavoriteLists}' gridModel="favoriteLists" sortable="true" pager="true" pagerButtons="true" pagerInput="true" navigator="true" rownumbers="false" autowidth="true" viewrecords="true" @@ -153,7 +99,6 @@ </legend> <s:textfield key="deleteFavoriteList.name" required="true" readonly="true" size="40" label="%{getText('pollen.common.name')}"/> - </fieldset> <br/> <s:submit action="deleteFavoriteList" key="pollen.action.delete" Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,99 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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% + */ +function initFavoritePage(action, loadPollActionUrl) { + if (action == 'create') { + $('#createForm').show(); + } else if (action == 'edit') { + $('#editForm').show(); + } else if (action == 'delete') { + $('#deleteForm').show(); + } + + // listen row selection + $.addRowSelectTopic('pollAccounts'); + + $.addClearSelectTopic('pollAccounts', function () { + if (action != '') { + // come back from action + action = ''; + return; + } + $(".pollAccountForm").hide(); + }); + + // to create a new row + $.listenRowTopic('pollAccounts-addRow', function (event) { + $('#createForm [name="createPollAccount.votingId"]').val(""); + $('#createForm [name="createPollAccount.email"]').val(""); + $('#deleteForm').hide(); + $('#editForm').hide(); + $('#createForm').show(); + }); + + // to edit the selected row + $.listenRowTopic('pollAccounts-editRow', function (event) { + var id = $.getSelectedId('pollAccounts'); + if (!id) { + + // no row selected + return; + } + + jQuery.getJSON(loadPollActionUrl, { "pollAccountId":id }, + function (result) { + + var pollAccount = result.pollAccount; + $('#editForm [name="editPollAccount.topiaId"]').val(pollAccount.id); + $('#editForm [name="editPollAccount.votingId"]').val(pollAccount.votingId); + $('#editForm [name="editPollAccount.email"]').val(pollAccount.email); + $('#deleteForm').hide(); + $('#createForm').hide(); + $('#editForm').show(); + } + ); + }); + + // to delete the selected row + $.listenRowTopic('pollAccounts-deleteRow', function (event) { + var id = $.getSelectedId('pollAccounts'); + if (!id) { + + // no row selected + return; + } + + jQuery.getJSON(loadPollActionUrl, { "pollAccountId":id }, + function (result) { + + var pollAccount = result.pollAccount; + $('#deleteForm [name="deletePollAccount.topiaId"]').val(pollAccount.id); + $('#deleteForm [name="deletePollAccount.votingId"]').val(pollAccount.votingId); + $('#deleteForm [name="deletePollAccount.email"]').val(pollAccount.email); + $('#editForm').hide(); + $('#createForm').hide(); + $('#deleteForm').show(); + } + ); + }); +} \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,84 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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% + */ +function initFavoritesPage(action, loadFavoriteList) { + + if (action == 'create') { + $('#createForm').show(); + } else if (action == 'delete') { + $('#deleteForm').show(); + } + + // listen row selection + $.addRowSelectTopic('favoriteLists'); + + $.addClearSelectTopic('favoriteLists', function () { + if (action != '') { + // come back from action + action = ''; + return; + } + $(".userForm").hide(); + }); + + // to create a new row + $.listenRowTopic('favoriteLists-addRow', function (event) { + + $('#createForm .errorMessage').hide(); + $('#createForm [name="favoriteList.name"]').val(""); + $('#createForm [name="csvImport"]').val(""); + $('#createForm [name="ldapImport"]').val(""); + $('#deleteForm').hide(); + $('#createForm').show(); + }); + + // to edit a selected row + $.listenRowTopic('favoriteLists-editRow', function (event) { + var id = $.getSelectedId('favoriteLists'); + if (!id) { + // no row selected + return; + } + + $('#editForm [name="favoriteListId"]').val(id); + $('#editForm').submit(); + }); + + // to delete the selected row + $.listenRowTopic('favoriteLists-deleteRow', function (event) { + var id = $.getSelectedId('favoriteLists'); + if (!id) { + // no row selected + return; + } + jQuery.getJSON(loadFavoriteList, { favoriteListId:id }, + function (result) { + var user = result.favoriteList; + $('#deleteForm [name="deleteFavoriteList.topiaId"]').val(user.id); + $('#deleteForm [name="deleteFavoriteList.name"]').val(user.name); + $('#createForm').hide(); + $('#deleteForm').show(); + } + ); + }); +} \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js 2012-03-23 21:32:36 UTC (rev 3207) @@ -0,0 +1,122 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 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% + */ +function initUsersPage(action, loadUserUrl) { + + if (action == 'create') { + $('#createForm').show(); + } + if (action == 'edit') { + $('#editForm').show(); + } + if (action == 'delete') { + $('#deleteForm').show(); + } + + // listen row selection + $.addRowSelectTopic('users'); + + $.addClearSelectTopic('users', function () { + if (action != '') { + // come back from action + action = ''; + return; + } + $(".userForm").hide(); + }); + + // to create a new row + $.listenRowTopic('users-addRow', function (event) { + + $('#createForm .errorMessage').hide(); + $('#createForm [name="createUser.login"]').val(""); + $('#createForm [name="createUser.email"]').val(""); + $('#createForm [name="createUser.firstName"]').val(""); + $('#createForm [name="createUser.lastName"]').val(""); + $('#createForm [name="createUser.administrator"]').prop('checked', false); + $('#editForm').hide(); + $('#deleteForm').hide(); + $('#createForm').show(); + }); + + // to edit a selected row + $.listenRowTopic('users-editRow', function (event) { + var id = $.getSelectedId('users'); + if (!id) { + + // no user selected + return; + } + $('#editForm .errorMessage').hide(); + jQuery.getJSON(loadUserUrl, { "userId":id }, function (result) { + + var user = result.user; + $('#editForm [name="editUser.topiaId"]').val(user.id); + $('#editForm [name="editUser.login"]').val(user.login); + $('#editForm [name="editUser.email"]').val(user.email); + $('#editForm [name="editUser.firstName"]').val(user.firstName); + $('#editForm [name="editUser.lastName"]').val(user.lastName); + $('#editForm [name="editUser.administrator"]').prop('checked', false); + $('#editForm [name="editUser.administrator"]').prop('checked', user.administrator); + $('#editForm').show(); + $('#createForm').hide(); + $('#deleteForm').hide(); + } + ); + }); + + // to delete the selected row + $.listenRowTopic('users-deleteRow', function (event) { + var id = $.getSelectedId('users'); + if (!id) { + + // no user selected + return; + } + + var userId = '${user.topiaId}'; + + if (id == userId) { + + // can not delete connected user + return; + } + $('#deleteForm .errorMessage').hide(); + + jQuery.getJSON(loadUserUrl, { "userId":id }, function (result) { + + var user = result.user; + $('#deleteForm [name="deleteUser.topiaId"]').val(user.id); + $('#deleteForm [name="deleteUser.login"]').val(user.login); + $('#deleteForm [name="deleteUser.email"]').val(user.email); + $('#deleteForm [name="deleteUser.firstName"]').val(user.firstName); + $('#deleteForm [name="deleteUser.lastName"]').val(user.lastName); + $('#deleteForm [name="deleteUser.administrator"]').prop('checked', false); + $('#deleteForm [name="deleteUser.administrator"]').prop('checked', user.administrator); + $('#editForm').hide(); + $('#createForm').hide(); + $('#deleteForm').show(); + } + ); + }); +} \ No newline at end of file