Wao-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
June 2014
- 6 participants
- 139 discussions
See <http://ci.codelutin.com/jenkins/job/wao-ci/218/changes>
Changes:
[bleny] refs #4490 just put the link on the name
[bleny] fix NPE
[bleny] refs #4490 introduce cache for boats
[bleny] refs #4490 too many shipowners, ask user to type 3 caracters before searching
------------------------------------------
[...truncated 55 lines...]
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wao-group/org/nuiton/nuiton-ut… (2 KB at 13.9 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wao-persistence ---
[INFO] Deleting <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ wao-persistence ---
[INFO]
[INFO] --- eugene-maven-plugin:2.9:generate (generate-entities) @ wao-persistence ---
[INFO] Process phase [zargo]
[INFO] Generate one file in 13.807ms.
[INFO] Process phase [xmi]
[INFO] Generate one file in 1.298s.
[INFO] Process phase [model]
[INFO] Process phase [generator]
[INFO] Apply generator TopiaMetaTransformer
[INFO] Generate 173 files in 495.865ms.
[INFO]
[INFO] --- i18n-maven-plugin:3.1:parserJava (parseOthersAndGen) @ wao-persistence ---
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…,> includes:[**/*.java]
[INFO] 145 file(s) to process (among 145 files)
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…,> includes:[**/*.java]
[INFO] 65 file(s) to process (among 65 files)
[INFO] Parsing is done. [treated file(s) : 13/210](total time:4.612s) ( ~ 21.96ms / file)
[INFO]
[INFO] >>> i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-persistence >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.1:get (get) @ wao-persistence ---
[INFO] config - basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] import getter java.getter in 352901ns
[INFO] Copying wao-persistence.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] Copying wao-persistence.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-persistence <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-persistence ---
[INFO] config - src basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>
[INFO] config - out basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] prepare bundle for locale fr_FR
[INFO] merge bundle fr_FR to out
[WARNING] bundle fr_FR contains 1/150 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle fr_FR to src
[INFO] prepare bundle for locale en_GB
[INFO] merge bundle en_GB to out
[WARNING] bundle en_GB contains 2/150 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle en_GB to src
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wao-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO] Copying 28 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wao-persistence ---
[INFO] Compiling 210 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[404,48] formatDate(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[407,70] formatDate(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[408,70] formatDate(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[43,82] formatMonth(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[43,47] formatMonth(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/src/mai…>:[49,90] formatMonth(java.util.Date) in fr.ifremer.wao.WaoUtils has been deprecated
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ wao-persistence ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ wao-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ wao-persistence ---
[INFO] Compiling 1 source file to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ wao-persistence ---
[INFO] Surefire report directory: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running fr.ifremer.wao.entity.SampleRowLogImplTest
2014/06/03 07:25:31 DEBUG (SampleRowLogImplTest.java:77) testNewSampleRowLog Le nombre d'observateurs est de 0
Le durée moyenne d'une marée est de 0.0
La ligne est sur la période du 03/2011 au 06/2011
Le métier de la ligne est
2014/06/03 07:25:31 DEBUG (SampleRowLogImplTest.java:93) testCompareSampleRowToItself
2014/06/03 07:25:31 DEBUG (SampleRowLogImplTest.java:117) testModifySampleRow La durée moyenne d'une marée est passé de 0.0 jours à 1.0
La ligne est désormais associée au programme programName
La date de fin est passée de 06/2011 à 07/2011
Les zones de pêches suivantes ont été ajoutées : null - null - IV
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.155 sec - in fr.ifremer.wao.entity.SampleRowLogImplTest
Results :
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ wao-persistence ---
[INFO] Building jar: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-persistence/target/…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ wao-persistence ---
[JENKINS] Archiving disabled
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Wao :: Services 4.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wao-services ---
[INFO] Deleting <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ wao-services ---
[INFO]
[INFO] --- i18n-maven-plugin:3.1:parserJava (parseOthersAndGen) @ wao-services ---
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…,> includes:[**/*.java]
[INFO] 112 file(s) to process (among 112 files)
[INFO] Parsing is done. [treated file(s) : 32/112](total time:444.844ms) ( ~ 3.972ms / file)
[INFO]
[INFO] >>> i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-services >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.1:get (get) @ wao-services ---
[INFO] config - basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] import getter java.getter in 207089ns
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-services <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-services ---
[INFO] config - src basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/r…>
[INFO] config - out basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/gen…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] prepare bundle for locale fr_FR
[INFO] merge bundle fr_FR to out
[INFO] copy bundle fr_FR to src
[INFO] prepare bundle for locale en_GB
[INFO] merge bundle en_GB to out
[WARNING] bundle en_GB contains 2/93 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle en_GB to src
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wao-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wao-services ---
[INFO] Compiling 112 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/cla…>
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/main/j…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ wao-services ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/sur…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ wao-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ wao-services ---
[INFO] Compiling 11 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/target/tes…>
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/test/j…>:[29,8] fr.ifremer.wao.services.FakeWaoApplicationContext is not abstract and does not override abstract method getBoatsFilterValuesCache() in fr.ifremer.wao.services.WaoApplicationContext
[INFO] 1 error
[INFO] -------------------------------------------------------------
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Wao ............................................... SUCCESS [ 1.649 s]
[INFO] Wao :: Persistence ................................ SUCCESS [ 16.211 s]
[INFO] Wao :: Services ................................... FAILURE [ 1.863 s]
[INFO] Wao :: Web ........................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.878 s
[INFO] Finished at: 2014-06-03T19:25:35+01:00
[INFO] Final Memory: 55M/1219M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project wao-services: Compilation failure
[ERROR] <http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/test/j…>:[29,8] fr.ifremer.wao.services.FakeWaoApplicationContext is not abstract and does not override abstract method getBoatsFilterValuesCache() in fr.ifremer.wao.services.WaoApplicationContext
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project wao-services: Compilation failure
<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/test/j…>:[29,8] fr.ifremer.wao.services.FakeWaoApplicationContext is not abstract and does not override abstract method getBoatsFilterValuesCache() in fr.ifremer.wao.services.WaoApplicationContext
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
<http://ci.codelutin.com/jenkins/job/wao-ci/ws/trunk/wao-services/src/test/j…>:[29,8] fr.ifremer.wao.services.FakeWaoApplicationContext is not abstract and does not override abstract method getBoatsFilterValuesCache() in fr.ifremer.wao.services.WaoApplicationContext
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:152)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 30 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :wao-services
Sending e-mails to: wao-commits(a)list.forge.codelutin.com leny(a)codelutin.com
channel stopped
1
1
Build failed in Jenkins: wao-ci » Wao :: Services #218
by admin+ci-codelutin.com@codelutin.com 04 Jun '14
by admin+ci-codelutin.com@codelutin.com 04 Jun '14
04 Jun '14
See <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/218/chan…>
Changes:
[bleny] refs #4490 introduce cache for boats
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Wao :: Services 4.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wao-services ---
[INFO] Deleting <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ wao-services ---
[INFO]
[INFO] --- i18n-maven-plugin:3.1:parserJava (parseOthersAndGen) @ wao-services ---
[INFO] start entry basedir:<http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…,> includes:[**/*.java]
[INFO] 112 file(s) to process (among 112 files)
[INFO] Parsing is done. [treated file(s) : 32/112](total time:444.844ms) ( ~ 3.972ms / file)
[INFO]
[INFO] >>> i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-services >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.1:get (get) @ wao-services ---
[INFO] config - basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] import getter java.getter in 207089ns
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] Copying wao-services.properties to <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-services <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.1:gen (parseOthersAndGen) @ wao-services ---
[INFO] config - src basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>
[INFO] config - out basedir : <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] config - locales : [fr_FR, en_GB]
[INFO] prepare bundle for locale fr_FR
[INFO] merge bundle fr_FR to out
[INFO] copy bundle fr_FR to src
[INFO] prepare bundle for locale en_GB
[INFO] merge bundle en_GB to out
[WARNING] bundle en_GB contains 2/93 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO] copy bundle en_GB to src
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wao-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wao-services ---
[INFO] Compiling 112 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/m…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ wao-services ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ wao-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ wao-services ---
[INFO] Compiling 11 source files to <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/targe…>
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.codelutin.com/jenkins/job/wao-ci/fr.ifremer$wao-services/ws/src/t…>:[29,8] fr.ifremer.wao.services.FakeWaoApplicationContext is not abstract and does not override abstract method getBoatsFilterValuesCache() in fr.ifremer.wao.services.WaoApplicationContext
[INFO] 1 error
[INFO] -------------------------------------------------------------
[JENKINS] Archiving disabled
1
1
r1992 - trunk/wao-services/src/test/java/fr/ifremer/wao/services
by bleny@users.forge.codelutin.com 04 Jun '14
by bleny@users.forge.codelutin.com 04 Jun '14
04 Jun '14
Author: bleny
Date: 2014-06-04 10:12:57 +0200 (Wed, 04 Jun 2014)
New Revision: 1992
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1992
Log:
fix build
Modified:
trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-06-03 17:14:46 UTC (rev 1991)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-06-04 08:12:57 UTC (rev 1992)
@@ -7,6 +7,8 @@
import fr.ifremer.wao.WaoTechnicalException;
import fr.ifremer.wao.WaoTopiaApplicationContext;
import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.BoatsFilterValues;
+import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.InitWaoService;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
@@ -46,6 +48,8 @@
protected Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> samplingPlansCache;
+ protected Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache;
+
public FakeWaoApplicationContext(String context, boolean initWithReferential) {
this.context = context;
this.initWithReferential = initWithReferential;
@@ -210,14 +214,6 @@
}
@Override
- public Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache() {
- if (samplingPlansCache == null) {
- samplingPlansCache = CacheBuilder.newBuilder().build();
- }
- return samplingPlansCache;
- }
-
- @Override
public WaoTopiaPersistenceContext newPersistenceContext() {
WaoTopiaPersistenceContext persistenceContext = getTopiaApplicationContext().newPersistenceContext();
@@ -243,4 +239,19 @@
}
}
+ @Override
+ public Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache() {
+ if (samplingPlansCache == null) {
+ samplingPlansCache = CacheBuilder.newBuilder().build();
+ }
+ return samplingPlansCache;
+ }
+
+ @Override
+ public Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache() {
+ if (boatsFilterValuesCache == null) {
+ boatsFilterValuesCache = CacheBuilder.newBuilder().build();
+ }
+ return boatsFilterValuesCache;
+ }
}
1
0
r1991 - trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer
by bleny@users.forge.codelutin.com 03 Jun '14
by bleny@users.forge.codelutin.com 03 Jun '14
03 Jun '14
Author: bleny
Date: 2014-06-03 19:14:46 +0200 (Tue, 03 Jun 2014)
New Revision: 1991
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1991
Log:
refs #4490 just put the link on the name
Modified:
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-03 17:14:20 UTC (rev 1990)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-03 17:14:46 UTC (rev 1991)
@@ -296,14 +296,15 @@
<s:text name="wao.ui.field.Boat.shipOwner"/>
</th>
<td class="no-border-top">
- <s:property value="boatDetails.boatInfos.boat.shipOwner.firstName"/>
- <s:property value="boatDetails.boatInfos.boat.shipOwner.lastName"/>
-
<s:url action="boats" id="shipOwnerBoatsUrl">
<s:param name="filter.shipOwnerIds" value="boatDetails.boatInfos.boat.shipOwner.topiaId"/>
</s:url>
- <s:a href="%{shipOwnerBoatsUrl}">
+ <s:set name="shipOwnerBoatsTitle">
<s:text name="wao.ui.action.viewShipOwnerBoats"/>
+ </s:set>
+ <s:a href="%{shipOwnerBoatsUrl}" title="%{shipOwnerBoatsTitle}">
+ <s:property value="boatDetails.boatInfos.boat.shipOwner.firstName"/>
+ <s:property value="boatDetails.boatInfos.boat.shipOwner.lastName"/>
</s:a>
</td>
</tr>
1
0
r1990 - trunk/wao-web/src/main/java/fr/ifremer/wao/web
by bleny@users.forge.codelutin.com 03 Jun '14
by bleny@users.forge.codelutin.com 03 Jun '14
03 Jun '14
Author: bleny
Date: 2014-06-03 19:14:20 +0200 (Tue, 03 Jun 2014)
New Revision: 1990
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1990
Log:
fix NPE
Modified:
trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-03 17:06:09 UTC (rev 1989)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-03 17:14:20 UTC (rev 1990)
@@ -159,8 +159,8 @@
public void close() {
if (log.isInfoEnabled()) {
- log.info("samplingPlansCache stats: " + samplingPlansCache.stats().toString());
- log.info("boatsFilterValuesCache stats: " + boatsFilterValuesCache.stats().toString());
+ log.info("samplingPlansCache stats: " + getSamplingPlansCache().stats().toString());
+ log.info("boatsFilterValuesCache stats: " + getBoatsFilterValuesCache().stats().toString());
}
if (topiaApplicationContext != null) {
1
0
r1989 - in trunk: wao-services/src/main/java/fr/ifremer/wao/services wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/main/java/fr/ifremer/wao/services/service/administration wao-web/src/main/java/fr/ifremer/wao/web
by bleny@users.forge.codelutin.com 03 Jun '14
by bleny@users.forge.codelutin.com 03 Jun '14
03 Jun '14
Author: bleny
Date: 2014-06-03 19:06:09 +0200 (Tue, 03 Jun 2014)
New Revision: 1989
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1989
Log:
refs #4490 introduce cache for boats
Added:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java
Modified:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-06-03 17:05:18 UTC (rev 1988)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-06-03 17:06:09 UTC (rev 1989)
@@ -25,6 +25,8 @@
import fr.ifremer.wao.WaoApplicationConfig;
import fr.ifremer.wao.WaoTechnicalException;
import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.BoatsFilterValues;
+import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
@@ -123,4 +125,9 @@
return waoApplicationContext.getSamplingPlansCache();
}
+ @Override
+ public Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache() {
+ return waoApplicationContext.getBoatsFilterValuesCache();
+ }
+
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-06-03 17:05:18 UTC (rev 1988)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-06-03 17:06:09 UTC (rev 1989)
@@ -3,6 +3,8 @@
import com.google.common.cache.Cache;
import fr.ifremer.wao.WaoApplicationConfig;
import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.BoatsFilterValues;
+import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
@@ -31,6 +33,8 @@
Cache<SamplingPlanCacheKey,ObsMerSamplingPlan> getSamplingPlansCache();
+ Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache();
+
void close();
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-06-03 17:05:18 UTC (rev 1988)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-06-03 17:06:09 UTC (rev 1989)
@@ -24,6 +24,8 @@
import com.google.common.cache.Cache;
import fr.ifremer.wao.WaoApplicationConfig;
import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.BoatsFilterValues;
+import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
@@ -40,8 +42,6 @@
WaoTopiaPersistenceContext getPersistenceContext();
- Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache();
-
Date getNow();
<E extends WaoService> E newService(Class<E> serviceClass);
@@ -54,4 +54,8 @@
String newUuid();
+ Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache();
+
+ Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache();
+
}
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java 2014-06-03 17:06:09 UTC (rev 1989)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import fr.ifremer.wao.entity.ObsProgram;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+public class BoatsFilterValuesCacheKey implements Serializable {
+
+ protected final Locale locale;
+
+ protected final ObsProgram obsProgram;
+
+ protected final Optional<String> optionalCompanyId;
+
+ public BoatsFilterValuesCacheKey(Locale locale, ObsProgram obsProgram, Optional<String> optionalCompanyId) {
+ this.locale = locale;
+ this.obsProgram = obsProgram;
+ this.optionalCompanyId = optionalCompanyId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ BoatsFilterValuesCacheKey that = (BoatsFilterValuesCacheKey) o;
+ boolean equals = Objects.equal(locale, that.locale)
+ && Objects.equal(optionalCompanyId, that.optionalCompanyId)
+ && Objects.equal(obsProgram, that.obsProgram);
+ return equals;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(locale, optionalCompanyId, obsProgram);
+ }
+
+}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-06-03 17:05:18 UTC (rev 1988)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-06-03 17:06:09 UTC (rev 1989)
@@ -24,6 +24,7 @@
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableSet;
import fr.ifremer.wao.BoatsFilter;
import fr.ifremer.wao.ContactsFilter;
@@ -51,10 +52,8 @@
import java.io.InputStream;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
/**
* Created on 4/1/14.
@@ -67,30 +66,37 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ObsMerBoatsService.class);
- protected static final Map<BoatsFilter, BoatsFilterValues> cache = new HashMap();
-
public BoatsFilterValues getBoatsFilterValues(AuthenticatedWaoUser authenticatedWaoUser, BoatsFilter filter) {
- BoatsFilterValues boatsFilterValues = cache.get(filter);
+ Optional<String> optionalCompanyId = Optional.absent();
+ if (authenticatedWaoUser.isCoordinatorOrObserver()) {
+ optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId());
+ }
+ BoatsFilterValuesCacheKey boatsFilterValuesCacheKey =
+ new BoatsFilterValuesCacheKey(
+ serviceContext.getLocale(),
+ authenticatedWaoUser.getObsProgram(),
+ optionalCompanyId);
+
+ Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> cache =
+ serviceContext.getBoatsFilterValuesCache();
+
+ BoatsFilterValues boatsFilterValues = cache.getIfPresent(boatsFilterValuesCacheKey);
+
if (boatsFilterValues == null) {
BoatTopiaDao dao = getBoatDao();
List<Boat> boats = dao.findAll(filter);
- Optional<String> optionalCompanyId = Optional.absent();
- if (authenticatedWaoUser.isCoordinatorOrObserver()) {
- optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId());
- }
-
boatsFilterValues = new BoatsFilterValues(serviceContext.getLocale(), authenticatedWaoUser.getObsProgram(), optionalCompanyId);
for (Boat boat : boats) {
boatsFilterValues.addBoat(boat);
}
- cache.put(filter, boatsFilterValues);
+ cache.put(boatsFilterValuesCacheKey, boatsFilterValues);
}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java 2014-06-03 17:05:18 UTC (rev 1988)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java 2014-06-03 17:06:09 UTC (rev 1989)
@@ -943,6 +943,8 @@
commit();
+ serviceContext.getBoatsFilterValuesCache().invalidateAll();
+
}
public void importBoatGroups(InputStream input) throws ImportErrorException {
@@ -995,6 +997,8 @@
commit();
+ serviceContext.getBoatsFilterValuesCache().invalidateAll();
+
}
public List<Boat> getBoatsFromImmatriculations(String joinedImmatriculations) throws UnknownBoatImmatriculationsException {
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-03 17:05:18 UTC (rev 1988)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-03 17:06:09 UTC (rev 1989)
@@ -23,7 +23,6 @@
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheStats;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import fr.ifremer.wao.WaoApplicationConfig;
import fr.ifremer.wao.WaoTopiaApplicationContext;
@@ -32,6 +31,8 @@
import fr.ifremer.wao.services.WaoApplicationContext;
import fr.ifremer.wao.services.WaoServiceContext;
import fr.ifremer.wao.services.WaoWebApplicationContext;
+import fr.ifremer.wao.services.service.BoatsFilterValues;
+import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
import fr.ifremer.wao.services.service.InitWaoService;
import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
@@ -66,6 +67,8 @@
protected Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> samplingPlansCache;
+ protected Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache;
+
@Override
public WaoApplicationConfig getApplicationConfig() {
if (applicationConfig == null) {
@@ -116,6 +119,14 @@
return samplingPlansCache;
}
+ @Override
+ public Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache() {
+ if (boatsFilterValuesCache == null) {
+ boatsFilterValuesCache = newCacheBuilder(100).expireAfterAccess(30, TimeUnit.DAYS).build();
+ }
+ return boatsFilterValuesCache;
+ }
+
protected <K, V> CacheBuilder<K, V> newCacheBuilder(int expectedMaximumCacheSize) {
int maximumCacheSize = applicationConfig.isCachingEnabled() ? expectedMaximumCacheSize : 0;
CacheBuilder<K, V> cacheBuilder = (CacheBuilder<K, V>) CacheBuilder.newBuilder().maximumSize(maximumCacheSize);
@@ -148,8 +159,8 @@
public void close() {
if (log.isInfoEnabled()) {
- CacheStats cacheStats = samplingPlansCache.stats();
- log.info("samplingPlansCache stats: " + cacheStats.toString());
+ log.info("samplingPlansCache stats: " + samplingPlansCache.stats().toString());
+ log.info("boatsFilterValuesCache stats: " + boatsFilterValuesCache.stats().toString());
}
if (topiaApplicationContext != null) {
1
0
r1988 - trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer
by bleny@users.forge.codelutin.com 03 Jun '14
by bleny@users.forge.codelutin.com 03 Jun '14
03 Jun '14
Author: bleny
Date: 2014-06-03 19:05:18 +0200 (Tue, 03 Jun 2014)
New Revision: 1988
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1988
Log:
refs #4490 too many shipowners, ask user to type 3 caracters before searching
Modified:
trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp
Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp
===================================================================
--- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp 2014-06-03 16:41:50 UTC (rev 1987)
+++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp 2014-06-03 17:05:18 UTC (rev 1988)
@@ -62,7 +62,8 @@
{
filterName: 'shipOwnerIds',
filterLabel: "<s:text name="wao.ui.field.Boat.shipOwner"/>",
- filterValuesField: 'shipOwners'
+ filterValuesField: 'shipOwners',
+ minimumInputLength: 3
},
{
filterName: 'portOfRegistryIds',
1
0
r1987 - in trunk: wao-persistence/src/main/java/fr/ifremer/wao wao-services/src/main/java/fr/ifremer/wao/services/service wao-web/src/main/java/fr/ifremer/wao/web
by bleny@users.forge.codelutin.com 03 Jun '14
by bleny@users.forge.codelutin.com 03 Jun '14
03 Jun '14
Author: bleny
Date: 2014-06-03 18:41:50 +0200 (Tue, 03 Jun 2014)
New Revision: 1987
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1987
Log:
fixes #4483 cache for sampling plan
Modified:
trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java
trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfig.java
trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfigOption.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java
===================================================================
--- trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-06-03 15:11:41 UTC (rev 1986)
+++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-06-03 16:41:50 UTC (rev 1987)
@@ -229,7 +229,14 @@
@Override
public int hashCode() {
int hashCode = Objects.hashCode(obsProgram);
+ if (periodFrom != null) {
+ hashCode = 31 * hashCode + periodFrom.hashCode();
+ }
+ if (periodTo != null) {
+ hashCode = 31 * hashCode + periodTo.hashCode();
+ }
hashCode = 31 * hashCode + WaoUtils.collectionHashcode(sampleRowIds);
+ hashCode = 31 * hashCode + WaoUtils.collectionHashcode(sampleRowIds);
hashCode = 31 * hashCode + WaoUtils.collectionHashcode(fishingZoneFacadeNames);
hashCode = 31 * hashCode + WaoUtils.collectionHashcode(fishingZoneSectorNames);
hashCode = 31 * hashCode + WaoUtils.collectionHashcode(sampleRowCodes);
Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfig.java
===================================================================
--- trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfig.java 2014-06-03 15:11:41 UTC (rev 1986)
+++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfig.java 2014-06-03 16:41:50 UTC (rev 1987)
@@ -122,4 +122,9 @@
public String getEmailToUpdateAllegroWallets() {
return applicationConfig.getOption(WaoApplicationConfigOption.EMAIL_TO_UPDATE_ALLEGRO_WALLETS.key);
}
+
+ public boolean isCachingEnabled() {
+ boolean isCachingEnabled = applicationConfig.getOptionAsBoolean(WaoApplicationConfigOption.CACHING_ENABLED.key);
+ return isCachingEnabled;
+ }
}
Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfigOption.java
===================================================================
--- trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfigOption.java 2014-06-03 15:11:41 UTC (rev 1986)
+++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoApplicationConfigOption.java 2014-06-03 16:41:50 UTC (rev 1987)
@@ -55,6 +55,11 @@
"Mode développement, court-circuite l'envoi de mail",
"true", Boolean.class),
+ CACHING_ENABLED(
+ "wao.cachingEnabled",
+ "Active les caches métiers",
+ "true", Boolean.class),
+
LOG_CONFIGURATION_FILE(
"logConfigurationFile",
"Chemin vers le fichier de configuration des journaux",
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-06-03 15:11:41 UTC (rev 1986)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-06-03 16:41:50 UTC (rev 1987)
@@ -364,8 +364,28 @@
}
commit();
+ if (updateSampleRowCommand.isCreation()) {
+ invalidateCachesForAllSampleRows();
+ } else {
+ invalidateCachesForSampleRow(sampleRow);
+ }
+
}
+ protected void invalidateCachesForAllSampleRows() {
+ serviceContext.getSamplingPlansCache().invalidateAll();
+ }
+
+ protected void invalidateCachesForSampleRow(SampleRow sampleRow) {
+ Set<SamplingPlanCacheKey> toInvalidate = new HashSet<>();
+ Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> samplingPlansCache = serviceContext.getSamplingPlansCache();
+ for (Map.Entry<SamplingPlanCacheKey, ObsMerSamplingPlan> entry : samplingPlansCache.asMap().entrySet()) {
+ entry.getValue().getFilterValues().getSampleRowCodes().contains(sampleRow.getCode());
+ toInvalidate.add(entry.getKey());
+ }
+ samplingPlansCache.invalidateAll();
+ }
+
public SampleRow getSampleRow(String sampleRowId) {
SampleRow sampleRow = getSampleRowDao().findByTopiaId(sampleRowId);
@@ -387,6 +407,8 @@
commit();
+ invalidateCachesForSampleRow(sampleRow);
+
}
public List<SampleRow> getSamplingPlanRows(SampleRowsFilter sampleRowsFilter) {
@@ -550,6 +572,8 @@
commit();
+ invalidateCachesForAllSampleRows();
+
}
protected ImportModel<SampleRow> newSamplingPlanImportModel(AuthenticatedWaoUser authenticatedWaoUser) {
@@ -797,6 +821,9 @@
month.setEstimatedTidesValue(month.getEstimatedTidesValue() + 1);
}
}
+
+ invalidateCachesForSampleRow(sampleRow);
+
}
public List<SampleRow> getUnfinishedSampleRows(AuthenticatedWaoUser authenticatedWaoUser, String companyId) {
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-03 15:11:41 UTC (rev 1986)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-03 16:41:50 UTC (rev 1987)
@@ -23,6 +23,7 @@
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheStats;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import fr.ifremer.wao.WaoApplicationConfig;
import fr.ifremer.wao.WaoTopiaApplicationContext;
@@ -47,6 +48,7 @@
import java.util.Locale;
import java.util.Random;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
public class DefaultWaoApplicationContext implements WaoApplicationContext {
@@ -109,11 +111,20 @@
@Override
public Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache() {
if (samplingPlansCache == null) {
- samplingPlansCache = CacheBuilder.newBuilder().build();
+ samplingPlansCache = newCacheBuilder(100).expireAfterAccess(30, TimeUnit.DAYS).build();
}
return samplingPlansCache;
}
+ protected <K, V> CacheBuilder<K, V> newCacheBuilder(int expectedMaximumCacheSize) {
+ int maximumCacheSize = applicationConfig.isCachingEnabled() ? expectedMaximumCacheSize : 0;
+ CacheBuilder<K, V> cacheBuilder = (CacheBuilder<K, V>) CacheBuilder.newBuilder().maximumSize(maximumCacheSize);
+ if (log.isInfoEnabled()) {
+ cacheBuilder.recordStats();
+ }
+ return cacheBuilder;
+ }
+
@Override
public WaoTopiaPersistenceContext newPersistenceContext() {
@@ -136,6 +147,11 @@
@Override
public void close() {
+ if (log.isInfoEnabled()) {
+ CacheStats cacheStats = samplingPlansCache.stats();
+ log.info("samplingPlansCache stats: " + cacheStats.toString());
+ }
+
if (topiaApplicationContext != null) {
topiaApplicationContext.closeContext();
1
0
r1986 - in trunk: . wao-services/src/main/java/fr/ifremer/wao/services wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/test/java/fr/ifremer/wao/services wao-services/src/test/java/fr/ifremer/wao/services/service wao-web wao-web/src/main/java/fr/ifremer/wao/web
by bleny@users.forge.codelutin.com 03 Jun '14
by bleny@users.forge.codelutin.com 03 Jun '14
03 Jun '14
Author: bleny
Date: 2014-06-03 17:11:41 +0200 (Tue, 03 Jun 2014)
New Revision: 1986
Url: http://forge.codelutin.com/projects/wao/repository/revisions/1986
Log:
refactor to allow caching
Added:
trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java
trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
Removed:
trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationContext.java
Modified:
trunk/pom.xml
trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
trunk/wao-services/src/test/java/fr/ifremer/wao/services/AbstractWaoServiceTest.java
trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java
trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java
trunk/wao-web/pom.xml
trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationListener.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/pom.xml 2014-06-03 15:11:41 UTC (rev 1986)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>5.0.7</version>
+ <version>5.0.8</version>
</parent>
<groupId>fr.ifremer</groupId>
@@ -111,6 +111,7 @@
<commonsEmailVersion>1.3.2</commonsEmailVersion>
<mustacheVersion>0.8.15</mustacheVersion>
<commonsCodecVersion>1.9</commonsCodecVersion>
+ <ehCacheVersion>2.6.9</ehCacheVersion>
<nuitonWebVersion>1.16</nuitonWebVersion>
<nuitonI18nVersion>3.1</nuitonI18nVersion>
@@ -370,6 +371,12 @@
<version>${jsoupVersion}</version>
</dependency>
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache-core</artifactId>
+ <version>${ehCacheVersion}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -21,47 +21,43 @@
* #L%
*/
+import com.google.common.cache.Cache;
import fr.ifremer.wao.WaoApplicationConfig;
import fr.ifremer.wao.WaoTechnicalException;
import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
+import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.Locale;
import java.util.Random;
-import java.util.UUID;
public class DefaultWaoServiceContext implements WaoServiceContext {
- protected WaoApplicationConfig applicationConfig;
+ protected WaoApplicationContext waoApplicationContext;
protected WaoTopiaPersistenceContext persistenceContext;
- protected WaoWebApplicationContext webApplicationContext;
-
- protected Random random;
-
protected Locale locale;
+ public DefaultWaoServiceContext(WaoApplicationContext waoApplicationContext, WaoTopiaPersistenceContext persistenceContext, Locale locale) {
+ this.waoApplicationContext = waoApplicationContext;
+ this.persistenceContext = persistenceContext;
+ this.locale = locale;
+ }
+
@Override
public WaoApplicationConfig getApplicationConfig() {
- return applicationConfig;
+ return waoApplicationContext.getApplicationConfig();
}
- public void setPersistenceContext(WaoTopiaPersistenceContext persistenceContext) {
- this.persistenceContext = persistenceContext;
- }
-
@Override
public WaoTopiaPersistenceContext getPersistenceContext() {
return persistenceContext;
}
- public void setApplicationConfig(WaoApplicationConfig applicationConfig) {
- this.applicationConfig = applicationConfig;
- }
-
@Override
public <E extends WaoService> E newService(Class<E> serviceClass) {
@@ -99,38 +95,32 @@
@Override
public Random getRandom() {
- if (random == null) {
- random = new Random();
- }
- return random;
+ return waoApplicationContext.getRandom();
}
@Override
public Date getNow() {
- Date now = new Date();
- return now;
+ return waoApplicationContext.getNow();
}
@Override
public WaoWebApplicationContext getWebApplicationContext() {
- return webApplicationContext;
+ return waoApplicationContext.getWebApplicationContext();
}
- public void setWebApplicationContext(WaoWebApplicationContext webApplicationContext) {
- this.webApplicationContext = webApplicationContext;
- }
-
+ @Override
public Locale getLocale() {
return locale;
}
- public void setLocale(Locale locale) {
- this.locale = locale;
+ @Override
+ public String newUuid() {
+ return waoApplicationContext.newUuid();
}
@Override
- public String newUuid() {
- return UUID.randomUUID().toString();
+ public Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache() {
+ return waoApplicationContext.getSamplingPlansCache();
}
}
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -0,0 +1,36 @@
+package fr.ifremer.wao.services;
+
+import com.google.common.cache.Cache;
+import fr.ifremer.wao.WaoApplicationConfig;
+import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
+import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
+
+import java.util.Date;
+import java.util.Locale;
+import java.util.Random;
+
+/**
+ * @author bleny
+ */
+public interface WaoApplicationContext {
+
+ WaoApplicationConfig getApplicationConfig();
+
+ String newUuid();
+
+ Date getNow();
+
+ Random getRandom();
+
+ WaoTopiaPersistenceContext newPersistenceContext();
+
+ WaoServiceContext newServiceContext(WaoTopiaPersistenceContext persistenceContext, Locale locale);
+
+ WaoWebApplicationContext getWebApplicationContext();
+
+ Cache<SamplingPlanCacheKey,ObsMerSamplingPlan> getSamplingPlansCache();
+
+ void close();
+
+}
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -21,8 +21,11 @@
* #L%
*/
+import com.google.common.cache.Cache;
import fr.ifremer.wao.WaoApplicationConfig;
import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
+import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
import java.util.Date;
import java.util.Locale;
@@ -37,6 +40,8 @@
WaoTopiaPersistenceContext getPersistenceContext();
+ Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache();
+
Date getNow();
<E extends WaoService> E newService(Class<E> serviceClass);
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -24,6 +24,7 @@
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@@ -400,46 +401,65 @@
AuthenticatedWaoUser authenticatedWaoUser,
SampleRowsFilter sampleRowsFilter) {
- SampleRowTopiaDao dao = getSampleRowDao();
-
- // recuperation des lignes du plan
- List<SampleRow> sampleRows = dao.findAll(sampleRowsFilter);
-
- // creation du plan d'echantillonnage
Optional<String> optionalCompanyId = Optional.absent();
if (authenticatedWaoUser.isCoordinatorOrObserver()) {
optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId());
}
- ObsMerSamplingPlanBuilder builder = new ObsMerSamplingPlanBuilder(serviceContext.getLocale(),
- optionalCompanyId,
- sampleRowsFilter);
- // begin of month
- Date periodFrom = sampleRowsFilter.getPeriodFrom();
- // end of month
- Date periodTo = WaoUtils.getEndOfMonth(sampleRowsFilter.getPeriodTo());
+ SamplingPlanCacheKey samplingPlanCacheKey =
+ new SamplingPlanCacheKey(
+ serviceContext.getLocale(),
+ optionalCompanyId,
+ sampleRowsFilter);
- for (SampleRow sampleRow : sampleRows) {
+ Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> samplingPlansCache =
+ serviceContext.getSamplingPlansCache();
- // calcul effort plannifie
- Double observationTimesInDaysExpected =
- getObservationTimesInDayExpected(periodFrom,
- periodTo,
- sampleRow);
+ ObsMerSamplingPlan result = samplingPlansCache.getIfPresent(samplingPlanCacheKey);
- Pair<Long, Long> realAndEstimated =
- getSampleRowObservationTimesInDayRealAndEstimated(
- sampleRow.getTopiaId(), periodFrom, periodTo);
- Long observationTimesInDaysReal = realAndEstimated.getLeft();
- Long observationTimesInDaysEstimated = realAndEstimated.getRight();
+ if (result == null) {
- // ajout de la ligne au build de plan
- builder.addSampleRow(sampleRow,
- observationTimesInDaysExpected,
- observationTimesInDaysReal,
- observationTimesInDaysEstimated);
+ SampleRowTopiaDao dao = getSampleRowDao();
+
+ // recuperation des lignes du plan
+ List<SampleRow> sampleRows = dao.findAll(sampleRowsFilter);
+
+ // creation du plan d'echantillonnage
+ ObsMerSamplingPlanBuilder builder = new ObsMerSamplingPlanBuilder(
+ serviceContext.getLocale(),
+ optionalCompanyId,
+ sampleRowsFilter);
+
+ // begin of month
+ Date periodFrom = sampleRowsFilter.getPeriodFrom();
+ // end of month
+ Date periodTo = WaoUtils.getEndOfMonth(sampleRowsFilter.getPeriodTo());
+
+ for (SampleRow sampleRow : sampleRows) {
+
+ // calcul effort plannifie
+ Double observationTimesInDaysExpected =
+ getObservationTimesInDayExpected(periodFrom,
+ periodTo,
+ sampleRow);
+
+ Pair<Long, Long> realAndEstimated =
+ getSampleRowObservationTimesInDayRealAndEstimated(
+ sampleRow.getTopiaId(), periodFrom, periodTo);
+ Long observationTimesInDaysReal = realAndEstimated.getLeft();
+ Long observationTimesInDaysEstimated = realAndEstimated.getRight();
+
+ // ajout de la ligne au build de plan
+ builder.addSampleRow(sampleRow,
+ observationTimesInDaysExpected,
+ observationTimesInDaysReal,
+ observationTimesInDaysEstimated);
+ }
+ result = builder.toPlan();
+
+ samplingPlansCache.put(samplingPlanCacheKey, result);
+
}
- ObsMerSamplingPlan result = builder.toPlan();
return result;
Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -0,0 +1,40 @@
+package fr.ifremer.wao.services.service;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import fr.ifremer.wao.SampleRowsFilter;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+public class SamplingPlanCacheKey implements Serializable {
+
+ protected Locale locale;
+
+ protected Optional<String> optionalCompanyId;
+
+ protected SampleRowsFilter sampleRowsFilter;
+
+ public SamplingPlanCacheKey(Locale locale, Optional<String> optionalCompanyId, SampleRowsFilter sampleRowsFilter) {
+ this.locale = locale;
+ this.optionalCompanyId = optionalCompanyId;
+ this.sampleRowsFilter = sampleRowsFilter;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SamplingPlanCacheKey that = (SamplingPlanCacheKey) o;
+ boolean equals = Objects.equal(locale, that.locale)
+ && Objects.equal(optionalCompanyId, that.optionalCompanyId)
+ && Objects.equal(sampleRowsFilter, that.sampleRowsFilter);
+ return equals;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(locale, optionalCompanyId, sampleRowsFilter);
+ }
+
+}
Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/AbstractWaoServiceTest.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/AbstractWaoServiceTest.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/AbstractWaoServiceTest.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -21,189 +21,44 @@
* #L%
*/
-import fr.ifremer.wao.WaoApplicationConfig;
-import fr.ifremer.wao.WaoTechnicalException;
-import fr.ifremer.wao.WaoTopiaApplicationContext;
import fr.ifremer.wao.WaoTopiaPersistenceContext;
-import fr.ifremer.wao.services.service.InitWaoService;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.Environment;
import org.junit.After;
-import org.nuiton.util.DateUtil;
-import org.nuiton.util.FileUtil;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.Locale;
import java.util.UUID;
public class AbstractWaoServiceTest {
private static final Log log = LogFactory.getLog(AbstractWaoServiceTest.class);
- protected static final double DELTA = 0.0001;
-
- protected static final String DATABASE_REF = "DataBaseRef";
-
- protected static WaoApplicationConfig applicationConfig;
-
protected FakeWaoServiceContext serviceContext;
- protected WaoTopiaApplicationContext applicationContext;
+ protected FakeWaoApplicationContext applicationContext;
- protected List<WaoTopiaPersistenceContext> openedTransactions = new LinkedList<>();
-
- protected WaoTopiaApplicationContext newApplicationContext(String dataBase) {
-
- Map<String, String> hibernateH2Config = new HashMap<>();
-
- hibernateH2Config.putAll(getApplicationConfig().getTopiaProperties());
-
- hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
- hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
- hibernateH2Config.put(Environment.USER, "sa");
- hibernateH2Config.put(Environment.PASS, "");
-
- File tempDirFile = SystemUtils.getJavaIoTmpDir();
-
- File databaseFile = new File(tempDirFile, dataBase);
-
- String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
-
- String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
-
- hibernateH2Config.put(Environment.URL, jdbcUrl);
-
- if (log.isTraceEnabled()) {
- log.trace("will store H2 data in " + h2dataPath);
- log.trace("allJpaParameters = " + hibernateH2Config);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("jdbc url is\n" + jdbcUrl);
- }
-
- WaoTopiaApplicationContext applicationContext = new WaoTopiaApplicationContext(hibernateH2Config);
-
- if (log.isTraceEnabled()) {
- log.trace("created root context " + applicationContext);
- }
-
- return applicationContext;
- }
-
protected boolean isDatabaseWithReferential() {
return false;
}
- protected WaoTopiaApplicationContext getApplicationContext() {
+ protected FakeWaoApplicationContext getApplicationContext() {
- String databaseName = UUID.randomUUID().toString();
-
- if (isDatabaseWithReferential()) {
-
- File tempDirFile = SystemUtils.getJavaIoTmpDir();
-
- File databaseRefFile = new File(tempDirFile, DATABASE_REF);
-
- if (!databaseRefFile.exists()) {
-
- if (log.isTraceEnabled()) {
- log.trace("create referential data base");
- }
-
- WaoTopiaApplicationContext applicationContext = newApplicationContext(DATABASE_REF);
-
- WaoTopiaPersistenceContext persistenceContext;
-
- persistenceContext = applicationContext.newPersistenceContext();
-
- if (log.isTraceEnabled()) {
- log.trace("opened transaction " + persistenceContext);
- }
-
- FakeWaoServiceContext serviceContext = new FakeWaoServiceContext();
-
- serviceContext.setDate(DateUtil.createDate(1, 11, 2009));
-
- serviceContext.setApplicationConfig(getApplicationConfig());
-
- serviceContext.setPersistenceContext(persistenceContext);
-
- InitWaoService initWaoService = serviceContext.newService(InitWaoService.class);
-
- initWaoService.init();
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + persistenceContext);
- }
-
- persistenceContext.closeContext();
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + applicationContext);
- }
-
- applicationContext.closeContext();
-
- File lockFile = new File(databaseRefFile, "h2data.lock.db");
-
- while (lockFile.exists()) {
- if (log.isDebugEnabled()) {
- log.debug("referential database is still locked, will wait 5 more seconds");
- }
- try {
- Thread.sleep(5 * 1000);
- } catch (InterruptedException e) {
- throw new WaoTechnicalException("can't wait", e);
- }
- }
-
- }
-
- File databaseFile = new File(tempDirFile, databaseName);
-
- if (log.isTraceEnabled()) {
- log.trace("Copy referential database to " + databaseFile.getName());
- }
-
- try {
- FileUtil.copyAndRenameRecursively(databaseRefFile, databaseFile, false, null, null, false);
- } catch (IOException e) {
- throw new WaoTechnicalException("can't copy database Ref", e);
- }
-
- if (log.isTraceEnabled()) {
- log.trace("Copy referential database : Complete");
- }
+ if (applicationContext == null) {
+ applicationContext = new FakeWaoApplicationContext(UUID.randomUUID().toString(), isDatabaseWithReferential());
}
- return newApplicationContext(databaseName);
+ return applicationContext;
+
}
protected WaoTopiaPersistenceContext newPersistenceContext() {
- if (applicationContext == null) {
+ WaoTopiaPersistenceContext persistenceContext = getApplicationContext().newPersistenceContext();
- applicationContext = getApplicationContext();
-
- }
-
- WaoTopiaPersistenceContext persistenceContext;
-
- persistenceContext = applicationContext.newPersistenceContext();
-
if (log.isTraceEnabled()) {
log.trace("opened transaction " + persistenceContext);
}
- openedTransactions.add(persistenceContext);
-
return persistenceContext;
}
@@ -211,52 +66,24 @@
@After
public void tearDown() {
- for (WaoTopiaPersistenceContext openedTransaction : openedTransactions) {
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + openedTransaction);
- }
-
- openedTransaction.closeContext();
-
- }
-
if (applicationContext != null) {
if (log.isTraceEnabled()) {
log.trace("closing transaction " + applicationContext);
}
- applicationContext.closeContext();
+ applicationContext.close();
}
}
- protected static WaoApplicationConfig getApplicationConfig() {
-
- if (applicationConfig == null) {
-
- applicationConfig = new WaoApplicationConfig();
-
- }
-
- return applicationConfig;
-
- }
-
protected FakeWaoServiceContext newServiceContext() {
- FakeWaoServiceContext serviceContext = new FakeWaoServiceContext();
+ WaoTopiaPersistenceContext persistenceContext = getApplicationContext().newPersistenceContext();
- serviceContext.setApplicationConfig(getApplicationConfig());
+ serviceContext = getApplicationContext().newServiceContext(persistenceContext, Locale.FRANCE);
- WaoTopiaPersistenceContext persistenceContext = newPersistenceContext();
-
- serviceContext.setPersistenceContext(persistenceContext);
-
- serviceContext.setDate(DateUtil.createDate(2, 11, 2009));
-
return serviceContext;
}
Added: trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java (rev 0)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -0,0 +1,246 @@
+package fr.ifremer.wao.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import fr.ifremer.wao.WaoApplicationConfig;
+import fr.ifremer.wao.WaoTechnicalException;
+import fr.ifremer.wao.WaoTopiaApplicationContext;
+import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.service.InitWaoService;
+import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
+import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
+import org.apache.commons.lang3.SystemUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.cfg.Environment;
+import org.nuiton.util.DateUtil;
+import org.nuiton.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+
+public class FakeWaoApplicationContext implements WaoApplicationContext {
+
+ private static final Log log = LogFactory.getLog(FakeWaoApplicationContext.class);
+
+ protected static final String DATABASE_REF = "DataBaseRef";
+
+ protected String context;
+
+ protected boolean initWithReferential;
+
+ protected WaoTopiaApplicationContext topiaApplicationContext;
+
+ protected WaoApplicationConfig applicationConfig;
+
+ protected Random random = new Random(540727613);
+
+ protected Date date = DateUtil.createDate(1, 11, 2009);
+
+ protected Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> samplingPlansCache;
+
+ public FakeWaoApplicationContext(String context, boolean initWithReferential) {
+ this.context = context;
+ this.initWithReferential = initWithReferential;
+ }
+
+ @Override
+ public WaoApplicationConfig getApplicationConfig() {
+ if (applicationConfig == null) {
+ applicationConfig = new WaoApplicationConfig();
+ }
+ return applicationConfig;
+ }
+
+ public WaoTopiaApplicationContext getTopiaApplicationContext() {
+
+ if (topiaApplicationContext == null) {
+
+ if (initWithReferential) {
+
+ File databaseRefFile = getDatabaseFile(DATABASE_REF);
+
+ if (!databaseRefFile.exists()) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("create referential database");
+ }
+
+ WaoTopiaApplicationContext applicationContext = newWaoTopiaApplicationContext(DATABASE_REF);
+
+ WaoTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
+
+ if (log.isTraceEnabled()) {
+ log.trace("opened persistence context " + persistenceContext);
+ }
+
+ WaoServiceContext serviceContext = new DefaultWaoServiceContext(this, persistenceContext, Locale.FRANCE);
+
+ InitWaoService initWaoService = serviceContext.newService(InitWaoService.class);
+
+ initWaoService.init();
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing persistence context " + persistenceContext);
+ }
+
+ persistenceContext.closeContext();
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing application context " + applicationContext);
+ }
+
+ applicationContext.closeContext();
+
+ File lockFile = new File(databaseRefFile, "h2data.lock.db");
+
+ while (lockFile.exists()) {
+ if (log.isDebugEnabled()) {
+ log.debug("referential database is still locked, will wait 5 more seconds");
+ }
+ try {
+ Thread.sleep(5 * 1000);
+ } catch (InterruptedException e) {
+ throw new WaoTechnicalException("can't wait", e);
+ }
+ }
+
+ }
+
+ File databaseFile = getDatabaseFile(context);
+
+ if (log.isTraceEnabled()) {
+ log.trace("copy referential database from " + databaseRefFile.getAbsolutePath() + " to " + databaseFile.getAbsolutePath());
+ }
+
+ try {
+ FileUtil.copyAndRenameRecursively(databaseRefFile, databaseFile, false, null, null, false);
+ } catch (IOException e) {
+ throw new WaoTechnicalException("cannot copy database from " + databaseRefFile.getAbsolutePath() + " to " + databaseFile.getAbsolutePath(), e);
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("copy referential database completed");
+ }
+ }
+
+ WaoTopiaApplicationContext applicationContext = newWaoTopiaApplicationContext(context);
+
+ if (log.isTraceEnabled()) {
+ log.trace("created application context " + applicationContext);
+ }
+
+ return applicationContext;
+ }
+
+ return topiaApplicationContext;
+
+ }
+
+ protected WaoTopiaApplicationContext newWaoTopiaApplicationContext(String context) {
+
+ Map<String, String> hibernateH2Config = new HashMap<>();
+
+ hibernateH2Config.putAll(getApplicationConfig().getTopiaProperties());
+
+ hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
+ hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
+ hibernateH2Config.put(Environment.USER, "sa");
+ hibernateH2Config.put(Environment.PASS, "");
+
+ File databaseFile = getDatabaseFile(context);
+
+ String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
+
+ String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
+
+ hibernateH2Config.put(Environment.URL, jdbcUrl);
+
+ if (log.isTraceEnabled()) {
+ log.trace("will store H2 data in " + h2dataPath);
+ log.trace("allJpaParameters = " + hibernateH2Config);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("jdbc url is\n" + jdbcUrl);
+ }
+
+ return new WaoTopiaApplicationContext(hibernateH2Config);
+
+ }
+
+ protected File getDatabaseFile(String context) {
+ File tempDirFile = SystemUtils.getJavaIoTmpDir();
+ return new File(tempDirFile, context);
+ }
+
+ @Override
+ public Date getNow() {
+ Preconditions.checkState(date != null, "you must provide a date before running service test");
+ if (log.isTraceEnabled()) {
+ log.trace("injecting fake date in service: " + date);
+ }
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ @Override
+ public String newUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ @Override
+ public WaoWebApplicationContext getWebApplicationContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Random getRandom() {
+ return random;
+ }
+
+ @Override
+ public Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache() {
+ if (samplingPlansCache == null) {
+ samplingPlansCache = CacheBuilder.newBuilder().build();
+ }
+ return samplingPlansCache;
+ }
+
+ @Override
+ public WaoTopiaPersistenceContext newPersistenceContext() {
+
+ WaoTopiaPersistenceContext persistenceContext = getTopiaApplicationContext().newPersistenceContext();
+
+ return persistenceContext;
+
+ }
+
+ @Override
+ public FakeWaoServiceContext newServiceContext(WaoTopiaPersistenceContext persistenceContext, Locale locale) {
+
+ FakeWaoServiceContext newServiceContext =
+ new FakeWaoServiceContext(this, persistenceContext, locale);
+
+ return newServiceContext;
+
+ }
+
+ @Override
+ public void close() {
+ if (topiaApplicationContext != null) {
+ topiaApplicationContext.closeContext();
+ }
+ }
+
+}
Deleted: trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -1,69 +0,0 @@
-package fr.ifremer.wao.services;
-
-/*
- * #%L
- * Wao :: Services
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * 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%
- */
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Date;
-import java.util.Locale;
-import java.util.Random;
-
-public class FakeWaoServiceContext extends DefaultWaoServiceContext {
-
- private static final Log log = LogFactory.getLog(FakeWaoServiceContext.class);
-
- protected Date date;
-
- public FakeWaoServiceContext() {
- // default locale
- setLocale(Locale.FRANCE);
- }
-
- @Override
- public Random getRandom() {
- if (random == null) {
- random = new Random(540727613);
- }
- return random;
- }
-
- @Override
- public Date getNow() {
- Preconditions.checkState(date != null, "you must provide a date before running service test");
- if (log.isTraceEnabled()) {
- log.trace("injecting fake date in service: " + date);
- }
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
-// @Override
-// public Locale getLocale() {
-// return Locale.FRANCE;
-// }
-
-}
Added: trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java (rev 0)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoServiceContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -0,0 +1,17 @@
+package fr.ifremer.wao.services;
+
+import fr.ifremer.wao.WaoTopiaPersistenceContext;
+
+import java.util.Locale;
+
+public class FakeWaoServiceContext extends DefaultWaoServiceContext {
+
+ public FakeWaoServiceContext(WaoApplicationContext waoApplicationContext, WaoTopiaPersistenceContext persistenceContext, Locale locale) {
+ super(waoApplicationContext, persistenceContext, locale);
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+}
Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerContactsServiceTest.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -79,7 +79,7 @@
fixtures.navires();
// today must be after the observation end date
- serviceContext.setDate(DateUtil.createDate(1, 2, 2011));
+ applicationContext.setDate(DateUtil.createDate(1, 2, 2011));
InputStream input = null;
try {
Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java
===================================================================
--- trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -88,7 +88,7 @@
fixtures.samplingPlan();
- serviceContext.setDate(DateUtil.createDate(15, 5, 2010));
+ applicationContext.setDate(DateUtil.createDate(15, 5, 2010));
SampleRowsFilter filter = service.newSampleRowsFilter(fixtures.admin());
ObsMerSamplingPlan samplingPlan = service.getSamplingPlan(fixtures.admin(), filter);
@@ -129,7 +129,7 @@
fixtures.samplingPlan();
- serviceContext.setDate(DateUtil.createDate(15, 5, 2010));
+ applicationContext.setDate(DateUtil.createDate(15, 5, 2010));
SampleRowsFilter filter = service.newSampleRowsFilter(fixtures.admin());
@@ -164,7 +164,7 @@
FakeWaoServiceContext serviceContext = newServiceContext();
// today must be after the observation end date (for contacts import)
- serviceContext.setDate(DateUtil.createDate(1, 2, 2011));
+ applicationContext.setDate(DateUtil.createDate(1, 2, 2011));
fixtures = new ObsMerFixtures(serviceContext);
fixtures.contacts();
Modified: trunk/wao-web/pom.xml
===================================================================
--- trunk/wao-web/pom.xml 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-web/pom.xml 2014-06-03 15:11:41 UTC (rev 1986)
@@ -163,6 +163,11 @@
<artifactId>jsoup</artifactId>
</dependency>
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache-core</artifactId>
+ </dependency>
+
</dependencies>
<build>
Copied: trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java (from rev 1985, trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationContext.java)
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java (rev 0)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -0,0 +1,200 @@
+package fr.ifremer.wao.web;
+
+/*
+ * #%L
+ * Wao :: Web
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer
+ * %%
+ * 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%
+ */
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import fr.ifremer.wao.WaoApplicationConfig;
+import fr.ifremer.wao.WaoTopiaApplicationContext;
+import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.DefaultWaoServiceContext;
+import fr.ifremer.wao.services.WaoApplicationContext;
+import fr.ifremer.wao.services.WaoServiceContext;
+import fr.ifremer.wao.services.WaoWebApplicationContext;
+import fr.ifremer.wao.services.service.InitWaoService;
+import fr.ifremer.wao.services.service.ObsMerSamplingPlan;
+import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.PropertyConfigurator;
+import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+import org.nuiton.i18n.init.I18nInitializer;
+
+import java.io.File;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Random;
+import java.util.UUID;
+
+public class DefaultWaoApplicationContext implements WaoApplicationContext {
+
+ private static Log log = LogFactory.getLog(DefaultWaoApplicationContext.class);
+
+ public static final String APPLICATION_CONTEXT_PARAMETER = "WaoApplicationContext";
+
+ protected WaoTopiaApplicationContext topiaApplicationContext;
+
+ protected WaoApplicationConfig applicationConfig;
+
+ protected WaoWebApplicationContext webApplicationContext;
+
+ protected Random random;
+
+ protected Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> samplingPlansCache;
+
+ @Override
+ public WaoApplicationConfig getApplicationConfig() {
+ if (applicationConfig == null) {
+ applicationConfig = new WaoApplicationConfig();
+ }
+ return applicationConfig;
+ }
+
+ public WaoTopiaApplicationContext getTopiaApplicationContext() {
+ if (topiaApplicationContext == null) {
+ topiaApplicationContext = new WaoTopiaApplicationContext(getApplicationConfig().getTopiaProperties());
+ }
+ return topiaApplicationContext;
+ }
+
+ @Override
+ public String newUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ @Override
+ public WaoWebApplicationContext getWebApplicationContext() {
+ if (webApplicationContext == null) {
+ webApplicationContext = new DefaultWaoWebApplicationContext(getApplicationConfig().getInstanceUrl());
+ }
+ return webApplicationContext;
+ }
+
+ @Override
+ public Date getNow() {
+ Date now = new Date();
+ return now;
+ }
+
+ @Override
+ public Random getRandom() {
+ if (random == null) {
+ random = new Random();
+ }
+ return random;
+ }
+
+ @Override
+ public Cache<SamplingPlanCacheKey, ObsMerSamplingPlan> getSamplingPlansCache() {
+ if (samplingPlansCache == null) {
+ samplingPlansCache = CacheBuilder.newBuilder().build();
+ }
+ return samplingPlansCache;
+ }
+
+ @Override
+ public WaoTopiaPersistenceContext newPersistenceContext() {
+
+ WaoTopiaPersistenceContext persistenceContext = getTopiaApplicationContext().newPersistenceContext();
+
+ return persistenceContext;
+
+ }
+
+ @Override
+ public WaoServiceContext newServiceContext(WaoTopiaPersistenceContext persistenceContext, Locale locale) {
+
+ DefaultWaoServiceContext newServiceContext =
+ new DefaultWaoServiceContext(this, persistenceContext, locale);
+
+ return newServiceContext;
+
+ }
+
+ @Override
+ public void close() {
+
+ if (topiaApplicationContext != null) {
+
+ topiaApplicationContext.closeContext();
+
+ }
+
+ }
+
+ public void init() {
+
+ if (getApplicationConfig().isLogConfigurationProvided()) {
+
+ File log4jConfigurationFile = getApplicationConfig().getLogConfigurationFile();
+
+ String log4jConfigurationFileAbsolutePath = log4jConfigurationFile.getAbsolutePath();
+
+ if (log4jConfigurationFile.exists()) {
+
+ if (log.isInfoEnabled()) {
+ log.info("will use logging configuration " + log4jConfigurationFileAbsolutePath);
+ }
+
+ // reset logger configuration
+ LogManager.resetConfiguration();
+
+ // use generate log config file
+ PropertyConfigurator.configure(log4jConfigurationFileAbsolutePath);
+
+ log = LogFactory.getLog(DefaultWaoApplicationContext.class);
+
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("there is no file " + log4jConfigurationFileAbsolutePath + ". Default logging configuration will be used.");
+ }
+ }
+
+ } else {
+ log.info("will use default logging configuration");
+ }
+
+ I18nInitializer initializer = new DefaultI18nInitializer("wao");
+ // to show none translated sentences
+ initializer.setMissingKeyReturnNull(true);
+
+ I18n.init(initializer, Locale.FRANCE);
+
+ LocalizedTextUtil.addDefaultResourceBundle("i18n.wao-web");
+
+ WaoTopiaPersistenceContext persistenceContext = newPersistenceContext();
+
+ WaoServiceContext serviceContext = newServiceContext(persistenceContext, Locale.FRANCE);
+
+ InitWaoService initWaoService =
+ serviceContext.newService(InitWaoService.class);
+
+ initWaoService.init();
+
+ persistenceContext.closeContext();
+
+ }
+
+}
Deleted: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationContext.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationContext.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationContext.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -1,160 +0,0 @@
-package fr.ifremer.wao.web;
-
-/*
- * #%L
- * Wao :: Web
- * %%
- * Copyright (C) 2009 - 2014 Ifremer
- * %%
- * 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%
- */
-
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
-import fr.ifremer.wao.WaoApplicationConfig;
-import fr.ifremer.wao.WaoTopiaApplicationContext;
-import fr.ifremer.wao.WaoTopiaPersistenceContext;
-import fr.ifremer.wao.services.DefaultWaoServiceContext;
-import fr.ifremer.wao.services.WaoServiceContext;
-import fr.ifremer.wao.services.WaoWebApplicationContext;
-import fr.ifremer.wao.services.service.InitWaoService;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.PropertyConfigurator;
-import org.nuiton.i18n.I18n;
-import org.nuiton.i18n.init.DefaultI18nInitializer;
-import org.nuiton.i18n.init.I18nInitializer;
-
-import java.io.File;
-import java.util.Locale;
-
-public class WaoApplicationContext {
-
- private static Log log = LogFactory.getLog(WaoApplicationContext.class);
-
- public static final String APPLICATION_CONTEXT_PARAMETER = "WaoApplicationContext";
-
- protected static WaoTopiaApplicationContext topiaApplicationContext;
-
- protected static WaoApplicationConfig applicationConfig;
-
- public static WaoApplicationConfig getApplicationConfig() {
- if (applicationConfig == null) {
- applicationConfig = new WaoApplicationConfig();
- }
- return applicationConfig;
- }
-
- public static WaoTopiaApplicationContext getTopiaApplicationContext() {
- if (topiaApplicationContext == null) {
- topiaApplicationContext = new WaoTopiaApplicationContext(getApplicationConfig().getTopiaProperties());
- }
- return topiaApplicationContext;
- }
-
- public WaoTopiaPersistenceContext newPersistenceContext() {
-
- WaoTopiaPersistenceContext persistenceContext = getTopiaApplicationContext().newPersistenceContext();
-
- return persistenceContext;
-
- }
-
- public WaoServiceContext newServiceContext(WaoTopiaPersistenceContext persistenceContext, Locale locale) {
-
- DefaultWaoServiceContext newServiceContext =
- new DefaultWaoServiceContext();
-
- WaoApplicationConfig applicationConfig = getApplicationConfig();
-
- newServiceContext.setApplicationConfig(applicationConfig);
-
- newServiceContext.setPersistenceContext(persistenceContext);
-
- WaoWebApplicationContext webApplicationContext =
- new DefaultWaoWebApplicationContext(applicationConfig.getInstanceUrl());
-
- newServiceContext.setWebApplicationContext(webApplicationContext);
-
- newServiceContext.setLocale(locale);
-
- return newServiceContext;
-
- }
-
- public void close() {
-
- if (topiaApplicationContext != null) {
-
- topiaApplicationContext.closeContext();
-
- }
-
- }
-
- public void init() {
-
- if (getApplicationConfig().isLogConfigurationProvided()) {
-
- File log4jConfigurationFile = getApplicationConfig().getLogConfigurationFile();
-
- String log4jConfigurationFileAbsolutePath = log4jConfigurationFile.getAbsolutePath();
-
- if (log4jConfigurationFile.exists()) {
-
- if (log.isInfoEnabled()) {
- log.info("will use logging configuration " + log4jConfigurationFileAbsolutePath);
- }
-
- // reset logger configuration
- LogManager.resetConfiguration();
-
- // use generate log config file
- PropertyConfigurator.configure(log4jConfigurationFileAbsolutePath);
-
- log = LogFactory.getLog(WaoApplicationContext.class);
-
- } else {
- if (log.isWarnEnabled()) {
- log.warn("there is no file " + log4jConfigurationFileAbsolutePath + ". Default logging configuration will be used.");
- }
- }
-
- } else {
- log.info("will use default logging configuration");
- }
-
- I18nInitializer initializer = new DefaultI18nInitializer("wao");
- // to show none translated sentences
- initializer.setMissingKeyReturnNull(true);
-
- I18n.init(initializer, Locale.FRANCE);
-
- LocalizedTextUtil.addDefaultResourceBundle("i18n.wao-web");
-
- WaoTopiaPersistenceContext persistenceContext = newPersistenceContext();
-
- WaoServiceContext serviceContext = newServiceContext(persistenceContext, Locale.FRANCE);
-
- InitWaoService initWaoService =
- serviceContext.newService(InitWaoService.class);
-
- initWaoService.init();
-
- persistenceContext.closeContext();
-
- }
-
-}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationListener.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationListener.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoApplicationListener.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -31,7 +31,7 @@
private static final Log log = LogFactory.getLog(WaoApplicationListener.class);
- protected WaoApplicationContext applicationContext;
+ protected DefaultWaoApplicationContext applicationContext;
@Override
public void contextInitialized(ServletContextEvent sce) {
@@ -40,12 +40,12 @@
log.info("init WAO");
}
- applicationContext = new WaoApplicationContext();
+ applicationContext = new DefaultWaoApplicationContext();
applicationContext.init();
sce.getServletContext().setAttribute(
- WaoApplicationContext.APPLICATION_CONTEXT_PARAMETER,
+ DefaultWaoApplicationContext.APPLICATION_CONTEXT_PARAMETER,
applicationContext);
}
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java 2014-05-27 15:31:39 UTC (rev 1985)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoInterceptor.java 2014-06-03 15:11:41 UTC (rev 1986)
@@ -33,6 +33,7 @@
import fr.ifremer.wao.entity.UserRole;
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.services.AuthenticatedWaoUser;
+import fr.ifremer.wao.services.WaoApplicationContext;
import fr.ifremer.wao.services.WaoService;
import fr.ifremer.wao.services.WaoServiceContext;
import fr.ifremer.wao.web.action.authentication.LoginAction;
@@ -198,11 +199,11 @@
protected WaoApplicationContext getWaoApplicationContext(ActionInvocation invocation) {
- WaoApplicationContext applicationContext =
- (WaoApplicationContext) invocation
+ DefaultWaoApplicationContext applicationContext =
+ (DefaultWaoApplicationContext) invocation
.getInvocationContext()
.getApplication()
- .get(WaoApplicationContext.APPLICATION_CONTEXT_PARAMETER);
+ .get(DefaultWaoApplicationContext.APPLICATION_CONTEXT_PARAMETER);
Preconditions.checkNotNull(applicationContext,
"application context must be initialized before calling an action");
1
0