r15 - in trunk/chorem-web: . src/main/java/org/chorem src/main/java/org/chorem/action src/main/java/org/chorem/gepeto/action src/main/resources src/main/resources/i18n src/main/webapp/WEB-INF src/main/webapp/css
Author: bpoussin Date: 2011-03-16 10:49:56 +0100 (Wed, 16 Mar 2011) New Revision: 15 Url: http://chorem.org/repositories/revision/chorem/15 Log: - ajout de la config log4j - deplacement de BaseAction depuis gepeto.action vers chorem.action - ajout d'une action Home pour le / qui presente un resume --> les jsp dans WEB-INF Added: trunk/chorem-web/src/main/java/org/chorem/ChoremSession.java trunk/chorem-web/src/main/java/org/chorem/action/ trunk/chorem-web/src/main/java/org/chorem/action/BaseAction.java Removed: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/BaseAction.java Modified: trunk/chorem-web/pom.xml trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties trunk/chorem-web/src/main/resources/struts.xml trunk/chorem-web/src/main/webapp/WEB-INF/web.xml trunk/chorem-web/src/main/webapp/css/style.css Modified: trunk/chorem-web/pom.xml =================================================================== --- trunk/chorem-web/pom.xml 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/pom.xml 2011-03-16 09:49:56 UTC (rev 15) @@ -141,7 +141,12 @@ <artifactId>commons-io</artifactId> <scope>compile</scope> </dependency> - + + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + </dependency> + </dependencies> <build> Modified: trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java 2011-03-16 09:49:56 UTC (rev 15) @@ -6,7 +6,8 @@ import org.nuiton.wikitty.WikittyServiceFactory; /** - * Proxy to use for wikitty + * Proxy pour l'application. Certaines methodes specifiques pour l'application + * peuvent y etre ajoutees (ex: des find particulier) */ public class ChoremProxy extends WikittyProxy { Added: trunk/chorem-web/src/main/java/org/chorem/ChoremSession.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/ChoremSession.java (rev 0) +++ trunk/chorem-web/src/main/java/org/chorem/ChoremSession.java 2011-03-16 09:49:56 UTC (rev 15) @@ -0,0 +1,108 @@ +package org.chorem; + + +import java.io.Serializable; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.wikitty.entities.WikittyUser; +import org.nuiton.wikitty.services.WikittySecurityUtil; + +/** + * Le seul objet qui doit etre mis en session pour l'application. S'il y a + * d'autres information a mettre en session. Ces informations doivent etre + * ajoutee ici. + * + * Une fois l'utilisateur authentifié, il faut que le securityToken soit mis + * a jour. + * + * @author poussin + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +public class ChoremSession implements Serializable { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + final static private Log log = LogFactory.getLog(ChoremSession.class); + + final static private String CHOREM_SESSION_KEY = ChoremSession.class.getSimpleName(); + + protected String securityToken = null; + protected WikittyUser user = null; + transient protected ChoremProxy proxy = null; + + public ChoremSession() { + } + + /** + * You must used this method to login user, don't used proxy.login method + * directly + * + * @param login + * @param password + */ + public void login(String login, String password) { + getProxy().login(login, password); + securityToken = getProxy().getSecurityToken(); + // TODO poussin 20110315, lors que la methode proxy.getUser() existera + // remplacer le code suivant + String userId = WikittySecurityUtil.getUserForToken( + getProxy().getWikittyService(), securityToken); + user = getProxy().restore(WikittyUser.class, userId); + } + + public ChoremProxy getProxy() { + if (proxy == null) { + proxy = ChoremProxy.getInstance(securityToken); + } + return proxy; + } + + public WikittyUser getUser() { + return user; + } + + public void setUser(WikittyUser user) { + this.user = user; + } + + /** + * logout the user + * + * @param session + */ + static public void invalidate(Map<String, Object> session) { + ChoremSession choremSession = getChoremSession(session); + choremSession.getProxy().logout(); + session.remove(CHOREM_SESSION_KEY); + } + + static public ChoremSession getChoremSession(HttpServletRequest request) { + HttpSession session = request.getSession(); + ChoremSession result = getChoremSession(session); + return result; + } + + static public ChoremSession getChoremSession(HttpSession httpSession) { + ChoremSession result = (ChoremSession) httpSession.getAttribute(CHOREM_SESSION_KEY); + if (result == null) { + result = new ChoremSession(); + httpSession.setAttribute(CHOREM_SESSION_KEY, result); + } + return result; + } + + static public ChoremSession getChoremSession(Map<String, Object> session) { + ChoremSession result = (ChoremSession)session.get(CHOREM_SESSION_KEY); + if (result == null) { + result = new ChoremSession(); + session.put(CHOREM_SESSION_KEY, result); + } + return result; + } + +} Copied: trunk/chorem-web/src/main/java/org/chorem/action/BaseAction.java (from rev 13, trunk/chorem-web/src/main/java/org/chorem/gepeto/action/BaseAction.java) =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/action/BaseAction.java (rev 0) +++ trunk/chorem-web/src/main/java/org/chorem/action/BaseAction.java 2011-03-16 09:49:56 UTC (rev 15) @@ -0,0 +1,116 @@ +package org.chorem.action; + +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.util.ValueStack; +import java.util.Map; +import org.apache.struts2.interceptor.SessionAware; +import org.chorem.ChoremProxy; +import org.chorem.ChoremSession; + +/** + * Base class which must be extended by every action + * Overrides the Struts2 methods to render text in order to explicitly show + * the missing i18n translations + */ +public class BaseAction extends ActionSupport implements SessionAware { + + private static final long serialVersionUID = 6360393466153765988L; + + private static final Log log = LogFactory.getLog(BaseAction.class); + + final static protected String CONTEXT_ACTION_KEY = "action"; + public static final String UNTRANSLATED_MARKER = "???"; + + protected Map<String, Object> session; + + public ChoremSession getChoremSession() { + ChoremSession result = ChoremSession.getChoremSession(session); + return result; + } + + public ChoremProxy getChoremProxy() { + ChoremProxy result = getChoremSession().getProxy(); + return result; + } + + @Override + public void setSession(Map<String, Object> session) { + this.session = session; + } + + @Override + public String getText(String aTextName) { + String value = super.getText(aTextName); + return getSafeText(aTextName, value); + } + + @Override + public String getText(String aTextName, String defaultValue) { + String value = super.getText(aTextName, defaultValue); + return getSafeText(aTextName, value); + } + + @Override + public String getText(String aTextName, String defaultValue, String obj) { + String value = super.getText(aTextName, defaultValue, obj); + return getSafeText(aTextName, value); + } + + @Override + public String getText(String aTextName, List<Object> args) { + String value = super.getText(aTextName, args); + return getSafeText(aTextName, value); + } + + @Override + public String getText(String key, String[] args) { + String value = super.getText(key, args); + return getSafeText(key, value); + } + + @Override + public String getText(String aTextName, String defaultValue, + List<Object> args) { + String value = super.getText(aTextName, defaultValue, args); + return getSafeText(aTextName, value); + } + + @Override + public String getText(String key, String defaultValue, String[] args) { + String value = super.getText(key, defaultValue, args); + return getSafeText(key, value); + } + + @Override + public String getText(String key, String defaultValue, List<Object> args, + ValueStack stack) { + String value = super.getText(key, defaultValue, args, stack); + return getSafeText(key, value); + } + + @Override + public String getText(String key, String defaultValue, String[] args, + ValueStack stack) { + String value = super.getText(key, defaultValue, args, stack); + return getSafeText(key, value); + } + + /** + * Surrounds the non translated keys with a marker to make them visible + */ + protected String getSafeText(String key, String value) { + if (StringUtils.isEmpty(value)) { + if (log.isWarnEnabled()) { + log.warn("Key [" + key + "] is not translated"); + } + return UNTRANSLATED_MARKER + key + UNTRANSLATED_MARKER; + } + return value; + } +} Deleted: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/BaseAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/gepeto/action/BaseAction.java 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/action/BaseAction.java 2011-03-16 09:49:56 UTC (rev 15) @@ -1,94 +0,0 @@ -package org.chorem.gepeto.action; - -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.util.ValueStack; - -/** - * Base class which must be extended by every action - * Overrides the Struts2 methods to render text in order to explicitly show - * the missing i18n translations - */ -public class BaseAction extends ActionSupport { - - private static final long serialVersionUID = 6360393466153765988L; - - protected static final Log log = LogFactory.getLog(BaseAction.class); - - public static final String UNTRANSLATED_MARKER = "???"; - - @Override - public String getText(String aTextName) { - String value = super.getText(aTextName); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String aTextName, String defaultValue) { - String value = super.getText(aTextName, defaultValue); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String aTextName, String defaultValue, String obj) { - String value = super.getText(aTextName, defaultValue, obj); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String aTextName, List<Object> args) { - String value = super.getText(aTextName, args); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String key, String[] args) { - String value = super.getText(key, args); - return getSafeText(key, value); - } - - @Override - public String getText(String aTextName, String defaultValue, - List<Object> args) { - String value = super.getText(aTextName, defaultValue, args); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String key, String defaultValue, String[] args) { - String value = super.getText(key, defaultValue, args); - return getSafeText(key, value); - } - - @Override - public String getText(String key, String defaultValue, List<Object> args, - ValueStack stack) { - String value = super.getText(key, defaultValue, args, stack); - return getSafeText(key, value); - } - - @Override - public String getText(String key, String defaultValue, String[] args, - ValueStack stack) { - String value = super.getText(key, defaultValue, args, stack); - return getSafeText(key, value); - } - - /** - * Surrounds the non translated keys with a marker to make them visible - */ - protected String getSafeText(String key, String value) { - if (StringUtils.isEmpty(value)) { - if (log.isWarnEnabled()) { - log.warn("Key [" + key + "] is not translated"); - } - return UNTRANSLATED_MARKER + key + UNTRANSLATED_MARKER; - } - return value; - } -} Modified: trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties =================================================================== --- trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-03-16 09:49:56 UTC (rev 15) @@ -1,4 +1,5 @@ chorem.config.configFileName.description=chorem''s configuration filename +chorem.error.internal= chorem.gepeto.project=Project {0} chorem.gepeto.project.add=Add a new project chorem.gepeto.project.description=Description Modified: trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties =================================================================== --- trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-03-16 09:49:56 UTC (rev 15) @@ -1,4 +1,5 @@ chorem.config.configFileName.description=Nom du fichier de configuration de chorem +chorem.error.internal= chorem.gepeto.project=Projet {0} chorem.gepeto.project.add=Ajouter un nouveau projet chorem.gepeto.project.description=Description Modified: trunk/chorem-web/src/main/resources/struts.xml =================================================================== --- trunk/chorem-web/src/main/resources/struts.xml 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/src/main/resources/struts.xml 2011-03-16 09:49:56 UTC (rev 15) @@ -3,9 +3,23 @@ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> + <constant name="struts.devMode" value="true" /> <constant name="struts.ognl.allowStaticMethodAccess" value="true" /> <package name="default" extends="struts-default"> </package> + + <package name="chorem" namespace="/" extends="struts-default"> + <action name="home" class="org.chorem.action.HomeAction" method="execute"> + <result name="success">/WEB-INF/jsp/Home.jsp</result> + </action> + </package> +<!-- + <package name="bonzoms" namespace="/bonzoms" extends="struts-default"> + <action name="home" class="org.chorem.bonzoms.action.HomeAction" method="execute"> + <result name="success">/WEB-INF/jsp/bonzoms/Home.jsp</result> + </action> + </package> +--> </struts> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/web.xml 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/src/main/webapp/WEB-INF/web.xml 2011-03-16 09:49:56 UTC (rev 15) @@ -57,6 +57,7 @@ <!-- Welcome file lists --> <welcome-file-list> + <welcome-file>home.action</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> Modified: trunk/chorem-web/src/main/webapp/css/style.css =================================================================== --- trunk/chorem-web/src/main/webapp/css/style.css 2011-03-15 09:31:48 UTC (rev 14) +++ trunk/chorem-web/src/main/webapp/css/style.css 2011-03-16 09:49:56 UTC (rev 15) @@ -0,0 +1,7 @@ +.block { + border-style: solid; + border-width: 1px; + border-color: blue; + margin: 3px; + padding: 3px; +} \ No newline at end of file
participants (1)
-
bpoussin@users.chorem.org