[coselmar] branch feature/single-page-ui updated (5e13d1c -> 8c660fe)
This is an automated email from the git hooks/post-receive script. New change to branch feature/single-page-ui in repository coselmar. See http://git.codelutin.com/coselmar.git from 5e13d1c remove jetty from pom new 8c660fe fix servlet version and add default render The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 8c660fe2c56967e1d88238b3e85b32fbd93c44de Author: Yannick Martel <yannick.martel@gmail.com> Date: Thu Oct 30 18:58:27 2014 +0100 fix servlet version and add default render Summary of changes: coselmar-services/pom.xml | 21 +++++++++ .../ifremer/coselmar/services/CoselmarRender.java | 52 ++++++++++++++++++++++ .../services/CoselmarRestApplicationListener.java | 5 --- .../services/config/CoselmarServicesConfig.java | 5 +++ .../config/CoselmarServicesConfigOption.java | 5 +++ .../src/main/resources/log4j.properties | 4 +- coselmar-services/src/main/resources/mapping | 2 +- 7 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRender.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/single-page-ui in repository coselmar. See http://git.codelutin.com/coselmar.git commit 8c660fe2c56967e1d88238b3e85b32fbd93c44de Author: Yannick Martel <yannick.martel@gmail.com> Date: Thu Oct 30 18:58:27 2014 +0100 fix servlet version and add default render --- coselmar-services/pom.xml | 21 +++++++++ .../ifremer/coselmar/services/CoselmarRender.java | 52 ++++++++++++++++++++++ .../services/CoselmarRestApplicationListener.java | 5 --- .../services/config/CoselmarServicesConfig.java | 5 +++ .../config/CoselmarServicesConfigOption.java | 5 +++ .../src/main/resources/log4j.properties | 4 +- coselmar-services/src/main/resources/mapping | 2 +- 7 files changed, 86 insertions(+), 8 deletions(-) diff --git a/coselmar-services/pom.xml b/coselmar-services/pom.xml index 9e51483..8cc717f 100644 --- a/coselmar-services/pom.xml +++ b/coselmar-services/pom.xml @@ -18,6 +18,12 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> <description>Coselmar services module</description> <packaging>war</packaging> + <properties> + <i18n.silent>true</i18n.silent> + <i18n.bundleOutputName>coselmar-i18n</i18n.bundleOutputName> + </properties> + + <dependencies> <!-- internal --> @@ -100,6 +106,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> </dependency> <!-- Tests --> @@ -138,6 +145,20 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> </plugins> </pluginManagement> + <plugins> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>i18n-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>bundle</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> diff --git a/coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRender.java b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRender.java new file mode 100644 index 0000000..1ff674c --- /dev/null +++ b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRender.java @@ -0,0 +1,52 @@ +package fr.ifremer.coselmar.services; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; + +import fr.ifremer.coselmar.converter.JsonHelper; +import org.debux.webmotion.server.call.Call; +import org.debux.webmotion.server.call.HttpContext; +import org.debux.webmotion.server.mapping.Mapping; +import org.debux.webmotion.server.render.Render; + +/** + * @author ymartel <martel@codelutin.com> + */ +public class CoselmarRender<T> extends Render { + + protected T model; + + public CoselmarRender(T model) { + this.model = model; + } + + @Override + public void create(Mapping mapping, Call call) throws IOException, ServletException { + + HttpContext context = call.getContext(); + HttpServletResponse response = context.getResponse(); + response.setContentType("application/json"); + + CoselmarServicesApplicationContext applicationContext = + CoselmarServicesApplicationContext.getApplicationContext(context.getServletContext()); + + //TODO ymartel 20141030 : think about formException render +// if (model instanceof InvalidFormException) { +// +// response.setStatus(HttpServletResponse.SC_BAD_REQUEST); +// +// } + + boolean devMode = applicationContext.getApplicationConfig().isDevMode(); + + JsonHelper gson = new JsonHelper(devMode); + String json = gson.toJson(model); + + PrintWriter out = context.getOut(); + out.print(json); + + } +} diff --git a/coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java index 74d0356..c8904df 100644 --- a/coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java +++ b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java @@ -27,11 +27,8 @@ public class CoselmarRestApplicationListener implements WebMotionServerListener public void onStart(Mapping mapping, ServerContext serverContext) { // init application context // - System.out.println("start"); - CoselmarServicesApplicationContext applicationContext = CoselmarServicesApplicationContext.getApplicationContext(); - System.out.println("application context get"); CoselmarServicesApplicationContext.setApplicationContext(serverContext.getServletContext(), applicationContext); @@ -49,8 +46,6 @@ public class CoselmarRestApplicationListener implements WebMotionServerListener } // init injectors // - - System.out.println("add injectors"); serverContext.addInjector(new CoselmarRestRequestContextInjector()); serverContext.addInjector(new CoselmarServicesInjector()); diff --git a/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfig.java b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfig.java index 0d61eba..18c87df 100644 --- a/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfig.java +++ b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfig.java @@ -82,4 +82,9 @@ public class CoselmarServicesConfig { public File getLogConfigurationFile() { return applicationConfig.getOptionAsFile(CoselmarServicesConfigOption.LOG_CONFIGURATION_FILE.key); } + + public boolean isDevMode() { + boolean isDevMode = applicationConfig.getOptionAsBoolean(CoselmarServicesConfigOption.DEV_MODE.key); + return isDevMode; + } } diff --git a/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfigOption.java b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfigOption.java index 601a276..184e918 100644 --- a/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfigOption.java +++ b/coselmar-services/src/main/java/fr/ifremer/coselmar/services/config/CoselmarServicesConfigOption.java @@ -21,6 +21,11 @@ public enum CoselmarServicesConfigOption implements ConfigOptionDef { "Path to the logs config file", null, String.class), + + DEV_MODE( + "pollen.devMode", + "Mode développement, court-circuite l'envoi de mail", + "true", Boolean.class), ; protected final String key; diff --git a/coselmar-services/src/main/resources/log4j.properties b/coselmar-services/src/main/resources/log4j.properties index 1bb5852..0302156 100644 --- a/coselmar-services/src/main/resources/log4j.properties +++ b/coselmar-services/src/main/resources/log4j.properties @@ -1,9 +1,9 @@ -log4j.rootCategory=DEBUG, console +log4j.rootCategory=INFO, console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{hh:mm:ss} %5p (%F:%L) %m%n log4j.logger.fr.ifremer.coselmar=DEBUG -log4j.logger.org.debux=DEBUG +log4j.logger.org.debux=INFO diff --git a/coselmar-services/src/main/resources/mapping b/coselmar-services/src/main/resources/mapping index c3a8ea7..6fff1ca 100644 --- a/coselmar-services/src/main/resources/mapping +++ b/coselmar-services/src/main/resources/mapping @@ -7,7 +7,7 @@ package.filters=fr.ifremer.coselmar.services.filter package.actions=fr.ifremer.coselmar.services.v1 package.errors=fr.ifremer.coselmar.services.errors server.listener.class=fr.ifremer.coselmar.services.CoselmarRestApplicationListener -#default.render=fr.ifremer.coselmar.services.CoselmarRender +default.render=fr.ifremer.coselmar.services.CoselmarRender [filters] * /* CoselmarRestRequestFilter.inject -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm