r366 - in trunk: . coser-web coser-web/src/main/java/fr/ifremer/coser/web coser-web/src/main/java/fr/ifremer/coser/web/actions coser-web/src/main/resources coser-web/src/main/resources/i18n coser-web/src/main/webapp/WEB-INF coser-web/src/main/webapp/WEB-INF/content
Author: chatellier Date: 2010-12-06 13:25:56 +0000 (Mon, 06 Dec 2010) New Revision: 366 Log: Begin strut2 code (hello world) Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/WelcomeUserAction.java trunk/coser-web/src/main/resources/i18n/ trunk/coser-web/src/main/resources/i18n/coser-web_en_GB.properties trunk/coser-web/src/main/resources/i18n/coser-web_fr_FR.properties trunk/coser-web/src/main/webapp/WEB-INF/content/ trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result-success.jsp trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result.jsp trunk/coser-web/src/main/webapp/WEB-INF/content/welcome-user.jsp Removed: trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserServlet.java Modified: trunk/coser-web/pom.xml trunk/coser-web/src/main/webapp/WEB-INF/web.xml trunk/pom.xml Modified: trunk/coser-web/pom.xml =================================================================== --- trunk/coser-web/pom.xml 2010-12-06 13:24:48 UTC (rev 365) +++ trunk/coser-web/pom.xml 2010-12-06 13:25:56 UTC (rev 366) @@ -54,9 +54,20 @@ <build> <finalName>coser-${project.version}</finalName> - <!-- Add main class into war to make it executable --> <plugins> <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <configuration> Deleted: trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserServlet.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserServlet.java 2010-12-06 13:24:48 UTC (rev 365) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserServlet.java 2010-12-06 13:25:56 UTC (rev 366) @@ -1,56 +0,0 @@ -/* - * #%L - * - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 Codelutin, Chatellier Eric - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.web; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Coser main servlet. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class CoserServlet extends HttpServlet { - - /** serialVersionUID. */ - private static final long serialVersionUID = 8814522533745401133L; - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - resp.getWriter().print("Coser : It's works"); - } - - -} Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java (rev 0) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1,91 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.web; + +import static org.nuiton.i18n.I18n._; + +import java.io.File; + +import fr.ifremer.coser.CoserBusinessConfig; + +/** + * Coser web configuration. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class CoserWebConfig extends CoserBusinessConfig { + + public CoserWebConfig() { + // init configuration with default options + for (CoserWebOption o : CoserWebOption.values()) { + if (o.defaultValue != null) { + setDefaultOption(o.key, o.defaultValue); + } + } + } + + /** + * Get coser web result directory. + * + * @return + */ + public File getResultDirectory() { + File result = getOptionAsFile(CoserWebOption.RESULT_DIRECTORY.key); + return result; + } + + public enum CoserWebOption { + CONFIG_FILE(CONFIG_FILE_NAME, _("coser.config.config.file.description"), "coserweb.properties"), + + RESULT_DIRECTORY("coser.web.directory", _("coser.config.config.file.description"), "${java.io.tmpdir}" + File.separator + "coserweb"); + + protected String key; + protected String description; + protected String defaultValue; + + private CoserWebOption(String key, String description, String defaultValue) { + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + } + + public String getDefaultValue() { + return defaultValue; + } + + public String getDescription() { + return description; + } + + public String getKey() { + return key; + } + } +} Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java (rev 0) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1,76 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.web.actions; + +import java.io.File; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class UploadResultAction extends ActionSupport { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3887268253160622587L; + + protected File resultFile; + + protected File resultFileFileName; + + public void setResultFile(File resultFile) { + this.resultFile = resultFile; + } + + public File getResultFile() { + return resultFile; + } + + public File getResultFileFileName() { + return resultFileFileName; + } + + public void setResultFileFileName(File resultFileFileName) { + this.resultFileFileName = resultFileFileName; + } + + //@Action(params={"allowedTypes", "application/zip"}) + public String execute() { + if (resultFile == null) { + System.out.println("File size = " + null); + return INPUT; + } + else { + System.out.println("File size = " + resultFile.length()); + return SUCCESS; + } + } +} Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/WelcomeUserAction.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/WelcomeUserAction.java (rev 0) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/WelcomeUserAction.java 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1,72 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.web.actions; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.ResultPath; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * TODO add comment here. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class WelcomeUserAction extends ActionSupport { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3887268253160622587L; + + private String userName; + private String message; + + public String execute() { + message = "Welcome " + userName; + return SUCCESS; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getUserName() { + return userName; + } + + public String getMessage() { + return message; + } +} Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/WelcomeUserAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-web/src/main/resources/i18n/coser-web_en_GB.properties =================================================================== --- trunk/coser-web/src/main/resources/i18n/coser-web_en_GB.properties (rev 0) +++ trunk/coser-web/src/main/resources/i18n/coser-web_en_GB.properties 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1 @@ +coser.config.config.file.description= Added: trunk/coser-web/src/main/resources/i18n/coser-web_fr_FR.properties =================================================================== --- trunk/coser-web/src/main/resources/i18n/coser-web_fr_FR.properties (rev 0) +++ trunk/coser-web/src/main/resources/i18n/coser-web_fr_FR.properties 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1 @@ +coser.config.config.file.description= Added: trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp (rev 0) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1,20 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<%@taglib uri="/struts-tags" prefix="s" %> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Hello World</title> + </head> + <body> + <s:form action="upload-result" method="post" enctype="multipart/form-data"> + <s:actionerror /> + <s:file name="resultFile" label="Result archive" /> + <s:submit /> + </s:form> + <s:form action="welcome-user"> + <s:textfield name="userName" label="User Name" /> + <s:submit /> + </s:form> + </body> +</html> \ No newline at end of file Added: trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result-success.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result-success.jsp (rev 0) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result-success.jsp 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1,15 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<%@taglib uri="/struts-tags" prefix="s" %> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Hello World</title> + </head> + <body> + <s:form action="upload-result" method="post" enctype="multipart/form-data"> + <s:file name="resultFile" label="Result archive" /> + <s:submit /> + </s:form> + </body> +</html> \ No newline at end of file Added: trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result.jsp (rev 0) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/upload-result.jsp 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<%@taglib uri="/struts-tags" prefix="s" %> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Hello World</title> + </head> + <body> + Success !!! + <s:form action="upload-result" method="post" enctype="multipart/form-data"> + <s:actionerror /> + <s:file name="resultFile" label="Result archive" /> + <s:submit /> + </s:form> + </body> +</html> \ No newline at end of file Added: trunk/coser-web/src/main/webapp/WEB-INF/content/welcome-user.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/welcome-user.jsp (rev 0) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/welcome-user.jsp 2010-12-06 13:25:56 UTC (rev 366) @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<%@taglib uri="/struts-tags" prefix="s" %> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Welcome User</title> + </head> + <body> + <h1>Hi : ${message}</h1> + </body> +</html> \ No newline at end of file Modified: trunk/coser-web/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/web.xml 2010-12-06 13:24:48 UTC (rev 365) +++ trunk/coser-web/src/main/webapp/WEB-INF/web.xml 2010-12-06 13:25:56 UTC (rev 366) @@ -23,20 +23,37 @@ #L% --> -<web-app version="3.0" +<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> + <display-name>Coser</display-name> - - <servlet> - <servlet-name>coser</servlet-name> - <servlet-class>fr.ifremer.coser.web.CoserServlet</servlet-class> - </servlet> - - <servlet-mapping> - <servlet-name>coser</servlet-name> - <url-pattern>/coser</url-pattern> - </servlet-mapping> + <!-- <welcome-file-list> + <welcome-file>index.jsp</welcome-file> + </welcome-file-list> --> + + <filter> + <filter-name>struts2</filter-name> + <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> + <init-param> + <param-name>struts.convention.action.packages</param-name> + <param-value>fr.ifremer.coser.web</param-value> + </init-param> + <!-- <init-param> + <param-name>struts.convention.result.path</param-name> + <param-value>WEB-INF/jsp</param-value> + </init-param> --> + <init-param> + <param-name>struts.devMode</param-name> + <param-value>true</param-value> + </init-param> + </filter> + + <filter-mapping> + <filter-name>struts2</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + </web-app> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-12-06 13:24:48 UTC (rev 365) +++ trunk/pom.xml 2010-12-06 13:25:56 UTC (rev 366) @@ -172,21 +172,21 @@ <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> - <version>2.2.1</version> + <version>${struts.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-convention-plugin</artifactId> - <version>2.2.1</version> + <version>${struts.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.struts.xwork</groupId> <artifactId>xwork-core</artifactId> - <version>2.2.1</version> + <version>${struts.version}</version> <scope>compile</scope> </dependency> @@ -244,6 +244,7 @@ <!-- Versions --> <jaxx.version>2.2.4-SNAPSHOT</jaxx.version> <i18n.version>2.0</i18n.version> + <struts.version>2.2.1</struts.version> </properties> <scm>
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org