Author: sletellier Date: 2011-05-18 17:56:32 +0200 (Wed, 18 May 2011) New Revision: 31 Url: http://chorem.org/repositories/revision/vradi/31 Log: #375 Initialisation du module Vradi-web Added: trunk/vradi-web/src/main/java/org/ trunk/vradi-web/src/main/java/org/chorem/ trunk/vradi-web/src/main/java/org/chorem/vradi/ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebConfig.java trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties Modified: trunk/pom.xml trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java trunk/vradi-web/pom.xml trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties trunk/vradi-web/src/main/webapp/WEB-INF/web.xml trunk/vradi-web/src/main/webapp/index.jsp Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-05-18 15:00:05 UTC (rev 30) +++ trunk/pom.xml 2011-05-18 15:56:32 UTC (rev 31) @@ -17,8 +17,8 @@ <module>vradi-entities</module> <module>vradi-services</module> <module>vradi-services-web</module> + <module>vradi-web</module> <module>vradi-swing</module> - <module>vradi-web</module> </modules> <name>Vradi</name> Modified: trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java 2011-05-18 15:00:05 UTC (rev 30) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java 2011-05-18 15:56:32 UTC (rev 31) @@ -26,7 +26,6 @@ import com.caucho.hessian.client.HessianProxyFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.vradi.VradiConfig; import org.chorem.vradi.VradiConfigHelper; import org.nuiton.util.ApplicationConfig; import org.nuiton.wikitty.WikittyProxy; Modified: trunk/vradi-web/pom.xml =================================================================== --- trunk/vradi-web/pom.xml 2011-05-18 15:00:05 UTC (rev 30) +++ trunk/vradi-web/pom.xml 2011-05-18 15:56:32 UTC (rev 31) @@ -15,6 +15,7 @@ <version>0.7-SNAPSHOT</version> </parent> + <groupId>org.chorem.vradi</groupId> <artifactId>vradi-web</artifactId> <name>Vradi :: Web</name> @@ -34,6 +35,25 @@ <dependencies> + <!-- project dependencies --> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-entities</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-services</artifactId> + <version>${project.version}</version> + <!-- WARNING! check it works chemit 2010-10-28 : it comes from wikitty-solr-impl but conflits with stax --> + <exclusions> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-stax-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- compile dependencies --> <dependency> Added: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java (rev 0) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java 2011-05-18 15:56:32 UTC (rev 31) @@ -0,0 +1,74 @@ +package org.chorem.vradi; + +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.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.WikittyServiceFactory; +import org.nuiton.wikitty.entities.WikittyUser; + +/** + * Classe utilisee pour stocker les objets utils en session utilisateur + * + * @author poussin + * @version $Revision: 285 $ + * + * Last update: $Date: 2011-05-16 15:21:52 +0200 (lun. 16 mai 2011) $ + * by : $Author: sletellier $ + */ +public class VradiSession { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(VradiSession.class); + + static final private String VRADI_SESSION_KEY = VradiSession.class.getSimpleName(); + + protected WikittyProxy proxy; + private WikittyUser user; + + public VradiSession() { + ApplicationConfig config = VradiWebConfig.getConfig(); + WikittyService ws = WikittyServiceFactory.buildWikittyService(config); + proxy = new WikittyProxy(config, ws); + } + + static public void invalidate(Map<String, Object> session) { + session.remove(VRADI_SESSION_KEY); + } + + static public VradiSession getVradiSession(HttpServletRequest request) { + HttpSession session = request.getSession(); + VradiSession result = getVradiSession(session); + return result; + } + + static public VradiSession getVradiSession(HttpSession httpSession) { + VradiSession result = (VradiSession) httpSession.getAttribute(VRADI_SESSION_KEY); + if (result == null) { + result = new VradiSession(); + httpSession.setAttribute(VRADI_SESSION_KEY, result); + } + return result; + } + + static public VradiSession getVradiSession(Map<String, Object> session) { + VradiSession result = (VradiSession)session.get(VRADI_SESSION_KEY); + if (result == null) { + result = new VradiSession(); + session.put(VRADI_SESSION_KEY, result); + } + return result; + } + + public WikittyProxy getProxy() { + return proxy; + } + + public WikittyUser getUser() { + return user; + } +} Added: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebConfig.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebConfig.java (rev 0) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebConfig.java 2011-05-18 15:56:32 UTC (rev 31) @@ -0,0 +1,179 @@ +package org.chorem.vradi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ArgumentsParserException; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; +import org.nuiton.wikitty.WikittyConfigOption; + +import java.util.Locale; + +import static org.nuiton.i18n.I18n._; + +/** + * Vradi Web configuration. + * + * @author sletellier + * @version $Revision: 21 $ + * <p/> + * Last update : $Date: 2011-05-09 18:43:58 +0200 (lun. 09 mai 2011) $ + * By : $Author: sletellier $ + */ +public class VradiWebConfig { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(VradiWebConfig.class); + + private static ApplicationConfig config; + + private VradiWebConfig() { + } + + public static ApplicationConfig getConfig(String... args) { + + if (config == null) { + + // Creating instance of ApplicationConfig + config = new ApplicationConfig(VradiWebOption.CONFIG_FILE.getDefaultValue()); + + // Load service options + config.loadDefaultOptions(VradiServiceConfiguration.VradiServiceOption.class); + + // Load wikitty options + config.loadDefaultOptions(WikittyConfigOption.class); + + // Load vradi options + config.loadDefaultOptions(VradiWebOption.class); + + try { + // Parse args + config.parse(args); + + // on supprime le stamp de snapshot s'il existe + String sVersion = VersionUtil.removeSnapshot(config.getOption("application.version")); + Version version = VersionUtil.valueOf(sVersion); + config.setDefaultOption(VradiWebOption.VRADI_VERSION.key, version.getVersion()); + + // la version de la base est sans classifier (pas de alpha, ou rc,...) + Version dbVersion; + if (version.hasClassifier()) { + dbVersion = VersionUtil.removeClassifier(version); + } else { + dbVersion = VersionUtil.valueOf(version.toString()); + } + + config.setDefaultOption(VradiWebOption.VRADI_DATABASE_VERSION.key, dbVersion.getVersion()); + } catch (ArgumentsParserException eee) { + if (log.isErrorEnabled()) { + log.error("Can't load vradi configuration", eee); + } + } + } + return config; + } + + /** Vradi option enum. */ + public enum VradiWebOption implements ApplicationConfig.OptionDef { + + CONFIG_FILE( + ApplicationConfig.CONFIG_FILE_NAME, + _("vradi.config.configFileName.description"), + "vradi.properties", String.class, true, true), + + VRADI_VERSION( + "vradi.version", + _("vradi.config.version.description"), + null, String.class, true, true), + + VRADI_DATABASE_VERSION( + "vradi.database.version", + _("vradi.config.database.version.description"), + null, String.class, true, true), + + VRADI_LAST_VERSION( + "vradi.last.version", + _("vradi.config.last.version.description"), + null, String.class, true, true), + + // ui config + LOCALE( + "ui.locale", + _("vradi.config.ui.locale"), + Locale.FRANCE.toString(), + Locale.class, false, false), + + // achitecture client serveur + REMOTE_ENDPOINT( + "vradi.remote.endpoint", + _("vradi.config.remote.endpoint.description"), + "", String.class, false, false); + + public String key; + + public String description; + + public String defaultValue; + + public Class<?> type; + + public boolean isTransient; + + public boolean isFinal; + + VradiWebOption(String key, String description, String defaultValue, Class<?> type, boolean isTransient, boolean isFinal) { + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + this.type = type; + this.isTransient = isTransient; + this.isFinal = isFinal; + } + + @Override + public boolean isFinal() { + return isFinal; + } + + @Override + public boolean isTransient() { + return isTransient; + } + + @Override + public String getDefaultValue() { + return defaultValue; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public String getKey() { + return key; + } + + @Override + public Class<?> getType() { + return type; + } + + @Override + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + @Override + public void setTransient(boolean isTransient) { + this.isTransient = isTransient; + } + + @Override + public void setFinal(boolean isFinal) { + this.isFinal = isFinal; + } + } +} Added: trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties =================================================================== --- trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties (rev 0) +++ trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-05-18 15:56:32 UTC (rev 31) @@ -0,0 +1,6 @@ +vradi.config.configFileName.description=Vradi web config files name +vradi.config.database.version.description=Database version +vradi.config.last.version.description=Last started version +vradi.config.remote.endpoint.description=Url of vradi service +vradi.config.ui.locale=Vradi web locale +vradi.config.version.description=Vradi web version \ No newline at end of file Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties =================================================================== --- trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-05-18 15:00:05 UTC (rev 30) +++ trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-05-18 15:56:32 UTC (rev 31) @@ -0,0 +1,6 @@ +vradi.config.configFileName.description=Fichier de configuration de Vradi web +vradi.config.database.version.description=Version de la base de donnée +vradi.config.last.version.description=Dernière version de Vradi web lancée +vradi.config.remote.endpoint.description=Url de l'addresse de Vradi service +vradi.config.ui.locale=Locale de l'instance de Vradi web +vradi.config.version.description=Version de Vradi web Modified: trunk/vradi-web/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/vradi-web/src/main/webapp/WEB-INF/web.xml 2011-05-18 15:00:05 UTC (rev 30) +++ trunk/vradi-web/src/main/webapp/WEB-INF/web.xml 2011-05-18 15:56:32 UTC (rev 31) @@ -56,7 +56,6 @@ <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> - <trim-directive-whitespaces>true</trim-directive-whitespaces> </jsp-property-group> </jsp-config> </web-app> Modified: trunk/vradi-web/src/main/webapp/index.jsp =================================================================== --- trunk/vradi-web/src/main/webapp/index.jsp 2011-05-18 15:00:05 UTC (rev 30) +++ trunk/vradi-web/src/main/webapp/index.jsp 2011-05-18 15:56:32 UTC (rev 31) @@ -1,5 +1,13 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<html> -<head><title>Simple jsp page</title></head> -<body>Place your content here</body> +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <%--<meta http-equiv="refresh" content="0;URL=home.action?request_locale=fr_FR"/>--%> + <title>Vradi web</title> + </head> + + <body onload=""> + + </body> </html> \ No newline at end of file