Nuiton-utils-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
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
December 2010
- 6 participants
- 45 discussions
r2005 - in trunk: nuiton-rss nuiton-tapestry-extra nuiton-utils nuiton-utils-extra nuiton-validator
by tchemit@users.nuiton.org 30 Dec '10
by tchemit@users.nuiton.org 30 Dec '10
30 Dec '10
Author: tchemit
Date: 2010-12-30 13:14:03 +0100 (Thu, 30 Dec 2010)
New Revision: 2005
Url: http://nuiton.org/repositories/revision/nuiton-utils/2005
Log:
improve assembly-profile (package phase and standalone profile)
Modified:
trunk/nuiton-rss/pom.xml
trunk/nuiton-tapestry-extra/pom.xml
trunk/nuiton-utils-extra/pom.xml
trunk/nuiton-utils/pom.xml
trunk/nuiton-validator/pom.xml
Modified: trunk/nuiton-rss/pom.xml
===================================================================
--- trunk/nuiton-rss/pom.xml 2010-12-30 12:09:29 UTC (rev 2004)
+++ trunk/nuiton-rss/pom.xml 2010-12-30 12:14:03 UTC (rev 2005)
@@ -204,6 +204,7 @@
</property>
</activation>
<build>
+ <defaultGoal>package</defaultGoal>
<plugins>
<!-- launch in a release the assembly automaticly -->
@@ -212,7 +213,7 @@
<executions>
<execution>
<id>create-assemblies</id>
- <phase>verify</phase>
+ <phase>package</phase>
<goals>
<goal>single</goal>
</goals>
Modified: trunk/nuiton-tapestry-extra/pom.xml
===================================================================
--- trunk/nuiton-tapestry-extra/pom.xml 2010-12-30 12:09:29 UTC (rev 2004)
+++ trunk/nuiton-tapestry-extra/pom.xml 2010-12-30 12:14:03 UTC (rev 2005)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2004 - 2010 CodeLutin
+ Copyright (C) 2004 - 2010 CodeLutin, Tony Chemit
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -165,6 +165,46 @@
</profile>
+ <!-- create assemblies at release time -->
+ <profile>
+ <id>assembly-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+
</profiles>
</project>
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2010-12-30 12:09:29 UTC (rev 2004)
+++ trunk/nuiton-utils/pom.xml 2010-12-30 12:14:03 UTC (rev 2005)
@@ -178,6 +178,7 @@
</property>
</activation>
<build>
+ <defaultGoal>package</defaultGoal>
<plugins>
<!-- launch in a release the assembly automaticly -->
@@ -186,7 +187,7 @@
<executions>
<execution>
<id>create-assemblies</id>
- <phase>verify</phase>
+ <phase>package</phase>
<goals>
<goal>single</goal>
</goals>
Modified: trunk/nuiton-utils-extra/pom.xml
===================================================================
--- trunk/nuiton-utils-extra/pom.xml 2010-12-30 12:09:29 UTC (rev 2004)
+++ trunk/nuiton-utils-extra/pom.xml 2010-12-30 12:14:03 UTC (rev 2005)
@@ -132,6 +132,7 @@
</property>
</activation>
<build>
+ <defaultGoal>package</defaultGoal>
<plugins>
<!-- launch in a release the assembly automaticly -->
@@ -140,7 +141,7 @@
<executions>
<execution>
<id>create-assemblies</id>
- <phase>verify</phase>
+ <phase>package</phase>
<goals>
<goal>single</goal>
</goals>
Modified: trunk/nuiton-validator/pom.xml
===================================================================
--- trunk/nuiton-validator/pom.xml 2010-12-30 12:09:29 UTC (rev 2004)
+++ trunk/nuiton-validator/pom.xml 2010-12-30 12:14:03 UTC (rev 2005)
@@ -231,6 +231,7 @@
</property>
</activation>
<build>
+ <defaultGoal>package</defaultGoal>
<plugins>
<!-- launch in a release the assembly automaticly -->
@@ -239,7 +240,7 @@
<executions>
<execution>
<id>create-assemblies</id>
- <phase>verify</phase>
+ <phase>package</phase>
<goals>
<goal>single</goal>
</goals>
1
0
30 Dec '10
Author: tchemit
Date: 2010-12-30 13:09:29 +0100 (Thu, 30 Dec 2010)
New Revision: 2004
Url: http://nuiton.org/repositories/revision/nuiton-utils/2004
Log:
fix svn-keywords
Modified:
trunk/nuiton-tapestry-extra/LICENSE.txt
trunk/nuiton-tapestry-extra/README.txt
trunk/nuiton-tapestry-extra/changelog.txt
trunk/nuiton-tapestry-extra/pom.xml
trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js
trunk/nuiton-tapestry-extra/src/site/apt/index.apt
trunk/nuiton-tapestry-extra/src/site/site_fr.xml
Property changes on: trunk/nuiton-tapestry-extra/LICENSE.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/README.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/changelog.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/nuiton-tapestry-extra/pom.xml
===================================================================
--- trunk/nuiton-tapestry-extra/pom.xml 2010-12-30 12:09:09 UTC (rev 2003)
+++ trunk/nuiton-tapestry-extra/pom.xml 2010-12-30 12:09:29 UTC (rev 2004)
@@ -3,7 +3,7 @@
#%L
Nuiton Utils :: Nuiton Tapestry Extra
$Id$
- $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/trunk/nuiton-utils-extra/pom.xml $
+ $HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
%%
Property changes on: trunk/nuiton-tapestry-extra/pom.xml
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/site/apt/index.apt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-tapestry-extra/src/site/site_fr.xml
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2010-12-30 13:09:09 +0100 (Thu, 30 Dec 2010)
New Revision: 2003
Url: http://nuiton.org/repositories/revision/nuiton-utils/2003
Log:
Evolution #1190: Introduce nuiton-tapestry-extra module
Added:
trunk/nuiton-tapestry-extra/
trunk/nuiton-tapestry-extra/LICENSE.txt
trunk/nuiton-tapestry-extra/README.txt
trunk/nuiton-tapestry-extra/changelog.txt
trunk/nuiton-tapestry-extra/pom.xml
trunk/nuiton-tapestry-extra/src/
trunk/nuiton-tapestry-extra/src/license/
trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties
trunk/nuiton-tapestry-extra/src/main/
trunk/nuiton-tapestry-extra/src/main/java/
trunk/nuiton-tapestry-extra/src/main/java/org/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java
trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java
trunk/nuiton-tapestry-extra/src/main/resources/
trunk/nuiton-tapestry-extra/src/main/resources/org/
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js
trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js
trunk/nuiton-tapestry-extra/src/site/
trunk/nuiton-tapestry-extra/src/site/apt/
trunk/nuiton-tapestry-extra/src/site/apt/index.apt
trunk/nuiton-tapestry-extra/src/site/site_fr.xml
trunk/nuiton-tapestry-extra/src/test/
trunk/nuiton-tapestry-extra/src/test/java/
trunk/nuiton-tapestry-extra/src/test/resources/
Modified:
trunk/pom.xml
Property changes on: trunk/nuiton-tapestry-extra
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
Added: trunk/nuiton-tapestry-extra/LICENSE.txt
===================================================================
--- trunk/nuiton-tapestry-extra/LICENSE.txt (rev 0)
+++ trunk/nuiton-tapestry-extra/LICENSE.txt 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Property changes on: trunk/nuiton-tapestry-extra/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-tapestry-extra/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-tapestry-extra/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/pom.xml
===================================================================
--- trunk/nuiton-tapestry-extra/pom.xml (rev 0)
+++ trunk/nuiton-tapestry-extra/pom.xml 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Nuiton Tapestry Extra
+ $Id$
+ $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/trunk/nuiton-utils-extra/pom.xml $
+ %%
+ Copyright (C) 2004 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>nuiton-tapestry-extra</artifactId>
+
+ <dependencies>
+
+ <!--dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency-->
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-ioc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry5-annotations</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton Utils :: Nuiton Tapestry Extra</name>
+ <description>Extra classes for Tapestry based applications</description>
+ <inceptionYear>2010</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <properties>
+
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <compress>true</compress>
+ <index>true</index>
+ <!-- Add NuitonModule to manifest for Tapestry IOC engine -->
+ <manifestEntries>
+ <Tapestry-Module-Classes>
+ org.nuiton.web.tapestry5.services.NuitonModule
+ </Tapestry-Module-Classes>
+ <Implementation-Version>
+ ${project.version}
+ </Implementation-Version>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <profiles>
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <quiet>true</quiet>
+ <links>
+ <link>http://java.sun.com/javase/6/docs/api/</link>
+ </links>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ </profiles>
+
+</project>
Property changes on: trunk/nuiton-tapestry-extra/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,17 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - Apache Software License 2.0
+# - BSD License
+# - Common Public License Version 1.0
+# - Lesser General Public License (LGPL) v 2.1
+# - MIT License
+# - The Apache Software License, Version 2.0
+# - The BSD License
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Dec 30 13:07:08 CET 2010
+javassist--javassist--3.9.0.GA--jar=Lesser General Public License (LGPL) v 2.1
+org.antlr--antlr-runtime--3.1.1--jar=BSD License
Property changes on: trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,48 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.nuiton.web.tapestry5.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used on pages and components that need authentication
+ * to be rendered.
+ *
+ * Created: 3 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+@Target({ ElementType.TYPE })
+(a)Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface RequiresAuthentication {
+
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,158 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.web.tapestry5.components;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * Composant qui affiche des messages à l'utilisateur.
+ *
+ * Ce composant permet d'afficher des messages avec une apparence différente
+ * selon leur type (info ou erreur). Lors de l'affichage de la page, les
+ * messages seront affichés et la collection de messages sera vidée.
+ *
+ * Pour personnaliser l'apparence des messages il faut définir les classes
+ * fb-error et fb-info dans le CSS.
+ *
+ * <pre>
+ * Utilisation :
+ * <t:feedback t:id="feedback"/>
+ * @Component(id = "feedback") private FeedBack feedback;
+ * feedback.addInfo("message d'info");
+ * feedback.addError("message d'erreur");
+ * </pre>
+ *
+ * @author rannou
+ * @version $Id$
+ */
+@IncludeStylesheet("feedback.css")
+public class FeedBack {
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, value= "true")
+ private boolean autoClear;
+
+ /** Messages d'erreur */
+ private List<String> errorMessages;
+
+ /** Messages d'info */
+ private List<String> infoMessages;
+
+ private boolean errors;
+
+ @Inject
+ private ComponentResources resources;
+
+ private boolean reload;
+
+ public FeedBack() {
+ errorMessages = new ArrayList<String>();
+ infoMessages = new ArrayList<String>();
+ }
+
+ void beginRender(MarkupWriter writer) {
+
+ // Rendu des messages d'erreur et vidage de la collection
+ if (!errorMessages.isEmpty()) {
+ errors = true;
+ writer.element("div", "class", "fb-error");
+ for (String message : errorMessages) {
+ writer.write(message);
+ writer.element("br");
+ writer.end();
+ }
+ writer.end();
+ }
+ if (autoClear) {
+ errorMessages.clear();
+ }
+
+ // Rendu des messages d'info et vidage de la collection
+ if (!infoMessages.isEmpty()) {
+ writer.element("div", "class", "fb-info");
+ for (String message : infoMessages) {
+ writer.write(message);
+ writer.element("br");
+ writer.end();
+ }
+ writer.end();
+ }
+ infoMessages.clear();
+
+ resources.renderInformalParameters(writer);
+ }
+
+ void afterRender(MarkupWriter writer) {
+
+ }
+
+ /**
+ * Ajout d'un message d'info.
+ *
+ * @param message le message
+ */
+ public void addInfo(String message) {
+ if (!infoMessages.contains(message)) {
+ infoMessages.add(message);
+ }
+ }
+
+ /**
+ * Ajout d'un message d'erreur.
+ *
+ * @param message le message
+ */
+ public void addError(String message) {
+ if (!errorMessages.contains(message)) {
+ errorMessages.add(message);
+ }
+ }
+
+ public boolean hasErrors() {
+ return errors;
+ }
+
+ @Log
+ public void reload() {
+ reload = true;
+ }
+
+ public boolean hasBeeanReloaded() {
+ return reload;
+ }
+
+ public void clearErrors() {
+ errorMessages.clear();
+ reload = false;
+ }
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,61 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.web.tapestry5.components;
+
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.slf4j.Logger;
+
+/**
+ * Created: 14 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class SubForm {
+
+ @Parameter
+ private boolean visible;
+
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private Block formBlock;
+
+ @Inject
+ private Block noFormBlock;
+
+ public Block getActiveBlock() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("form already visible : " + visible);
+ }
+ if (visible) {
+ return formBlock;
+ }
+ return noFormBlock;
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,214 @@
+/** %%Ignore-License
+ *
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.nuiton.web.tapestry5.components;
+
+import org.apache.tapestry5.Asset;
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.ComponentAction;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.EventConstants;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.Events;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.SupportsInformalParameters;
+import org.apache.tapestry5.dom.Element;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.FormSupport;
+import org.apache.tapestry5.services.Heartbeat;
+import org.apache.tapestry5.services.Request;
+
+/**
+ * Corresponds to <input type="submit">, a client-side element that can
+ * force the enclosing form to submit. The submit responsible for the form
+ * submission will post a notification that allows the application to know that
+ * it was the responsible entity. The notification is named "selected" and has a
+ * String context. The major difference between this component and Tapestry's
+ * Submit component is that this component's context is immutable and can, for
+ * example, be set to different values within a loop.
+ */
+@SupportsInformalParameters
+(a)Events(EventConstants.SELECTED + " by default, may be overridden")
+public final class SubmitContext implements ClientElement {
+
+ /**
+ * If true, then any notification sent by the component will be deferred
+ * until the end of the form submission (this is usually desirable).
+ */
+ @Parameter
+ private boolean defer = true;
+
+ /**
+ * The name of the event that will be triggered if this component is the
+ * cause of the form submission. The default is "selected".
+ */
+ @Parameter(allowNull = false, defaultPrefix = BindingConstants.LITERAL)
+ private String event = EventConstants.SELECTED;
+
+ /**
+ * If true, then the field will render out with a disabled attribute (to
+ * turn off client-side behavior). Further, a disabled field ignores any
+ * value in the request when the form is submitted.
+ */
+ @Parameter("false")
+ private boolean disabled;
+
+ /**
+ * The value that will be made available to event handler method of this
+ * component when the form is submitted.
+ */
+ @Parameter
+ private String context;
+
+ /**
+ * If provided, the component renders an input tag with type "image".
+ * Otherwise "submit".
+ */
+ @Parameter(defaultPrefix = BindingConstants.ASSET)
+ private Asset image;
+
+ @Environmental
+ private FormSupport formSupport;
+
+ @Environmental
+ private Heartbeat heartbeat;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Inject
+ private Request request;
+
+ @Inject
+ private RenderSupport renderSupport;
+
+ private Element element;
+
+ private String clientId;
+
+ private static class ProcessSubmission implements ComponentAction<SubmitContext> {
+
+ private final String elementName;
+
+ private final String context;
+
+ public ProcessSubmission(String elementName, String context) {
+ this.elementName = elementName;
+ this.context = context;
+ }
+
+ public void execute(SubmitContext component) {
+ component.processSubmission(elementName, context);
+ }
+ }
+
+ public SubmitContext() {
+ }
+
+ SubmitContext(Request request) {
+ this.request = request;
+ }
+
+ void beginRender(MarkupWriter writer) {
+ clientId = null;
+
+ String name = formSupport.allocateControlName(resources.getId());
+
+ // Save the element, to see if an id is later requested.
+
+ String type = image == null ? "submit" : "image";
+
+ element = writer.element("input", "type", type, "name", name);
+
+ if (disabled) {
+ writer.attributes("disabled", "disabled");
+ }
+
+ if (image != null) {
+ writer.attributes("src", image.toClientURL());
+ }
+
+ formSupport.store(this, new ProcessSubmission(name, context));
+
+ resources.renderInformalParameters(writer);
+ }
+
+ void afterRender(MarkupWriter writer) {
+ writer.end();
+ }
+
+ void processSubmission(final String elementName, final String context) {
+ if (disabled) {
+ return;
+ }
+
+ String value = request.getParameter(elementName);
+
+ if (value == null) {
+ return;
+ }
+
+ Runnable sendNotification = new Runnable() {
+ public void run() {
+ resources.triggerEvent(event, new Object[]{context}, null);
+ }
+ };
+
+ // When not deferred, don't wait, fire the event now (actually, at the end of the current
+ // heartbeat). This is most likely because the Submit is inside a Loop and some contextual
+ // information will change if we defer.
+
+ if (defer) {
+ formSupport.defer(sendNotification);
+ } else {
+ heartbeat.defer(sendNotification);
+ }
+ }
+
+ // For testing:
+
+ void setDefer(boolean defer) {
+ this.defer = defer;
+ }
+
+ void setup(ComponentResources resources, FormSupport formSupport, Heartbeat heartbeat, RenderSupport renderSupport) {
+ this.resources = resources;
+ this.formSupport = formSupport;
+ this.heartbeat = heartbeat;
+ this.renderSupport = renderSupport;
+ }
+
+ /**
+ * Returns the component's client id. This must be called after the
+ * component has rendered. The id is allocated lazily (first time this
+ * method is invoked).
+ *
+ * @return client id for the component
+ */
+ public String getClientId() {
+ if (clientId == null) {
+ clientId = renderSupport.allocateClientId(resources);
+
+ element.forceAttributes("id", clientId);
+ }
+
+ return clientId;
+ }
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,172 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.nuiton.web.tapestry5.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.tapestry5.beaneditor.PropertyModel;
+import org.apache.tapestry5.grid.ColumnSort;
+import org.apache.tapestry5.grid.GridDataSource;
+import org.apache.tapestry5.grid.SortConstraint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * AbstractMappedGridDataSource
+ *
+ * TODO : javadoc
+ *
+ * Created: 18 janv. 2010
+ *
+ * @param <K> Type of the map key
+ * @param <E> Type of the map value
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ */
+public abstract class AbstractMappedGridDataSource<K, E>
+ implements GridDataSource {
+
+ private Logger log =
+ LoggerFactory.getLogger(AbstractMappedGridDataSource.class);
+
+ private Map<K, E> mapResults;
+
+ private List<E> listResults;
+
+ private int nbRows = -1;
+
+ private int nbRowsPerPage;
+
+ private boolean prepared;
+
+ /** Need to be provided by subclass, used by Grid component **/
+ @Override
+ public abstract Class<?> getRowType();
+
+ protected abstract int count();
+
+ protected abstract Map<K, E> execute(int startIndex, int endIndex,
+ SortConstraint orderBy);
+
+ @Override
+ public int getAvailableRows() {
+ if (nbRows < 0) {
+ nbRows = count();
+ if (log.isDebugEnabled()) {
+ log.debug("Count : " + nbRows);
+ }
+ }
+ return nbRows;
+ }
+
+ @Override
+ public void prepare(int startIndex, int endIndex,
+ List<SortConstraint> sortConstraints) {
+ if (log.isDebugEnabled()) {
+ log.debug("Prepare results : " + startIndex + ", " + endIndex);
+ }
+ nbRowsPerPage = endIndex - startIndex + 1;
+ mapResults = execute(startIndex, endIndex,
+ getSortConstraint(sortConstraints));
+ listResults = new ArrayList<E>(mapResults.values());
+ prepared = true;
+ }
+
+ @Override
+ public Object getRowValue(int index) {
+ index = index % nbRowsPerPage;
+ if (index >= listResults.size()) {
+ if (log.isErrorEnabled()) {
+ log.error("Size error : " + index + " / " + listResults.size());
+ }
+ return null;
+ }
+ return CollectionUtils.get(listResults, index);
+ }
+
+ /**
+ * Detect if the data has already been prepared. This will prevent errors
+ * on calling {@link #get(Object)}, {@link #values()} and
+ * {@link #contains(Object)} methods.
+ *
+ * @return true if data is ready, false otherwise.
+ */
+ public boolean isPrepared() {
+ return prepared;
+ }
+
+ public E get(K key) {
+ if (mapResults == null) {
+ return null;
+ }
+ return mapResults.get(key);
+ }
+
+ public List<E> values() {
+ if (listResults == null) {
+ listResults = new ArrayList<E>();
+ }
+ return listResults;
+ }
+
+ public boolean contains(K key) {
+ if (mapResults == null) {
+ return false;
+ }
+ return mapResults.containsKey(key);
+ }
+
+ protected SortConstraint getSortConstraint(
+ List<SortConstraint> sortConstraints) {
+ for (SortConstraint constraint : sortConstraints) {
+ final ColumnSort sort = constraint.getColumnSort();
+ if (sort != ColumnSort.UNSORTED) {
+ return constraint;
+ }
+ }
+ return null;
+ }
+
+ protected String resolveOrderBy(SortConstraint orderBy) {
+ String filterOrder = null;
+ if (orderBy != null) {
+ PropertyModel property = orderBy.getPropertyModel();
+ filterOrder = property.getPropertyName();
+
+ ColumnSort sort = orderBy.getColumnSort();
+ if (sort.equals(ColumnSort.DESCENDING)) {
+ filterOrder += " desc";
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Order : " + filterOrder);
+ }
+ }
+ return filterOrder;
+ }
+
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,72 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.web.tapestry5.mixins;
+
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.annotations.AfterRender;
+import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * A simple mixin for attaching a javascript confirmation box to the onclick
+ * event of any component that implements ClientElement.
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+@IncludeJavaScriptLibrary("confirm.js")
+public class Confirm {
+
+ @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.MESSAGE)
+ private String message;
+
+ @Parameter(value = "true")
+ private boolean condition;
+
+ @Inject
+ private RenderSupport renderSupport;
+
+ @InjectContainer
+ private ClientElement element;
+
+ @Parameter
+ private boolean wDisabled;
+
+ @AfterRender
+ public void afterRender() {
+ if (!wDisabled) {
+ renderSupport.addScript(String.format("new Confirm('%s', '%s', %b);",
+ element.getClientId(), message.replace("'", "\\'"), condition));
+ }
+ }
+
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,103 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.web.tapestry5.mixins;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * From <a href="http://tinybits.blogspot.com/2009/05/update-zone-on-any-client-side-event.h…">Ingesol Blog</a>
+ *
+ * @author ingesol
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+@IncludeJavaScriptLibrary("zoneUpdater.js")
+public class ZoneUpdater {
+
+ public static final String PLACEHOLDER = "XXX";
+
+ @Inject
+ private ComponentResources resources;
+
+ @Environmental
+ private RenderSupport renderSupport;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String clientEvent;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
+ private String event;
+
+ @InjectContainer
+ private ClientElement element;
+
+ @Parameter
+ private Object[] context;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ // To enable popups to fire events on this document, enter "document" here.
+ private String listeningElement;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
+ private String zone;
+
+ protected Link createLink(Object[] context) {
+
+ if (context == null) {
+ context = new Object[]{PLACEHOLDER};
+ } else {
+ context = ArrayUtils.add(context, PLACEHOLDER); // To be replaced by javascript
+ }
+
+ return resources.createEventLink(event, context);
+
+ }
+
+ void afterRender() {
+ String link = createLink(context).toAbsoluteURI();
+ String elementId = element.getClientId();
+ if (clientEvent == null) {
+ clientEvent = event;
+ }
+
+ if (listeningElement == null) {
+ listeningElement = "$('" + elementId + "')";
+ }
+ renderSupport.addScript("new ZoneUpdater('%s', %s, '%s', '%s', '%s', '%s')", elementId, listeningElement, clientEvent, link, zone, PLACEHOLDER);
+
+ }
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,170 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.web.tapestry5.services;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.runtime.Component;
+import org.apache.tapestry5.services.ComponentEventRequestParameters;
+import org.apache.tapestry5.services.ComponentRequestFilter;
+import org.apache.tapestry5.services.ComponentRequestHandler;
+import org.apache.tapestry5.services.ComponentSource;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.apache.tapestry5.services.PageRenderRequestParameters;
+import org.apache.tapestry5.services.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * AbstractAuthenticationFilter
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U> type of User
+ * @param <A> type of Annotation that manage authentication on pages/components
+ * @author fdesbois
+ * $Id$
+ */
+public abstract class AbstractAuthenticationFilter<U, A extends Annotation>
+ implements ComponentRequestFilter {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(AbstractAuthenticationFilter.class);
+
+ private final PageRenderLinkSource pageRender;
+
+ private final ComponentSource componentSource;
+
+ private final Response response;
+
+ private final ServiceAuthentication<U> serviceAuthentication;
+
+ protected Class<A> annotationClass;
+
+ protected enum AuthenticationRedirect {
+ NOT_CONNECTED, NOT_ALLOWED;
+ }
+
+ protected abstract Class<?> getRedirectPage(
+ AuthenticationRedirect redirectType);
+
+ public AbstractAuthenticationFilter(PageRenderLinkSource renderLinkSource,
+ ComponentSource componentSource, Response response,
+ ServiceAuthentication<U> serviceAuthentication,
+ Class<A> annotationClass) {
+ this.pageRender = renderLinkSource;
+ this.componentSource = componentSource;
+ this.response = response;
+ this.serviceAuthentication = serviceAuthentication;
+ this.annotationClass = annotationClass;
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Construct");
+ }
+ }
+
+ @Override
+ public void handleComponentEvent(
+ ComponentEventRequestParameters parameters,
+ ComponentRequestHandler handler) throws IOException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("handleComponentEvent");
+ }
+
+ if (redirectUnauthorizedUser(parameters.getActivePageName())) {
+ return;
+ }
+
+ handler.handleComponentEvent(parameters);
+
+ }
+
+ @Override
+ public void handlePageRender(PageRenderRequestParameters parameters,
+ ComponentRequestHandler handler) throws IOException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("handlePageRender");
+ }
+
+ if (redirectUnauthorizedUser(parameters.getLogicalPageName())) {
+ return;
+ }
+
+ handler.handlePageRender(parameters);
+ }
+
+ protected boolean redirectUnauthorizedUser(String pageName)
+ throws IOException {
+
+ Component page = componentSource.getPage(pageName);
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Page name : " + pageName);
+ logger.trace("Page class : " + page.getClass());
+ logger.trace("RequiresLogin annotation : " +
+ page.getClass().isAnnotationPresent(annotationClass));
+ logger.trace("User in session : " +
+ serviceAuthentication.isUserConnected());
+ }
+
+ if (!page.getClass().isAnnotationPresent(annotationClass)) {
+ return false;
+ }
+
+ AuthenticationRedirect redirectType = AuthenticationRedirect.NOT_CONNECTED;
+
+ if (serviceAuthentication.isUserConnected()) {
+ U user = serviceAuthentication.getUserConnected();
+ if (logger.isTraceEnabled()) {
+ logger.trace("User connected : " + user);
+ logger.trace("User allowed : " +
+ serviceAuthentication.isAllowed(page.getClass()));
+ }
+
+ if (serviceAuthentication.isAllowed(page.getClass())) {
+ return false;
+ }
+
+ redirectType = AuthenticationRedirect.NOT_ALLOWED;
+ }
+
+ Class<?> redirectPage = getRedirectPage(redirectType);
+ Link link = pageRender.createPageRenderLinkWithContext(redirectPage,
+ pageName);
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Redirection to " + redirectPage.getSimpleName() +
+ " page...");
+ }
+
+ response.sendRedirect(link);
+
+ return true;
+ }
+}
+
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,102 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.web.tapestry5.services;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.tapestry5.Binding;
+import org.apache.tapestry5.internal.bindings.AbstractBinding;
+import org.apache.tapestry5.ioc.Location;
+import org.apache.tapestry5.ioc.Messages;
+
+/**
+ * From <a href="http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix">Tapestry5HowTo</a>
+ * <h2>Usage :</h2>
+ * <pre>
+ * ${format:key=value1,value2} or <t:component t:parameter="format:key=value1,value2">
+ * </pre>
+ *
+ * Created: 27 avr. 2010
+ *
+ * @see FormatBindingFactory
+ * @author fdesbois
+ * $Id$
+ */
+public class FormatBinding extends AbstractBinding {
+
+ private final Messages messages;
+ private final boolean invariant;
+ private final List<Binding> keyBindings;
+ private final List<Binding> valueBindings;
+
+ public FormatBinding(Location location, Messages messages, boolean invariant,
+ ArrayList<Binding> keyBindings, List<Binding> valueBindings) {
+ super(location);
+
+ this.messages = messages;
+ this.invariant = invariant;
+ this.keyBindings = keyBindings;
+ this.valueBindings = valueBindings;
+ }
+
+ public FormatBinding(Location location, Messages messages, boolean invariant, ArrayList<Binding> keyBindings) {
+ super(location);
+
+ this.messages = messages;
+ this.invariant = invariant;
+ this.keyBindings = keyBindings;
+ this.valueBindings = null;
+ }
+
+ @Override
+ public Object get() {
+ String key = "";
+ for (Binding keyBinding : keyBindings) {
+ key += keyBinding.get();
+ }
+
+ if (null == valueBindings) {
+ return messages.get(key);
+ }
+
+ List<Object> values = new ArrayList<Object>(valueBindings.size());
+ for (Binding valueBinding : valueBindings) {
+ values.add(valueBinding.get());
+ }
+
+ return messages.format(key, values.toArray());
+ }
+
+ @Override
+ public boolean isInvariant() {
+ return this.invariant;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<?> getBindingType() {
+ return String.class;
+ }
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,113 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.web.tapestry5.services;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.tapestry5.Binding;
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.ioc.Location;
+import org.apache.tapestry5.services.BindingFactory;
+import org.apache.tapestry5.services.BindingSource;
+
+/**
+ * From <a href="http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix">Tapestry5HowTo</a>
+ * <br \>
+ * <h2>AppModule contribution :</h2>
+ * <pre>
+ * public static void contributeBindingSource(
+ * MappedConfiguration<String, BindingFactory> configuration,
+ * BindingSource bindingSource) {
+ * configuration.add("format", new FormatBindingFactory(bindingSource));
+ * }
+ * </pre>
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class FormatBindingFactory
+ implements BindingFactory {
+
+ private static final String SEPARATOR = "=";
+ private static final String DELIMITER = ",";
+ private static final String KEY_PREFIX = BindingConstants.LITERAL;
+ private static final String VALUE_PREFIX = BindingConstants.PROP;
+ private final BindingSource bindingSource;
+
+ public FormatBindingFactory(BindingSource bindingSource) {
+ this.bindingSource = bindingSource;
+ }
+
+ @Override
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location) {
+ int separatorIndex = expression.indexOf(SEPARATOR);
+
+ if (-1 == separatorIndex) {
+ List<String> keys = Arrays.asList(expression.split(DELIMITER));
+
+ ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location);
+
+ boolean invariant = isInvariant(keyBindings);
+ return new FormatBinding(location, container.getMessages(), invariant, keyBindings);
+ }
+
+ List<String> keys = Arrays.asList(expression.substring(0, separatorIndex).split(DELIMITER));
+ ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location);
+
+ List<String> values = Arrays.asList(expression.substring(separatorIndex + 1).split(DELIMITER));
+ ArrayList<Binding> valueBindings = createBindings(description, container, component, VALUE_PREFIX, values,
+ location);
+
+ boolean invariant = isInvariant(keyBindings) && isInvariant(valueBindings);
+ return new FormatBinding(location, container.getMessages(), invariant, keyBindings, valueBindings);
+ }
+
+ private ArrayList<Binding> createBindings(String description, ComponentResources container,
+ ComponentResources component, String defaultPrefix,
+ List<String> expressions, Location location) {
+ ArrayList<Binding> bindings = new ArrayList<Binding>(expressions.size());
+
+ for (String expression : expressions) {
+ bindings.add(bindingSource.newBinding(description, container, component, defaultPrefix, expression, location));
+ }
+
+ return bindings;
+ }
+
+ private boolean isInvariant(ArrayList<Binding> bindings) {
+ for (Binding binding : bindings) {
+ if (!binding.isInvariant()) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.nuiton.web.tapestry5.services;
+
+import org.apache.tapestry5.ioc.Configuration;
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.services.BindingFactory;
+import org.apache.tapestry5.services.BindingSource;
+import org.apache.tapestry5.services.LibraryMapping;
+
+/**
+ * NuitonModule
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class NuitonModule {
+
+ private static final String PACKAGE_ROOT = "org.nuiton.web.tapestry5";
+
+ public void contributeComponentClassResolver(
+ Configuration<LibraryMapping> configuration) {
+
+ configuration.add(new LibraryMapping("nuiton", PACKAGE_ROOT));
+ }
+
+ public static void contributeBindingSource(
+ MappedConfiguration<String, BindingFactory> configuration,
+ BindingSource bindingSource) {
+
+ configuration.add("format", new FormatBindingFactory(bindingSource));
+ }
+
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,115 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.nuiton.web.tapestry5.services;
+
+/**
+ * This service is used to provide authentication managment for a final
+ * application. The user type used in the application is needed. This service
+ * need to be implemented and build in the AppModule of your application.
+ * An abstract implementation is available {@link ServiceAuthenticationAbstract}
+ * This service is used in {@link AbstractAuthenticationFilter} to verify
+ * user rights for displaying pages using {@link #isAllowed(Class)} method.
+ * See documentation site for more explanation of using this service and
+ * authentication managment.
+ * <br \>
+ * <h2>AppModule contribution :</2>
+ * Exemple with MyUser type for user and ServiceAuthenticationImpl for
+ * implementation :
+ * <pre>
+ * public ServiceAuthentication<MyUser> buildServiceAuthentication(
+ * ApplicationStateManager stateManager) {
+ * ServiceAuthentication<MyUser> instance =
+ * new ServiceAuthenticationImpl(stateManager);
+ * return instance;
+ * }
+ * </pre>
+ * Contribute to ApplicationStateManager to instantiate MyUser automatically :
+ * <pre>
+ * public void contributeApplicationStateManager(
+ * MappedConfiguration<Class<?>,
+ * ApplicationStateContribution> configuration,
+ * final ServiceAuthentication<MyUser> serviceAuthentication) {
+ *
+ * ApplicationStateCreator<MyUser> creator =
+ * new ApplicationStateCreator<MyUser>() {
+ *
+ * @Override
+ * public MyUser create() {
+ * return serviceAuthentication.getNewUserInstance();
+ * }
+ * };
+ *
+ * configuration.add(MyUser.class,
+ * new ApplicationStateContribution("session", creator));
+ * }
+ * </pre>
+ *
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U> user type
+ * @author fdesbois
+ * $Id$
+ */
+public interface ServiceAuthentication<U> {
+
+ /**
+ * Detect if user is connected.
+ *
+ * @return true if the user is connected, false otherwise.
+ */
+ boolean isUserConnected();
+
+ /**
+ * Get the current user connected.
+ *
+ * @return the user connected
+ */
+ U getUserConnected();
+
+ /**
+ * Set the connected user to {@code user}.
+ *
+ * @param user that will be connected
+ */
+ void setUserConnected(U user);
+
+ /**
+ * Check if the current user is allowed to display this {@code page}.
+ *
+ * @param page to check
+ * @return true if the connected user is allowed, false otherwise
+ */
+ boolean isAllowed(Class<?> page);
+
+ /**
+ * Create a new instance of user.
+ *
+ * @return a new user.
+ */
+ U getNewUserInstance();
+
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,166 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.nuiton.web.tapestry5.services;
+
+import java.lang.annotation.Annotation;
+import org.apache.tapestry5.ioc.internal.util.TapestryException;
+import org.apache.tapestry5.services.ApplicationStateManager;
+
+/**
+ * This class is an abstract implementation of {@link ServiceAuthentication}.
+ * This service use {@link ApplicationStateManager} to manage connected user.
+ * You can inherit this class to provide a momre specific authentication
+ * managmentan depends on user type and annotation used to identify
+ * pages that need authentication. This behavior is done in
+ * {@link #isAllowed(Class)} that detect the annotation on the page (ex :
+ * {@link RequiresAuthentication} annotation) and call the method
+ * {@link #checkAuthorizations(Object, Annotation)} that is implemented by
+ * default to do nothing (return true).
+ * <br \>
+ * <h2>AppModule contribution :</2>
+ * Exemple with MyUser type for user and RequiresAnnotation for annotation :
+ * <pre>
+ * public ServiceAuthentication<MyUser> buildServiceAuthentication(ApplicationStateManager stateManager) {
+ * return new ServiceAuthenticationImpl<MyUser, RequiresAuthentication>(stateManager);
+ * }
+ * </pre>
+ * No need to contribute to ApplicationStateManager to provide instantiation
+ * of user. Even this service used the default constructor to instanciate a new
+ * user.
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U> user type
+ * @param <A> annotation type used to identify which page need authentication
+ * @author fdesbois
+ * $Id$
+ */
+public class ServiceAuthenticationImpl<U, A extends Annotation>
+ implements ServiceAuthentication<U> {
+
+ /**
+ * Tapestry service used to save user in session and retrieve it when
+ * needed.
+ **/
+ private final ApplicationStateManager stateManager;
+
+ /**
+ * User type
+ **/
+ protected Class<U> userClass;
+
+ /**
+ * Annotation type to detect pages that need authentication (ex :
+ * RequiresAuthentication).
+ */
+ protected Class<A> annotationClass;
+
+ /**
+ * Constructor to call in subclasses.
+ *
+ * @param stateManager from Tapestry
+ * @param userClass to identify which type of user is managed
+ * @param annotationClass to identify which type of annotation is managed
+ * for authentication treatment.
+ */
+ public ServiceAuthenticationImpl(ApplicationStateManager stateManager,
+ Class<U> userClass, Class<A> annotationClass) {
+ this.stateManager = stateManager;
+ this.userClass = userClass;
+ this.annotationClass = annotationClass;
+ }
+
+ @Override
+ public boolean isUserConnected() {
+ return stateManager.exists(userClass);
+ }
+
+ @Override
+ public U getUserConnected() {
+ return stateManager.getIfExists(userClass);
+ }
+
+ @Override
+ public void setUserConnected(U user) {
+ stateManager.set(userClass, user);
+ }
+
+ /**
+ * Detect the annotation in the given {@code page}. If annotation is
+ * detected, the user authorizations need to be check using
+ * {@link #checkAuthorizations(Object, Annotation)} method.
+ *
+ * @param page to check
+ * @return true if connected user can display the page, false otherwise
+ */
+ @Override
+ public boolean isAllowed(Class<?> page) {
+ if (page.isAnnotationPresent(annotationClass) &&
+ isUserConnected()) {
+
+ A check = page.getAnnotation(annotationClass);
+
+ U user = getUserConnected();
+
+ return checkAuthorizations(user, check);
+ }
+ // No restriction if annotation is not present
+ return true;
+ }
+
+ /**
+ * Check the connected user authorizations. Called in
+ * {@link #isAllowed(Class)} method after detect the annotation on the
+ * current page. Override this method to provide more specific
+ * authentication managment.
+ *
+ * @param user current user connected.
+ * @param annotation from page to check authorizations.
+ * @return true if the user is granted, false otherwise
+ */
+ protected boolean checkAuthorizations(U user, A annotation) {
+ // The user is connected so, he can access to the page.
+ return true;
+ }
+
+ /**
+ * Default instanciation of the user. The user class need a default
+ * constructor.
+ *
+ * @return a new user instance.
+ */
+ @Override
+ public U getNewUserInstance() {
+ try {
+ return userClass.newInstance();
+ } catch (Exception eee) {
+ new TapestryException("Error on user instanciation " +
+ userClass.getName(), eee);
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,30 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+/**
+ * This package contains extra services (or abstraction) for Tapestry
+ * applications. Generally, these services need to be built in the
+ * AppModule class of your Tapestry application.
+ */
+package org.nuiton.web.tapestry5.services;
\ No newline at end of file
Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,38 @@
+<!--
+ #%L
+ Nuiton Utils :: Nuiton Tapestry Extra
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <t:delegate t:to="activeBlock" />
+ <t:block t:id="formBlock">
+ <form t:type="form" action="tapestry">
+ <t:body />
+ </form>
+ </t:block>
+ <t:block t:id="noFormBlock">
+ <t:body />
+ </t:block>
+
+</html>
\ No newline at end of file
Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,48 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Tapestry Extra
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+.fb-error {
+ width: 400px;
+ margin: auto;
+ text-align: center;
+ color: #000;
+ font-weight: bold;
+ padding: 3px;
+ border: solid;
+ border-color: #f00;
+ border-width: 2px;
+ margin-bottom: 10px;
+}
+
+.fb-info {
+ width: 400px;
+ margin: auto;
+ text-align: center;
+ color: #000;
+ padding: 3px;
+ border: solid;
+ border-color: #000;
+ border-width: 2px;
+}
\ No newline at end of file
Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,23 @@
+/**
+ * Dialogue de confirmation
+ */
+var Confirm = Class.create({
+ /**
+ * element : Element DOM depuis lequel le dialogue de confirmation va s'ouvrir
+ * message : Message à afficher dans la boîte de dialogue
+ */
+ initialize: function(element, message, condition) {
+ this.message = message;
+ this.condition = condition;
+ Event.observe($(element), 'click', this.doConfirm.bindAsEventListener(this));
+ },
+ doConfirm: function(e) {
+ //Tapestry.debug('click ' + element);
+ if (this.condition) {
+ if (!confirm(this.message)) {
+ //Tapestry.debug('STOP ' + e);
+ Event.stop(e);
+ }
+ }
+ }
+});
\ No newline at end of file
Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js
===================================================================
--- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js (rev 0)
+++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,103 @@
+var ZoneUpdater = Class.create();
+
+ZoneUpdater.prototype = {
+
+ initialize: function(zoneElementId, listeningElement, event, link, zone, placeholder) {
+
+ this.zoneElement = $(zoneElementId);
+
+ this.event = event;
+
+ this.link = link;
+
+ this.placeholder = placeholder;
+
+ $T(this.zoneElement).zoneId = zone;
+
+ listeningElement.observe(this.event, this.updateZone.bindAsEventListener(this));
+
+ },
+
+ updateZone: function(event) {
+
+ var zoneObject = Tapestry.findZoneManager(this.zoneElement);
+
+ if ( !zoneObject ) return;
+
+ var param;
+
+ if (this.zoneElement.value) {
+
+ param = this.zoneElement.value;
+
+ }
+
+ if (!param) param = ' ';
+
+ param = this.encodeForUrl(param);
+
+ var updatedLink = this.link.gsub(this.placeholder, param);
+
+ zoneObject.updateFromURL(updatedLink);
+
+ },
+
+ encodeForUrl: function(string) {
+
+ /**
+
+ * See equanda.js for updated version of this
+
+ */
+
+ string = string.replace(/\r\n/g,"\n");
+
+ var res = "";
+
+ for (var n = 0; n < string.length; n++)
+
+ {
+
+ var c = string.charCodeAt( n );
+
+ if ( '$' == string.charAt( n ) )
+
+ {
+
+ res += '$$';
+
+ }
+
+ else if ( this.inRange( c, "AZ" ) || this.inRange( c, "az" ) || this.inRange( c, "09" ) || this.inRange( c, ".." ) )
+
+ {
+
+ res += string.charAt( n )
+
+ }
+
+ else
+
+ {
+
+ var tmp = c.toString(16);
+
+ while ( tmp.length < 4 ) tmp = "0" + tmp;
+
+ res += '$' + tmp;
+
+ }
+
+ }
+
+ return res;
+
+ },
+
+ inRange: function(code, range) {
+
+ return code >= range.charCodeAt( 0 ) && code <= range.charCodeAt( 1 );
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/site/apt/index.apt
===================================================================
--- trunk/nuiton-tapestry-extra/src/site/apt/index.apt (rev 0)
+++ trunk/nuiton-tapestry-extra/src/site/apt/index.apt 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,34 @@
+~~~
+~~ #%L
+~~ Nuiton Utils :: Nuiton Tapestry Extra
+~~
+~~ $Id$
+~~ $HeadURL$
+~~ %%
+~~ Copyright (C) 2010 CodeLutin, Florian Desbois, Tony chemit
+~~ %%
+~~ This program is free software: you can redistribute it and/or modify
+~~ it under the terms of the GNU Lesser General Public License as
+~~ published by the Free Software Foundation, either version 3 of the
+~~ License, or (at your option) any later version.
+~~
+~~ This program is distributed in the hope that it will be useful,
+~~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~~ GNU General Lesser Public License for more details.
+~~
+~~ You should have received a copy of the GNU General Lesser Public
+~~ License along with this program. If not, see
+~~ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+~~ #L%
+~~~
+ ----
+ Nuiton Tapestry Extra
+ ----
+ ----
+ 2009-08-23
+ ----
+
+Présentation
+
+ A Faire...
\ No newline at end of file
Property changes on: trunk/nuiton-tapestry-extra/src/site/apt/index.apt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-tapestry-extra/src/site/site_fr.xml
===================================================================
--- trunk/nuiton-tapestry-extra/src/site/site_fr.xml (rev 0)
+++ trunk/nuiton-tapestry-extra/src/site/site_fr.xml 2010-12-30 12:09:09 UTC (rev 2003)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Nuiton Tapestry Extra
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: trunk/nuiton-tapestry-extra/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-12-30 11:25:43 UTC (rev 2002)
+++ trunk/pom.xml 2010-12-30 12:09:09 UTC (rev 2003)
@@ -45,6 +45,7 @@
<module>nuiton-utils</module>
<module>nuiton-validator</module>
<module>nuiton-utils-extra</module>
+ <module>nuiton-tapestry-extra</module>
<module>nuiton-rss</module>
</modules>
@@ -70,7 +71,7 @@
<version>7.1.0.v20100505</version>
</dependency>
- <!-- xworks dependencies -->
+ <!-- xworks dependencies -->
<dependency>
<groupId>com.opensymphony</groupId>
@@ -104,33 +105,73 @@
<version>${aspectwerkzVersion}</version>
</dependency>
- <dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>rome</groupId>
- <artifactId>rome</artifactId>
- <version>0.9</version>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <!-- tapestry dependencies -->
- <!--Provided-->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-core</artifactId>
+ <version>${tapestryVersion}</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-ioc</artifactId>
+ <version>${tapestryVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry5-annotations</artifactId>
+ <version>${tapestryVersion}</version>
+ </dependency>
+
+ <!-- sl4j dependencies -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4jVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4jVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>0.9</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!--Provided-->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
</dependencyManagement>
@@ -163,7 +204,7 @@
<organization>CodeLutin</organization>
<timezone>+2</timezone>
<roles>
- <role>Développeur</role>
+ <role>developer</role>
<role>Debian packager</role>
</roles>
</developer>
@@ -175,18 +216,29 @@
<organization>CodeLutin</organization>
<timezone>+2</timezone>
<roles>
- <role>Développeur</role>
+ <role>developer</role>
</roles>
</developer>
<developer>
+ <name>Florian Desbois</name>
+ <id>fdesbois</id>
+ <email>desbois(a)codelutin.com</email>
+ <organization>Code Lutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>developer</role>
+ </roles>
+ </developer>
+
+ <developer>
<name>Sylvain Letellier</name>
<id>sletellier</id>
<email>letellier(a)codelutin.com</email>
<organization>CodeLutin</organization>
<timezone>+2</timezone>
<roles>
- <role>Développeur</role>
+ <role>developer</role>
</roles>
</developer>
@@ -216,12 +268,16 @@
<nuitonI18nVersion>2.0.1</nuitonI18nVersion>
<aspectwerkzVersion>2.0</aspectwerkzVersion>
-
+
+ <tapestryVersion>5.1.0.5</tapestryVersion>
+
+ <slf4jVersion>1.5.10</slf4jVersion>
</properties>
<build>
<pluginManagement>
<plugins>
+
<!-- plugin i18n -->
<plugin>
<groupId>org.nuiton.i18n</groupId>
1
0
Author: tchemit
Date: 2010-12-30 12:25:43 +0100 (Thu, 30 Dec 2010)
New Revision: 2002
Url: http://nuiton.org/repositories/revision/nuiton-utils/2002
Log:
fix headers + license
Modified:
trunk/nuiton-utils-extra/LICENSE.txt
trunk/nuiton-utils-extra/pom.xml
trunk/nuiton-utils/pom.xml
trunk/nuiton-validator/pom.xml
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java
trunk/nuiton-validator/src/main/resources/validators.xml
trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java
trunk/nuiton-validator/src/test/resources/log4j.properties
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml
trunk/nuiton-validator/src/test/resources/validators.xml
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-utils/pom.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
- Nuiton Utils
+ Nuiton Utils :: Nuiton Utils
$Id$
$HeadURL$
%%
- Copyright (C) 2004 - 2010 CodeLutin
+ Copyright (C) 2004 - 2010 CodeLutin, Tony Chemit
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-utils-extra/LICENSE.txt
===================================================================
--- trunk/nuiton-utils-extra/LICENSE.txt 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-utils-extra/LICENSE.txt 2010-12-30 11:25:43 UTC (rev 2002)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Modified: trunk/nuiton-utils-extra/pom.xml
===================================================================
--- trunk/nuiton-utils-extra/pom.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-utils-extra/pom.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
- Nuiton Utils
+ Nuiton Utils :: Nuiton Utils Extra
$Id$
$HeadURL$
%%
Modified: trunk/nuiton-validator/pom.xml
===================================================================
--- trunk/nuiton-validator/pom.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/pom.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,5 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Nuiton Validator
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -72,7 +94,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Nuiton Utils :: Validator</name>
+ <name>Nuiton Utils :: Nuiton Validator</name>
<description>Validator Api.</description>
<inceptionYear>2011</inceptionYear>
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/main/resources/validators.xml
===================================================================
--- trunk/nuiton-validator/src/main/resources/validators.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/main/resources/validators.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
/*
* #%L
- * Nuiton Utils :: Validator
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
/*
* #%L
- * JAXX :: Runtime
+ * Nuiton Utils :: Nuiton Validator
*
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-validator/src/test/resources/log4j.properties
===================================================================
--- trunk/nuiton-validator/src/test/resources/log4j.properties 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/log4j.properties 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,11 +1,11 @@
###
# #%L
-# JAXX :: Runtime
+# Nuiton Utils :: Nuiton Validator
#
# $Id$
# $HeadURL$
# %%
-# Copyright (C) 2008 - 2010 CodeLutin
+# Copyright (C) 2011 CodeLutin, Tony Chemit
# %%
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
@@ -22,6 +22,7 @@
# <http://www.gnu.org/licenses/lgpl-3.0.html>.
# #L%
###
+
# Global logging configuration
log4j.rootLogger=ERROR, stdout
# Console output...
Modified: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,6 +1,6 @@
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
Modified: trunk/nuiton-validator/src/test/resources/validators.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/validators.xml 2010-12-30 11:25:14 UTC (rev 2001)
+++ trunk/nuiton-validator/src/test/resources/validators.xml 2010-12-30 11:25:43 UTC (rev 2002)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
- Nuiton Utils :: Validator
+ Nuiton Utils :: Nuiton Validator
$Id$
$HeadURL$
1
0
Author: tchemit
Date: 2010-12-30 12:25:14 +0100 (Thu, 30 Dec 2010)
New Revision: 2001
Url: http://nuiton.org/repositories/revision/nuiton-utils/2001
Log:
Evolution #1189: Introduce nuiton-rss module
Added:
trunk/nuiton-rss/
trunk/nuiton-rss/LICENSE.txt
trunk/nuiton-rss/README.txt
trunk/nuiton-rss/changelog.txt
trunk/nuiton-rss/pom.xml
trunk/nuiton-rss/src/
trunk/nuiton-rss/src/license/
trunk/nuiton-rss/src/license/THIRD-PARTY.properties
trunk/nuiton-rss/src/main/
trunk/nuiton-rss/src/main/java/
trunk/nuiton-rss/src/main/java/org/
trunk/nuiton-rss/src/main/java/org/nuiton/
trunk/nuiton-rss/src/main/java/org/nuiton/rss/
trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java
trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java
trunk/nuiton-rss/src/main/resources/
trunk/nuiton-rss/src/main/resources/fckeditor/
trunk/nuiton-rss/src/main/resources/fckeditor/editor/
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/button.rss.gif
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js
trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js
trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js
trunk/nuiton-rss/src/main/resources/log4j.properties
trunk/nuiton-rss/src/main/webapp/
trunk/nuiton-rss/src/main/webapp/WEB-INF/
trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml
trunk/nuiton-rss/src/main/webapp/feed.css
trunk/nuiton-rss/src/main/webapp/feeds.txt
trunk/nuiton-rss/src/main/webapp/index.html
trunk/nuiton-rss/src/main/webapp/rssgenerator.js
trunk/nuiton-rss/src/main/webapp/rssinclude.js
trunk/nuiton-rss/src/main/webapp/testFck.html
trunk/nuiton-rss/src/main/webapp/testGenerator.html
trunk/nuiton-rss/src/main/webapp/testRender.html
trunk/nuiton-rss/src/site/
trunk/nuiton-rss/src/site/apt/
trunk/nuiton-rss/src/site/apt/index.apt
trunk/nuiton-rss/src/site/site_fr.xml
trunk/nuiton-rss/src/test/
trunk/nuiton-rss/src/test/java/
trunk/nuiton-rss/src/test/java/org/
trunk/nuiton-rss/src/test/java/org/nuiton/
trunk/nuiton-rss/src/test/java/org/nuiton/rss/
trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java
trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java
trunk/nuiton-rss/src/test/java/resources/
trunk/nuiton-rss/src/test/java/resources/log4j.properties
Modified:
trunk/pom.xml
Property changes on: trunk/nuiton-rss
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
Added: trunk/nuiton-rss/LICENSE.txt
===================================================================
--- trunk/nuiton-rss/LICENSE.txt (rev 0)
+++ trunk/nuiton-rss/LICENSE.txt 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Property changes on: trunk/nuiton-rss/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-rss/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-rss/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/pom.xml
===================================================================
--- trunk/nuiton-rss/pom.xml (rev 0)
+++ trunk/nuiton-rss/pom.xml 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>nuiton-rss</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Test-->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!--Provided-->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton Utils :: Nuiton RSS</name>
+ <description>Servlet pouvant etre appeler depuis du JS pour recuperer un
+ flux RSS
+ </description>
+ <inceptionYear>2008</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>war</packaging>
+
+ <properties>
+
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+
+ </properties>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webappDirectory>target/nuitonrss</webappDirectory>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </pluginManagement>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <profiles>
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <quiet>true</quiet>
+ <links>
+ <link>http://java.sun.com/javase/6/docs/api/</link>
+ </links>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ <!-- create assemblies at release time -->
+ <profile>
+ <id>assembly-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
Property changes on: trunk/nuiton-rss/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/nuiton-rss/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/nuiton-rss/src/license/THIRD-PARTY.properties 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,13 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD License
+# - Common Public License Version 1.0
+# - The Apache Software License, Version 2.0
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Dec 30 12:16:27 CET 2010
+javax.servlet--servlet-api--2.5--jar=Sun Microsystems, Inc. Binary Code License Agreement for the JDK 5.0
+org.jdom--jdom--1.1--jar=Apache Software License Like
Property changes on: trunk/nuiton-rss/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,136 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.io.*;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * Servlet de base
+ * @param <D> la classe de l'object de delegation
+ *
+ * @author chemit
+ */
+public abstract class BaseServlet<D> extends HttpServlet {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ protected static final Log log = LogFactory.getLog(BaseServlet.class);
+ /** L'objet de delegation du metier de la servlet */
+ protected transient D delegate;
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ * @return the new delegate object to be used by servlet
+ * @throws Exception if any problem while instanciation
+ */
+ protected abstract D newDelegate() throws Exception;
+
+ /**
+ *
+ * @return a new ConfigInitializer to be used in
+ * {@link #init(ServletConfig, boolean)} method to prepare
+ * default config.
+ */
+ protected abstract ConfigInitializer<ServletConfig,? > newConfigInitializer();
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws IOException TODO
+ * @throws ServletException TODO
+ */
+ protected abstract void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ init(config, true);
+ }
+
+ protected void init(ServletConfig config, boolean initConfig) throws ServletException {
+ try {
+ super.init(config);
+ if (initConfig) {
+ // init de la configuration par defaut depuis la config de servlet
+ newConfigInitializer().init(config);
+ }
+ // instanciate delegate
+ delegate = newDelegate();
+ } catch (Exception eee) {
+ log.warn("Can't configure Servlet", eee);
+ if (eee instanceof ServletException) {
+ throw (ServletException) eee;
+ }
+ throw new ServletException("Can't configure Servlet", eee);
+ }
+ }
+
+ protected Integer convertToInt(String parameter) {
+ Integer result = null;
+ try {
+ result = Integer.parseInt(parameter);
+ } catch (Exception eee) {
+ log.debug("Can't convert to int: '" + parameter + "'", eee);
+ }
+ return result;
+ }
+ // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Returns a short description of the servlet.
+ */
+ @Override
+ public String getServletInfo() {
+ return "RSS Servlet";
+ }
+ // </editor-fold>
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,82 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import org.apache.commons.beanutils.BeanUtils;
+
+/**
+ *
+ * @author tony
+ *
+ * @param <S> la classe source de la configuration
+ * @param <D> la classe destination de la configuration
+ */
+public abstract class ConfigInitializer<S,D> {
+
+
+ /**
+ *
+ * @param config l'object source contenant les configs
+ * @param fullConfigName le nom complet de la propriete recherchee
+ * @return la valeur de la propriete ou null si non trouve
+ */
+ protected abstract String getConfigValue(S config, String fullConfigName);
+
+ public abstract void init(S config) ;
+
+ /**
+ * Initialise RSSConfig.
+ * @param prefix
+ * @param klass la class de la configuration de destination
+ * @param config la configuration source
+ * @param keys
+ */
+ public void init(String prefix,Class<D> klass, S config, String... keys) {
+ try {
+ String prefixConfig = getConfigValue(config, prefix);
+ prefixConfig = prefixConfig == null ? "" : prefixConfig.trim();
+
+ D instance = klass.newInstance();
+ for (String key : keys) {
+ loadConfig(config, instance, prefixConfig, key);
+ }
+ } catch (InstantiationException ex) {
+ throw new RuntimeException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ protected void loadConfig(S config, D instance, String prefix, String configName) {
+ String value = getConfigValue(config, prefix + configName);
+ if (value != null && !"".equals(value)) {
+ try {
+ BeanUtils.setProperty(instance, configName, value);
+ } catch (Exception ex) {
+ throw new IllegalStateException("could not load property " + configName + " from config " + config + " for reason : " + ex.getMessage());
+ }
+ }
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,119 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndFeed;
+import java.net.URL;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * Represente une URL demandee. Cette objet est conserve durant le temps de vie
+ * de la JVM pour permettre de mutualiser la recuperation et la transformation en
+ * HTML.
+ * </p>
+ * <p>
+ * Lorsque l'on demande le HTML et que l'url n'a pas encore ete recuperee ou
+ * est trop ancienne alors on lance la recuperation. Si deux threads demandent
+ * la recuperation, le deuxieme est mis en attente et profitera de la recuperation
+ * de l'autre.
+ * </p>
+ *
+ * @author poussin
+ */
+public class FeedData {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(FeedData.class);
+
+ /** url du feed */
+ protected URL url;
+ /** les champs que l'on souhaite visualiser pour le feed */
+ protected FeedRendererConfig rendererConfig;
+ /** Le nombre d'item que l'on souhaite visualiser pour le feed */
+ protected int nbItem = -1;
+
+ protected SyndFeed feed;
+ protected long lastRetrived;
+
+ public FeedData(URL url, int nbItem, String representation) {
+ this(url);
+ this.nbItem = nbItem;
+ rendererConfig = new FeedRendererConfig(representation);
+ }
+
+ public FeedData(URL url) {
+ this.url = url;
+ }
+
+ public long getLastRetrived() {
+ return lastRetrived;
+ }
+
+ public URL getUrl() {
+ return url;
+ }
+
+ public FeedRendererConfig getRendererConfig() {
+ return rendererConfig;
+ }
+
+ public void setRendererConfig(FeedRendererConfig rendererConfig) {
+ this.rendererConfig = rendererConfig;
+ }
+
+ public int getNbItem() {
+ return nbItem;
+ }
+
+ public void setNbItem(int nbItem) {
+ this.nbItem = nbItem;
+ }
+
+ /**
+ * Retourne la representation HTML du RSS
+ *
+ * @return la representation HTML du RSS
+ */
+ public SyndFeed getFeed() {
+ if (feed == null || lastRetrived + RSSConfig.TIME_FORCE_RETRIEVED < System.currentTimeMillis()) {
+ forceRetrived();
+ }
+
+ return feed;
+ }
+
+ synchronized protected void forceRetrived() {
+ if (lastRetrived + RSSConfig.TIME_FORCE_RETRIEVED < System.currentTimeMillis()) {
+ try {
+ feed = RSSIOUtil.readFeed(url);
+ lastRetrived = System.currentTimeMillis();
+ } catch (Exception eee) {
+ log.warn("Can't get feed: " + url, eee);
+ }
+ }
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,40 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import java.util.Comparator;
+
+/**
+ * Comparator of entry base on his publication date
+ * @author tony
+ */
+public class FeedEntryComparator implements Comparator<SyndEntry> {
+
+ public int compare(SyndEntry o1, SyndEntry o2) {
+ return o1.getPublishedDate().compareTo(o2.getPublishedDate());
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,237 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author poussin
+ */
+public class FeedHTMLRenderer implements FeedRenderer {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(FeedHTMLRenderer.class);
+
+ private static final String FEED_CSS_PREFIX ="feed-";
+ private static final String FEED_ITEM_CSS_PREFIX ="feedItem-";
+
+ /** tous les HTMLCleaner a utiliser pour nettoyer les chaines */
+ protected Set<HTMLCleaner> cleaners = new HashSet<HTMLCleaner>();
+
+ protected EnumMap<Field, String> templates = new EnumMap<Field, String>(Field.class);
+ protected EnumMap<Field, String> classnames = new EnumMap<Field, String>(Field.class);
+ protected EnumMap<Field, String> feedProperties = new EnumMap<Field, String>(Field.class);
+ protected EnumMap<Field, String> itemProperties = new EnumMap<Field, String>(Field.class);
+
+ /**
+ *
+ * @param cleaners La liste des cleaners a utiliser par defaut. Si aucun
+ * cleaner n'est passer en argument HTMLScriptCleaner est automatiquement
+ * ajoute
+ */
+ public FeedHTMLRenderer(HTMLCleaner ... cleaners) {
+ if (cleaners.length == 0) {
+ addHTMLCleaner(new HTMLScriptCleaner());
+ }
+ for (HTMLCleaner cleaner : cleaners) {
+ addHTMLCleaner(cleaner);
+ }
+
+ templates.put(Field.NAME, "<span class=\"%1$s\">%2$s</span>\n");
+ templates.put(Field.LINK, "<a class=\"%1$s\" href=\"%2$s\">%3$s</a>");
+ templates.put(Field.IMAGE, "<span class=\"%1$s\"><img src=\"%2$s\"/></span>\n");
+ templates.put(Field.DESCRIPTION, "<span class=\"%1$s\">%2$s</span>\n");
+ templates.put(Field.AUTHOR, "<span class=\"%1$s\">%2$s</span>\n");
+ //Probleme de conversion FIXME
+ templates.put(Field.TIME, "<span class=\"%1$s\">%2$s</span>\n");
+ //templates.put(Field.TIME, "<span class=\"%1$s\">%2$tF</span>\n");
+
+ classnames.put(Field.NAME, "name");
+ classnames.put(Field.LINK, "link");
+ classnames.put(Field.IMAGE, "image");
+ classnames.put(Field.DESCRIPTION, "description");
+ classnames.put(Field.AUTHOR, "author");
+ classnames.put(Field.TIME, "time");
+
+ feedProperties.put(Field.NAME, "title");
+ feedProperties.put(Field.LINK, "link");
+ // cela engendre des NPE...
+ feedProperties.put(Field.IMAGE, "image.url");
+ feedProperties.put(Field.DESCRIPTION, "description");
+ feedProperties.put(Field.AUTHOR, "author");
+ feedProperties.put(Field.TIME, "publishedDate");
+
+ itemProperties.put(Field.NAME, "title");
+ itemProperties.put(Field.LINK, "link");
+ itemProperties.put(Field.IMAGE, null);
+ itemProperties.put(Field.DESCRIPTION, "description.value");
+ itemProperties.put(Field.AUTHOR, "author");
+ itemProperties.put(Field.TIME, "publishedDate");
+ }
+
+
+ public FeedHTMLRenderer() {
+ this(new HTMLCleaner[0]);
+ }
+
+ /**
+ * Supprime tous les cleaners de code html
+ */
+ public void clearCleaners() {
+ cleaners.clear();
+ }
+
+ /**
+ * Ajoute un nouveau cleaner de code HTML
+ * @param cleaner cleaner to add
+ */
+ public void addHTMLCleaner(HTMLCleaner cleaner) {
+ cleaners.add(cleaner);
+ }
+
+ public String render(FeedRendererConfig config, SyndFeed feed, SyndEntry[] items) {
+
+ StringBuffer sbGlobal= new StringBuffer();
+
+ StringBuffer sbTemp= new StringBuffer();
+ for (Field f : config.getFeedFieldOrder()) {
+ renderField(f, FEED_CSS_PREFIX,feedProperties, feed,sbTemp);
+ }
+
+ String tmp = sbTemp.toString();
+ if (!"".equals(tmp)) {
+ sbGlobal.append("<div class='rss-feed'>\n").append(tmp).append("</div>\n");
+ }
+ sbGlobal.append("<ul class='rss-items'>\n");
+ sbTemp = new StringBuffer();
+ for (SyndEntry item : items) {
+ sbTemp.append( "<li>\n");
+ for (Field f : config.getItemFieldOrder()) {
+ renderField(f, FEED_ITEM_CSS_PREFIX,itemProperties,item,sbTemp);
+ }
+ sbTemp.append("</li>\n");
+ }
+ sbGlobal.append(sbTemp.toString()).append("</ul>\n");
+
+ return sbGlobal.toString();
+ }
+
+ protected void renderField(Field f, String cssPrefix, EnumMap<Field, String> properties,Object src,StringBuffer buffer) {
+
+ if (f== Field.LINK) {
+ // do nothing, link should not be called alone but inside name field only
+ return;
+ }
+ String template = templates.get(f);
+ String classname = cssPrefix + classnames.get(f);
+ String prop = properties.get(f);
+
+ if ("".equals(prop)) {
+ return;
+ }
+
+ String result;
+ Object value = null;
+ try {
+
+ value = BeanUtils.getProperty(src, prop);
+ if (f == Field.NAME) {
+ //special case, we must first render link
+ String templateLink = templates.get(Field.LINK);
+ String classnameLink = "feed-" + classnames.get(Field.LINK);
+ String propLink = properties.get(Field.LINK);
+ Object value2 = BeanUtils.getProperty(src, propLink);
+ value = render(templateLink, classnameLink, value2, value);
+ }
+
+ result = render(template, classname, value);
+
+ if (result != null && buffer != null) {
+ buffer.append(result);
+ }
+ } catch (Exception eee) {
+ log.warn("Can't get feed property value for property " + prop + ", value:" + value);
+ }
+
+ }
+
+ /**
+ * Permet de rendre un element du feed
+ *
+ * @param template le template pour rendre l'element
+ * @param classname la class de l'element html (pour une utilisation CSS)
+ * @param value la valeur de l'element
+ * @return le code HTML
+ */
+ protected String render(String template, String classname, Object value) {
+ StringBuffer sb = new StringBuffer();
+ if (value != null && !"".equals(value)) {
+ if (value instanceof String) {
+ // si value est une chaine, on la nettoie avec les cleaners enregistrer
+ for (HTMLCleaner cleaner : cleaners) {
+ value = cleaner.clean((String)value);
+ }
+ }
+ sb.append(renderTemplate(template, classname, value));
+ }
+ return sb.toString();
+ }
+
+ protected String render(String template, String classname, Object value,Object value2) {
+ StringBuffer sb = new StringBuffer();
+ if (value != null && !"".equals(value)) {
+ if (value instanceof String) {
+ // si value est une chaine, on la nettoie avec les cleaners enregistrer
+ for (HTMLCleaner cleaner : cleaners) {
+ value = cleaner.clean((String)value);
+ }
+ }
+ sb.append(renderTemplate(template, classname, value,value2));
+ }
+ return sb.toString();
+ }
+
+ protected String renderTemplate(String template,Object... args) {
+ try {
+ String result;
+ result = String.format(template, args);
+ return result;
+ } catch (Exception e) {
+ log.warn("could not format template "+template+" with args : "+ Arrays.toString(args));
+ return "";
+ }
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,45 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+
+/**
+ *
+ * @author poussin
+ */
+public interface FeedRenderer {
+
+ /**
+ * Retourne une chaine qui est la representation du feed et de ces items
+ *
+ * @param config la configuration a utiliser pour rendre le feed
+ * @param feed le feed a representer
+ * @param items la liste des items du feed a prendre en compte
+ * @return la representation souhaitee
+ */
+ String render(FeedRendererConfig config, SyndFeed feed, SyndEntry[] items);
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,120 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * Permet de spcecifier les champs a rendre, cet objet peut etre converti
+ * en une representation chaine pour etre facilement transportable.
+ * </p>
+ * <p>
+ * Exemple de representation texte: ndat-ndat. Le premier block represente le
+ * feed le second les items. S'il n'y a qu'un block cela veut dire qu'il ne
+ * faut pas reprensenter le feed mais seulement les items. L'ordre des lettres
+ * determine l'ordre du rendu.
+ * <li>n: name pour demander le nom ou titre du feed ou de l'item
+ * <li>i: image
+ * <li>d: description
+ * <li>a: author
+ * <li>t: time pour demander la date du feed ou de l'item
+ * </p>
+ *
+ * @author poussin
+ */
+public class FeedRendererConfig {
+
+ protected String feedString = "indat";
+ protected List<Field> feedList;
+ protected String itemString = "indat";
+ protected List<Field> itemList;
+
+ public FeedRendererConfig() {
+ }
+
+ public FeedRendererConfig(String representation) {
+ setString(representation);
+ }
+
+ protected List<Field> createList(String value) {
+ List<Field> result = new ArrayList<Field>();
+ for (char c : value.toCharArray()) {
+ Field field = Field.valueOf(c);
+ if (field!=null) {
+ result.add(field);
+ }
+ }
+ return result;
+ }
+
+ public List<Field> getFeedFieldOrder() {
+ if (feedList == null) {
+ feedList = createList(feedString);
+ }
+ return feedList;
+ }
+
+ public List<Field> getItemFieldOrder() {
+ if (itemList == null) {
+ itemList = createList(itemString);
+ }
+ return itemList;
+ }
+
+ /**
+ * Permet de modifier la representation souhaitee
+ *
+ * @param f la nouvelle representation par ex: n-na
+ */
+ public void setString(String f) {
+ String [] fi = f.split("-");
+ if (fi.length > 1) {
+ feedString = fi[0];
+ itemString = fi[1];
+ } else {
+ feedString = "";
+ itemString = fi[0];
+ }
+ feedList = null;
+ itemList = null;
+ }
+
+ /**
+ * Permet de retourner la representation string
+ *
+ * @return par ex: n-nad
+ */
+ public String getString() {
+ String result = "";
+ if (!"".equals(feedString)) {
+ result = feedString + "-";
+ }
+ result += itemString;
+ return result;
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,53 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+/**
+ * Enumeration of known feed's type.
+ *
+ * Used to generate some feed files.
+ *
+ * @author tony
+ */
+public enum FeedType {
+
+ RSS_0_90("rss_0.90"),
+ RSS_0_91("rss_0.91"),
+ RSS_0_92("rss_0.92"),
+ RSS_0_93("rss_0.93"),
+ RSS_1_0("rss_1.0"),
+ RSS_2_0("rss_2.0"),
+ ATOM_0_3("atom_0.3"),
+ ATOM_1_0("atom_1.0");
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ private FeedType(String type) {
+ this.type = type;
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,39 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.net.MalformedURLException;
+
+/**
+ * Permet de convertir une chaine en une URL. Le resolver le plus simple
+ * peut créer une URL avec la chaine, mais un autre resolver peut utiliser
+ * cette chaine comme cle dans une base de données pour recuperer la bonne URL.
+ *
+ * @author poussin
+ */
+public interface FeedURLResolver {
+
+ FeedData resolv(String ask) throws MalformedURLException;
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,64 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+/**
+ * Enumeration des champs disponibles pour le renderer
+ *
+ * @author poussin
+ */
+public enum Field {
+
+ NAME('n'), IMAGE('i'), DESCRIPTION('d'), AUTHOR('a'), TIME('t'),LINK('l'),CATEGORY('c');
+
+ /** le caractere utilise pour la version compactee d'une configuration de renderer */
+ private char c;
+
+ Field(char c) {
+ this.c= c;
+ }
+
+ public char getC() {
+ return c;
+ }
+
+ public static Field valueOf(char c) {
+ for (Field field : values()) {
+ if (field.c==c){
+ return field;
+ }
+ }
+ return null;
+ }
+
+ public static Field[] getFeedFields() {
+ return new Field[]{NAME,IMAGE,DESCRIPTION,AUTHOR,TIME,LINK};
+ }
+
+ public static Field[] getItemFields() {
+ return new Field[]{NAME,DESCRIPTION,AUTHOR,TIME,LINK};
+ }
+}
+
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,36 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+/**
+ * Permet de nettoyer une chaine avant incorporation dans du HTML
+ *
+ * @author poussin
+ */
+public interface HTMLCleaner {
+
+ String clean(String s);
+
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,39 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+/**
+ * Supprime les balises <script.*</script> de la chaine
+ *
+ * @author poussin
+ */
+public class HTMLScriptCleaner implements HTMLCleaner {
+
+ public String clean(String s) {
+ String result = s.replaceAll("(?i)(?s)<script.*?</script>", "");
+ return result;
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,87 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+/**
+ * Default configuration for {@link RSSHelper}.
+ *
+ * @author poussin
+ */
+public class RSSConfig {
+
+ /**
+ * la propriete de configuration qui definit le prefix a jouter pour scruter la configuration
+ */
+ private static final String CONFIGURATION_PREFIX_PROPERTY = RSSServlet.class.getSimpleName() + "_configuration_prefix";
+
+
+ /** Temps a partir duquel on reforce une recuperation */
+ public static long TIME_FORCE_RETRIEVED = 5 * 60 * 1000;
+ public static FeedRendererConfig DEFAULT_RENDERER_CONFIG = new FeedRendererConfig("n-natd");
+ public static int DEFAULT_NB_ITEM = 7;
+ public static Class<? extends FeedRenderer> DEFAULT_RENDERER_CLASS = FeedHTMLRenderer.class;
+ public static Class<? extends FeedURLResolver> DEFAULT_RESOLVER_CLASS = SimpleFeedURLResolver.class;
+
+ public void setTIME_FORCE_RETRIEVED(long TIME_FORCE_RETRIEVED) {
+ RSSConfig.TIME_FORCE_RETRIEVED = TIME_FORCE_RETRIEVED;
+ }
+
+ public void setDEFAULT_RENDERER_CONFIG(String DEFAULT_RENDERER_CONFIG) {
+ RSSConfig.DEFAULT_RENDERER_CONFIG = new FeedRendererConfig(DEFAULT_RENDERER_CONFIG);
+ }
+
+ public void setDEFAULT_NBITEM(int DEFAULT_NBITEM) {
+ RSSConfig.DEFAULT_NB_ITEM = DEFAULT_NBITEM;
+ }
+
+ public void setDEFAULT_RENDERER_CLASS(Class<? extends FeedRenderer> DEFAULT_RENDERER_CLASS) {
+ RSSConfig.DEFAULT_RENDERER_CLASS = DEFAULT_RENDERER_CLASS;
+ }
+
+ public void setDEFAULT_RESOLVER_CLASS(Class<? extends FeedURLResolver> DEFAULT_RESOLVER_CLASS) {
+ RSSConfig.DEFAULT_RESOLVER_CLASS = DEFAULT_RESOLVER_CLASS;
+ }
+
+ /**
+ *
+ * @param <S> la classe source de la configuration
+ */
+ public static abstract class RSSConfigInitializer<S> extends ConfigInitializer<S,RSSConfig > {
+
+ /**
+ * Initialise RSSConfig.
+ * @param config la configuration source
+ */
+ public void init(S config) {
+ RSSHelper.log.info("with source "+config);
+ super.init(CONFIGURATION_PREFIX_PROPERTY,RSSConfig.class, config,
+ "TIME_FORCE_RETRIEVED",
+ "DEFAULT_RENDERER_CONFIG",
+ "DEFAULT_NB_ITEM",
+ "DEFAULT_RENDERER_CLASS",
+ "DEFAULT_RESOLVER_CLASS");
+ }
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,331 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * generator of rss feeds to be stored in a file
+ * @author tony
+ */
+public class RSSGenerator {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static final Log log = LogFactory.getLog(RSSGenerator.class);
+ /** date formater use to save date in feed and entries */
+ public static final DateFormat DATE_PARSER = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+
+ /**
+ *
+ * @return une nouvelle instance de RssHelper en utilisant les implantations
+ * definies dans RSSGeneratorConfig.
+ * @throws Exception pour tout pb lors de l'instanciation des objects
+ */
+ public static RSSGenerator newDefaultInstance() throws Exception {
+ RSSGenerator helper = new RSSGenerator();
+ return helper;
+ }
+
+
+ /** dictonnary of field <-> property for feed */
+ protected final EnumMap<Field, String> feedProperties;
+ /** dictonnary of field <-> property for entry */
+ protected final EnumMap<Field, String> itemProperties;
+ /** directory where feeds are stored */
+ protected final File generatorDirectory;
+ /** feed format to use **/
+ protected final FeedType format;
+ /** number of feed to use by default */
+ protected final int nbItems;
+
+ protected RSSGenerator() {
+ this(null);
+ }
+
+ protected RSSGenerator(EnumMap<Field, String> feedProperties, EnumMap<Field, String> itemProperties, File generatorDirectory,FeedType format,int nbItems) {
+ this.feedProperties = feedProperties;
+ this.itemProperties = itemProperties;
+ this.generatorDirectory = generatorDirectory;
+ this.format=format;
+ this.nbItems=nbItems;
+ }
+
+ protected RSSGenerator(File generatorDirectory) {
+
+ feedProperties = new EnumMap<Field, String>(Field.class);
+ feedProperties.put(Field.NAME, "title");
+ feedProperties.put(Field.LINK, "link");
+ // cela engendre des NPE...
+ feedProperties.put(Field.IMAGE, "image.url");
+ feedProperties.put(Field.DESCRIPTION, "description");
+ feedProperties.put(Field.AUTHOR, "author");
+ feedProperties.put(Field.TIME, "publishedDate");
+ feedProperties.put(Field.CATEGORY, "categories");
+
+ itemProperties = new EnumMap<Field, String>(Field.class);
+ itemProperties.put(Field.NAME, "title");
+ itemProperties.put(Field.LINK, "link");
+ itemProperties.put(Field.IMAGE, null);
+ itemProperties.put(Field.DESCRIPTION, "description.value");
+ itemProperties.put(Field.AUTHOR, "author");
+ itemProperties.put(Field.TIME, "publishedDate");
+
+ this.generatorDirectory = generatorDirectory==null?new File(RSSGeneratorConfig.GENERATOR_DIRECTORY):generatorDirectory;
+ format =FeedType.valueOf(RSSGeneratorConfig.DEFAULT_GENERATOR_FORMAT);
+ nbItems = RSSGeneratorConfig.DEFAULT_GENERATOR_NB_ITEM;
+ }
+
+ /**
+ *
+ * @param url location where to create the file
+ * @param type fromat of feed to create
+ * @param values properties of the feed
+ * @throws ParseException if pb while parsing date
+ * @throws IOException if io pb
+ * @throws FeedException if pb while creating feed
+ */
+ public void createFeedFile(URL url, FeedType type, Map<Field, Object> values) throws IOException, FeedException, ParseException {
+ if (url == null) {
+ throw new NullPointerException("can not create a feed with null url");
+ }
+ if (type == null) {
+ throw new NullPointerException("can not create a feed with null feedtype");
+ }
+ if (values == null || values.isEmpty()) {
+ //TODO Should check mandatory values (title, link,...)
+ throw new NullPointerException("can not create a feed with null nor empty values dictonnary");
+ }
+ File f = getFile(url);
+
+ if (f.exists()) {
+ throw new IllegalStateException("feed already existing in " + f.getName());
+ }
+
+ // make sure parent exists
+ f.getParentFile().mkdirs();
+
+ // block until can acquire lock
+ FileLock lock = acquireLock(f);
+
+ try {
+
+ SyndFeed feed = RSSIOUtil.createFeed(feedProperties, type, values);
+
+ RSSIOUtil.saveFeed(f, feed);
+
+ } catch (FeedException e) {
+ // file must not be created
+ f.delete();
+ throw e;
+ } catch (ParseException e) {
+ // file must not be created
+ f.delete();
+ throw e;
+ } finally {
+ releaseLock(f, lock);
+ }
+ }
+
+ /**
+ * Add a item to an existing feed file.
+ *
+ * @param url location of feed to used
+ * @param nbEntries number of maximum entries to be written in feed file
+ * @param values dictionnary of properties to write
+ * @throws FeedException if feed pb
+ * @throws IOException if io pb
+ * @throws ParseException if dateparser pb
+ */
+ public void addItemToFeedFile(URL url, int nbEntries, Map<Field, Object> values) throws IOException, FeedException, ParseException {
+ if (url == null) {
+ throw new NullPointerException("can not add a feed's entry with null url");
+ }
+ if (values == null || values.isEmpty()) {
+ //TODO Should check mandatory values (title, link,...)
+ throw new NullPointerException("can not add a feed's entry with null nor empty values dictonnary");
+ }
+ File f = getFile(url);
+
+ if (!f.exists()) {
+ throw new FileNotFoundException("file not existing " + f);
+ }
+
+ // block until can acquire lock
+ FileLock lock = acquireLock(f);
+
+ try {
+ // get feed
+ SyndFeed feed = RSSIOUtil.readFeed(url);
+
+ // create item
+ SyndEntry item = RSSIOUtil.createFeedItem(itemProperties, values);
+
+ // add item
+ feed = RSSIOUtil.addItemToFeed(feed, item, nbEntries, values);
+
+ // save feed into a tmp file
+ File tmpFile = new File(f.getAbsolutePath() + "-tmp_" + System.nanoTime());
+
+ RSSIOUtil.saveFeed(tmpFile, feed);
+
+ // move tmpFile to real file
+ tmpFile.renameTo(f);
+ } finally {
+ releaseLock(f, lock);
+ }
+ }
+
+ public void deleteFeedFile(URL toURL) {
+ File f = getFile(toURL);
+ if (f.exists() && !f.delete()) {
+ throw new IllegalStateException("could not delete feed " + f.getName());
+ }
+ }
+/**
+ *
+ * @param url
+ * @param values
+ * @return the set of modified fields.
+ * @throws IOException
+ * @throws FeedException
+ * @throws ParseException
+ */
+ public EnumSet<Field> updateFeedFile(URL url,Map<Field,Object> values) throws IOException, FeedException, ParseException {
+ if (url == null) {
+ throw new NullPointerException("can not add a feed's entry with null url");
+ }
+ if (values == null || values.isEmpty()) {
+ //TODO Should check mandatory values (title, link,...)
+ throw new NullPointerException("can not add a feed's entry with null nor empty values dictonnary");
+ }
+ File f = getFile(url);
+
+ if (!f.exists()) {
+ throw new FileNotFoundException("file not existing " + f);
+ }
+
+ // block until can acquire lock
+ FileLock lock = acquireLock(f);
+
+ try {
+
+ SyndFeed feed =RSSIOUtil.readFeed(url);
+
+ // update feed and keep trace of modified fields
+ EnumSet<Field> modifieds = RSSIOUtil.updateFeed(feed,feedProperties, values);
+
+ // save feed into a tmp file
+ File tmpFile = new File(f.getAbsolutePath() + "-tmp_" + System.nanoTime());
+
+ RSSIOUtil.saveFeed(tmpFile, feed);
+
+ // move tmpFile to real file
+ tmpFile.renameTo(f);
+
+ // feed link has changed
+ return modifieds;
+ } finally {
+ releaseLock(f, lock);
+ }
+ }
+
+ public FeedType getFormat() {
+ return format;
+ }
+
+ public File getFeedFile(String name) {
+ return new File(getGeneratorDirectory(),name+".xml");
+ }
+
+ public int getNbItems() {
+ return nbItems;
+ }
+
+ /**
+ * Obtain the file from his url location.
+ *
+ * @param url location of the file
+ * @return the file
+ * @throws IllegalStateException if uri is not sytax valid
+ */
+ protected File getFile(URL url) throws IllegalStateException {
+ try {
+ return new File(url.toURI());
+ } catch (URISyntaxException e) {
+ throw new IllegalStateException("could not obtain file from url " + url, e);
+ }
+ }
+
+ protected FileLock acquireLock(File f) throws IOException {
+ File lockFile = getWriteFileLock(f);
+
+ /*if (!lockFile.exists()) lockFile.createNewFile(); */
+ // open file for writing only
+ FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel();
+
+ // block until can acquire lock
+
+ return channel.lock();
+ }
+
+ protected File getWriteFileLock(File f) {
+ return new File(f.getParentFile(), f.getName() + ".wlock");
+ }
+
+ protected void releaseLock(File f, FileLock lock) throws IOException {
+ // release lock
+ lock.release();
+ // close channel
+ lock.channel().close();
+ // delete file lock
+ File lockFile = getWriteFileLock(f);
+ // delete lock file
+ lockFile.delete();
+ }
+
+ public File getGeneratorDirectory() {
+ return generatorDirectory;
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,89 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.io.File;
+
+/**
+ *
+ * Default Configuration for {@link RSSGenerator}.
+ *
+ * @author chemit
+ */
+public class RSSGeneratorConfig {
+
+ /**
+ * la propriete de configuration qui definit le prefix a jouter pour scruter la configuration
+ */
+ private static final String CONFIGURATION_PREFIX_PROPERTY = RSSGeneratorServlet.class.getSimpleName() + "_configuration_prefix";
+ /** nombre d'items max à ecrire dans le fichier du flux */
+ public static int DEFAULT_GENERATOR_NB_ITEM = 100;
+ /** le format par défaut duflux à générer */
+ public static String DEFAULT_GENERATOR_FORMAT = "RSS_2_0";
+ /** le répertoire où générer les flux */
+ public static String GENERATOR_DIRECTORY = "/tmp/rssinclude";
+ /** le caractère séparateur des listes de métas (categorie par exemple) */
+ public static String DEFAULT_LIST_SEPARATOR = ";";
+
+ public void setDEFAULT_GENERATOR_NB_ITEM(int DEFAULT_GENERATOR_NB_ITEM) {
+ RSSGeneratorConfig.DEFAULT_GENERATOR_NB_ITEM = DEFAULT_GENERATOR_NB_ITEM;
+ }
+
+ public void setDEFAULT_GENERATOR_FORMAT(String DEFAULT_GENERATOR_FORMAT) {
+ RSSGeneratorConfig.DEFAULT_GENERATOR_FORMAT = DEFAULT_GENERATOR_FORMAT;
+ }
+
+ public void setGENERATOR_DIRECTORY(String GENERATOR_DIRECTORY) {
+ RSSGeneratorConfig.GENERATOR_DIRECTORY = GENERATOR_DIRECTORY;
+ }
+
+ public void setDEFAULT_LIST_SEPARATOR(String DEFAULT_LIST_SEPARATOR) {
+ RSSGeneratorConfig.DEFAULT_LIST_SEPARATOR = DEFAULT_LIST_SEPARATOR;
+ }
+ /**
+ *
+ * @param <S> la classe source de la configuration
+ */
+ public static abstract class RssGeneratorConfigInitializer<S> extends ConfigInitializer<S,RSSGeneratorConfig> {
+
+ /**
+ * Initialise RSSGeneratorConfig.
+ * @param config la configuration source
+ */
+ public void init(S config) {
+ RSSGenerator.log.info("with source "+config);
+
+ super.init(CONFIGURATION_PREFIX_PROPERTY,RSSGeneratorConfig.class, config,
+ "DEFAULT_GENERATOR_NB_ITEM",
+ "DEFAULT_GENERATOR_FORMAT",
+ "DEFAULT_LIST_SEPARATOR",
+ "GENERATOR_DIRECTORY");
+
+ // create delegate directory
+ new File(GENERATOR_DIRECTORY).mkdirs();
+
+ }
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,244 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import java.io.*;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+/**
+ * <p>
+ * Servlet permettant de generer des flux generes par RSSGenerator et de
+ * les publier.
+ *
+ * @author chemit
+ */
+public class RSSGeneratorServlet extends BaseServlet<RSSGenerator> {
+
+ private static final long serialVersionUID = 1L;
+
+ public void doCreateFeed(HttpServletRequest request, HttpServletResponse response, String feedName, File file) throws ServletException, IOException {
+ String type = request.getParameter("feedType");
+ FeedType feedType = null;
+ if (type != null) {
+ try {
+ feedType = FeedType.valueOf(type);
+ } catch (Exception e) {
+ feedType = null;
+ }
+ }
+ if (feedType == null) {
+ feedType = delegate.getFormat();
+ }
+ String description = request.getParameter("feedDescription");
+ String link = request.getParameter("feedLink");
+ String author = request.getParameter("feedAuthor");
+ String categories = request.getParameter("feedCategories");
+ Map<Field, Object> values = new HashMap<Field, Object>();
+ values.put(Field.NAME, feedName);
+ addFieldValue(Field.DESCRIPTION, description, values);
+ addFieldValue(Field.LINK, link, values);
+ addFieldValue(Field.AUTHOR, author, values);
+ addFieldValue(Field.CATEGORY, categories, values);
+ values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date()));
+ try {
+ delegate.createFeedFile(file.toURI().toURL(), feedType, values);
+ } catch (Exception ex) {
+ throw new ServletException(ex);
+ }
+
+ String redirect = request.getParameter("from");
+ if (redirect != null) {
+ response.sendRedirect(redirect);
+ }
+ }
+
+ public void doDeleteFeed(HttpServletRequest request, HttpServletResponse response, String feedName, File file) throws ServletException, IOException {
+ try {
+ delegate.deleteFeedFile(file.toURI().toURL());
+ } catch (Exception ex) {
+ throw new ServletException(ex);
+ }
+
+ String redirect = request.getParameter("from");
+ if (redirect != null) {
+ response.sendRedirect(redirect);
+ }
+ }
+
+ public void doAddItem(HttpServletRequest request, HttpServletResponse response, String feedName, File file) throws ServletException, IOException {
+
+ Integer nbItems = convertToInt(request.getParameter("nbItems"));
+ if (nbItems == null) {
+ nbItems = RSSGeneratorConfig.DEFAULT_GENERATOR_NB_ITEM;
+ }
+ String description = request.getParameter("itemDescription");
+ String link = request.getParameter("itemLink");
+ String author = request.getParameter("itemAuthor");
+ String name = request.getParameter("itemName");
+
+ Map<Field, Object> values = new HashMap<Field, Object>();
+ addFieldValue(Field.NAME, name, values);
+ addFieldValue(Field.DESCRIPTION, description, values);
+ addFieldValue(Field.LINK, link, values);
+ addFieldValue(Field.AUTHOR, author, values);
+ values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date()));
+ try {
+ delegate.addItemToFeedFile(file.toURI().toURL(), nbItems, values);
+ } catch (Exception ex) {
+ throw new ServletException(ex);
+ }
+
+ String redirect = request.getParameter("from");
+ if (redirect != null) {
+ response.sendRedirect(redirect);
+ }
+ }
+
+ public void doList(HttpServletResponse response) throws IOException {
+ // obtain the list of known feeds
+ File[] files = delegate.getGeneratorDirectory().listFiles(new FileFilter() {
+
+ public boolean accept(File pathname) {
+ return pathname.isFile() && pathname.getName().endsWith(".xml");
+ }
+ });
+ response.setContentType("text/xml;charset=UTF-8");
+ PrintWriter out = response.getWriter();
+
+ try {
+ if (files.length > 0) {
+ String format = "<option value=\"%1$s\">%1$s</option>";
+ for (File f : files) {
+ String name = f.getName();
+ out.println(String.format(format, name.substring(0, name.length() - 4)));
+ }
+ } else {
+ out.println("<span class='error'>no feed generated</span>");
+ }
+ } finally {
+ out.close();
+ }
+ }
+
+ public void doShow(File file, String feedName, HttpServletResponse response) throws ServletException, IOException {
+ // no action, just publication
+ if (!file.exists()) {
+ throw new ServletException("could not find feed " + feedName);
+ }
+ response.setContentType("text/xml;charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ SyndFeed feed = RSSIOUtil.readFeed(file.toURI().toURL());
+ RSSIOUtil.saveFeed(out, feed);
+ } catch (IllegalArgumentException ex) {
+ throw new ServletException(ex);
+ } catch (FeedException ex) {
+ throw new ServletException(ex);
+ } finally {
+ out.close();
+ }
+ }
+
+ @Override
+ protected ConfigInitializer<ServletConfig, ?> newConfigInitializer() {
+ return new RSSGeneratorConfig.RssGeneratorConfigInitializer<ServletConfig>() {
+
+ protected String getConfigValue(ServletConfig config, String fullConfigName) {
+ return config.getInitParameter(fullConfigName);
+ }
+ };
+ }
+
+ @Override
+ protected RSSGenerator newDelegate() throws Exception {
+ return RSSGenerator.newDefaultInstance();
+ }
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws IOException TODO
+ * @throws ServletException TODO
+ */
+ @Override
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ String action = request.getParameter("action");
+ if (action == null) {
+ action = "";
+ }
+ action = action.trim().toLowerCase();
+ if ("list".equals(action)) {
+ doList(response);
+ return;
+ }
+
+ String feedName = request.getParameter("feedName");
+
+ if (feedName == null || "".equals(feedName)) {
+ throw new ServletException("could not find feedName parameter");
+ }
+ //feedName =new String(feedName.getBytes(),0,feedName.length(),Charset.forName("utf-8"));
+ File file = new File(delegate.getGeneratorDirectory(), feedName + ".xml");
+
+ if ("show".equals(action)) {
+ doShow(file, feedName, response);
+ return;
+ }
+
+ if ("create".equals(action)) {
+ doCreateFeed(request, response, feedName, file);
+ return;
+ }
+
+ if ("delete".equals(action)) {
+ doDeleteFeed(request, response, feedName, file);
+ return;
+ }
+
+ if ("additem".equals(action)) {
+ doAddItem(request, response, feedName, file);
+ return;
+ }
+
+ throw new ServletException("action '" + action + "' is unknown ");
+
+ }
+
+ protected void addFieldValue(Field field, String value, Map<Field, Object> values) {
+ if (value != null && !"".equals(value.trim())) {
+ values.put(field, value);
+ }
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,151 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.net.MalformedURLException;
+import java.util.List;
+
+/**
+ * @author poussin
+ */
+public class RSSHelper {
+
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
+ static final Log log = LogFactory.getLog(RSSHelper.class);
+
+ /**
+ * @return une nouvelle instance de RssHelper en utilisant les implantations
+ * definies dans RSSConfig.
+ * @throws Exception pour tout pb lors de l'instanciation des objects
+ */
+ public static RSSHelper newDefaultInstance() throws Exception {
+ FeedURLResolver r = RSSConfig.DEFAULT_RESOLVER_CLASS.newInstance();
+ FeedRenderer rr = RSSConfig.DEFAULT_RENDERER_CLASS.newInstance();
+ RSSHelper helper = new RSSHelper(r, rr);
+ return helper;
+ }
+
+ /**
+ * La classe permettant de resoudre les urls
+ */
+ protected FeedURLResolver resolver;
+ /**
+ * on utilise des soft reference pour eviter de trop utiliser la memoire
+ * key: String, value: FeedData
+ */
+ protected ReferenceMap feeds = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
+ protected FeedRenderer renderer;
+
+ /**
+ * Utilise un SimpleFeedURLResolver comme resolver de feed
+ */
+ public RSSHelper() {
+ this(new SimpleFeedURLResolver(), new FeedHTMLRenderer(new HTMLScriptCleaner()));
+ }
+
+ public RSSHelper(FeedURLResolver resolver, FeedRenderer renderer) {
+ this.resolver = resolver;
+ this.renderer = renderer;
+ }
+
+ public void setResolver(FeedURLResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ public void setRenderer(FeedRenderer renderer) {
+ this.renderer = renderer;
+ }
+
+ public FeedRenderer getRenderer() {
+ return renderer;
+ }
+
+ public FeedURLResolver getResolver() {
+ return resolver;
+ }
+
+ public void removeFeed(String feedName) {
+ feeds.remove(feedName);
+ }
+
+ /**
+ * Permet de recuperer un certain nombre d'item du feed demande
+ *
+ * @param feedName nom du feed souhaite, l'url sera resolu avec le FeedURLResolver
+ * @param representation indique les champs en sortie souhaites (ex: n-nt)
+ * @param nbItem le nombre d'item du feed souhaite
+ * @param forceReload un flag pour forcer la relecture du feed
+ * @return le code html representant le feed
+ */
+ public String getHTML(String feedName, String representation, Integer nbItem, boolean forceReload) {
+ try {
+ FeedData feed = (FeedData) feeds.get(feedName);
+ if (forceReload || feed == null || feed.getLastRetrived() + RSSConfig.TIME_FORCE_RETRIEVED < System.currentTimeMillis()) {
+ feed = resolver.resolv(feedName);
+ if (feed == null) {
+ log.warn("could not find feed for " + feedName);
+ return "<span class='feed-error'>No feed found for " + feedName + "</span>";
+ }
+ feeds.put(feedName, feed);
+ }
+
+ FeedRendererConfig c;
+ if (representation != null) {
+ c = new FeedRendererConfig(representation);
+ } else {
+ c = feed.getRendererConfig();
+ }
+
+ int nb;
+ if (nbItem != null) {
+ nb = nbItem;
+ } else {
+ nb = feed.getNbItem();
+ }
+
+ SyndFeed sf = feed.getFeed();
+ //TODO Deal with NPE... if feed is null
+ List<?> syndEntries = sf.getEntries();
+ if (nb >= 0 && syndEntries.size() >= nb) {
+ syndEntries = syndEntries.subList(syndEntries.size() - nb, syndEntries.size());
+ }
+ SyndEntry[] items = syndEntries.toArray(new SyndEntry[syndEntries.size()]);
+
+ String result = renderer.render(c, sf, items);
+ return result;
+ } catch (MalformedURLException eee) {
+ log.warn("Can't resolv feed url: " + feedName, eee);
+ return "<span class='feed-error'>" + eee.getMessage() + "</span>";
+ }
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,253 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import com.sun.syndication.feed.synd.SyndCategory;
+import com.sun.syndication.feed.synd.SyndCategoryImpl;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.SyndFeedOutput;
+import com.sun.syndication.io.XmlReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.IllegalArgumentException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * helper to read or save a feed
+ * @author tony
+ */
+public class RSSIOUtil {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static final Log log = LogFactory.getLog(RSSIOUtil.class);
+
+ /**
+ * Load a feed from his url
+ * @param url location of feed
+ * @return the java pojo feed
+ * @throws IllegalArgumentException
+ * @throws FeedException
+ * @throws IOException
+ */
+ public static SyndFeed readFeed(URL url) throws IllegalArgumentException, FeedException, IOException {
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed feed = input.build(new XmlReader(url));
+ return feed;
+ }
+
+ /**
+ * save a feed into a file.
+ * @param file
+ * @param feed
+ * @throws IOException
+ * @throws FeedException
+ */
+ public static void saveFeed(File file, SyndFeed feed) throws IOException, FeedException {
+ SyndFeedOutput output = new SyndFeedOutput();
+ output.output(feed, file);
+ }
+
+ /**
+ * save a feed into a writer.
+ * @param writer
+ * @param feed
+ * @throws IOException
+ * @throws FeedException
+ */
+ public static void saveFeed(Writer writer, SyndFeed feed) throws IOException, FeedException {
+ SyndFeedOutput output = new SyndFeedOutput();
+ output.output(feed, writer);
+ }
+
+ public static SyndFeed createFeed(EnumMap<Field, String> feedProperties, FeedType type, Map<Field, Object> values) throws ParseException {
+ SyndFeed feed = new SyndFeedImpl();
+ feed.setFeedType(type.getType());
+ feed.setEncoding("utf-8");
+ fillFeed(values, feedProperties, feed, false);
+ return feed;
+ }
+
+ public static EnumSet<Field> updateFeed(URL url, EnumMap<Field, String> feedProperties, Map<Field, Object> values) throws ParseException, IllegalArgumentException, FeedException, IOException {
+ SyndFeed feed = RSSIOUtil.readFeed(url);
+ return updateFeed(feed, feedProperties, values);
+ }
+
+ public static EnumSet<Field> updateFeed(SyndFeed feed, EnumMap<Field, String> feedProperties, Map<Field, Object> values) throws ParseException, IllegalArgumentException, FeedException, IOException {
+ EnumSet<Field> modifieds = fillFeed(values, feedProperties, feed, true);
+ return modifieds;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected static SyndFeed addItemToFeed(SyndFeed feed, SyndEntry item, int nbEntries, Map<Field, Object> values) throws IOException, IllegalArgumentException, FeedException, ParseException {
+ List<SyndEntry> entries = feed.getEntries();
+ if (!entries.isEmpty()) {
+ // always sort by publication date
+ Collections.sort(entries, new FeedEntryComparator());
+ // keep only nbEntries -1 entries
+ while (entries.size() > nbEntries - 1) {
+ entries.remove(0);
+ }
+ }
+ entries.add(item);
+ if (log.isDebugEnabled()) {
+ log.debug("new item " + item);
+ }
+ return feed;
+ }
+
+ public static SyndEntry createFeedItem(EnumMap<Field, String> itemProperties, Map<Field, Object> values) throws ParseException {
+
+ SyndEntry feedEntry = new SyndEntryImpl();
+
+ for (Entry<Field, Object> entry : values.entrySet()) {
+ Field field = entry.getKey();
+ String name = itemProperties.get(field);
+ if (name == null) {
+ // this field is not managed
+ log.warn("the field " + field + " is not managed in item");
+ continue;
+ }
+ Object value = entry.getValue();
+ Object realValue;
+ switch (field) {
+ case TIME:
+ realValue = RSSGenerator.DATE_PARSER.parse((String) value);
+ break;
+ case DESCRIPTION:
+ //TODO Deal with xml content ?
+ SyndContent description = new SyndContentImpl();
+ description.setType("text/plain");
+ feedEntry.setDescription(description);
+ realValue = String.valueOf(value);
+ break;
+ default:
+ realValue = value;
+ }
+ setFieldValue(feedEntry, name, realValue);
+ }
+
+ return feedEntry;
+ }
+
+ protected static EnumSet<Field> fillFeed(Map<Field, Object> values, EnumMap<Field, String> feedProperties, SyndFeed feed, boolean treateModfied) throws ParseException {
+ EnumSet<Field> modifieds = EnumSet.noneOf(Field.class);
+
+ for (Entry<Field, Object> entry : values.entrySet()) {
+ Field field = entry.getKey();
+ String name = feedProperties.get(field);
+ if (name == null) {
+ // this field is not managed
+ log.warn("the field " + field + " is not managed in feed");
+ continue;
+ }
+ Object value = entry.getValue();
+ Object realValue;
+ switch (field) {
+ case TIME:
+ realValue = RSSGenerator.DATE_PARSER.parse((String) value);
+ break;
+ case CATEGORY:
+ List<String> categoriesAsList = new ArrayList<String>();
+ if (value instanceof List) {
+ categoriesAsList = (List) value;
+ } else {
+ // categories as String
+ String cats = String.valueOf(value);
+ String[] categories = cats.split(RSSGeneratorConfig.DEFAULT_LIST_SEPARATOR);
+ categoriesAsList = Arrays.asList(categories);
+ }
+ realValue = new ArrayList<SyndCategory>();
+ for (String cat : categoriesAsList) {
+ SyndCategory scat = new SyndCategoryImpl();
+ scat.setName(cat);
+ ((List) realValue).add(scat);
+ }
+ break;
+ default:
+ realValue = value;
+ }
+ if (treateModfied) {
+ Object oldValue = getFieldValue(feed, name);
+ if (oldValue == null) {
+ if (realValue != null) {
+ modifieds.add(field);
+ }
+ } else {
+ if (!oldValue.equals(realValue)) {
+ modifieds.add(field);
+ }
+ }
+ }
+ setFieldValue(feed, name, realValue);
+ }
+ return modifieds;
+ }
+
+ protected static void setFieldValue(Object dst, String name, Object value) {
+ if (value == null) {
+ // null value is not managed
+ log.warn("null value for field " + name + " is not managed");
+ return;
+ }
+ try {
+ BeanUtils.setProperty(dst, name, value);
+ } catch (Exception ex) {
+ log.warn("could not access property " + name, ex);
+ }
+ }
+
+ protected static Object getFieldValue(Object dst, String name) {
+ try {
+ return BeanUtils.getProperty(dst, name);
+ } catch (Exception ex) {
+ log.warn("could not access property " + name, ex);
+ return null;
+ }
+ }
+
+ protected RSSIOUtil() {
+ // no instance
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,179 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.io.*;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+/**
+ * <p>
+ * Servlet permettant de retourner un feed RSSHelper en une representation HTML.
+ * Si la servlet est appele sans parametre alors le code JS permettant d'utiliser
+ * cette servlet en Ajax est retourne.
+ * </p><p>
+ * Sinon la servlet peut prendre en parametre:
+ * <li> feedName: le nom du feed souhaite
+ * <li> nbItem: le nombre d'item du feed a retourner
+ * <li> feedRepr: le chaine permettant de connaitre les champs du feed voulu
+ * </p><p>
+ * Utilisation dans une page HTML. Dans le header ajouter
+ * <pre>
+ * <script src="url/to/RSSServlet"></script>
+ * </pre>
+ * Dans le corps placer un element div avec un id particulier.
+ * Et soit a la fin de la page soit juste apres le div, ajouter le script
+ * <pre>
+ * rssinclude('feedName', 'divid', 5, 'n-n');
+ * </pre>
+ * </p>
+ * @author poussin
+ */
+public class RSSServlet extends BaseServlet<RSSHelper> {
+
+ /**
+ * Le code JavaScript a utilise dans les pages clientes
+ *
+ * Provient du fichier rssinclude.js
+ * cat rssinclude.js |sed 's/"/\\"/g' |sed -re 's/^(.*)$/"\1\\n" +/'
+ */
+ protected static String js =
+ "function rssincludeUpdateDiv(div, background) {\n" +
+ " // mettre background a false est utile lorsque l'on appelle la methode\n" +
+ " // depuis une fenetre que l'on ferme ensuite\n" +
+ " var serlvetUrl = \"%1$s\"; \n" +
+ " win = window;\n" +
+ " var xhr = null;\n" +
+ " var error=null;\n" +
+ " var feedName = div.getAttribute(\"feedName\");\n" +
+ " if (!feedName) // pas de feed name, fatal error\n" +
+ " error = \"<span class='feed-error'>Aucun feed name detecte...</span>\"; \n" +
+ " else if(win.XMLHttpRequest) // Firefox, Opera detected\n" +
+ " xhr = new win.XMLHttpRequest();\n" +
+ " else if(win.ActiveXObject) // Internet Explorer detected\n" +
+ " xhr = new win.ActiveXObject(\"Microsoft.XMLHTTP\");\n" +
+ " else // XMLHttpRequest non supporte par le navigateur\n" +
+ " error = \"<span class='feed-error'>Votre navigateur ne supporte pas les objets XMLHTTPRequest...</span>\"; \n" +
+ " if (!!error) { div.innerHTML = error; return; } \n" +
+ " \n" +
+ " var nbItem = div.getAttribute(\"nbItem\");\n" +
+ " var feedRepr = div.getAttribute(\"feedRepr\"); \n" +
+ " var forceReload = div.getAttribute(\"forceReload\"); \n" +
+ " var url = serlvetUrl+(serlvetUrl.indexOf('?')>-1?'&':'?')+\"feedName=\" + escape(feedName); \n" +
+ " if (!!nbItem) {url += '&nbItem=' + escape(nbItem);} \n" +
+ " if (!!feedRepr) {url += '&feedRepr=' + escape(feedRepr);}\n" +
+ " if (!!forceReload) {url += '&forceReload=true';}\n" +
+ "\n" +
+ " xhr.open(\"GET\", url, !!background);\n" +
+ " xhr.onreadystatechange = function() {\n" +
+ " if(xhr.readyState == 1) div.innerHTML = \"Chargement du flux '\"+feedName+\"'\";\n" +
+ " if(xhr.readyState == 4) div.innerHTML = xhr.responseText;\n" +
+ " }\n" +
+ " xhr.send(null);\n" +
+ "}\n" +
+ "var initRss =function () {\n" +
+ " var divs = document.getElementsByTagName(\"div\"); \n" +
+ " var i = 0;var max=divs.length; \n" +
+ " var toTreate = [];\n" +
+ " while (i < max) {\n" +
+ " var div = divs[i++];\n" +
+ " if (div.getAttribute('name')=='rssinclude') toTreate[toTreate.length] = div;\n" +
+ " }\n" +
+ " i=0;max = toTreate.length;\n" +
+ " while (i<max) rssincludeUpdateDiv(toTreate[i++], true);" +
+ "}\n" +
+ "if (window.addEventListener) window.addEventListener( 'load', initRss,false);\n" +
+ "else if (window.attachEvent) window.attachEvent( 'onload', initRss);";
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @param url current url to add in script
+ * @return the rssinclude script, patched with url
+ */
+ public static String getJs(String url) {
+ String code = String.format(js, url);
+ return code;
+ }
+
+ public void doJs(HttpServletResponse response, HttpServletRequest request) throws IOException {
+ // on renvoie le code js
+ response.setContentType("text/plain;charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ String code = getJs(request.getRequestURL().toString());
+ out.println(code);
+ } finally {
+ out.close();
+ }
+ }
+
+ public void doRender(HttpServletResponse response, HttpServletRequest request, String feedName) throws IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ String feedRepr = request.getParameter("feedRepr");
+ Integer nbItem = convertToInt(request.getParameter("nbItem"));
+ boolean forceReload = "true".equalsIgnoreCase(request.getParameter("forceReload"));
+ out.println(delegate.getHTML(feedName, feedRepr, nbItem, forceReload));
+ } finally {
+ out.close();
+ }
+ }
+
+ @Override
+ protected ConfigInitializer<ServletConfig,? > newConfigInitializer() {
+ return new RSSConfig.RSSConfigInitializer<ServletConfig>() {
+
+ protected String getConfigValue(ServletConfig config, String fullConfigName) {
+ return config.getInitParameter(fullConfigName);
+ }
+ };
+ }
+
+ @Override
+ protected RSSHelper newDelegate() throws Exception {
+ return RSSHelper.newDefaultInstance();
+ }
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws IOException TODO
+ * @throws ServletException TODO
+ */
+ @Override
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ String feedName = request.getParameter("feedName");
+ if (feedName == null || "".equals(feedName)) {
+ doJs(response, request);
+ } else {
+ doRender(response, request, feedName);
+ }
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java
===================================================================
--- trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java (rev 0)
+++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,45 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Par defaut retourne un FeedData ou la chaine passer est convertie en URL,
+ * le nombre d'item est positionne a -1 et le renderer a n-natd
+ * @author poussin
+ */
+public class SimpleFeedURLResolver implements FeedURLResolver {
+
+ public FeedData resolv(String ask) throws MalformedURLException {
+ URL url = new URL(ask);
+ FeedData result = new FeedData(url);
+ result.setNbItem(RSSConfig.DEFAULT_NB_ITEM);
+ result.setRendererConfig(RSSConfig.DEFAULT_RENDERER_CONFIG);
+ return result;
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt
===================================================================
--- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt (rev 0)
+++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,15 @@
+This plugin was developped by Code Lutin
+
+Installation Instructions
+1. Copy rssinclude directory into "editor/plugins/"
+
+2. Copy myfckconfig.js in fckeditor root path and customize it (or merge the
+ content in your already customized config...)
+
+3. To create an editor use this code
+
+var oFCKeditor = new FCKeditor( 'editorName' ) ;
+oFCKeditor.Config["CustomConfigurationsPath"] = oFCKeditor.BasePath+"/myfckconfig.js";
+oFCKeditor.Create() ;
+
+Please let me know if you experience any issues.
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/button.rss.gif
===================================================================
(Binary files differ)
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/button.rss.gif
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html
===================================================================
--- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html (rev 0)
+++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,163 @@
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!--
+ * FCKeditor - The text editor for internet
+ * Copyright (C) 2003-2004 Frederico Caldeira Knabben
+ *
+ * Licensed under the terms of the GNU Lesser General Public License:
+ * http://www.opensource.org/licenses/lgpl-license.php
+ *
+ * For further information visit:
+ * http://www.fckeditor.net/
+ *
+ * File Name: fck_image.html
+ * Image Properties dialog window.
+ *
+ * Version: 2.0 Beta 2
+ * Modified: 2004-06-19 00:24:56
+ *
+ * File Authors:
+ * hmlyons (hmlyons(a)users.sourceforge.net)
+ * Andrey Grebnev (andrey.grebnev(a)blandware.com)
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Rss Include Properties</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="robots" content="noindex, nofollow">
+ <script src="../../dialog/common/fck_dialog_common.js" type="text/javascript"></script>
+ <script src="fck_rssinclude.js" type="text/javascript"></script>
+ <link href="../../dialog/common/fck_dialog_common.css" rel="stylesheet" type="text/css" />
+ <style type="text/css">div.rssinclude { background-color: #ffff00; }</style>
+ <script type="text/javascript">
+ <!--
+ document.writeln(FCK.TempBaseTag);
+ -->
+ </script>
+ </head>
+ <body scroll="no">
+ <div id="divInfo">
+ <table cellspacing="1" cellpadding="1" border="0" width="100%" height="100%">
+ <tr>
+ <td>
+ <table cellspacing="0" cellpadding="0" width="100%" border="0">
+ <tr>
+ <td valign="top" width="100%">
+ <span fckLang="DlgRssincludeFeedName">name or URL</span><br>
+ <div id="divFeedName" style="margin-top:2">
+ <input style="width: 100%" type="text" id="txtFeedName" onblur="updatePreview();">
+ </div>
+ <a id="editFeed" href='#' fckLang="DlgRssincludeFeedNameEdit" target="_editFeed">Edit</a>
+ <a id="addFeed" href='#' fckLang="DlgRssincludeFeedNameAdd" target="_addFeed">Add</a>
+ <script type="text/javascript">
+ <!--
+ var editWidget = document.getElementById('editFeed');
+ var addWidget = document.getElementById('addFeed');
+
+ if (!FCKConfig.RssCanEditFeed) {
+ editWidget.style.display='none';
+ } else {
+ editWidget.href='#';
+ /** lors de la sortie, on fixe l'url du lien edit pour ce qui est selectionné */
+ editWidget.onclick = function changeEdit() {
+ var input = document.getElementById("txtFeedName");
+ editWidget.href = FCKConfig.RssEditURL+ escape(input.value);
+ };
+
+ }
+ if (!FCKConfig.RssCanAddFeed) {
+ addWidget.style.display='none';
+ } else {
+ addWidget.href = FCKConfig.RssAddURL;
+ }
+ -->
+ </script>
+ </td>
+ </tr>
+ </table>
+ <hr width="100%" color="#000000" size="2">
+ </td>
+ </tr>
+ <tr height="100%">
+ <td valign="top">
+ <table cellspacing="0" cellpadding="0" width="100%" border="0" height="100%">
+ <tr>
+ <td height="140" valign="top">
+ <br>
+ <table cellspacing="2" cellpadding="1" border="0">
+ <tr>
+ <td><span fckLang="DlgRssincludeNbItem">Item's number</span> </td>
+ <td><input type="text" size="3" id="txtNbItem" onblur="updatePreview();"></td>
+ </tr>
+ <tr>
+ <td><span fckLang="DlgRssincludeFeedRepr">feed representation</span> </td>
+ <td><input type="text" size="10" id="txtFeedRepr" onblur="updatePreview();"></td>
+ </tr>
+ </table>
+ </td>
+ <td> </td>
+ <td width="100%" valign="top">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><span fckLang="DlgImgPreview">Preview</span></td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <div class="ImagePreviewArea">
+ <div
+ id="rssincludePreview"
+ name="rssinclude"
+ class="rssinclude">
+ </div>
+
+ Magnus es, domine, et laudabilis
+ valde: magna virtus tua, et sapientiae tuae non est numerus. et laudare te vult
+ homo, aliqua portio creaturae tuae, et homo circumferens mortalitem suam,
+ circumferens testimonium peccati sui et testimonium, quia superbis resistis: et
+ tamen laudare te vult homo, aliqua portio creaturae tuae.tu excitas, ut laudare
+ te delectet, quia fecisti nos ad te et inquietum est cor nostrum, donec
+ requiescat in te. da mihi, domine, scire et intellegere, utrum sit prius
+ invocare te an laudare te, et scire te prius sit an invocare te. sed quis te
+ invocat nesciens te? aliud enim pro alio potest invocare nesciens. an potius
+ invocaris, ut sciaris? quomodo autem invocabunt, in quem non crediderunt? aut
+ quomodo credent sine praedicante? et laudabunt dominum qui requirunt eum.
+ quaerentes enim inveniunt eum et invenientes laudabunt eum. quaeram te, domine,
+ invocans te, et invocem te credens in te: praedicatus enim es nobis. invocat
+ te, domine, fides mea, quam dedisti mihi, quam inspirasti mihi per humanitatem
+ filii tui, per ministerium praedicatoris tui.
+ </div>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </body>
+</html>
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js
===================================================================
--- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js (rev 0)
+++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,159 @@
+var dialog = window.parent;
+var oEditor = dialog.InnerDialogLoaded();
+var FCK = oEditor.FCK;
+var FCKLang = oEditor.FCKLang;
+var FCKConfig = oEditor.FCKConfig;
+var FCKTools = oEditor.FCKTools;
+
+// Set the language direction.
+window.document.dir = oEditor.FCKLang.Dir;
+
+// load rssinclude script
+document.writeln("<script type=\"text/javascript\" src=\""+FCKConfig.RssScriptURL+"\"></script>");
+
+// Recuperation du feed selectionne
+var oRss = dialog.Selection.GetSelectedElement();
+
+// Un peu de travail au chargement de la page
+window.onload = function()
+{
+ // Translate the dialog box texts.
+ oEditor.FCKLanguageManager.TranslatePage(document);
+
+ // chargement de la combo avec les feeds configures
+ LoadCombo();
+
+ // Load the selected element information (if any).
+ LoadSelection();
+
+ // Activate the "OK" button.
+ window.parent.SetOkButton( true );
+
+ SelectField( 'txtFeedName' );
+}
+
+/**
+ * Remplace le textfield de saisie du nom d'un feed par une combo.
+ * Cela n'est fait que si le serveur peut etre contacte
+ */
+function LoadCombo() {
+ var xhr = null;
+ if(window.XMLHttpRequest) // Firefox
+ xhr = new window.XMLHttpRequest();
+ else if(window.ActiveXObject) // Internet Explorer
+ xhr = new window.ActiveXObject("Microsoft.XMLHTTP");
+
+ if (xhr) {
+ xhr.open("GET", FCKConfig.RssKnownFeedsURL, true);
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState == 4 && xhr.status == 200) /* 200 : code HTTP pour OK */
+ {
+ var content = '<select style="WIDTH: 100%" id="txtFeedName" onblur="updatePreview(this);">'+
+ xhr.responseText + '</select>';
+ document.getElementById("divFeedName").innerHTML = content;
+ if (oRss) {
+ // on selectionne l'ancienne valeur
+ GetE('txtFeedName').value = GetAttribute( oRss, 'feedname', '' );
+ }
+ }
+ }
+ xhr.send(null);
+ }
+}
+
+/**
+ * Chargement du feed que l'on re-edite
+ */
+function LoadSelection() {
+ if (! oRss) return;
+ GetE('txtFeedName').value = GetAttribute( oRss, 'feedname', '' );
+ GetE('txtNbItem').value = GetAttribute( oRss, 'nbitem', '' );
+ GetE('txtFeedRepr').value = GetAttribute( oRss, 'feedrepr', '' );
+
+ updatePreview();
+}
+
+/**
+ * Fonction appeler lors de la validation
+ */
+function Ok()
+{
+ if ( GetE('txtFeedName').value.length == 0 )
+ {
+ GetE('txtFeedName').focus();
+
+ alert( oEditor.FCKLang.DlgRssincludeAlertFeedName );
+ return false ;
+ }
+
+ oEditor.FCKUndo.SaveUndoStep();
+ if ( !oRss )
+ {
+ oRss = FCK.InsertElement( 'DIV' ) ;
+ if (!detectScript()) {
+ // add script to editor only once
+ oScript = FCK.InsertElement('SCRIPT');
+ SetAttribute( oScript, 'src', FCKConfig.RssScriptURL);
+ }
+ }
+ updateRss( oRss );
+
+ // rssincludeUpdateDiv(oRss, false);
+ return true;
+}
+
+/**
+ * Detection de la presence ou non du script rssinclude dans l'edition
+ */
+function detectScript() {
+ var scripts = FCK.GetXHTML();
+ return (scripts.indexOf("src=\""+FCKConfig.RssScriptURL+"\"")!=-1);
+}
+
+/**
+ * Mise a jour d'un div avec les informations trouvees dans l'interface
+ */
+function updateRss(e){
+ e.contentEditable = false;
+
+ SetAttribute( e, 'class', 'rssinclude');
+ SetAttribute( e, 'contentEditable', 'false');
+ SetAttribute( e, 'name', 'rssinclude');
+ SetAttribute( e, 'feedname', GetE('txtFeedName').value );
+ SetAttribute( e, 'nbitem', GetE('txtNbItem').value );
+ SetAttribute( e, 'feedrepr', GetE('txtFeedRepr').value );
+ //SetAttribute( e, 'forceReload', 'true' );
+ e.innerHTML = 'RSS ' + GetE('txtFeedName').value + ' (items:'+GetE('txtNbItem').value+')';
+}
+
+// L'element servant a la preview
+var ePreview ;
+
+/**
+ * Mise a jour du flux dans la preview
+ * @param combo la combo utilisee (undefined si uniquement un input)
+ */
+function updatePreview(combo){
+
+ if ( !ePreview ) {
+ ePreview = GetE('rssincludePreview');
+ }
+
+ if ( ! ePreview) {
+ return;
+ }
+
+ if ( GetE('txtFeedName').value.length == 0 ) {
+ ePreview.innerHTML = 'Invalid RSS';
+ } else {
+ if (!!combo) {
+ // mise à jour des champs à partir de l'option selectionne
+ var index = combo.options.selectedIndex;
+ var option = combo.options[index];
+ GetE('txtNbItem').value = GetAttribute( option, 'nbitem', '' )
+ GetE('txtFeedRepr').value = GetAttribute( option, 'feedrepr', '' )
+ }
+ updateRss(ePreview);
+ rssincludeUpdateDiv(ePreview, true);
+ }
+}
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js
===================================================================
--- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js (rev 0)
+++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,53 @@
+// Register the related commands.
+var dialogPath = FCKConfig.PluginsPath + 'rssinclude/fck_rssinclude.html';
+var rssincludeDialogCmd = new FCKDialogCommand( FCKLang["DlgRssincludeTitle"], FCKLang["DlgRssincludeTitle"], dialogPath, 480, 470 );
+FCKCommands.RegisterCommand( 'rssinclude', rssincludeDialogCmd ) ;
+
+// Create the Rssinclude toolbar button.
+var oRssincludeItem = new FCKToolbarButton( 'rssinclude', FCKLang["DlgRssincludeTitle"]) ;
+oRssincludeItem.IconPath = FCKConfig.PluginsPath + 'rssinclude/button.rss.gif' ;
+
+FCKToolbarItems.RegisterItem( 'rssinclude', oRssincludeItem ) ;
+// 'Rssinclude' is the name used in the Toolbar config.
+
+FCK.ContextMenu.RegisterListener( {
+ AddItems : function( menu, tag, tagName ) {
+ var e = tag;
+ if (! (e && e.nodeName == 'DIV' && e.getAttribute('name') == 'rssinclude' )) {
+ var selection = FCKSelection.GetSelection() ;
+ var range = selection.getRangeAt(0) ;
+ e = range.endContainer ;
+ while (e && (e.nodeName != 'DIV' || e.getAttribute('name') != 'rssinclude')) {
+ e = e.parentNode;
+ }
+ }
+
+ // under what circumstances do we display this option
+ if (!!e && e.nodeName == 'DIV' && e.getAttribute('name') == 'rssinclude' ) {
+ FCKSelection.SelectNode(e);
+ // when the option is displayed, show a separator the command
+ menu.AddSeparator() ;
+ // the command needs the registered command name, the title for the context menu, and the icon path
+ menu.AddItem( 'rssinclude', FCKLang.DlgRssincludeTitle, oRssincludeItem.IconPath ) ;
+ }
+ }
+} );
+
+/**
+OnClick = function( e )
+{
+ if ( e.target.tagName == 'DIV' && e.target.getAttribute('class') == 'rssinclude' )
+ FCKSelection.SelectNode( e.target ) ;
+}
+
+FCK.EditorDocument.addEventListener( 'click', OnClick, true ) ;
+**/
+
+OnDoubleClick = function( e ) {
+ if ( e.tagName == 'DIV' && e.getAttribute('name') == 'rssinclude' ) {
+ FCKSelection.SelectNode(e);
+ FCKCommands.GetCommand( 'rssinclude' ).Execute() ;
+ }
+}
+
+FCK.RegisterDoubleClickHandler( OnDoubleClick, 'DIV' ) ;
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js
===================================================================
--- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js (rev 0)
+++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,9 @@
+// Rssinclude Dialog
+FCKLang["DlgRssincludeTitle"] = "Rss Include";
+FCKLang["DlgRssincludeFeedName"] = "name or URL" ;
+FCKLang["DlgRssincludeFeedNameEdit"] = "Edit" ;
+FCKLang["DlgRssincludeFeedNameAdd"] = "Add" ;
+FCKLang["DlgRssincludeNbItem"] = "item's number" ;
+FCKLang["DlgRssincludeFeedRepr"] = "Feed representation" ;
+FCKLang["DlgRssincludeAlertFeedName"] = "Please input the feed name or feed URL"
+FCKLang["DlgRssincludeLoading"] = "Loading rss..."
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js
===================================================================
--- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js (rev 0)
+++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,9 @@
+// Rssinclude Dialog
+FCKLang["DlgRssincludeTitle"] = "Rss Include";
+FCKLang["DlgRssincludeFeedName"] = "nom ou URL" ;
+FCKLang["DlgRssincludeFeedNameEdit"] = "Edition" ;
+FCKLang["DlgRssincludeFeedNameAdd"] = "Ajout" ;
+FCKLang["DlgRssincludeNbItem"] = "nombre d'item" ;
+FCKLang["DlgRssincludeFeedRepr"] = "Feed representation" ;
+FCKLang["DlgRssincludeAlertFeedName"] = "Veuillez entrer un nom ou une URL pour le feed"
+FCKLang["DlgRssincludeLoading"] = "Chargement du rss..."
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js
===================================================================
--- trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js (rev 0)
+++ trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,65 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * Editor configuration settings.
+ *
+ * Follow this link for more information:
+ * http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Configurations_…
+ */
+
+FCKConfig.Plugins.Add("rssinclude", "en,fr");
+
+FCKConfig.ToolbarSets["Default"] = [
+ ['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
+ ['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
+ ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
+ ['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
+ '/',
+ ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
+ ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
+ ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
+ ['Link','Unlink','Anchor'],
+ ['rssinclude', 'Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
+ '/',
+ ['Style','FontFormat','FontName','FontSize'],
+ ['TextColor','BGColor'],
+ ['FitWindow','ShowBlocks','-','About'] // No comma for the last row.
+] ;
+
+// to authorize user to add a new feed
+FCKConfig.RssCanAddFeed = false;
+
+// to authorize user to edit a known feed
+FCKConfig.RssCanEditFeed = false;
+
+// url to render a feed
+FCKConfig.RssRenderURL = '/nuitonrss-2.4/RSSServlet&feedName=' ;
+
+// url to obtain rssinclude script
+FCKConfig.RssScriptURL = '/nuitonrss-2.4/RSSServlet' ;
+
+// url to obtain known feeds as a list of html options
+FCKConfig.RssKnownFeedsURL = '/nuitonrss-2.4/feeds.txt' ;
+
+// url to create a new feed
+FCKConfig.RssAddURL = '';
+
+// url to edit a known feed
+FCKConfig.RssEditURL = '' ;
Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/resources/log4j.properties
===================================================================
--- trunk/nuiton-rss/src/main/resources/log4j.properties (rev 0)
+++ trunk/nuiton-rss/src/main/resources/log4j.properties 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,33 @@
+###
+# #%L
+# Nuiton Utils :: Nuiton RSS
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+#log4j.appender.stdout.layout.ConversionPattern=%%c=%c %%C=%C %%d=%d %%F=%F %%l=%l %%L=%L %%m=%m %%M=%M %%p=%p %%r=%r %%t=%t %%x=%x %%X=%X
+# package level
+log4j.logger.org.nuiton.rss=INFO
Property changes on: trunk/nuiton-rss/src/main/resources/log4j.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <display-name>RSSServlet</display-name>
+
+ <servlet>
+ <servlet-name>RSSServlet</servlet-name>
+ <servlet-class>org.nuiton.rss.RSSServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>RSSServlet</servlet-name>
+ <url-pattern>/RSSServlet</url-pattern>
+ </servlet-mapping>
+ <servlet>
+ <servlet-name>RSSGeneratorServlet</servlet-name>
+ <servlet-class>org.nuiton.rss.RSSGeneratorServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>RSSGeneratorServlet</servlet-name>
+ <url-pattern>/RSSGeneratorServlet</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Property changes on: trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/feed.css
===================================================================
--- trunk/nuiton-rss/src/main/webapp/feed.css (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/feed.css 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+.rssinclude {
+ border: 1px dotted black;
+}
+
+.rss-feed {
+ display: block;
+}
+
+.rss-items {
+ clear: both;
+ display: block;
+}
+
+.rss-items li {
+ clear: both;
+ display: block;
+}
+
+.feed-name {
+ font-weight: bold;
+ color: blue;
+ display: block;
+}
+
+.feed-link {
+ font-size: 10px;
+}
+
+.feed-time{
+ font-size: 10px;
+ clear: both;
+ display: block;
+}
+
+.feed-image {
+ /*float: right;*/
+ border: 1px dotted black;
+ margin: 0 0 15px 20px;
+}
+
+.feed-description {
+ clear: both;
+ display: block;
+ font-style: italic;
+ color: green;
+ font-size: 10px;
+}
+
+.feed-author {
+ color: black;
+ font-size: 10px;
+}
+
+.feedItem-name {
+ font-weight: bold;
+ color: red;
+ display: block;
+ clear: both;
+ font-size: 10px;
+}
+
+.feedItem-link {
+ font-size: 10px;
+}
+
+.feedItem-description {
+ font-style: italic;
+ color: gray;
+ font-size: 10px;
+ clear: both;
+ display: block;
+}
+
+.feedItem-author {
+ color: black;
+ font-size: 10px;
+ clear: both;
+ display: block;
+}
+
+.feedItem-time{
+ font-size: 10px;
+ clear: both;
+ display: block;
+}
Property changes on: trunk/nuiton-rss/src/main/webapp/feed.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/feeds.txt
===================================================================
--- trunk/nuiton-rss/src/main/webapp/feeds.txt (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/feeds.txt 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,7 @@
+<option value="http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml" nbitem="1" feedrepr="indat-natd">le monde informatique</option>
+<option value="http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml" nbitem="2" feedrepr="indat-natd">le monde</option>
+<option value="http://blog.developpez.com/xmlsrv/rss2.php?blog=42" nbitem="3" feedrepr="indat-natd">developpez.com</option>
+<option value="http://formats-ouverts.org/rss.php" nbitem="4" feedrepr="indat-natd">formats ouverts</option>
+<option value="http://www.h2database.com/html/newsfeed-rss.xml" nbitem="5" feedrepr="indat-natd">h2</option>
+<option value="http://www.opensi.org/news.rss" nbitem="6" feedrepr="indat-natd">opensi</option>
+
Property changes on: trunk/nuiton-rss/src/main/webapp/feeds.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/index.html
===================================================================
--- trunk/nuiton-rss/src/main/webapp/index.html (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/index.html 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,45 @@
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!--
+ Document : test
+ Created on : 18 avr. 2008, 11:46:56
+ Author : poussin
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Page de tests</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+ <body>
+ <h1>NuitonRSS tests index</h1>
+ <ul>
+ <li><a href="testRender.html" target="render">Test de rendu</a></li>
+ <li><a href="testGenerator.html" target="generator">Test de génération de flux</a></li>
+ <li><a href="testFck.html" target="fck">Test du plugin rssinclude dans fckeditor 2.6</a> (*)</li>
+ </ul>
+ <p>(*) required a FCKEditor 2.6 available on / apache path (means /fckeditor points to fckeditor root directory)</p>
+</body>
+</html>
Property changes on: trunk/nuiton-rss/src/main/webapp/index.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/rssgenerator.js
===================================================================
--- trunk/nuiton-rss/src/main/webapp/rssgenerator.js (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/rssgenerator.js 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,47 @@
+function rssgeneratorUpdateDiv(divs) {
+ var serlvetUrl = "RSSGeneratorServlet?action=list";
+ win = window;
+ var xhr = null;
+ var error=null;
+ if(win.XMLHttpRequest) // Firefox, Opera detected
+ xhr = new win.XMLHttpRequest();
+ else if(win.ActiveXObject) // Internet Explorer detected
+ xhr = new win.ActiveXObject("Microsoft.XMLHTTP");
+ else // XMLHttpRequest non supporte par le navigateur
+ error = "<span class='feed-error'>Votre navigateur ne supporte pas les objets XMLHTTPRequest...</span>";
+ if (!!error) { updateDiv(divs,false,error); return; }
+
+ xhr.open("GET", serlvetUrl, true);
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState == 1) { updateDiv(divs,false,"Chargement de la liste des feeds en cours..."); }
+ else if(xhr.readyState == 4) { updateDiv(divs,true,xhr.responseText); }
+ }
+ xhr.send(null);
+}
+
+var initRssGenerator =function () {
+ var divs = document.getElementsByTagName("div");
+ var i = 0;var max=divs.length;
+ var toTreate = [];
+ while (i < max) {
+ var div = divs[i++];
+ if (div.getAttribute('name')=='rssgeneratorlist') toTreate[toTreate.length] = div;
+ }
+ rssgeneratorUpdateDiv(toTreate);
+}
+var updateDiv= function(divs,select,text) {
+ var i=0;
+ var max = divs.length;
+ while (i<max) {
+ var divText=text;
+ var div = divs[i++];
+ if (!!select && text.indexOf("error")==-1) {
+ var name = div.getAttribute("action");
+ divText = "<select name='"+name+"' length='50'>" + text+"</select>"
+ }
+ div.innerHTML =divText;
+ }
+}
+// load initRssGenerator
+if (window.addEventListener) window.addEventListener( 'load', initRssGenerator,false);
+else if (window.attachEvent) window.attachEvent( 'onload', initRssGenerator);
Property changes on: trunk/nuiton-rss/src/main/webapp/rssgenerator.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/rssinclude.js
===================================================================
--- trunk/nuiton-rss/src/main/webapp/rssinclude.js (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/rssinclude.js 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,49 @@
+function rssincludeUpdateDiv(div, background) {
+ // mettre background a false est utile lorsque l'on appelle la methode
+ // depuis une fenetre que l'on ferme ensuite
+ //var serlvetUrl = "%1$1";
+ var serlvetUrl = "http://localhost:8083/nuitonrss-2.4/RSSServlet";
+ win = window;
+ var xhr = null;
+ var error=null;
+ var feedName = div.getAttribute("feedName");
+ if (!feedName) // pas de feed name, fatal error
+ error = "<span class='feed-error'>Aucun feed name detecte...</span>";
+ else if(win.XMLHttpRequest) // Firefox, Opera detected
+ xhr = new win.XMLHttpRequest();
+ else if(win.ActiveXObject) // Internet Explorer detected
+ xhr = new win.ActiveXObject("Microsoft.XMLHTTP");
+ else // XMLHttpRequest non supporte par le navigateur
+ error = "<span class='feed-error'>Votre navigateur ne supporte pas les objets XMLHTTPRequest...</span>";
+ if (!!error) { div.innerHTML = error; return; }
+
+ var nbItem = div.getAttribute("nbItem");
+ var feedRepr = div.getAttribute("feedRepr");
+ var forceReload = div.getAttribute("forceReload");
+ var url = serlvetUrl+(serlvetUrl.indexOf('?')>-1?'&':'?')+"feedName=" + escape(feedName);
+ if (!!nbItem) {url += '&nbItem=' + escape(nbItem);}
+ if (!!feedRepr) {url += '&feedRepr=' + escape(feedRepr);}
+ if (!!forceReload) {url += '&forceReload=true';}
+
+ xhr.open("GET", url, !!background);
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState == 1) div.innerHTML = "Chargement du flux '"+feedName+"' en cours...";
+ if(xhr.readyState == 4) div.innerHTML = xhr.responseText;
+ }
+ xhr.send(null);
+}
+
+var initRss =function () {
+ var divs = document.getElementsByTagName("div");
+ var i = 0;var max=divs.length;
+ var toTreate = [];
+ while (i < max) {
+ var div = divs[i++];
+ if (div.getAttribute('name')=='rssinclude') toTreate[toTreate.length] = div;
+ }
+ i=0;max = toTreate.length;
+ while (i<max) rssincludeUpdateDiv(toTreate[i++], true);
+}
+if (window.addEventListener) window.addEventListener( 'load', initRss,false);
+else if (window.attachEvent) window.attachEvent( 'onload', initRss);
+
Property changes on: trunk/nuiton-rss/src/main/webapp/rssinclude.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/testFck.html
===================================================================
--- trunk/nuiton-rss/src/main/webapp/testFck.html (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/testFck.html 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,72 @@
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!--
+ Document : test
+ Created on : 18 avr. 2008, 11:46:56
+ Author : poussin
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Page de test plugin FCKEditor rss</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <!--link href="feed.css" rel="stylesheet" type="text/css" /-->
+ <script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
+ <style type="text/css">div.rssinclude { background-color: #ffff00; }</style>
+</head>
+<body>
+<h1>Test plugin FCKEditor RSS (*)</h1>
+<form name="EditPostView" action="#" method="GET">
+ <script type="text/javascript">
+ <!--
+ var oFCKeditor = new FCKeditor( 'rssTest' ) ;
+ oFCKeditor.Config["CustomConfigurationsPath"] = oFCKeditor.BasePath+"/myfckconfig.js";
+
+ var content = "<div contenteditable='false' class=\"rssinclude\" name=\"rssinclude\" feedname=\"http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml\" nbitem=\"2\" feedrepr=\"n-n\">RSS http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml (items:2)</div><br></br>";
+ //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml\" nbitem=\"2\" feedrepr=\"indat-natd\" \">RSS http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml (items:2)</div><br/>";
+ //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://blog.developpez.com/xmlsrv/rss2.php?blog=42\" nbitem=\"3\" feedRepr=\"indat-natd\" \">RSS http://blog.developpez.com/xmlsrv/rss2.php?blog=42 (items:3)</div><br/>";
+ //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://formats-ouverts.org/rss.php\" nbitem=\"4\" feedrepr=\"indat-natd\" \">RSS http://formats-ouverts.org/rss.php (items:4)</div><br/>";
+ //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://www.h2database.com/html/newsfeed-rss.xml\" nbitem=\"5\" feedRepr=\"indat-natd\" \">RSS http://www.h2database.com/html/newsfeed-rss.xml (items:5)</div><br/>";
+ //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://www.opensi.org/news.rss\" nbitem=\"6\" feedrepr=\"indat-natd\" \">RSS http://www.opensi.org/news.rss (items:6)</div>";
+ content += "<s"+"cript src=\"/nuitonrss-2.4/RSSServlet\"></scri"+"pt><hr/><p>content...</p>";
+ oFCKeditor.Value = content;
+ oFCKeditor.Create() ;
+ -->
+ </script>
+ <hr/>
+ <input type="submit" value="envoyer">
+</form>
+<p>(*) required a FCKEditor 2.6 available on / apache path (means /fckeditor points to fckeditor root directory)</p>
+<p>add custom config like this code :
+ <pre>
+var oFCKeditor = new FCKeditor( 'rssTest' ) ;
+oFCKeditor.Config["CustomConfigurationsPath"] = oFCKeditor.BasePath+"/myfckconfig.js";
+oFCKeditor.Create() ;
+ </pre>
+</p>
+
+
+</body>
+</html>
Property changes on: trunk/nuiton-rss/src/main/webapp/testFck.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/testGenerator.html
===================================================================
--- trunk/nuiton-rss/src/main/webapp/testGenerator.html (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/testGenerator.html 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,132 @@
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!--
+ Document : test
+ Created on : 18 avr. 2008, 11:46:56
+ Author : poussin
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>Page de test de génération de flux rss</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <style type="text/css">
+ .error {color:red; display:block;}
+ fieldset {height:140px;}
+ iframe { width:100%;height:400px;}
+ </style>
+ <script src="rssgenerator.js"></script>
+ <script>
+ var doAction=function(action) {
+ var form = document.feeds;
+ form.action.value=action;
+ if (action=='show'){
+ //form.method='get';
+ form.target='content';
+ } else {
+ //form.action.value=action;
+ //form.method='post';
+ form.target='';
+ }
+ return true;
+ }
+ </script>
+ </head>
+ <body>
+ <h1>Test RSS Generator</h1>
+ <table width="100%">
+ <tr>
+ <td width="50%" valign="top">
+ <form method="post" action="RSSGeneratorServlet">
+ <fieldset>
+ <legend> <input type="submit" value="create a new feed"> </legend>
+ <input type="hidden" name="action" value="create">
+ <input type="hidden" name="from" value="testGenerator.html">
+ <table>
+ <tr>
+ <td>feedName (*) :</td>
+ <td><input name="feedName" type="text" size="50"></td>
+ </tr>
+ <tr>
+ <td>feedDescription (*) : </td>
+ <td><input name="feedDescription" type="text" size="50"></td>
+ </tr>
+ <tr>
+ <td>feedLink (*) : </td>
+ <td><input name="feedLink" type="text" size="50"></td>
+ </tr>
+ <tr>
+ <td>feedAuthor : </td>
+ <td><input name="feedAuthor" type="text" size="50"></td>
+ </tr>
+ <tr>
+ <td>feedCategories : </td>
+ <td><input name="feedCategories" type="text" size="50"></td>
+ </tr>
+ <tr><td style="font-size:11px">(*) Mandatory field</td></tr>
+ </table>
+ </fieldset>
+ </form>
+ </td>
+ <td width="50%" valign="top">
+ <form name="feeds" method="post" action="RSSGeneratorServlet">
+ <fieldset>
+ <legend> <input type="submit" value="add item to feed" onclick="return doAction('addItem');">
+ <input type="submit" value="delete feed" onclick="return doAction('delete');">
+ <input type="submit" value="show feed" onclick="return doAction('show');"> </legend>
+ <input type="hidden" name="from" value="testGenerator.html">
+ <input type="hidden" name="action" value="">
+ <table>
+ <tr>
+ <td>feedName :</td>
+ <td>
+ <div name="rssgeneratorlist" action="feedName"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>itemName :</td>
+ <td><input name="itemName" type="text" size="50"></td>
+ </tr>
+ <tr>
+ <td>itemDescription: </td>
+ <td><input name="itemDescription" type="text" size="50"></td>
+ </tr>
+ <tr>
+ <td>itemLink : </td>
+ <td><input name="itemLink" type="text" size="50"></td>
+ </tr>
+ <tr>
+ <td>itemAuthor : </td>
+ <td><input name="itemAuthor" type="text" size="50"></td>
+ </tr>
+ </table>
+ </fieldset>
+ </form>
+ </td>
+ </tr>
+ </table>
+ <iframe name="content" scrolling="yes" frameborder="1"></iframe>
+ </body>
+</html>
Property changes on: trunk/nuiton-rss/src/main/webapp/testGenerator.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/main/webapp/testRender.html
===================================================================
--- trunk/nuiton-rss/src/main/webapp/testRender.html (rev 0)
+++ trunk/nuiton-rss/src/main/webapp/testRender.html 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,47 @@
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!--
+ Document : test
+ Created on : 18 avr. 2008, 11:46:56
+ Author : poussin
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Page de test rss</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <link href="feed.css" rel="stylesheet" type="text/css" />
+ <script src="RSSServlet"></script>
+</head>
+ <body>
+ <h1>Test RSS</h1>
+ <div name="rssinclude" class="rssinclude" feedName="http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml" nbItem="1" feedRepr="indat-natd"></div>
+ <div name="rssinclude" class="rssinclude" feedName="http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml" nbItem="2" feedRepr="indat-natd"></div>
+ <div name="rssinclude" class="rssinclude" feedName="http://blog.developpez.com/xmlsrv/rss2.php?blog=42" nbItem="3" feedRepr="indat-natd"></div>
+ <div name="rssinclude" class="rssinclude" feedName="http://formats-ouverts.org/rss.php" nbItem="4" feedRepr="indat-natd"></div>
+ <div name="rssinclude" class="rssinclude" feedName="http://www.h2database.com/html/newsfeed-rss.xml" nbItem="5" feedRepr="indat-natd"></div>
+ <div name="rssinclude" class="rssinclude" feedName="http://www.opensi.org/news.rss" nbItem="6" feedRepr="indat-natd"></div>
+</body>
+</html>
Property changes on: trunk/nuiton-rss/src/main/webapp/testRender.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/site/apt/index.apt
===================================================================
--- trunk/nuiton-rss/src/site/apt/index.apt (rev 0)
+++ trunk/nuiton-rss/src/site/apt/index.apt 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,50 @@
+~~~
+~~ #%L
+~~ Nuiton Utils :: Nuiton RSS
+~~
+~~ $Id$
+~~ $HeadURL$
+~~ %%
+~~ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+~~ %%
+~~ This program is free software: you can redistribute it and/or modify
+~~ it under the terms of the GNU Lesser General Public License as
+~~ published by the Free Software Foundation, either version 3 of the
+~~ License, or (at your option) any later version.
+~~
+~~ This program is distributed in the hope that it will be useful,
+~~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~~ GNU General Lesser Public License for more details.
+~~
+~~ You should have received a copy of the GNU General Lesser Public
+~~ License along with this program. If not, see
+~~ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+~~ #L%
+~~~
+ ----
+ Nuiton RSS
+ ----
+ ----
+ 2009-08-23
+ ----
+
+Présentation
+
+ A faire...
+
+Utilisation
+===========
+
+ A faire ...
+
+--------------------------------------------------------------------------------
+ <script src="nuitonrss.js">
+ rss("rss1", "url", max, login, password)
+ </script>
+ <div id="rss1"></div>
+--------------------------------------------------------------------------------
+
+- si pas de fichier html pour l'url demandée ou plus vielle que N
+ - récupération de de l'url et sauvegarde en html
+- renvoi du html
\ No newline at end of file
Property changes on: trunk/nuiton-rss/src/site/apt/index.apt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/site/site_fr.xml
===================================================================
--- trunk/nuiton-rss/src/site/site_fr.xml (rev 0)
+++ trunk/nuiton-rss/src/site/site_fr.xml 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Nuiton RSS
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: trunk/nuiton-rss/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java
===================================================================
--- trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java (rev 0)
+++ trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,236 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.sun.syndication.feed.synd.SyndCategory;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+
+/**
+ *
+ * @author tony
+ */
+public class RSSGeneratorHelperTest {
+
+ private static Log log = LogFactory.getLog(RSSGeneratorHelperTest.class);
+
+ static RSSGenerator helper;
+ static File f;
+
+ @Before
+ public void setUp() throws Exception {
+ if (helper == null) {
+ helper = RSSGenerator.newDefaultInstance();
+ }
+ if (f == null) {
+ f = getFeedFile();
+ }
+ }
+
+ @Test
+ public void testCreateFeed() throws Exception {
+
+ Map<Field, Object> values = new HashMap<Field, Object>();
+ values.put(Field.NAME, "feedName : " + f.getName());
+ values.put(Field.DESCRIPTION, "feedDescription : " + f.getName());
+ values.put(Field.LINK, f.toURI().toURL() + "");
+ values.put(Field.AUTHOR, "feed author");
+ values.put(Field.CATEGORY, Arrays.asList("categorie1","categorie2"));
+ values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date()));
+
+ Assert.assertFalse(f.exists());
+ if (log.isInfoEnabled()) {
+ log.info("feedFile : " + f);
+ }
+ helper.createFeedFile(f.toURI().toURL(), helper.getFormat(), values);
+ // no lock
+ Assert.assertFalse(helper.getWriteFileLock(f).exists());
+ // file exist
+ Assert.assertTrue(f.exists());
+
+ SyndFeed feed = RSSIOUtil.readFeed(f.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug(feed);
+ }
+
+ Assert.assertEquals(feed.getFeedType(), helper.getFormat().getType());
+ Assert.assertEquals(feed.getLink(), values.get(Field.LINK));
+ Assert.assertEquals(feed.getTitle(), values.get(Field.NAME));
+ Assert.assertEquals(feed.getDescription(), values.get(Field.DESCRIPTION));
+ Assert.assertEquals(feed.getAuthor(), values.get(Field.AUTHOR));
+ List<?> cats = (List<?>) values.get(Field.CATEGORY);
+ for (Object o : feed.getCategories()) {
+ SyndCategory cat = (SyndCategory) o;
+ Assert.assertTrue(cats.contains(cat.getName()));
+ }
+ Assert.assertEquals(feed.getPublishedDate(), RSSGenerator.DATE_PARSER.parse((String) values.get(Field.TIME)));
+
+ }
+
+ @Test
+ public void testCreateFeedAlreadyExisting() throws Exception {
+
+ Map<Field, Object> values = new HashMap<Field, Object>();
+ values.put(Field.NAME, "feedName : " + f.getName());
+ values.put(Field.DESCRIPTION, "feedDescription : " + f.getName());
+ values.put(Field.LINK, f.toURI().toURL() + "");
+ values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date()));
+
+ Assert.assertTrue(f.exists());
+
+ try {
+ helper.createFeedFile(f.toURI().toURL(), helper.getFormat(), values);
+ // file already exist, can not reach this code
+ Assert.fail();
+ } catch (IllegalStateException e) {
+ Assert.assertTrue(true);
+ }
+ // no write lock
+ Assert.assertFalse(helper.getWriteFileLock(f).exists());
+
+ }
+
+ @Test
+ public void testAddFeedEntry() throws Exception {
+ Assert.assertTrue(f.exists());
+ Map<Field, Object> values = createEntry(0);
+
+ helper.addItemToFeedFile(f.toURI().toURL(), 2, values);
+
+ SyndFeed feed = RSSIOUtil.readFeed(f.toURI().toURL());
+
+ List entries = feed.getEntries();
+ Assert.assertEquals(1, entries.size());
+
+ if (log.isDebugEnabled()) {
+ log.debug(feed);
+ }
+
+ SyndEntry entry = (SyndEntry) entries.get(0);
+
+ assertEntry(entry, values);
+ }
+
+ @Test
+ public void testAddFeedEntryToMax() throws Exception {
+
+ Assert.assertTrue(f.exists());
+ SyndFeed feed = RSSIOUtil.readFeed(f.toURI().toURL());
+
+ List entries = feed.getEntries();
+ Assert.assertEquals(1, entries.size());
+ SyndEntry firsEntry = (SyndEntry) entries.get(0);
+
+ Map<Field, Object> values;
+
+ int nbMaxEntries = 10;
+
+ for (int i = 1; i < nbMaxEntries; i++) {
+ values = createEntry(i);
+ helper.addItemToFeedFile(f.toURI().toURL(), nbMaxEntries, values);
+ feed = RSSIOUtil.readFeed(f.toURI().toURL());
+
+ entries = feed.getEntries();
+ Assert.assertEquals(i + 1, entries.size());
+
+ SyndEntry entry = (SyndEntry) entries.get(i);
+
+ assertEntry(entry, values);
+ }
+
+ // feed file contains max items
+
+ values = createEntry(nbMaxEntries);
+
+ helper.addItemToFeedFile(f.toURI().toURL(), nbMaxEntries, values);
+
+ feed = RSSIOUtil.readFeed(f.toURI().toURL());
+
+ entries = feed.getEntries();
+
+ Assert.assertEquals(nbMaxEntries, entries.size());
+
+ SyndEntry entry = (SyndEntry) entries.get(nbMaxEntries - 1);
+
+ assertEntry(entry, values);
+
+ // check orginal first entry is no more present
+ entry = (SyndEntry) entries.get(0);
+ Assert.assertFalse(firsEntry.getTitle().equals(entry.getTitle()));
+ }
+
+ @Test
+ public void testCleanFile() throws Exception {
+ try {
+ Assert.assertNotNull(f);
+ Assert.assertTrue(f.exists());
+ // lock is delete
+ Assert.assertFalse(helper.getWriteFileLock(f).exists());
+ } finally {
+ if (f != null) {
+ f.deleteOnExit();
+ }
+ }
+ }
+
+ protected void assertEntry(SyndEntry entry, Map<Field, Object> values) throws ParseException {
+ Assert.assertEquals(entry.getLink(), values.get(Field.LINK));
+ Assert.assertEquals(entry.getTitle(), values.get(Field.NAME));
+ Assert.assertEquals(entry.getDescription().getValue(), values.get(Field.DESCRIPTION));
+ Assert.assertEquals(entry.getAuthor(), values.get(Field.AUTHOR));
+ Assert.assertEquals(entry.getPublishedDate(), RSSGenerator.DATE_PARSER.parse((String) values.get(Field.TIME)));
+ }
+
+ protected File getFeedFile() {
+ return helper.getFeedFile(getClass().getSimpleName() + "-" + System.nanoTime());
+ }
+
+ protected Map<Field, Object> createEntry(int number) throws MalformedURLException {
+ Map<Field, Object> values = new HashMap<Field, Object>();
+ values.put(Field.NAME, "entryName : " + f.getName() + "-" + number);
+ values.put(Field.DESCRIPTION, "entryDescription : " + f.getName() + "-" + number);
+ values.put(Field.AUTHOR, "author-" + number);
+ values.put(Field.LINK, f.toURI().toURL() + "/entry-" + number);
+ values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date()));
+ return values;
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java
===================================================================
--- trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java (rev 0)
+++ trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,112 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton RSS
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.rss;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ * @author poussin
+ */
+public class RSSTest {
+
+ @Test
+ public void testBeanUtils() throws Exception {
+// RSSConfig.class.getField("TIME_FORCE_RETRIEVED").set(null, 10);
+ System.out.println("TIME:" + RSSConfig.TIME_FORCE_RETRIEVED);
+ System.out.println("RENDER:" + RSSConfig.DEFAULT_RENDERER_CLASS);
+ BeanUtils.setProperty(new RSSConfig(), "TIME_FORCE_RETRIEVED", "10");
+ BeanUtils.setProperty(new RSSConfig(), "DEFAULT_RENDERER_CLASS", FeedRenderer.class.getName());
+ System.out.println("TIME:" + RSSConfig.TIME_FORCE_RETRIEVED);
+ System.out.println("RENDER:" + RSSConfig.DEFAULT_RENDERER_CLASS);
+ Assert.assertEquals("java.lang.String", BeanUtils.getProperty("Object", "class.name"));
+ }
+
+ @Test
+ public void testCleaner() throws Exception {
+ String s = "debut<Script src='toto.js'>et du script</scRipt>milieu<scripT>encore du code\n</script>fin";
+
+ HTMLCleaner cleaner = new HTMLScriptCleaner();
+ Assert.assertEquals("debutmilieufin", cleaner.clean(s));
+ }
+
+ @Test
+ public void testRendererConfig() throws Exception {
+ FeedRendererConfig c = new FeedRendererConfig("indat-ndat");
+
+ List<Field> l1 = new ArrayList<Field>();
+ l1.add(Field.IMAGE);
+ l1.add(Field.NAME);
+ l1.add(Field.DESCRIPTION);
+ l1.add(Field.AUTHOR);
+ l1.add(Field.TIME);
+
+ List<Field> l2 = new ArrayList<Field>();
+ l2.add(Field.NAME);
+ l2.add(Field.DESCRIPTION);
+ l2.add(Field.AUTHOR);
+ l2.add(Field.TIME);
+
+ Assert.assertEquals(l1, c.getFeedFieldOrder());
+ Assert.assertEquals(l2, c.getItemFieldOrder());
+ Assert.assertEquals("indat-ndat", c.getString());
+ }
+
+ /**
+ * Test of getHTML method, of class RSSHelper.
+ * TODO do the test, for the moment, do not launch it...
+ * @throws Exception if any pb
+ */
+ @Ignore
+ public void testGetHTML() throws Exception {
+ System.out.println("getHTML");
+ String feedName = "http://localhost/rss/rss_1.0.xml";
+ String feedRepr = "n-ndat";
+ int nbItem = -1;
+ RSSHelper instance = new RSSHelper();
+ String expResult = "";
+ String result = instance.getHTML(feedName, feedRepr, nbItem,false);
+ System.out.println("***" + result);
+ result = instance.getHTML(feedName, feedRepr, nbItem,false);
+ System.out.println("***" + result);
+
+ Thread.sleep(2000);
+
+ result = instance.getHTML(feedName, feedRepr, nbItem,false);
+ System.out.println("***" + result);
+ result = instance.getHTML(feedName, feedRepr, nbItem,false);
+ System.out.println("***" + result);
+ // assertEquals(expResult, result);
+ // TODO review the generated test code and remove the default call to fail.
+// fail("The test case is a prototype.");
+ }
+
+}
Property changes on: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-rss/src/test/java/resources/log4j.properties
===================================================================
--- trunk/nuiton-rss/src/test/java/resources/log4j.properties (rev 0)
+++ trunk/nuiton-rss/src/test/java/resources/log4j.properties 2010-12-30 11:25:14 UTC (rev 2001)
@@ -0,0 +1,31 @@
+###
+# #%L
+# Nuiton Utils :: Nuiton RSS
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+# Global logging configuration
+log4j.rootLogger=DEBUG, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
Property changes on: trunk/nuiton-rss/src/test/java/resources/log4j.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-12-30 10:43:20 UTC (rev 2000)
+++ trunk/pom.xml 2010-12-30 11:25:14 UTC (rev 2001)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2004 - 2010 CodeLutin
+ Copyright (C) 2004 - 2010 CodeLutin, Tony Chemit
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -43,8 +43,9 @@
<modules>
<module>nuiton-utils</module>
+ <module>nuiton-validator</module>
<module>nuiton-utils-extra</module>
- <module>nuiton-validator</module>
+ <module>nuiton-rss</module>
</modules>
<dependencyManagement>
@@ -103,6 +104,33 @@
<version>${aspectwerkzVersion}</version>
</dependency>
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>0.9</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!--Provided-->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
</dependencyManagement>
1
0
r2000 - in trunk/nuiton-utils-extra: . src/license src/main/java/org/nuiton/profiling src/site src/site/apt
by tchemit@users.nuiton.org 30 Dec '10
by tchemit@users.nuiton.org 30 Dec '10
30 Dec '10
Author: tchemit
Date: 2010-12-30 11:43:20 +0100 (Thu, 30 Dec 2010)
New Revision: 2000
Url: http://nuiton.org/repositories/revision/nuiton-utils/2000
Log:
fix svn-keywords
Modified:
trunk/nuiton-utils-extra/LICENSE.txt
trunk/nuiton-utils-extra/README.txt
trunk/nuiton-utils-extra/changelog.txt
trunk/nuiton-utils-extra/pom.xml
trunk/nuiton-utils-extra/src/license/THIRD-PARTY.properties
trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/NuitonTrace.java
trunk/nuiton-utils-extra/src/site/apt/index.apt
trunk/nuiton-utils-extra/src/site/site_fr.xml
Property changes on: trunk/nuiton-utils-extra/LICENSE.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-utils-extra/README.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-utils-extra/changelog.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/nuiton-utils-extra/pom.xml
===================================================================
--- trunk/nuiton-utils-extra/pom.xml 2010-12-30 10:42:58 UTC (rev 1999)
+++ trunk/nuiton-utils-extra/pom.xml 2010-12-30 10:43:20 UTC (rev 2000)
@@ -3,7 +3,7 @@
#%L
Nuiton Utils
$Id$
- $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/trunk/nuiton-utils/pom.xml $
+ $HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
%%
Property changes on: trunk/nuiton-utils-extra/pom.xml
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-utils-extra/src/license/THIRD-PARTY.properties
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/NuitonTrace.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/nuiton-utils-extra/src/site/apt/index.apt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/nuiton-utils-extra/src/site/site_fr.xml
===================================================================
--- trunk/nuiton-utils-extra/src/site/site_fr.xml 2010-12-30 10:42:58 UTC (rev 1999)
+++ trunk/nuiton-utils-extra/src/site/site_fr.xml 2010-12-30 10:43:20 UTC (rev 2000)
@@ -4,7 +4,7 @@
Nuiton Utils
$Id$
- $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/trunk/nuiton-utils/src/site/site_fr.… $
+ $HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
%%
Property changes on: trunk/nuiton-utils-extra/src/site/site_fr.xml
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2010-12-30 11:42:58 +0100 (Thu, 30 Dec 2010)
New Revision: 1999
Url: http://nuiton.org/repositories/revision/nuiton-utils/1999
Log:
Evolution #1188: Introduce nuiton-utils-extra module
Added:
trunk/nuiton-utils-extra/
trunk/nuiton-utils-extra/LICENSE.txt
trunk/nuiton-utils-extra/README.txt
trunk/nuiton-utils-extra/changelog.txt
trunk/nuiton-utils-extra/pom.xml
trunk/nuiton-utils-extra/src/
trunk/nuiton-utils-extra/src/license/
trunk/nuiton-utils-extra/src/license/THIRD-PARTY.properties
trunk/nuiton-utils-extra/src/main/
trunk/nuiton-utils-extra/src/main/java/
trunk/nuiton-utils-extra/src/main/java/org/
trunk/nuiton-utils-extra/src/main/java/org/nuiton/
trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/
trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/NuitonTrace.java
trunk/nuiton-utils-extra/src/main/resources/
trunk/nuiton-utils-extra/src/site/
trunk/nuiton-utils-extra/src/site/apt/
trunk/nuiton-utils-extra/src/site/apt/index.apt
trunk/nuiton-utils-extra/src/site/site_fr.xml
trunk/nuiton-utils-extra/src/test/
trunk/nuiton-utils-extra/src/test/java/
trunk/nuiton-utils-extra/src/test/java/org/
trunk/nuiton-utils-extra/src/test/java/org/nuiton/
trunk/nuiton-utils-extra/src/test/resources/
Modified:
trunk/nuiton-validator/src/site/site_fr.xml
trunk/pom.xml
trunk/src/site/apt/index.apt
trunk/src/site/site_fr.xml
Property changes on: trunk/nuiton-utils-extra
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
Property changes on: trunk/nuiton-utils-extra/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-utils-extra/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-utils-extra/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-utils-extra/pom.xml
===================================================================
--- trunk/nuiton-utils-extra/pom.xml (rev 0)
+++ trunk/nuiton-utils-extra/pom.xml 2010-12-30 10:42:58 UTC (rev 1999)
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils
+ $Id$
+ $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/trunk/nuiton-utils/pom.xml $
+ %%
+ Copyright (C) 2004 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>nuiton-utils-extra</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz-core</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz-jdk5</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton Utils :: Nuiton Utils Extra</name>
+ <description>Library of usefull class to be used in any project.</description>
+ <inceptionYear>2004</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <properties>
+
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+
+ </properties>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <profiles>
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <quiet>true</quiet>
+ <links>
+ <link>http://java.sun.com/javase/6/docs/api/</link>
+ </links>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ <!-- create assemblies at release time -->
+ <profile>
+ <id>assembly-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
Property changes on: trunk/nuiton-utils-extra/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-utils-extra/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/nuiton-utils-extra/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/nuiton-utils-extra/src/license/THIRD-PARTY.properties 2010-12-30 10:42:58 UTC (rev 1999)
@@ -0,0 +1,33 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - ASM License
+# - Apache Software License
+# - Apache Software License, Version 2.0
+# - BSD License
+# - GNU Lesser General Public License
+# - Jaxen license
+# - Lesser General Public License (LGPL)
+# - MIT License
+# - SAXPath License
+# - The Apache Software License, Version 2.0
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Dec 30 11:34:10 CET 2010
+aspectwerkz--aspectwerkz--2.0--jar=GNU Lesser General Public License
+aspectwerkz--aspectwerkz-core--2.0--jar=GNU Lesser General Public License
+aspectwerkz--aspectwerkz-jdk5--2.0--jar=GNU Lesser General Public License
+dom4j--dom4j--1.4--jar=BSD License
+isorelax--isorelax--20020414--jar=MIT License
+jaxen--jaxen--1.0-FCS--jar=Jaxen license
+jrexx--jrexx--1.1.1--jar=Apache Software License
+msv--msv--20020414--jar=BSD License
+org.nuiton.thirdparty--asm--1.5.4-snapshot--jar=ASM License
+org.nuiton.thirdparty--asm-attrs--1.5.4-snapshot--jar=ASM License
+org.nuiton.thirdparty--asm-util--1.5.4-snapshot--jar=ASM License
+qdox--qdox--1.4--jar=Apache Software License, Version 2.0
+relaxngDatatype--relaxngDatatype--20020414--jar=BSD License
+saxpath--saxpath--1.0-FCS--jar=SAXPath License
+trove--trove--1.0.2--jar=Lesser General Public License (LGPL)
Property changes on: trunk/nuiton-utils-extra/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/NuitonTrace.java
===================================================================
--- trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/NuitonTrace.java (rev 0)
+++ trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/NuitonTrace.java 2010-12-30 10:42:58 UTC (rev 1999)
@@ -0,0 +1,264 @@
+/*
+ * #%L
+ * Nuiton utilities extra library
+ * %%
+ * Copyright (C) 2006 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.profiling;
+
+import org.apache.commons.lang.time.DurationFormatUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.aspectwerkz.annotation.After;
+import org.codehaus.aspectwerkz.annotation.AfterThrowing;
+import org.codehaus.aspectwerkz.annotation.Aspect;
+import org.codehaus.aspectwerkz.annotation.Before;
+import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
+import org.codehaus.aspectwerkz.joinpoint.MethodSignature;
+
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+/**
+ * Permet de tracer les appels aux methodes.
+ * <p/>
+ * Pour l'utiliser il faut définir un fichier XML qui intercepte les methodes
+ * souhaiter.
+ * <pre>
+ * <?xml version="1.0" encoding="ISO-8859-1"?>
+ * <p/>
+ * <!DOCTYPE aspectwerkz PUBLIC
+ * "-//AspectWerkz//DTD//EN"
+ * "http://aspectwerkz.codehaus.org/dtd/aspectwerkz2.dtd">
+ * <p/>
+ * <aspectwerkz>
+ * <system id="sample">
+ * <aspect class="fr.ifremer.isisfish.aspect.TraceIsis">
+ * <pointcut name="executeMethod">
+ * execution(* fr.ifremer.isisfish.datastore.ResultStorage.*(..))
+ * || execution(* fr.ifremer.isisfish.aspect.Cache.*(..))
+ * || execution(* fr.ifremer.isisfish.aspect.Trace.*(..))
+ * || execution(* org.nuiton.topia..*(..))
+ * || execution(* org.nuiton.math.matrix..*(..))
+ * || execution(* fr.ifremer.isisfish.types..*(..))
+ * || execution(* org.apache.commons.collections..*(..))
+ * </pointcut>
+ * </aspect>
+ * </system>
+ * </aspectwerkz>
+ * <p/>
+ * </pre>
+ * Ensuite il faut lancer la JVM avec deux options
+ * <li> -javaagent:path/to/aspectwerkz-jdk5-2.0.jar
+ * <li> -Daspectwerkz.definition.file=path/to/trace-aop.xml
+ * <p/>
+ * il doit être possible d'utiliser des noms normalisé et
+ * trouvable dans le classpath a la place de -Daspectwerkz.definition.file
+ * <li> /aspectwerkz.xml
+ * <li> META-INF/aop.xml
+ * <li> WEB-INF/aop.xml
+ * <p/>
+ * Ensuite pour afficher les statistiques dans votre programme
+ * <li> log.info(NuitonTrace.getStatisticsAndClear());
+ * <li> NuitonTrace.printStatistiqueAndClear();
+ * <p/>
+ * <p/>
+ * <p/>
+ * Il doit être possible, plutot que d'écrire un fichier XML, de sous classer
+ * NuitonTrace en ajoutant par exemple
+ * <p/>
+ *
+ * @author poussin
+ * @Expression( "execution(* fr.ifremer.isisfish.datastore.ResultStorage.*(..))" +
+ * "|| execution(* fr.ifremer.isisfish.aspect.Cache.*(..))" +
+ * "|| execution(* fr.ifremer.isisfish.aspect.Trace.*(..))" +
+ * "|| execution(* org.nuiton.topia..*(..))" +
+ * "|| execution(* org.nuiton.math.matrix..*(..))" +
+ * "|| execution(* fr.ifremer.isisfish.types..*(..))" +
+ * "|| execution(* org.apache.commons.collections..*(..))"
+ * )
+ * Pointcut executeMethod;
+ * </p>
+ */
+@Aspect("perJVM")
+public class NuitonTrace {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(NuitonTrace.class);
+
+ static private List<NuitonTrace> instances = new ArrayList<NuitonTrace>();
+
+ /** nombre d'appel */
+ final static public int STAT_CALL = 0;
+ /** nombre d'appel vers une autre method depuis cette methode */
+ final static public int STAT_CALL_NEST_METHOD = 1;
+ /** temps mini d'execution de cette methode (sans le temps des autres methodes) */
+ final static public int STAT_TIME_MIN = 2;
+ /** temps max d'execution de cette methode (sans le temps des autres methodes) */
+ final static public int STAT_TIME_MAX = 3;
+ /** temps total d'execution de cette methode (sans le temps des autres methodes) */
+ final static public int STAT_TIME_TOTAL = 4;
+ /** temps total d'execution de cette methode (avec le temps des autres methodes) */
+ final static public int STAT_TIME_TOTAL_NEST_METHOD = 5;
+
+ /** nombre d'appel vers une autre method depuis cette methode */
+ final static private int STACK_CALL_NEST_METHOD = 0;
+ /** heure de depart de l'appel a la methode (sans le temps des autres methodes) */
+ final static private int STACK_TIME_START = 1;
+ /** heure de depart de l'appel a la methode (avec le temps des autres methodes) */
+ final static private int STACK_TIME_START_NEST_METHOD = 2;
+
+
+ /** array : [call's numbers, call do, min time, max time, total time, total time with child] */
+ protected Map<Method, long[]> statistics = new LinkedHashMap<Method, long[]>();
+
+ /** array : [nest method call, start time, start time with child] */
+ protected Stack<long[]> callStack = new Stack<long[]>();
+
+// @Expression(
+// "execution(* fr.ifremer.isisfish.datastore.ResultStorage.*(..))" +
+// "|| execution(* fr.ifremer.isisfish.aspect.Cache.*(..))" +
+// "|| execution(* fr.ifremer.isisfish.aspect.Trace.*(..))" +
+// "|| execution(* org.nuiton.topia..*(..))" +
+// "|| execution(* org.nuiton.math.matrix..*(..))" +
+// "|| execution(* fr.ifremer.isisfish.types..*(..))" +
+// "|| execution(* org.apache.commons.collections..*(..))"
+// )
+// Pointcut executeMethod;
+
+ public NuitonTrace() {
+ instances.add(this);
+ }
+
+ public long[] getStatistics(Method method) {
+ long[] result = statistics.get(method);
+ if (result == null) {
+ result = new long[]{0, 0, 0, 0, 0, 0};
+ statistics.put(method, result);
+ }
+ return result;
+ }
+
+ @Before("executeMethod")
+ public void traceBeforeExecute(JoinPoint jp) {
+ // ajout dans le stack
+ long current = System.nanoTime();
+ long[] stackItem = new long[]{0, current, current};
+ callStack.push(stackItem);
+
+
+ }
+
+ @AfterThrowing("executeMethod")
+ public void traceAfterThrowingExecute(JoinPoint jp) {
+ // si une exeption est leve, il faut faire la meme chose
+ traceAfterExecute(jp);
+ }
+
+ @After("executeMethod")
+ public void traceAfterExecute(JoinPoint jp) {
+ Method method = ((MethodSignature) jp.getSignature()).getMethod();
+
+ long current = System.nanoTime();
+
+ if (callStack.isEmpty()) {
+ log.warn("Empty stack in afterExecute for method " + method.getName());
+ } else {
+ long[] stackItem = callStack.pop();
+ long timeSpent = current - stackItem[STACK_TIME_START];
+ long timeSpentNestMethod = current - stackItem[STACK_TIME_START_NEST_METHOD];
+
+ long[] stat = getStatistics(method);
+ stat[STAT_CALL]++; // add +1 to call number
+ stat[STAT_CALL_NEST_METHOD] += stackItem[STACK_CALL_NEST_METHOD];
+ stat[STAT_TIME_TOTAL] += timeSpent;
+ stat[STAT_TIME_TOTAL_NEST_METHOD] += timeSpentNestMethod;
+ if (stat[STAT_TIME_MIN] > timeSpent) {
+ stat[STAT_TIME_MIN] = timeSpent;
+ }
+ if (stat[STAT_TIME_MAX] < timeSpent) {
+ stat[STAT_TIME_MAX] = timeSpent;
+ }
+
+ if (!callStack.isEmpty()) {
+ long[] parent = callStack.peek();
+ parent[STACK_CALL_NEST_METHOD]++; // add +1 to call number nest method
+ parent[STACK_TIME_START] += timeSpentNestMethod; // remove to time all time spent in nest method (yes + to remove :)
+ }
+ }
+
+ // ajouter le delta de temps dans le temps passé dans la méthod
+
+ // il faud garder le temps passé dans l'appel d'autre methode de la stack
+ // --> A
+ // =========
+ // --> B
+ // <-- B
+ // =========
+ // --> C
+ // --> D
+ // <-- D
+ // <-- C
+ // =========
+ // <-- A
+
+ // le temps reellement passé dans A est representé par les =====
+ }
+
+ /** @return les statistiques */
+ static public String getStatisticsAndClear() {
+ StringBuffer result = new StringBuffer();
+ for (NuitonTrace trace : instances) {
+ result.append("--- Statistics ---\n");
+ for (Method method : trace.statistics.keySet()) {
+ long[] stat = trace.getStatistics(method);
+ long meanTime = stat[STAT_TIME_TOTAL] / stat[STAT_CALL];
+ result.append(method).append("\t")
+ .append(" call: ").append(stat[STAT_CALL])
+ // TIme is in nano not millis, we must divide by 1000000
+ .append(" min: ").append(DurationFormatUtils.formatDuration(stat[STAT_TIME_MIN] / 1000000, "s'.'S"))
+ .append(" mean: ").append(DurationFormatUtils.formatDuration(meanTime / 1000000, "s'.'S"))
+ .append(" max: ").append(DurationFormatUtils.formatDuration(stat[STAT_TIME_MAX] / 1000000, "s'.'S"))
+ .append(" total: ").append(DurationFormatUtils.formatDuration(stat[STAT_TIME_TOTAL] / 1000000, "s'.'S"))
+ .append(" call_nest: ").append(stat[STAT_CALL_NEST_METHOD])
+ .append(" total_with_nest: ").append(DurationFormatUtils.formatDuration(stat[STAT_TIME_TOTAL_NEST_METHOD] / 1000000, "s'.'S"))
+ .append("\n");
+ }
+ result.append("--------------------\n");
+ }
+ instances.clear();
+ return result.toString();
+ }
+
+ static public void printStatisticsAndClear() {
+ printStatisticsAndClear(System.out);
+ }
+
+ static public void printStatisticsAndClear(PrintStream printer) {
+ String stat = getStatisticsAndClear();
+ if (stat != null && !"".equals(stat)) {
+ printer.println(stat);
+ }
+ }
+
+}
Property changes on: trunk/nuiton-utils-extra/src/main/java/org/nuiton/profiling/NuitonTrace.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-utils-extra/src/site/apt/index.apt
===================================================================
--- trunk/nuiton-utils-extra/src/site/apt/index.apt (rev 0)
+++ trunk/nuiton-utils-extra/src/site/apt/index.apt 2010-12-30 10:42:58 UTC (rev 1999)
@@ -0,0 +1,42 @@
+~~~
+~~ #%L
+~~ Nuiton Utils :: Nuiton Utils Extra
+~~
+~~ $Id$
+~~ $HeadURL$
+~~ %%
+~~ Copyright (C) 2004 - 2010 CodeLutin
+~~ %%
+~~ This program is free software: you can redistribute it and/or modify
+~~ it under the terms of the GNU Lesser General Public License as
+~~ published by the Free Software Foundation, either version 3 of the
+~~ License, or (at your option) any later version.
+~~
+~~ This program is distributed in the hope that it will be useful,
+~~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~~ GNU General Lesser Public License for more details.
+~~
+~~ You should have received a copy of the GNU General Lesser Public
+~~ License along with this program. If not, see
+~~ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+~~ #L%
+~~~
+ ----
+ Nuiton utils Extra
+ ----
+ ----
+ 2009-08-23
+ ----
+
+Présentation
+
+ nuiton-utils-extra contient un ensemble de librairies trop petites pour avoir
+ leur propre projet, mais avec trop de dépendances pour être dans nuiton-utils.
+ Elles sont aussi utiles à la plupart des projets de Code Lutin.
+
+NuitonTrace
+
+
+ Permet de tracer le temps passé dans les méthodes au cours de l'éxecution.
+ Cette classe utilise l'AOP pour cela. Pour l'utiliser voir sa javadoc.
Property changes on: trunk/nuiton-utils-extra/src/site/apt/index.apt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/nuiton-utils-extra/src/site/site_fr.xml
===================================================================
--- trunk/nuiton-utils-extra/src/site/site_fr.xml (rev 0)
+++ trunk/nuiton-utils-extra/src/site/site_fr.xml 2010-12-30 10:42:58 UTC (rev 1999)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils
+
+ $Id$
+ $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/trunk/nuiton-utils/src/site/site_fr.… $
+ %%
+ Copyright (C) 2004 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: trunk/nuiton-utils-extra/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/nuiton-validator/src/site/site_fr.xml
===================================================================
--- trunk/nuiton-validator/src/site/site_fr.xml 2010-12-30 09:44:04 UTC (rev 1998)
+++ trunk/nuiton-validator/src/site/site_fr.xml 2010-12-30 10:42:58 UTC (rev 1999)
@@ -41,9 +41,6 @@
<menu name="Utilisateur">
<item name="Accueil" href="index.html"/>
- <item name="Documentation" href="/nuitonUtil.html"/>
- <item name="Application config" href="/ApplicationConfig.html"/>
- <item name="War launcher" href="/Warlauncher.html"/>
</menu>
<menu name="Téléchargement">
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-12-30 09:44:04 UTC (rev 1998)
+++ trunk/pom.xml 2010-12-30 10:42:58 UTC (rev 1999)
@@ -43,6 +43,7 @@
<modules>
<module>nuiton-utils</module>
+ <module>nuiton-utils-extra</module>
<module>nuiton-validator</module>
</modules>
@@ -82,6 +83,26 @@
</exclusions>
</dependency>
+ <!-- aspectwerkz dependencies -->
+
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz-core</artifactId>
+ <version>${aspectwerkzVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz</artifactId>
+ <version>${aspectwerkzVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz-jdk5</artifactId>
+ <version>${aspectwerkzVersion}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
@@ -89,7 +110,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Nuiton Utils :: Parent</name>
+ <name>Nuiton Utils</name>
<description>Parent of nuiton utils projects.</description>
<inceptionYear>2011</inceptionYear>
<url>http://maven-site.nuiton.org/nuiton-utils</url>
@@ -166,6 +187,8 @@
<nuitonI18nVersion>2.0.1</nuitonI18nVersion>
+ <aspectwerkzVersion>2.0</aspectwerkzVersion>
+
</properties>
<build>
Modified: trunk/src/site/apt/index.apt
===================================================================
--- trunk/src/site/apt/index.apt 2010-12-30 09:44:04 UTC (rev 1998)
+++ trunk/src/site/apt/index.apt 2010-12-30 10:42:58 UTC (rev 1999)
@@ -1,6 +1,6 @@
~~~
~~ #%L
-~~ Nuiton Utils :: Parent
+~~ Nuiton Utils
~~
~~ $Id$
~~ $HeadURL$
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2010-12-30 09:44:04 UTC (rev 1998)
+++ trunk/src/site/site_fr.xml 2010-12-30 10:42:58 UTC (rev 1999)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
- Nuiton Utils Parent
+ Nuiton Utils
$Id$
$HeadURL$
@@ -45,6 +45,10 @@
<menu ref="modules"/>
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ </menu>
+
<menu ref="reports"/>
</body>
1
0
Author: tchemit
Date: 2010-12-30 10:44:04 +0100 (Thu, 30 Dec 2010)
New Revision: 1998
Url: http://nuiton.org/repositories/revision/nuiton-utils/1998
Log:
Evolution #1187: Introduce nuiton-validator module
Added:
trunk/LICENSE.txt
trunk/README.txt
trunk/changelog.txt
trunk/nuiton-validator/
trunk/nuiton-validator/LICENSE.txt
trunk/nuiton-validator/README.txt
trunk/nuiton-validator/changelog.txt
trunk/nuiton-validator/pom.xml
trunk/nuiton-validator/src/
trunk/nuiton-validator/src/license/
trunk/nuiton-validator/src/license/THIRD-PARTY.properties
trunk/nuiton-validator/src/main/
trunk/nuiton-validator/src/main/java/
trunk/nuiton-validator/src/main/java/org/
trunk/nuiton-validator/src/main/java/org/nuiton/
trunk/nuiton-validator/src/main/java/org/nuiton/validator/
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java
trunk/nuiton-validator/src/main/resources/
trunk/nuiton-validator/src/main/resources/i18n/
trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_en_GB.properties
trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_fr_FR.properties
trunk/nuiton-validator/src/main/resources/validators.xml
trunk/nuiton-validator/src/site/
trunk/nuiton-validator/src/site/apt/
trunk/nuiton-validator/src/site/apt/index.apt
trunk/nuiton-validator/src/site/site_fr.xml
trunk/nuiton-validator/src/test/
trunk/nuiton-validator/src/test/java/
trunk/nuiton-validator/src/test/java/org/
trunk/nuiton-validator/src/test/java/org/nuiton/
trunk/nuiton-validator/src/test/java/org/nuiton/validator/
trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java
trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java
trunk/nuiton-validator/src/test/resources/
trunk/nuiton-validator/src/test/resources/log4j.properties
trunk/nuiton-validator/src/test/resources/org/
trunk/nuiton-validator/src/test/resources/org/nuiton/
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml
trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml
trunk/nuiton-validator/src/test/resources/validators.xml
trunk/pom.xml
trunk/src/
trunk/src/site/
trunk/src/site/apt/
trunk/src/site/apt/index.apt
trunk/src/site/site_fr.xml
Modified:
trunk/nuiton-utils/
trunk/nuiton-utils/pom.xml
trunk/nuiton-utils/src/site/site_fr.xml
Added: trunk/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt (rev 0)
+++ trunk/LICENSE.txt 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Property changes on: trunk/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-utils
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2010-12-29 23:16:21 UTC (rev 1997)
+++ trunk/nuiton-utils/pom.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -22,7 +22,9 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
#L%
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -32,23 +34,15 @@
<parent>
<groupId>org.nuiton</groupId>
- <artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.4.1</version>
+ <artifactId>nuiton-utils-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
</parent>
<artifactId>nuiton-utils</artifactId>
- <version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <!--version>1.2.16</version-->
- <scope>provided</scope>
- </dependency>
-
- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
@@ -71,8 +65,6 @@
<dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
- <version>${nuitonI18nVersion}</version>
- <scope>compile</scope>
</dependency>
<dependency>
@@ -84,17 +76,21 @@
<dependency>
<groupId>org.jvnet.hudson.winstone</groupId>
<artifactId>winstone</artifactId>
- <version>0.9.10-hudson-24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-webapp</artifactId>
- <version>7.1.0.v20100505</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
@@ -102,84 +98,19 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Nuiton Utils</name>
+ <name>Nuiton Utils :: Nuiton Utils</name>
<description>Library of usefull class to be used in any project.</description>
<inceptionYear>2004</inceptionYear>
- <url>http://maven-site.nuiton.org/nuiton-utils</url>
- <developers>
-
- <developer>
- <name>Brendan Le Ny</name>
- <id>bleny</id>
- <email>bleny(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>developer</role>
- </roles>
- </developer>
-
- <developer>
- <name>Benjamin Poussin</name>
- <id>bpoussin</id>
- <email>poussin(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- <role>Debian packager</role>
- </roles>
- </developer>
-
- <developer>
- <name>Éric Chatellier</name>
- <id>echatellier</id>
- <email>chatellier(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- </roles>
- </developer>
-
- <developer>
- <name>Sylvain Letellier</name>
- <id>sletellier</id>
- <email>letellier(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- </roles>
- </developer>
-
- <developer>
- <name>Tony Chemit</name>
- <id>tchemit</id>
- <email>chemit(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>developer</role>
- </roles>
- </developer>
-
- </developers>
-
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
<!-- ************************************************************* -->
- <packaging>jar</packaging>
-
<properties>
-
- <nuitonI18nVersion>2.0.1</nuitonI18nVersion>
-
+
<!-- extra files to include in release -->
<redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
-
+
</properties>
<build>
@@ -190,7 +121,6 @@
<plugin>
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
- <version>${nuitonI18nVersion}</version>
<configuration>
<silent>true</silent>
</configuration>
@@ -212,13 +142,6 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
- <!-- Source control management. -->
- <scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/nuiton-utils/trunk</url>
- </scm>
-
<profiles>
<profile>
<id>reporting</id>
Modified: trunk/nuiton-utils/src/site/site_fr.xml
===================================================================
--- trunk/nuiton-utils/src/site/site_fr.xml 2010-12-29 23:16:21 UTC (rev 1997)
+++ trunk/nuiton-utils/src/site/site_fr.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -31,16 +31,14 @@
<href>index.html</href>
</bannerLeft>
- <poweredBy>
- <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
- </poweredBy>
-
<body>
<breadcrumbs>
<item name="${project.name}" href="index.html"/>
</breadcrumbs>
+ <menu ref="parent"/>
+
<menu name="Utilisateur">
<item name="Accueil" href="index.html"/>
<item name="Documentation" href="/nuitonUtil.html"/>
Property changes on: trunk/nuiton-validator
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
Added: trunk/nuiton-validator/LICENSE.txt
===================================================================
--- trunk/nuiton-validator/LICENSE.txt (rev 0)
+++ trunk/nuiton-validator/LICENSE.txt 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Property changes on: trunk/nuiton-validator/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-validator/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-validator/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/pom.xml
===================================================================
--- trunk/nuiton-validator/pom.xml (rev 0)
+++ trunk/nuiton-validator/pom.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>nuiton-validator</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ </dependency>
+
+ <!-- xworks dependencies -->
+
+ <dependency>
+ <groupId>com.opensymphony</groupId>
+ <artifactId>xwork</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton Utils :: Validator</name>
+ <description>Validator Api.</description>
+ <inceptionYear>2011</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <properties>
+
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+
+ </properties>
+
+ <build>
+
+ <plugins>
+
+ <!-- plugin i18n -->
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <configuration>
+ <silent>true</silent>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <profiles>
+
+ <!-- perform only on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+
+ <!-- always compute tests source jar -->
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test-sources</id>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- always compute tests javadoc jar -->
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test-javadoc</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <quiet>true</quiet>
+ <links>
+ <link>http://java.sun.com/javase/6/docs/api/</link>
+ </links>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ <!-- create assemblies at release time -->
+ <profile>
+ <id>assembly-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
Property changes on: trunk/nuiton-validator/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/nuiton-validator/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/nuiton-validator/src/license/THIRD-PARTY.properties 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,16 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD License
+# - Common Public License Version 1.0
+# - Lesser General Public License (LGPL) v 3.0
+# - The Apache Software License, Version 2.0
+# - The OpenSymphony Software License 1.1
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Dec 30 09:14:11 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+opensymphony--ognl--2.6.11--jar=The OpenSymphony Software License 1.1
+
Property changes on: trunk/nuiton-validator/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,635 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.converter.ConverterUtil;
+
+import javax.swing.event.EventListenerList;
+import java.beans.EventSetDescriptor;
+import java.beans.Introspector;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * A customized validator for a given bean.
+ * <p/>
+ * <b>Note:</b> The bean must be listenable on properyChange events (means must
+ * have public addPropertychangeListener and removePropertyChangeListener
+ * methods).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @param <B> type of the bean to validate.
+ */
+public class BeanValidator<B> {
+
+ /** la nom de la propriété bean */
+ static public final String BEAN_PROERTY = "bean";
+
+ /** la nom de la propriété contextName */
+ static public final String CONTEXT_NAME_PROPERTY = "contextName";
+
+ /** la nom de l'état valid */
+ static public final String VALID_PROERTY = "valid";
+
+ /** la nom de l'état changed */
+ static public final String CHANGED_PROERTY = "changed";
+
+ /** Logger */
+ static protected final Log log = LogFactory.getLog(BeanValidator.class);
+
+ protected static final BeanValidatorScope[] FILTER_SCOPES_EMPTY =
+ new BeanValidatorScope[0];
+
+ /** the type of bean to watch */
+ protected final Class<B> beanClass;
+
+ /** the validation named context (can be null) */
+ protected String contextName;
+
+ /** to chain to a prent validator */
+ protected BeanValidator<?> parentValidator;
+
+ /**
+ * state to indicate that validator has changed since the last time bean was
+ * setted
+ */
+ protected boolean changed;
+
+ /** state of the validator (is true if no errors of error scope is found) */
+ protected boolean valid = true;
+
+ /** bean to be watched */
+ protected B bean;
+
+ /** to add and remove PropertyChangeListener on watched beans */
+ protected EventSetDescriptor beanEventDescriptor;
+
+ /** list of fields watched by this validator */
+ protected Set<BeanValidatorField<B>> fields;
+
+ /** map of conversion errors detected by this validator */
+ protected Map<String, String> conversionErrors;
+
+ /** xworks scope validator * */
+ protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators;
+
+ /** filter scopes (if {@code null}, no filter on scopes) */
+ protected BeanValidatorScope[] filterScopes;
+
+ /** listener that listens on bean modification */
+ protected PropertyChangeListener l;
+
+ /** delegate property change support */
+ protected PropertyChangeSupport pcs;
+
+ /** A list of event listeners for this validators */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ public BeanValidator(Class<B> beanClass,
+ String contextName) {
+ this(beanClass,
+ contextName,
+ BeanValidatorScope.values()
+ );
+ }
+
+ public BeanValidator(Class<B> beanClass,
+ String contextName,
+ BeanValidatorScope... filterScopes) {
+ this.beanClass = beanClass;
+ if (filterScopes != null && filterScopes.length > 0) {
+ this.filterScopes = filterScopes;
+ }
+ pcs = new PropertyChangeSupport(this);
+ conversionErrors = new TreeMap<String, String>();
+ validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(
+ BeanValidatorScope.class);
+
+ setContextName(contextName);
+
+ l = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ // chaque modification lance la validation
+ doValidate();
+ }
+ };
+ }
+
+ public Class<B> getBeanClass() {
+ return beanClass;
+ }
+
+ public BeanValidator<?> getParentValidator() {
+ return parentValidator;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public Set<BeanValidatorField<B>> getFields() {
+ return fields;
+ }
+
+ public Set<BeanValidatorScope> getScopes() {
+ return new HashSet<BeanValidatorScope>(validators.keySet());
+ }
+
+ /**
+ * Retourne vrai si l'objet bean a ete modifie depuis le dernier {@link
+ * #setBean}
+ *
+ * @return <code>true</code> if bean was modify since last {@link
+ * #setBean(Object)} invocation
+ */
+ public boolean isChanged() {
+ return changed;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public B getBean() {
+ return bean;
+ }
+
+ public BeanValidatorField<B> getField(String fieldName) {
+ for (BeanValidatorField<B> field : fields) {
+ if (fieldName.equals(field.getName())) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ public boolean hasFatalErrors() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasFatalErrors()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasErrors() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasErrors()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasWarnings() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasWarnings()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasInfos() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasInfos()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test a the validator contains the field given his name
+ *
+ * @param fieldName the name of the searched field
+ * @return <code>true</code> if validator contaisn this field,
+ * <code>false</code> otherwise
+ */
+ public boolean containsField(String fieldName) {
+ BeanValidatorField<B> field = getField(fieldName);
+ return field != null;
+ }
+
+ public boolean isValid(String fieldName) {
+ BeanValidatorField<B> field = getField(fieldName);
+ if (field == null) {
+ throw new IllegalArgumentException(
+ "could not find a validator field " + fieldName);
+ }
+ return field.isValid();
+ }
+
+ /**
+ * Permet de force la remise a false de l'etat de changement du bean
+ *
+ * @param changed flag to force reset of property {@link #changed}
+ */
+ public void setChanged(boolean changed) {
+ this.changed = changed;
+ // force the property to be fired (never pass the older value)
+ pcs.firePropertyChange(CHANGED_PROERTY, null, changed);
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ // force the property to be fired (never pass the older value)
+ pcs.firePropertyChange(VALID_PROERTY, null, valid);
+ }
+
+ public void setBean(B bean) {
+ B oldBean = this.bean;
+ if (log.isDebugEnabled()) {
+ log.debug(this + " : " + bean);
+ }
+
+ // clean conversions of previous bean
+ conversionErrors.clear();
+
+ if (oldBean != null) {
+ try {
+ EventSetDescriptor descriptor = getBeanEventDescriptor(oldBean);
+ descriptor.getRemoveListenerMethod().invoke(oldBean, l);
+ } catch (Exception eee) {
+ if (log.isInfoEnabled()) {
+ log.info("Can't register as listener for bean " + beanClass +
+ " for reason " + eee.getMessage(), eee);
+ }
+ }
+ }
+ this.bean = bean;
+
+ if (bean == null) {
+
+ // remove all messages for all fields of the validator
+
+ for (BeanValidatorField<B> f : fields) {
+
+ f.updateMessages(this, null, null);
+ }
+
+ } else {
+ try {
+ EventSetDescriptor descriptor = getBeanEventDescriptor(bean);
+ descriptor.getAddListenerMethod().invoke(bean, l);
+ } catch (Exception eee) {
+ if (log.isInfoEnabled()) {
+ log.info("Can't register as listener for bean " + beanClass +
+ " for reason " + eee.getMessage(), eee);
+ }
+ }
+ validate();
+ }
+ setChanged(false);
+ setValid(!hasFatalErrors() && !hasErrors());
+ pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean);
+ }
+
+ public void setContextName(String contextName) {
+ String oldContextName = this.contextName;
+ this.contextName = contextName;
+ // changing contextName could change fields definition
+ // so dettach bean, must rebuild the fields
+ if (bean != null) {
+ setBean(null);
+ }
+ // rebuild the fields
+ initFields();
+ pcs.firePropertyChange(CONTEXT_NAME_PROPERTY,
+ oldContextName,
+ contextName
+ );
+ }
+
+ /**
+ * Sets the filter scopes.
+ *
+ * @param filterScopes the scopes to used
+ */
+ public void setFilterScopes(BeanValidatorScope... filterScopes) {
+ this.filterScopes = filterScopes;
+ // changing contextName could change fields definition
+ // so dettach bean, must rebuild the fields
+ if (bean != null) {
+ setBean(null);
+ }
+ // rebuild the fields
+ initFields();
+ }
+
+ public void setParentValidator(BeanValidator<?> parentValidator) {
+ this.parentValidator = parentValidator;
+ }
+
+ /**
+ * Convert a value.
+ * <p/>
+ * If an error occurs, then add an error in validator.
+ *
+ * @param <T> the type of conversion
+ * @param fieldName the name of the bean property
+ * @param value the value to convert
+ * @param valueClass the type of converted value
+ * @return the converted value, or null if conversion was not ok
+ */
+ @SuppressWarnings({"unchecked"})
+ public <T> T convert(String fieldName, String value, Class<T> valueClass) {
+ if (fieldName == null) {
+ throw new IllegalArgumentException("fieldName can not be null");
+ }
+ if (valueClass == null) {
+ throw new IllegalArgumentException("valueClass can not be null");
+ }
+
+ // on ne convertit pas si il y a un bean et que le resultat de la
+ // validation pourra etre affiche quelque part
+ if (!canValidate() || value == null) {
+ return null;
+ }
+
+ // remove the previous conversion error for the field
+ conversionErrors.remove(fieldName);
+
+ T result;
+ try {
+ Converter converter = ConverterUtil.getConverter(valueClass);
+ if (converter == null) {
+ throw new RuntimeException(
+ "could not find converter for the type " + valueClass);
+ }
+ result = (T) converter.convert(valueClass, value);
+ /* Why this test ? if (result != null && !value.equals(result.toString())) {
+ conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ result = null;
+ validate();
+ }*/
+ } catch (ConversionException e) {
+ // get
+ String s = Introspector.decapitalize(valueClass.getSimpleName());
+ conversionErrors.put(fieldName, "error.convertor." + s);
+ result = null;
+ validate();
+ }
+ return result;
+ }
+
+ /**
+ * Methode pour forcer la revalidation d'un bean en mettant a jour les etats
+ * internes.
+ * <p/>
+ * La méthode appelle {@link #validate()} puis met à jour les etats internes
+ * {@link #valid} et {@link #changed}.
+ *
+ * @since 1.5
+ */
+ public void doValidate() {
+ validate();
+ setValid(!hasFatalErrors() && !hasErrors());
+ setChanged(true);
+ }
+
+ /**
+ * il faut eviter le code re-intrant (durant une validation, une autre est
+ * demandee). Pour cela on fait la validation dans un thread, et tant que la
+ * premiere validation n'est pas fini, on ne repond pas aux solicitations.
+ * Cette method est public pour permettre de force une validation par
+ * programmation, ce qui est utile par exemple si le bean ne supporte pas
+ * les {@link PropertyChangeListener}
+ * <p/>
+ * <b>Note:</b> la methode est protected et on utilise la methode
+ * {@link #doValidate()} car la méthode ne modifie pas les etats
+ * internes et cela en rend son utilisation delicate (le validateur entre
+ * dans un etat incoherent par rapport aux messages envoyés).
+ */
+ protected void validate() {
+
+ // on ne valide que si il y a un bean et que le resultat de la validation
+ // pourra etre affiche quelque part
+ if (!canValidate()) {
+ return;
+ }
+
+ for (BeanValidatorScope scope : validators.keySet()) {
+
+ XWorkBeanValidator<B> validator = validators.get(scope);
+
+ Map<String, List<String>> newMessages = validator.validate(bean);
+
+ if (scope == BeanValidatorScope.ERROR) {
+ // treate conversion errors
+ // reinject them
+ for (Entry<String, String> entry : conversionErrors.entrySet()) {
+ // remove from validation, errors occurs on this field
+ List<String> errors = newMessages.get(entry.getKey());
+ String conversionError = entry.getValue();
+ if (errors != null) {
+ errors.clear();
+ errors.add(conversionError);
+ } else {
+ errors = Collections.singletonList(conversionError);
+ if (XWorkBeanValidator.EMPTY_RESULT.equals(newMessages)) {
+ newMessages = new HashMap<String, List<String>>();
+ }
+ // add the concrete conversion error
+ newMessages.put(entry.getKey(), errors);
+ }
+ }
+ }
+
+ // for each field, update his list of messages
+ for (BeanValidatorField<B> field : fields) {
+ List<String> messagesForField = newMessages.get(field.getName());
+ if (field.getScopes().contains(scope)) {
+ field.updateMessages(this, scope, messagesForField);
+ }
+ }
+ }
+
+ if (parentValidator != null) {
+ // chained validation
+ // the parent validator should not be changed from this validation
+ boolean wasModified = parentValidator.isChanged();
+ parentValidator.doValidate();
+ if (!wasModified) {
+ // push back old state
+ parentValidator.setChanged(false);
+ }
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<beanClass:" + beanClass +
+ ", contextName:" + contextName + ">";
+ }
+
+ public void addBeanValidatorListener(BeanValidatorListener listener) {
+ listenerList.add(BeanValidatorListener.class, listener);
+ }
+
+ public void removeBeanValidatorListener(BeanValidatorListener listener) {
+ listenerList.remove(BeanValidatorListener.class, listener);
+ }
+
+ public BeanValidatorListener[] getBeanValidatorListeners() {
+ return listenerList.getListeners(BeanValidatorListener.class);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ /**
+ * @return <code>true</code> if validation is enabled, <code>false</code>
+ * otherwise.
+ */
+ protected boolean canValidate() {
+ return !(bean == null || fields.isEmpty());
+ }
+
+ protected void fireFieldChanged(BeanValidatorField<B> field,
+ BeanValidatorScope scope,
+ String[] toAdd,
+ String[] toDelete) {
+
+ BeanValidatorEvent evt = new BeanValidatorEvent(
+ this,
+ field,
+ scope,
+ toAdd,
+ toDelete
+ );
+
+ for (BeanValidatorListener listener :
+ listenerList.getListeners(BeanValidatorListener.class)) {
+ listener.onFieldChanged(evt);
+ }
+ }
+
+ protected void initFields() {
+
+ Set<String> detectedFieldNames = new HashSet<String>();
+ EnumMap<BeanValidatorScope, Set<String>> tmp;
+ tmp = new EnumMap<BeanValidatorScope, Set<String>>(
+ BeanValidatorScope.class
+ );
+ Set<BeanValidatorField<B>> detectedFields =
+ new HashSet<BeanValidatorField<B>>();
+
+ validators.clear();
+
+ BeanValidatorScope[] scopeUniverse;
+ if (filterScopes == null) {
+ // use all scopes
+ scopeUniverse = BeanValidatorScope.values();
+ } else {
+ // use customized scopes
+ scopeUniverse = filterScopes;
+ }
+
+ for (BeanValidatorScope scope : scopeUniverse) {
+ String scopeContext =
+ (contextName == null ? "" : contextName + "-") +
+ scope.name().toLowerCase();
+
+ XWorkBeanValidator<B> newValidator =
+ new XWorkBeanValidator<B>(beanClass, scopeContext, false);
+ Set<String> fieldNames = newValidator.getFieldNames();
+ if (log.isDebugEnabled()) {
+ log.debug("detected validators for scope " + scopeContext +
+ " : " + fieldNames);
+ }
+ if (!fieldNames.isEmpty()) {
+ // fields detected in this validator, keep it
+ validators.put(scope, newValidator);
+ detectedFieldNames.addAll(fieldNames);
+ tmp.put(scope, fieldNames);
+ }
+ }
+
+ List<BeanValidatorScope> scopes = new ArrayList<BeanValidatorScope>();
+ for (String fieldName : detectedFieldNames) {
+ scopes.clear();
+ // detect scopes for the field
+ for (BeanValidatorScope scope : scopeUniverse) {
+ if (tmp.containsKey(scope) &&
+ tmp.get(scope).contains(fieldName)) {
+ scopes.add(scope);
+ }
+ }
+ BeanValidatorField<B> f =
+ new BeanValidatorField<B>(beanClass, fieldName, scopes);
+ detectedFields.add(f);
+ }
+ tmp.clear();
+ detectedFieldNames.clear();
+
+ fields = Collections.unmodifiableSet(detectedFields);
+ }
+
+ protected EventSetDescriptor getBeanEventDescriptor(B bean) {
+ if (beanEventDescriptor == null) {
+ // check that the bean is listenable, otherwise, can't use the
+ // validator on it
+ beanEventDescriptor =
+ BeanValidatorUtil.getPropertyChangeListenerDescriptor(
+ bean.getClass()
+ );
+ }
+ return beanEventDescriptor;
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,342 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import org.apache.commons.beanutils.ConstructorUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Un detecteur de validateurs pour un liste de classes données et un répertoire
+ * où chercher les fichiers de validation.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.6.0
+ */
+public class BeanValidatorDetector {
+
+ /** Logger */
+ private static final Log log =
+ LogFactory.getLog(BeanValidatorDetector.class);
+
+ public SortedSet<BeanValidator<?>> detect(File sourceRoot,
+ Class<?>... types) {
+ SortedSet<BeanValidator<?>> result =
+ detect(BeanValidator.class, sourceRoot, null, types);
+ return result;
+ }
+
+ public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass,
+ File sourceRoot,
+ Pattern contextFilter,
+ Class<?>... types) {
+ SortedSet<BeanValidator<?>> result = detect(validatorClass,
+ sourceRoot,
+ contextFilter,
+ null,
+ types);
+ return result;
+ }
+
+ public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass,
+ File sourceRoot,
+ Pattern contextFilter,
+ BeanValidatorScope[] scopes,
+ Class<?>... types) {
+
+ SortedSet<BeanValidator<?>> result =
+ new TreeSet<BeanValidator<?>>(new BeanValidatorComparator());
+
+ for (Class<?> c : types) {
+ File dir = getClassDir(sourceRoot, c);
+ if (!dir.exists()) {
+
+ // pas de repertoire adequate
+ if (log.isDebugEnabled()) {
+ log.debug("skip non existing directory " + dir);
+ }
+ continue;
+ }
+ String[] contexts = getContexts(c, dir);
+ if (log.isDebugEnabled()) {
+ log.debug("contexts : " + Arrays.toString(contexts));
+ }
+
+ if (contexts.length > 0) {
+ String[] realContexts = getContextsWithoutScopes(contexts);
+
+ if (log.isDebugEnabled()) {
+ log.debug("realContexts : " +
+ Arrays.toString(realContexts));
+ }
+
+ if (contextFilter != null) {
+
+ // filter contexts
+ realContexts = getFilterContexts(contextFilter,
+ realContexts
+ );
+ if (log.isDebugEnabled()) {
+ log.debug("filterContexts : " +
+ Arrays.toString(realContexts));
+ }
+ }
+
+ for (String context : realContexts) {
+
+ // on cherche le validateur
+ BeanValidator<?> validator = getValidator(
+ validatorClass,
+ c,
+ context.isEmpty() ? null : context,
+ scopes
+ );
+ if (validator != null) {
+ // on enregistre le validateur
+ result.add(validator);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Pour un context et un type d'entité donné, instancie un validateur et
+ * test si ce validateur est utilisable (i.e qu'il admet des champs à
+ * valider).
+ * <p/>
+ * Si aucun champ n'est trouvé dans le validateur, alors on retourne null.
+ *
+ * @param <B> le type du bean
+ * @param validatorClass le type de validateur a instancie
+ * @param klass le type du bean
+ * @param context le context du validateur
+ * @param scopes les scopes a utiliser (si {@code null} alors pas de
+ * filtre sur les scopes)
+ * @return le validateur initialisé, ou <code>null</code> si aucun scope
+ * détecté dans le validateur.
+ */
+ protected <B> BeanValidator<B> getValidator(Class<?> validatorClass,
+ Class<B> klass,
+ String context,
+ BeanValidatorScope... scopes) {
+
+ BeanValidator<B> valitator;
+ valitator = createValidator(validatorClass, klass, context, scopes);
+
+ Set<BeanValidatorScope> resultScopes = valitator.getScopes();
+ if (resultScopes.isEmpty()) {
+ valitator = null;
+ if (log.isDebugEnabled()) {
+ log.debug(klass + " : validator skip (no scopes detected)");
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(klass + " : keep validator " + valitator);
+ }
+ }
+ return valitator;
+ }
+
+ protected <B> BeanValidator<B> createValidator(
+ Class<?> validatorClass,
+ Class<B> klass,
+ String context,
+ BeanValidatorScope[] scopes) {
+ BeanValidator<B> valitator;
+ Constructor<?> con;
+ try {
+ con = ConstructorUtils.getAccessibleConstructor(
+ validatorClass,
+ new Class<?>[]{
+ Class.class,
+ String.class,
+ BeanValidatorScope[].class
+ }
+ );
+ if (con != null) {
+
+ valitator = (BeanValidator<B>) con.newInstance(
+ klass,
+ context, scopes
+ );
+
+ } else {
+ con = ConstructorUtils.getAccessibleConstructor(
+ validatorClass,
+ new Class<?>[]{
+ Class.class,
+ String.class,
+ BeanValidatorScope[].class
+ }
+ );
+
+ if (con == null) {
+ throw new IllegalStateException(
+ "could not find a constructor with " +
+ "(Class.class, String) or " +
+ "(Class,String BeanValidatorScope[])");
+ }
+
+ valitator = (BeanValidator<B>) con.newInstance(
+ klass,
+ context
+ );
+ if (scopes != null && scopes.length > 0) {
+ valitator.setFilterScopes(scopes);
+ }
+ }
+
+ } catch (Exception ex) {
+ throw new RuntimeException(
+ "could not instanciate validator " + validatorClass +
+ " for reason " + ex.getMessage(), ex);
+ }
+ return valitator;
+ }
+
+ protected File getClassDir(File sourceRoot, Class<?> clazz) {
+ String path = clazz.getPackage().getName();
+ path = path.replaceAll("\\.", File.separator);
+ File dir = new File(sourceRoot, path);
+ return dir;
+ }
+
+ protected String[] getContexts(Class<?> clazz, File dir) {
+ Set<String> result = new TreeSet<String>();
+ ValidatorFilenameFilter filter = new ValidatorFilenameFilter(clazz);
+ if (log.isDebugEnabled()) {
+ log.debug("dir : " + dir);
+ }
+ String[] files = dir.list(filter);
+ for (String file : files) {
+ if (log.isDebugEnabled()) {
+ log.debug("file " + file);
+ }
+ String context = file.substring(
+ filter.prefix.length(),
+ file.length() - ValidatorFilenameFilter.SUFFIX.length()
+ );
+ if (log.isDebugEnabled()) {
+ log.debug("detect " + clazz.getSimpleName() +
+ " context [" + context + "]");
+ }
+ result.add(context);
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+ protected String[] getContextsWithoutScopes(String[] contexts) {
+ Set<String> result = new TreeSet<String>();
+ BeanValidatorScope[] scopes = BeanValidatorScope.values();
+ for (String context : contexts) {
+ for (BeanValidatorScope scope : scopes) {
+ String scopeName = scope.name().toLowerCase();
+ if (!context.endsWith(scopeName)) {
+ // pas concerne par ce scope
+ continue;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("detect context : " + context);
+ }
+ String realContext = context.substring(
+ 0,
+ context.length() - scopeName.length()
+ );
+ if (realContext.endsWith("-")) {
+ realContext = realContext.substring(
+ 0,
+ realContext.length() - 1
+ );
+ }
+ result.add(realContext);
+ }
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+ protected String[] getFilterContexts(Pattern contextFilter,
+ String[] realContexts) {
+ List<String> result = new ArrayList<String>();
+ for (String c : realContexts) {
+ Matcher m = contextFilter.matcher(c);
+ if (m.matches()) {
+ result.add(c);
+ }
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+ protected static class ValidatorFilenameFilter implements FilenameFilter {
+
+ protected static final String SUFFIX = "-validation.xml";
+
+ protected Class<?> clazz;
+
+ protected String prefix;
+
+ public ValidatorFilenameFilter(Class<?> clazz) {
+ this.clazz = clazz;
+ prefix = clazz.getSimpleName() + "-";
+ }
+
+ @Override
+ public boolean accept(File dir, String name) {
+ boolean result = name.endsWith(SUFFIX);
+ if (result) {
+ result = name.startsWith(prefix);
+ }
+ return result;
+ }
+ }
+
+ protected static class BeanValidatorComparator implements Comparator<BeanValidator<?>> {
+
+ @Override
+ public int compare(BeanValidator<?> o1, BeanValidator<?> o2) {
+ String contextName1 =
+ o1.getBeanClass().getSimpleName() + "-" +
+ (o1.getContextName() == null ? "" : o1.getContextName());
+ String contextName2 =
+ o2.getBeanClass().getSimpleName() + "-" +
+ (o2.getContextName() == null ? "" : o2.getContextName());
+ return contextName1.compareTo(contextName2);
+ }
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorDetector.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,86 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import java.util.EventObject;
+
+/**
+ * The definition of an event on {@link BeanValidatorListener}
+ * to be fired by a {@link BeanValidator}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class BeanValidatorEvent extends EventObject {
+
+ private static final long serialVersionUID = 1L;
+
+ /** the field impacted by the validator */
+ protected BeanValidatorField<?> field;
+
+ /** the scope impacted by the event */
+ protected BeanValidatorScope scope;
+
+ protected String[] messagestoAdd;
+
+ protected String[] messagestoDelete;
+
+ public BeanValidatorEvent(BeanValidator<?> source,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ String[] messagestoAdd,
+ String[] messagestoDelete) {
+ super(source);
+ this.field = field;
+ this.scope = scope;
+ this.messagestoAdd = messagestoAdd;
+ this.messagestoDelete = messagestoDelete;
+ }
+
+ @Override
+ public BeanValidator<?> getSource() {
+ return (BeanValidator<?>) super.getSource();
+ }
+
+ public String getFieldName() {
+ return field.getName();
+ }
+
+ public String[] getMessagesToAdd() {
+ return messagestoAdd;
+ }
+
+ public String[] getMessagesToDelete() {
+ return messagestoDelete;
+ }
+
+ public BeanValidatorScope getScope() {
+ return scope;
+ }
+
+ public BeanValidatorField<?> getField() {
+ return field;
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorEvent.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,286 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import com.opensymphony.xwork2.validator.FieldValidator;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Definition of a field to be handled in a {@link BeanValidator}.
+ * <p/>
+ * A such class is only registred in {@link BeanValidator } when the field of
+ * the bean was found in validator xml configuration file for a {@link
+ * FieldValidator} only.
+ * <p/>
+ * This class use properties {@link #beanClass}, {@link #name} to define his
+ * naturel order.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @param <B> the type of the bean handled by the validator and this field of
+ * validation.
+ * @since 1.3
+ */
+public class BeanValidatorField<B> implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** the class of bean */
+ protected final Class<B> beanClass;
+
+ /** name of field in bean */
+ protected final String name;
+
+ protected EnumMap<BeanValidatorScope, Set<String>> messages;
+
+ public BeanValidatorField(Class<B> beanClass,
+ String name,
+ List<BeanValidatorScope> scopes) {
+ this.beanClass = beanClass;
+ this.name = name;
+ messages = new EnumMap<BeanValidatorScope, Set<String>>(
+ BeanValidatorScope.class
+ );
+ for (BeanValidatorScope scope : scopes) {
+ messages.put(scope, new HashSet<String>());
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<B> getBeanClass() {
+ return beanClass;
+ }
+
+ /**
+ * @return {@code true} if this field is valid : no fatal errors and no
+ * errors), {@code false} otherwise.
+ */
+ public boolean isValid() {
+ return !hasFatalErrors() && !hasErrors();
+ }
+
+ public BeanValidatorScope getScope() {
+ if (hasErrors()) {
+ return BeanValidatorScope.ERROR;
+ }
+ if (hasWarnings()) {
+ return BeanValidatorScope.WARNING;
+ }
+ if (hasInfos()) {
+ return BeanValidatorScope.INFO;
+ }
+ return null;
+ }
+
+ public Set<BeanValidatorScope> getScopes() {
+ return messages.keySet();
+ }
+
+ public boolean hasFatalErrors() {
+ return hasMessages(BeanValidatorScope.FATAL);
+ }
+
+ public boolean hasErrors() {
+ return hasMessages(BeanValidatorScope.ERROR);
+ }
+
+ public boolean hasWarnings() {
+ return hasMessages(BeanValidatorScope.WARNING);
+ }
+
+ public boolean hasInfos() {
+ return hasMessages(BeanValidatorScope.INFO);
+ }
+
+ public Set<String> getFatalErrors() {
+ return getMessages(BeanValidatorScope.FATAL);
+ }
+
+ public Set<String> getErrors() {
+ return getMessages(BeanValidatorScope.ERROR);
+ }
+
+ public Set<String> getWarnings() {
+ return getMessages(BeanValidatorScope.WARNING);
+ }
+
+ public Set<String> getInfos() {
+ return getMessages(BeanValidatorScope.INFO);
+ }
+
+ public boolean hasMessages(BeanValidatorScope scope) {
+ return messages.containsKey(scope) && !getMessages(scope).isEmpty();
+ }
+
+ public Set<String> getMessages(BeanValidatorScope scope) {
+ return messages.get(scope);
+ }
+
+ public void updateMessages(BeanValidator<B> validator,
+ BeanValidatorScope scope,
+ List<String> messages) {
+
+ if (scope == null) {
+
+ // special case to reset all messages from all scopes
+
+ for (BeanValidatorScope s : getScopes()) {
+
+ clearMessages(s, validator);
+ }
+ return;
+ }
+
+ if (!this.messages.containsKey(scope)) {
+ throw new IllegalArgumentException(
+ "the scope " + scope + " was not registred for " + this);
+ }
+
+ if (messages == null || messages.isEmpty()) {
+
+ // no incoming message for this scope
+
+ clearMessages(scope, validator);
+ return;
+ }
+
+ // build the diff of messages (the one to delete, the one to add)
+
+ boolean hasChanged = false;
+
+ Set<String> currentMessages = getMessages(scope);
+
+ // detect messages to delete
+ Set<String> toDelete = new HashSet<String>(currentMessages);
+ toDelete.removeAll(messages);
+
+ if (!toDelete.isEmpty()) {
+ // apply delete
+ currentMessages.removeAll(toDelete);
+ hasChanged = true;
+ }
+
+ // detect messages to add
+ Set<String> toAdd = new HashSet<String>(messages);
+ toAdd.removeAll(currentMessages);
+
+ if (!toAdd.isEmpty()) {
+ // apply add
+ currentMessages.addAll(toAdd);
+ hasChanged = true;
+ }
+
+ if (hasChanged) {
+
+ // something has changed, fire notifications
+ String[] del = toDelete.toArray(new String[toDelete.size()]);
+ String[] add = toAdd.toArray(new String[toAdd.size()]);
+
+ validator.fireFieldChanged(this, scope, add, del);
+ }
+ toAdd.clear();
+ toDelete.clear();
+
+ }
+
+ public String getI18nError(String error) {
+ String text;
+ if (!error.contains("##")) {
+ text = _(error);
+ } else {
+ StringTokenizer stk = new StringTokenizer(error, "##");
+ String errorName = stk.nextToken();
+ List<String> args = new ArrayList<String>();
+ while (stk.hasMoreTokens()) {
+ args.add(stk.nextToken());
+ }
+ text = _(errorName, args.toArray());
+ }
+ return text;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof BeanValidatorField<?>)) {
+ return false;
+ }
+
+ BeanValidatorField<?> that = (BeanValidatorField<?>) o;
+ return beanClass.equals(that.beanClass) && name.equals(that.name);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = beanClass.hashCode();
+ result = 31 * result + name.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<").append(super.toString());
+ sb.append(" beanClass:").append(beanClass);
+ sb.append(", name:").append(name);
+ sb.append(", scopes:");
+ sb.append(messages == null ? "[]" : messages.keySet());
+ sb.append(", scope:").append(getScope());
+ //sb.append(", errors:").append(errors);
+ sb.append('>');
+ return sb.toString();
+ }
+
+ protected void clearMessages(BeanValidatorScope scope,
+ BeanValidator<B> validator) {
+ // remove all messages
+ Set<String> toDelete = getMessages(scope);
+
+ if (!toDelete.isEmpty()) {
+
+ // there is some messages to delete
+ String[] toDel = toDelete.toArray(new String[toDelete.size()]);
+
+ // apply deletion
+ toDelete.clear();
+
+ // fire
+ validator.fireFieldChanged(this, scope, null, toDel);
+ }
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorField.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,43 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import java.util.EventListener;
+
+/**
+ * The listener contract to be used on {@link BeanValidator}
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public interface BeanValidatorListener extends EventListener {
+
+ /**
+ * Invoked when a validator detects some changes on a field.
+ *
+ * @param event the event
+ */
+ void onFieldChanged(BeanValidatorEvent event);
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,118 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+/**
+ * The object to box a validation message.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @param <E> type of message (use for override {@link #compareTo(Object)}
+ * method.
+ * @since 1.3
+ */
+public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> {
+
+ /** the validator that produce the message */
+ protected BeanValidator<?> validator;
+
+ /** the field that produce the message */
+ protected BeanValidatorField<?> field;
+
+ /** the label of the message (to be displayed somewhere) */
+ protected String message;
+
+ /** the scope of the message */
+ protected BeanValidatorScope scope;
+
+ public BeanValidatorMessage(BeanValidator<?> validator,
+ BeanValidatorField<?> field,
+ String message,
+ BeanValidatorScope scope) {
+ this.field = field;
+ this.validator = validator;
+ this.message = message == null ? null : message.trim();
+ this.scope = scope;
+ }
+
+ public BeanValidator<?> getValidator() {
+ return validator;
+ }
+
+ public BeanValidatorField<?> getField() {
+ return field;
+ }
+
+ public BeanValidatorScope getScope() {
+ return scope;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public int compareTo(E o) {
+ // sort on scope
+ int result = getScope().compareTo(o.getScope());
+ if (result == 0) {
+ // sort on field name
+ result = field.getName().compareTo(o.field.getName());
+ if (result == 0) {
+ // sort on message
+ result = message.compareTo(o.message);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ BeanValidatorMessage<?> that = (BeanValidatorMessage<?>) o;
+
+ return field.equals(that.field) &&
+ message.equals(that.message) &&
+ scope == that.scope;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = field.hashCode();
+ result = 31 * result + message.hashCode();
+ result = 31 * result + scope.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return scope + " - " + field.getI18nError(message);
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorMessage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,79 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * The differents levels of messages in validation process.
+ * <p/>
+ * The order of the enum defines the severity of validation.
+ * <p/>
+ * Always begin with fatal, then error, then if no error found, try warning, then info...
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public enum BeanValidatorScope {
+
+ /**
+ * the fatal error scope level.
+ * <p/>
+ * When a message of a such scope is found on a validator, then the
+ * validator is invalid and modified.
+ * @since 2.2.4
+ */
+ FATAL(n_("validator.scope.fatal.label")),
+ /**
+ * the error scope level.
+ * <p/>
+ * When a message of a such scope is found on a validator, then the
+ * validator is invalid and modified.
+ */
+ ERROR(n_("validator.scope.error.label")),
+ /**
+ * the warning scope level.
+ * <p/>
+ * When a message of a such scope is found on a validator, then the
+ * validator is still valid but modified.
+ */
+ WARNING(n_("validator.scope.warning.label")),
+ /**
+ * the information scope level.
+ * <p/>
+ * When a message of a sucg scope is found on a validator, then the
+ * validator is still valid and not modified.
+ */
+ INFO(n_("validator.scope.info.label"));
+
+ private final String label;
+
+ BeanValidatorScope(String label) {
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorScope.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,196 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.List;
+
+/**
+ * The helper class for validation module.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class BeanValidatorUtil {
+
+ /** Logger */
+ static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
+
+ /**
+ * a shared value stack to allow external operations on it (for example add
+ * some datas in stack to be usedby validators
+ */
+ static private ValueStack sharedValueStack;
+
+ public static ValueStack getSharedValueStack() {
+ if (sharedValueStack == null) {
+
+ // init context
+ ConfigurationManager confManager = new ConfigurationManager();
+ Configuration conf = confManager.getConfiguration();
+
+ Container container = conf.getContainer();
+ ValueStackFactory stackFactory = container.getInstance(
+ ValueStackFactory.class);
+ sharedValueStack = stackFactory.createValueStack();
+ if (log.isDebugEnabled()) {
+ log.debug("init shared value stack " + sharedValueStack);
+ }
+ }
+ return sharedValueStack;
+ }
+
+ protected BeanValidatorUtil() {
+ // no instance
+ }
+
+ /**
+ * Convert a value to a given type and then if was succesffull try to set it
+ * in the bean manage by the validator.
+ *
+ * @param validator validator to be involved
+ * @param fieldName the name of the bean property
+ * @param value the actual value to convert
+ * @param valueClass the type of the conversion
+ */
+ public static void convert(BeanValidator<?> validator,
+ String fieldName,
+ String value,
+ Class<?> valueClass) {
+
+ Object result = validator.convert(fieldName, value, valueClass);
+ if (result != null) {
+ try {
+ BeanInfo info =
+ Introspector.getBeanInfo(validator.getBean().getClass());
+
+ for (PropertyDescriptor descriptor :
+ info.getPropertyDescriptors()) {
+ if (fieldName.equals(descriptor.getName()) &&
+ descriptor.getWriteMethod() != null) {
+
+ descriptor.getWriteMethod().invoke(
+ validator.getBean(),
+ result
+ );
+ break;
+ }
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("could not obtain beanInfo for " +
+ valueClass.getClass() + ", reason : " +
+ e.getMessage(), e);
+ }
+ }
+ } else {
+ //fixme : conversion failed, we should be able to notify ui
+ // that values has changed ?
+ // otherwise, bean value has not changed,...
+ }
+ }
+
+ public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class<?> beanClass) {
+ try {
+ // check that the bean is listenable, otherwise, can't use
+ // the validator on it
+ BeanInfo infos = Introspector.getBeanInfo(beanClass);
+ EventSetDescriptor[] events = infos.getEventSetDescriptors();
+ for (EventSetDescriptor event : events) {
+ if ("propertyChange".equals(event.getName())) {
+
+ if (event.getAddListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException(
+ "no addPropertyChangeListener method found " +
+ "for " + beanClass);
+ }
+ if (event.getRemoveListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException(
+ "no removePropertyChangeListener method found" +
+ " for " + beanClass);
+ }
+ return event;
+ }
+ }
+
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException(
+ "no PropertyChangeListener access method found for " +
+ beanClass);
+ } catch (IntrospectionException ex) {
+ throw new IllegalStateException(
+ "could not acquire PropertyChangeListener bean info for " +
+ beanClass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ public static EnumSet<BeanValidatorScope> getScopes(
+ List<BeanValidatorMessage<?>> messages) {
+ EnumSet<BeanValidatorScope> result =
+ EnumSet.noneOf(BeanValidatorScope.class);
+ for (BeanValidatorMessage<?> m : messages) {
+ result.add(m.getScope());
+ }
+ return result;
+ }
+
+ public static EnumMap<BeanValidatorScope, Integer> getScopesCount(
+ List<BeanValidatorMessage<?>> messages) {
+ EnumMap<BeanValidatorScope, Integer> result =
+ new EnumMap<BeanValidatorScope, Integer>(BeanValidatorScope.class);
+ for (BeanValidatorScope s : BeanValidatorScope.values()) {
+ result.put(s, 0);
+ }
+ for (BeanValidatorMessage<?> m : messages) {
+
+ BeanValidatorScope scope = m.getScope();
+
+ result.put(scope, result.get(scope) + 1);
+ }
+
+ for (BeanValidatorScope s : BeanValidatorScope.values()) {
+ if (result.get(s) == 0) {
+ result.remove(s);
+ }
+ }
+ return result;
+ }
+
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/BeanValidatorUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,126 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Un dictionnaire de validateurs ordonnees par le type de leur bean.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class ValidatorsMap implements Map<Class<?>, BeanValidator<?>> {
+
+ protected final Map<Class<?>, BeanValidator<?>> delegate;
+
+ public ValidatorsMap() {
+ delegate = new HashMap<Class<?>, BeanValidator<?>>();
+ }
+
+ public BeanValidatorScope[] getScopes() {
+ EnumSet<BeanValidatorScope> result =
+ EnumSet.noneOf(BeanValidatorScope.class);
+ for (BeanValidator<?> b : values()) {
+ result.addAll(b.getScopes());
+ }
+ return result.toArray(new BeanValidatorScope[result.size()]);
+ }
+
+// public <X> BeanValidator<X> getValidator(X klass) {
+// BeanValidator<X> beanValidator = (BeanValidator<X>) get(klass.getClass());
+// return beanValidator;
+// }
+
+ public <X> BeanValidator<X> getValidator(Class<X> klass) {
+ BeanValidator<X> beanValidator = (BeanValidator<X>) get(klass);
+ return beanValidator;
+ }
+
+ @Override
+ public int size() {
+ return delegate.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return delegate.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return delegate.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return delegate.containsValue(value);
+ }
+
+ @Override
+ public BeanValidator<?> get(Object key) {
+ return delegate.get(key);
+ }
+
+ @Override
+ public BeanValidator<?> put(Class<?> key, BeanValidator<?> value) {
+ return delegate.put(key, value);
+ }
+
+ @Override
+ public BeanValidator<?> remove(Object key) {
+ return delegate.remove(key);
+ }
+
+ @Override
+ public void putAll(Map<? extends Class<?>, ? extends BeanValidator<?>> m) {
+ delegate.putAll(m);
+ }
+
+ @Override
+ public void clear() {
+ delegate.clear();
+ }
+
+ @Override
+ public Set<Class<?>> keySet() {
+ return delegate.keySet();
+ }
+
+ @Override
+ public Collection<BeanValidator<?>> values() {
+ return delegate.values();
+ }
+
+ @Override
+ public Set<Entry<Class<?>, BeanValidator<?>>> entrySet() {
+ return delegate.entrySet();
+ }
+
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/ValidatorsMap.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,324 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ValidationAwareSupport;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import com.opensymphony.xwork2.validator.DelegatingValidatorContext;
+import com.opensymphony.xwork2.validator.FieldValidator;
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.Validator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A customized validator for a given bean.
+ * <p/>
+ * Use the method {@link #validate(Object)} to obtain the messages detected by
+ * the validator for the given bean.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @param <B> type of the bean to validate.
+ * @since 1.3
+ */
+public class XWorkBeanValidator<B> {
+
+ /** Logger */
+ private static final Log log = LogFactory.getLog(XWorkBeanValidator.class);
+
+ protected final static Map<String, List<String>> EMPTY_RESULT =
+ Collections.unmodifiableMap(new HashMap<String, List<String>>());
+
+ /** the type of bean to validate */
+ protected final Class<B> beanClass;
+
+ /** the validation named context (can be null) */
+ protected String contextName;
+
+ /** the list of field names detected for this validator */
+ protected Set<String> fieldNames;
+
+ /** a flag to include or not the default context validators */
+ protected boolean includeDefaultContext;
+
+ // --
+ // XWorks fields
+ // --
+
+ protected ValidationAwareSupport validationSupport;
+
+ protected DelegatingValidatorContext validationContext;
+
+ protected ActionValidatorManager validator;
+
+ protected ActionContext context;
+
+ public XWorkBeanValidator(Class<B> beanClass, String contextName) {
+ this(beanClass,
+ contextName,
+ true,
+ BeanValidatorUtil.getSharedValueStack()
+ );
+ }
+
+ public XWorkBeanValidator(Class<B> beanClass,
+ String contextName,
+ ValueStack vs) {
+ this(beanClass, contextName, true, vs);
+ }
+
+ public XWorkBeanValidator(Class<B> beanClass,
+ String contextName,
+ boolean includeDefaultContext) {
+ this(beanClass,
+ contextName,
+ includeDefaultContext,
+ BeanValidatorUtil.getSharedValueStack()
+ );
+ }
+
+ public XWorkBeanValidator(Class<B> beanClass,
+ String contextName,
+ boolean includeDefaultContext,
+ ValueStack vs) {
+
+ this.beanClass = beanClass;
+ this.includeDefaultContext = includeDefaultContext;
+ validationSupport = new ValidationAwareSupport();
+ validationContext = new DelegatingValidatorContext(validationSupport);
+
+ if (vs == null) {
+ // create a standalone value stack
+ ConfigurationManager confManager = new ConfigurationManager();
+ Configuration conf = confManager.getConfiguration();
+ Container container = conf.getContainer();
+ ValueStackFactory stackFactory =
+ container.getInstance(ValueStackFactory.class);
+ vs = stackFactory.createValueStack();
+ if (log.isDebugEnabled()) {
+ log.debug("create a standalone value stack " + vs);
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("use given value stack " + vs);
+ }
+ }
+
+ context = new ActionContext(vs.getContext());
+ ActionContext.setContext(context);
+
+ // init validator
+ Container container = context.getContainer();
+ validator = container.getInstance(ActionValidatorManager.class,
+ "no-annotations"
+ );
+
+ // init context
+ setContextName(contextName);
+ }
+
+ public boolean isIncludeDefaultContext() {
+ return includeDefaultContext;
+ }
+
+ public Class<B> getBeanClass() {
+ return beanClass;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public Set<String> getFieldNames() {
+ return fieldNames;
+ }
+
+ public ActionValidatorManager getValidator() {
+ return validator;
+ }
+
+ /**
+ * Test a the validator contains the field given his name
+ *
+ * @param fieldName the name of the searched field
+ * @return <code>true</code> if validator contaisn this field,
+ * <code>false</code> otherwise
+ */
+ public boolean containsField(String fieldName) {
+ return fieldNames.contains(fieldName);
+ }
+
+ public void setIncludeDefaultContext(boolean includeDefaultContext) {
+ this.includeDefaultContext = includeDefaultContext;
+ if (contextName != null) {
+ // reload context
+ setContextName(contextName);
+ }
+ }
+
+ public void setContextName(String contextName) {
+ this.contextName = contextName;
+ // changing contextName may change fields definition
+ // so reload fields
+ initFields();
+ }
+
+ /**
+ * Valide le bean donné et retourne les messages produits.
+ *
+ * @param bean le bean a valider (il doit etre non null)
+ * @return le dictionnaire des messages produits par la validation indexées
+ * par le nom du champs du bean impacté.
+ */
+ public Map<String, List<String>> validate(B bean) {
+
+ if (bean == null) {
+ throw new NullPointerException(
+ "bean can not be null in method validate");
+ }
+
+ Map<String, List<String>> result = EMPTY_RESULT;
+
+ // on lance la validation uniquement si des champs sont a valider
+ if (!fieldNames.isEmpty()) {
+
+ try {
+
+ //TC - 20081024 : since context is in a ThreadLocal variable,
+ // we must do the check
+ if (ActionContext.getContext() == null) {
+ ActionContext.setContext(context);
+ }
+
+ validator.validate(bean, contextName, validationContext);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Action errors: " +
+ validationContext.getActionErrors());
+ log.trace("Action messages: " +
+ validationContext.getActionMessages());
+ log.trace("Field errors: " +
+ validationContext.getFieldErrors());
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(this + " : " +
+ validationContext.getFieldErrors());
+ }
+
+ // retreave errors by field
+ if (validationContext.hasFieldErrors()) {
+ Map<?, ?> messages = validationContext.getFieldErrors();
+ result = new HashMap<String, List<String>>(messages.size());
+ for (Object fieldName : messages.keySet()) {
+ Collection<?> c =
+ (Collection<?>) messages.get(fieldName);
+ List<String> mm = new ArrayList<String>(c.size());
+ for (Object message : c) {
+ // tchemit 2010-08-28 : trim the incoming message
+ // (I18n will not translate it otherwise)
+ String messageStr = message == null ? "" : message + "";
+ mm.add(messageStr.trim());
+ }
+ result.put(fieldName + "", mm);
+ }
+ }
+
+ } catch (ValidationException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Error during validation on " + beanClass +
+ " for reason : " + eee.getMessage(), eee);
+ }
+
+ } finally {
+ // on nettoye toujours le validateur apres operation
+ validationSupport.clearErrorsAndMessages();
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<beanClass:" + beanClass +
+ ", contextName:" + contextName + ">";
+ }
+
+ /** update the property {@link #fieldNames}, says search in XWorks */
+ protected void initFields() {
+
+ if (fieldNames != null) {
+ fieldNames = null;
+ }
+
+ Set<String> detectedFieldNames = new HashSet<String>();
+
+ int skip = 0;
+ if (contextName != null && !includeDefaultContext) {
+ // count the number of validator to skip
+ for (Validator<?> v : validator.getValidators(beanClass, null)) {
+ // we only work on FieldValidator at the moment
+ if (v instanceof FieldValidator) {
+ skip++;
+ }
+ }
+ }
+
+ for (Validator<?> v : validator.getValidators(beanClass, contextName)) {
+ // we only work on FieldValidator at the moment
+ if (v instanceof FieldValidator) {
+ if (skip > 0) {
+ skip--;
+ continue;
+ }
+ FieldValidator fieldValidator = (FieldValidator) v;
+ if (log.isDebugEnabled()) {
+ log.debug("context " + contextName + " - field " +
+ fieldValidator.getFieldName());
+ }
+ String fName = fieldValidator.getFieldName();
+ detectedFieldNames.add(fName);
+ }
+ }
+
+ fieldNames = Collections.unmodifiableSet(detectedFieldNames);
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/XWorkBeanValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,490 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Un validateur basé sur {@link FieldExpressionValidator} qui valide sur une
+ * collection de propriéte.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class CollectionFieldExpressionValidator extends FieldExpressionValidator {
+
+ public enum Mode {
+
+ /** au moins une entrée de la collection doit etre valide */
+ AT_LEAST_ONE,
+ /** exactement une entrée dela collection doit être valide */
+ EXACTLY_ONE,
+ /** toutes les valeurs de la collection doivent etre valides */
+ ALL,
+ /** aucune valeur de la collection doivent etre valides */
+ NONE,
+ /** detection de clef unique */
+ UNIQUE_KEY
+ }
+
+ /** le mode de validation sur la liste */
+ protected Mode mode;
+
+ /**
+ * pour indiquer la propriété qui contient la liste à valider.
+ * <p/>
+ * Si cette prorpiété n'est pas renseignée alors on utilise la
+ * {@link #getFieldName()} pour obtenir la collection.
+ * <p/>
+ * Cela permet d'effectuer une validation si une collection mais portant
+ * en fait sur un autre champs
+ *
+ * @since 1.5
+ */
+ protected String collectionFieldName;
+
+ /**
+ * drapeau pour utiliser le contexte de parcours pour valider
+ * l'expression, on dispose donc alors des variables previous, current,
+ * index, size et empty dans l'expression.
+ * <p/>
+ * Sinon l'expression s'applique directement sur l'entrée courant dans le
+ * parcours sans préfixe.
+ */
+ protected boolean useSensitiveContext;
+
+ /**
+ * expression a valider sur la premiètre entrée de la collection.
+ * <p/>
+ * Note : Pour le moment, on autorise uniquement cela en mode ALL.
+ */
+ protected String expressionForFirst;
+
+ /**
+ * expression a valider sur la dernière entrée de la collection.
+ * <p/>
+ * Note : Pour le moment, on autorise uniquement cela en mode ALL.
+ */
+ protected String expressionForLast;
+
+ /**
+ * la liste des propriétés d'une entrée de la collection qui définit la
+ * clef unique (en mode UNIQUE_KEY).
+ */
+ protected String[] keys;
+
+ /** le context de parcours */
+ protected WalkerContext c;
+
+ private boolean useFirst, useLast;
+
+ public Mode getMode() {
+ return mode;
+ }
+
+ public void setMode(Mode mode) {
+ this.mode = mode;
+ }
+
+ public String getCollectionFieldName() {
+ return collectionFieldName;
+ }
+
+ public void setCollectionFieldName(String collectionFieldName) {
+ this.collectionFieldName = collectionFieldName;
+ }
+
+ public boolean isUseSensitiveContext() {
+ return useSensitiveContext;
+ }
+
+ public void setUseSensitiveContext(boolean useSensitiveContext) {
+ this.useSensitiveContext = useSensitiveContext;
+ }
+
+ public String getExpressionForFirst() {
+ return expressionForFirst;
+ }
+
+ public void setExpressionForFirst(String expressionForFirst) {
+ this.expressionForFirst = expressionForFirst;
+ }
+
+ public String getExpressionForLast() {
+ return expressionForLast;
+ }
+
+ public void setExpressionForLast(String expressionForLast) {
+ this.expressionForLast = expressionForLast;
+ }
+
+ public String[] getKeys() {
+ return keys;
+ }
+
+ public void setKeys(String[] keys) {
+ if (keys != null && keys.length == 1 && keys[0].contains(",")) {
+ this.keys = keys[0].split(",");
+ } else {
+ this.keys = keys;
+ }
+ }
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ if (mode == null) {
+ throw new ValidationException("no mode defined!");
+ }
+ useFirst = expressionForFirst != null && !expressionForFirst.trim().isEmpty();
+ useLast = expressionForLast != null && !expressionForLast.trim().isEmpty();
+
+ if (useFirst && mode != Mode.ALL) {
+ throw new ValidationException("can only use expressionForFirst in " +
+ "mode ALL but was " + mode);
+ }
+ if (useLast && mode != Mode.ALL) {
+ throw new ValidationException("can only use expressionForLast in " +
+ "mode ALL but was " + mode);
+ }
+
+ String fieldName = getFieldName();
+
+ Collection<?> col = getCollection(object);
+
+ if (useSensitiveContext) {
+ c = new WalkerContext(col.size());
+ }
+
+ boolean answer;
+
+ boolean pop = false;
+
+ if (!stack.getRoot().contains(object)) {
+ stack.push(object);
+ pop = true;
+ }
+
+ switch (mode) {
+ case ALL:
+ answer = validateAllEntries(col);
+ break;
+ case AT_LEAST_ONE:
+ answer = validateAtLeastOneEntry(col);
+ break;
+ case EXACTLY_ONE:
+ answer = validateExtacltyOneEntry(col);
+ break;
+ case NONE:
+ answer = validateNoneEntry(col);
+ break;
+ case UNIQUE_KEY:
+ if (keys == null || keys.length == 0) {
+ throw new ValidationException("no unique keys defined");
+ }
+ answer = validateUniqueKey(col);
+ break;
+
+ default:
+ // should never come here...
+ answer = false;
+ }
+
+ if (!answer) {
+ addFieldError(fieldName, object);
+ }
+ if (pop) {
+ stack.pop();
+ }
+ }
+
+ protected ValueStack stack;
+
+ @Override
+ public void setValueStack(ValueStack stack) {
+ super.setValueStack(stack);
+ this.stack = stack;
+ }
+
+ @Override
+ public String getMessage(Object object) {
+ boolean pop = false;
+
+ if (useSensitiveContext && !stack.getRoot().contains(c)) {
+ stack.push(c);
+ pop = true;
+ }
+ String message = super.getMessage(object);
+
+ if (pop) {
+ stack.pop();
+ }
+ return message;
+ }
+
+ protected Boolean validateAllEntries(Collection<?> col) throws ValidationException {
+ boolean answer = true;
+ for (Object entry : col) {
+ answer = validateOneEntry(entry);
+ if (!answer) {
+ // validation on one entry has failed
+ // no need to continue
+ break;
+ }
+ }
+ return answer;
+ }
+
+ protected Boolean validateNoneEntry(Collection<?> col) throws ValidationException {
+ boolean answer = true;
+ for (Object entry : col) {
+ boolean b = validateOneEntry(entry);
+ if (b) {
+ // one entry has sucessed, validation has failed
+ // no need to continue
+ answer = false;
+ break;
+ }
+ }
+ return answer;
+ }
+
+ protected Boolean validateAtLeastOneEntry(Collection<?> col) throws ValidationException {
+ boolean answer = false;
+ for (Object entry : col) {
+ answer = validateOneEntry(entry);
+ if (answer) {
+ // one entry was succes, validation is ok,
+ // no need to continue
+ break;
+ }
+ }
+ return answer;
+ }
+
+ protected Boolean validateExtacltyOneEntry(Collection<?> col) throws ValidationException {
+ int count = 0;
+ for (Object entry : col) {
+ boolean answer = validateOneEntry(entry);
+ if (answer) {
+ // one entry has succed
+ count++;
+ if (count > 1) {
+ // more than one entriy was successfull
+ // so validation has failed
+ break;
+ }
+
+ }
+ }
+ return count == 1;
+ }
+
+ protected Boolean validateUniqueKey(Collection<?> col) throws ValidationException {
+ boolean answer = true;
+
+ Set<Integer> hashCodes = new HashSet<Integer>();
+ int index = -1;
+ for (Object entry : col) {
+ index++;
+ // construction du hash de la clef d'unicite
+ Integer hash = getUniqueKeyHashCode(entry);
+ if (!hashCodes.contains(hash)) {
+ hashCodes.add(hash);
+ continue;
+ }
+ // une entree avec ce hash a deja ete trouvee
+ // on est donc en violation sur la clef unique
+ answer = false;
+ if (log.isDebugEnabled()) {
+ log.debug("duplicated uniquekey " + hash + " for entry " + index);
+ }
+ }
+ hashCodes.clear();
+ return answer;
+ }
+
+ protected boolean validateOneEntry(Object object) throws ValidationException {
+
+ Boolean answer = Boolean.FALSE;
+
+ boolean extraExpression = false;
+
+ if (useSensitiveContext) {
+ c.addCurrent(object);
+ object = c;
+
+ if (c.isFirst() && useFirst) {
+ // on valide l'expression sur la premiètre entrée
+ answer = evaluateExpression(expressionForFirst, object);
+ extraExpression = true;
+ }
+ if (c.isLast() && useLast) {
+ // on valide l'expression sur la dernière entrée
+ answer = (!extraExpression || answer) && evaluateExpression(expressionForLast, object);
+ extraExpression = true;
+ }
+ }
+
+ answer = (!extraExpression || answer) && evaluateExpression(getExpression(), object);
+
+ return answer;
+ }
+
+ protected boolean evaluateExpression(String expression, Object object) throws ValidationException {
+ Object obj = null;
+ try {
+ obj = getFieldValue(expression, object);
+ } catch (ValidationException e) {
+ throw e;
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ // let this pass, but it will be logged right below
+ }
+
+ Boolean answer = Boolean.FALSE;
+
+ if (obj != null && obj instanceof Boolean) {
+ answer = (Boolean) obj;
+ } else {
+ log.warn("Got result of " + obj + " when trying to get Boolean for expression " + expression);
+ }
+ return answer;
+ }
+
+ /**
+ * @param object the incoming object containing the collection to test
+ * @return the collection of the incoming object given by the fieldName property
+ * @throws ValidationException if any pb to retreave the collection
+ */
+ protected Collection<?> getCollection(Object object) throws ValidationException {
+ String fieldName = getCollectionFieldName();
+ if (fieldName == null || fieldName.trim().isEmpty()) {
+ // on travaille directement sur le fieldName
+ fieldName = getFieldName();
+ }
+
+ Object obj = null;
+
+ // obtain the collection to test
+ try {
+ obj = getFieldValue(fieldName, object);
+ } catch (ValidationException e) {
+ throw e;
+ } catch (Exception e) {
+ // let this pass, but it will be logged right below
+ }
+
+ if (obj == null) {
+ // la collection est nulle, donc on renvoie une collection vide
+ return Collections.emptyList();
+ }
+
+ if (!Collection.class.isInstance(obj)) {
+ throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")");
+ }
+ return (Collection<?>) obj;
+ }
+
+ /**
+ * Calcule pour une entrée donné, le hash de la clef unique
+ *
+ * @param o l'entree de la collection dont on va calculer le hash de la clef unique
+ * @return le hashCode calclé de la clef unique sur l'entrée donné
+ * @throws ValidationException if any pb to retreave properties values
+ */
+ protected Integer getUniqueKeyHashCode(Object o) throws ValidationException {
+ // calcul du hash à la volée
+ HashCodeBuilder builder = new HashCodeBuilder();
+ for (String key : keys) {
+ Object property = getFieldValue(key, o);
+ if (log.isDebugEnabled()) {
+ log.debug("key " + key + " : " + property);
+ }
+ builder.append(property);
+ }
+ return builder.toHashCode();
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "collectionFieldExpression";
+ }
+
+ public class WalkerContext {
+
+ protected final int size;
+
+ public WalkerContext(int size) {
+ this.size = size;
+ }
+
+ protected int index = -1;
+
+ protected Object current;
+
+ protected Object previous;
+
+ public void addCurrent(Object current) {
+ index++;
+ previous = this.current;
+ this.current = current;
+ }
+
+ public Object getCurrent() {
+ return current;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public Object getPrevious() {
+ return previous;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public boolean isEmpty() {
+ return size == 0;
+ }
+
+ public boolean isFirst() {
+ return index == 0;
+ }
+
+ public boolean isLast() {
+ return index == size - 1;
+ }
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionFieldExpressionValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,287 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Un validateur basé sur {@link FieldExpressionValidator} qui valide une clef
+ * unique sur une collection.
+ * <p/>
+ * Le {@link #fieldName} sert à récupérer la propriété de type de collection du
+ * bean.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class CollectionUniqueKeyValidator extends FieldExpressionValidator {
+
+ /**
+ * pour indiquer la propriété qui contient la liste à valider.
+ * <p/>
+ * Si cette prorpiété n'est pas renseignée alors on utilise la
+ * {@link #getFieldName()} pour obtenir la collection.
+ * <p/>
+ * Cela permet d'effectuer une validation si une collection mais portant
+ * en fait sur un autre champs
+ *
+ * @since 1.5
+ */
+ protected String collectionFieldName;
+
+ /**
+ * la liste des propriétés d'une entrée de la collection qui définit la
+ * clef unique.
+ */
+ protected String[] keys;
+
+ /**
+ * Une propriété optionnelle pour valider que l'objet reflétée par cette
+ * propriété ne viole pas l'intégrité de la clef unique.
+ * Cela permet de valider l'unicité sans que l'objet soit dans la collection
+ */
+ protected String againstProperty;
+
+ /**
+ * Une propriété optionnelle pour utiliser l'objet en cours de validation pour
+ * valider que l'objet reflétée par cette propriété ne viole pas l'intégrité de la clef unique.
+ * Cela permet de valider l'unicité sans que l'objet soit dans la collection
+ */
+ protected boolean againstMe;
+
+ /**
+ * Lors de l'utilisation de la againstProperty et qu'un ne peut pas utiliser
+ * le equals sur l'objet, on peut spécifier une expression pour exclure des
+ * tests lors de la recherche de la violation de clef unique.
+ */
+ protected String againstIndexExpression;
+
+ public String getCollectionFieldName() {
+ return collectionFieldName;
+ }
+
+ public void setCollectionFieldName(String collectionFieldName) {
+ this.collectionFieldName = collectionFieldName;
+ }
+
+ public String[] getKeys() {
+ return keys;
+ }
+
+ public boolean getAgainstMe() {
+ return againstMe;
+ }
+
+ public void setKeys(String[] keys) {
+ if (keys != null && keys.length == 1 && keys[0].indexOf(',') != -1) {
+ this.keys = keys[0].split(",");
+ } else {
+ this.keys = keys;
+ }
+ }
+
+ public String getAgainstProperty() {
+ return againstProperty;
+ }
+
+ public void setAgainstProperty(String againstProperty) {
+ this.againstProperty = againstProperty;
+ }
+
+ public String getAgainstIndexExpression() {
+ return againstIndexExpression;
+ }
+
+ public void setAgainstIndexExpression(String againstIndexExpression) {
+ this.againstIndexExpression = againstIndexExpression;
+ }
+
+ public void setAgainstMe(boolean againstMe) {
+ this.againstMe = againstMe;
+ }
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+
+ if (keys == null || keys.length == 0) {
+ throw new ValidationException("no unique keys defined");
+ }
+
+ String fieldName = getFieldName();
+
+ Collection<?> col = getCollection(object);
+
+ if (log.isDebugEnabled()) {
+ log.debug("collection found : " + col);
+ }
+ Object againstBean = againstProperty == null ? null :
+ getFieldValue(againstProperty, object);
+
+ if (log.isDebugEnabled()) {
+ log.debug("againtBean = " + againstBean);
+ }
+ Integer againstIndex = (Integer) (againstIndexExpression == null ?
+ -1 :
+ getFieldValue(againstIndexExpression, object));
+ if (againstIndex == null) {
+ againstIndex = -1;
+ }
+ if (againstBean == null && col.size() < 2) {
+ // la liste ne contient pas deux entrées donc c'est valide
+ return;
+ }
+
+ if (againstMe) {
+ // try on this object
+ againstBean = object;
+ if (log.isDebugEnabled()) {
+ log.debug("againtBean from me = " + againstBean);
+ }
+ }
+
+
+ boolean answer = true;
+
+ Integer againstHashCode = againstBean == null ?
+ null : getUniqueKeyHashCode(againstBean);
+ if (log.isDebugEnabled()) {
+ log.debug("hash for new key " + againstHashCode);
+ }
+ List<Integer> hashCodes = new ArrayList<Integer>();
+
+ int index = 0;
+ for (Object o : col) {
+ Integer hash = getUniqueKeyHashCode(o);
+ if (log.isDebugEnabled()) {
+ log.debug("hash for object " + o + " = " + hash);
+ }
+ if (againstBean == null) {
+ if (hashCodes.contains(hash)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ if (log.isDebugEnabled()) {
+ log.debug("Found same hashcode, not unique!");
+ }
+ break;
+ }
+ } else {
+ // utilisation de againstBean
+ if (againstIndex != -1) {
+ if (index != againstIndex &&
+ hash.equals(againstHashCode)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ break;
+ }
+ } else {
+ if (!againstBean.equals(o) &&
+ hash.equals(againstHashCode)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ break;
+ }
+ }
+ }
+ // nouveau hashcode enregistre
+ hashCodes.add(hash);
+ // index suivant
+ index++;
+ }
+
+ if (!answer) {
+ addFieldError(fieldName, object);
+ }
+ }
+
+ /**
+ * Calcule pour une entrée donné, le hash de la clef unique
+ *
+ * @param o l'entree de la collection dont on va calculer le hash de
+ * la clef unique
+ * @return le hashCode calclé de la clef unique sur l'entrée donné
+ * @throws ValidationException if any pb to retreave properties values
+ */
+ protected Integer getUniqueKeyHashCode(Object o)
+ throws ValidationException {
+ // calcul du hash à la volée
+ HashCodeBuilder builder = new HashCodeBuilder();
+ for (String key : keys) {
+ Object property = getFieldValue(key, o);
+ builder.append(property);
+ }
+ return builder.toHashCode();
+ }
+
+ /**
+ * @param object the incoming object containing the collection to test
+ * @return the collection of the incoming object given by the fieldName
+ * property
+ * @throws ValidationException if any pb to retreave the collection
+ */
+ protected Collection<?> getCollection(Object object)
+ throws ValidationException {
+ String fieldName = getCollectionFieldName();
+ if (fieldName == null || fieldName.trim().isEmpty()) {
+ // on travaille directement sur le fieldName
+ fieldName = getFieldName();
+ }
+
+ Object obj = null;
+
+ // obtain the collection to test
+ try {
+ obj = getFieldValue(fieldName, object);
+ } catch (ValidationException e) {
+ throw e;
+ } catch (Exception e) {
+ // let this pass, but it will be logged right below
+ }
+
+ if (obj == null) {
+ // la collection est nulle, donc on renvoie une collection vide
+ return Collections.emptyList();
+ }
+
+ if (!Collection.class.isInstance(obj)) {
+ throw new ValidationException("field " + fieldName +
+ " is not a collection type! (" + obj.getClass() + ')');
+ }
+ return (Collection<?>) obj;
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "collectionUniqueKey";
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/CollectionUniqueKeyValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,97 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * ExistingDirectoryFieldValidator checks that a File field exists and is a directory.
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="existingDirectory">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is not an existing directory</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="existingDirectory">
+ * <message>tmp is not an existing directory</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class ExistingDirectoryFieldValidator extends FieldValidatorSupport {
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (!(f.isDirectory() && f.exists())) {
+ // f is not a directory, nor exists
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "existingDirectory";
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingDirectoryFieldValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,97 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * ExistingFileFieldValidator checks that a File field exists. *
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="fileExisting">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is not an existing file</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="fileExisting">
+ * <message>tmp is not an existing file</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class ExistingFileFieldValidator extends FieldValidatorSupport {
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (!(f.isFile() && f.exists())) {
+ // f is not a file nor exists
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "existingFile";
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/ExistingFileFieldValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,219 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator;
+import org.nuiton.util.converter.ConverterUtil;
+
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Extends {@link FieldExpressionValidator} to add some extra parameters available
+ * in the {@link #getExpression()}
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class FieldExpressionWithParamsValidator extends FieldExpressionValidator {
+
+ protected static final Pattern EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(false|true)");
+
+ protected static final Pattern EXTRA_SHORT_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)");
+
+ protected static final Pattern EXTRA_INT_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)");
+
+ protected static final Pattern EXTRA_LONG_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)");
+
+ protected static final Pattern EXTRA_DOUBLE_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+\\.\\d+)");
+
+ protected static final Pattern EXTRA_STRING_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(.+)");
+
+ protected ValueStack stack;
+
+ protected String booleanParams;
+
+ protected String shortParams;
+
+ protected String intParams;
+
+ protected String longParams;
+
+ protected String doubleParams;
+
+ protected String stringParams;
+
+ protected Map<String, Boolean> booleans;
+
+ protected Map<String, Short> shorts;
+
+ protected Map<String, Integer> ints;
+
+ protected Map<String, Long> longs;
+
+ protected Map<String, Double> doubles;
+
+ protected Map<String, String> strings;
+
+ public String getBooleanParams() {
+ return booleanParams;
+ }
+
+ public void setBooleanParams(String booleanParams) {
+ this.booleanParams = booleanParams;
+ }
+
+ public String getDoubleParams() {
+ return doubleParams;
+ }
+
+ public void setDoubleParams(String doubleParams) {
+ this.doubleParams = doubleParams;
+ }
+
+ public String getIntParams() {
+ return intParams;
+ }
+
+ public void setIntParams(String intParams) {
+ this.intParams = intParams;
+ }
+
+ public String getLongParams() {
+ return longParams;
+ }
+
+ public void setLongParams(String longParams) {
+ this.longParams = longParams;
+ }
+
+ public String getShortParams() {
+ return shortParams;
+ }
+
+ public void setShortParams(String shortParams) {
+ this.shortParams = shortParams;
+ }
+
+ public String getStringParams() {
+ return stringParams;
+ }
+
+ public void setStringParams(String stringParams) {
+ this.stringParams = stringParams;
+ }
+
+ public Map<String, Boolean> getBooleans() {
+ return booleans;
+ }
+
+ public Map<String, Double> getDoubles() {
+ return doubles;
+ }
+
+ public Map<String, Integer> getInts() {
+ return ints;
+ }
+
+ public Map<String, Long> getLongs() {
+ return longs;
+ }
+
+ public Map<String, Short> getShorts() {
+ return shorts;
+ }
+
+ public Map<String, String> getStrings() {
+ return strings;
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "fieldexpressionwithparams";
+ }
+
+ @Override
+ public void setValueStack(ValueStack stack) {
+ super.setValueStack(stack);
+ this.stack = stack;
+ }
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+
+ booleans = initParams(Boolean.class, booleanParams, EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN);
+ shorts = initParams(Short.class, shortParams, EXTRA_SHORT_PARAM_ENTRY_PATTERN);
+ ints = initParams(Integer.class, intParams, EXTRA_INT_PARAM_ENTRY_PATTERN);
+ longs = initParams(Long.class, longParams, EXTRA_LONG_PARAM_ENTRY_PATTERN);
+ doubles = initParams(Double.class, doubleParams, EXTRA_DOUBLE_PARAM_ENTRY_PATTERN);
+ strings = initParams(String.class, stringParams, EXTRA_STRING_PARAM_ENTRY_PATTERN);
+
+ boolean pop = false;
+ if (!stack.getRoot().contains(this)) {
+ stack.push(this);
+ pop = true;
+ }
+
+ try {
+ super.validate(object);
+ } finally {
+ if (pop) {
+ stack.pop();
+ }
+ }
+
+ }
+
+ protected <T> Map<String, T> initParams(Class<T> klass, String extraParams, Pattern pattern) throws ValidationException {
+
+ if (extraParams == null || extraParams.isEmpty()) {
+ // not using
+ return null;
+ }
+
+ StringTokenizer stk = new StringTokenizer(extraParams, "|");
+ Map<String, T> result = new TreeMap<String, T>();
+ while (stk.hasMoreTokens()) {
+ String entry = stk.nextToken();
+ Matcher matcher = pattern.matcher(entry);
+ if (!matcher.matches()) {
+ throw new ValidationException("could not parse for extra params " + extraParams + " for type " + klass.getName());
+ }
+ String paramName = matcher.group(1);
+ String paramValueStr = matcher.group(2);
+ T paramValue = ConverterUtil.convert(klass, paramValueStr);
+ if (log.isDebugEnabled()) {
+ log.debug("detected extra param : <type:" + klass + ", name:" + paramName + ", value:" + paramValue + ">");
+ }
+ result.put(paramName, paramValue);
+ }
+ return result;
+ }
+}
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/FieldExpressionWithParamsValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,96 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * NotExistingDirectoryFieldValidator checks that a File field as a directory does not exist. *
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="notExistingDirectory">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is an existing directory</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="notExistingDirectory">
+ * <message>tmp is an existing directory</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class NotExistingDirectoryFieldValidator extends FieldValidatorSupport {
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (f.exists() || f.isFile()) {
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "notExistingDirectory";
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,97 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * NotExistingFileFieldValidator checks that a File field as a file does not exist. *
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="notExistingFile">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is an existing file</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="notExistingFile">
+ * <message>tmp is an existing file</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class NotExistingFileFieldValidator extends FieldValidatorSupport {
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (f.exists() || f.isDirectory()) {
+ // f is not a file and exist
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "notExistingFile";
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/NotExistingFileFieldValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java (rev 0)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,97 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * RequiredFileFieldValidator checks that a File field is not null nor have an empty filename.
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="requiredFile">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is required</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="requiredFile">
+ * <message>tmp is required</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class RequiredFileFieldValidator extends FieldValidatorSupport {
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (f.getPath().trim().isEmpty()) {
+ // f is not a directory nor exists
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "requiredFile";
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/main/java/org/nuiton/validator/field/RequiredFileFieldValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_en_GB.properties
===================================================================
--- trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_en_GB.properties (rev 0)
+++ trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_en_GB.properties 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,4 @@
+validator.scope.error.label=Error
+validator.scope.fatal.label=Fatal error
+validator.scope.info.label=Information
+validator.scope.warning.label=Warning
Property changes on: trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_en_GB.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_fr_FR.properties
===================================================================
--- trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_fr_FR.properties (rev 0)
+++ trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_fr_FR.properties 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,4 @@
+validator.scope.error.label=Erreur
+validator.scope.fatal.label=Erreur fatale
+validator.scope.info.label=Information
+validator.scope.warning.label=Avertissement
Property changes on: trunk/nuiton-validator/src/main/resources/i18n/nuiton-validator_fr_FR.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/main/resources/validators.xml
===================================================================
--- trunk/nuiton-validator/src/main/resources/validators.xml (rev 0)
+++ trunk/nuiton-validator/src/main/resources/validators.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator Config 1.0//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd">
+
+<!-- START SNIPPET: validators -->
+<validators>
+ <validator name="requiredFile"
+ class="org.nuiton.validator.field.RequiredFileFieldValidator"/>
+ <validator name="existingFile"
+ class="org.nuiton.validator.field.ExistingFileFieldValidator"/>
+ <validator name="notExistingFile"
+ class="org.nuiton.validator.field.NotExistingFileFieldValidator"/>
+ <validator name="existingDirectory"
+ class="org.nuiton.validator.field.ExistingDirectoryFieldValidator"/>
+ <validator name="notExistingDirectory"
+ class="org.nuiton.validator.field.NotExistingDirectoryFieldValidator"/>
+ <validator name="collectionFieldExpression"
+ class="org.nuiton.validator.field.CollectionFieldExpressionValidator"/>
+ <validator name="collectionUniqueKey"
+ class="org.nuiton.validator.field.CollectionUniqueKeyValidator"/>
+</validators>
+<!-- END SNIPPET: validators -->
Property changes on: trunk/nuiton-validator/src/main/resources/validators.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/site/apt/index.apt
===================================================================
--- trunk/nuiton-validator/src/site/apt/index.apt (rev 0)
+++ trunk/nuiton-validator/src/site/apt/index.apt 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,67 @@
+ ----
+ Nuiton utils
+ ----
+ ----
+ 2009-08-23
+ ----
+
+~~~
+~~ #%L
+~~ Nuiton Utils
+~~
+~~ $Id$
+~~ $HeadURL$
+~~ %%
+~~ Copyright (C) 2004 - 2010 CodeLutin
+~~ %%
+~~ This program is free software: you can redistribute it and/or modify
+~~ it under the terms of the GNU Lesser General Public License as
+~~ published by the Free Software Foundation, either version 3 of the
+~~ License, or (at your option) any later version.
+~~
+~~ This program is distributed in the hope that it will be useful,
+~~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~~ GNU General Lesser Public License for more details.
+~~
+~~ You should have received a copy of the GNU General Lesser Public
+~~ License along with this program. If not, see
+~~ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+~~ #L%
+~~~
+
+
+Présentation
+
+ Ensemble de classe Java permettant de simplifier le développement en
+ factorisant des besoins que l'on retrouve dans tous les développements.
+ On y trouve des fonctions de travail sur les chaînes de caractères, des
+ fonctions de parsage des arguements de la ligne de commande, des fonctions
+ permettant très simplement de rechercher une resource (images, fichier de
+ propriétés, ...), ...
+
+Librairie Util
+
+ Librairie regroupant les utilitaires classiques sur les fichiers, les tableaux,
+ les collections, les maps, les chaînes de caractères, ... De plus elle intègre
+ un parser des arguments et des options pour les lignes de commande.
+
+Librairie LutinLog
+
+ N'existe plus depuis la version <<1.1>>.
+
+Librairie i18n
+
+ Depuis la version <<1.1>>, cette librairie est déplacé dans le projet
+ {{{http://maven-site.nuiton.org/i18n/nuiton-i18n}nuiton-i18n}}.
+
+ Librairie permettant de rendre les programmes Java multilangue de façon
+ simple. Il utilise la même philosophie que gettext. C'est à dire que chaque
+ chaîne de caractères devant être traduite sont tagge avec I18n._("...").
+ Ensuite il suffit d'extraire ces cha?nes pour les mettres dans un fichier de
+ propriété, et d'indiquer quel fichier de propré?té charger au démarrage de
+ l'application selon la langue souhaitée.
+
+
+ <Veuillez consulter la JavaDoc pour de plus ample détails sur les différentes
+ librairies.>
Property changes on: trunk/nuiton-validator/src/site/apt/index.apt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/site/site_fr.xml
===================================================================
--- trunk/nuiton-validator/src/site/site_fr.xml (rev 0)
+++ trunk/nuiton-validator/src/site/site_fr.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2004 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ <item name="Documentation" href="/nuitonUtil.html"/>
+ <item name="Application config" href="/ApplicationConfig.html"/>
+ <item name="War launcher" href="/Warlauncher.html"/>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item
+ href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: trunk/nuiton-validator/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,196 @@
+/*
+ * #%L
+ * Nuiton Utils :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * An abstract test to detects validators for a given list of objets types and
+ * <p/>
+ * a given sourceroot directory where to find validations definitions.
+ * <p/>
+ * You just have to implements to {@link #assertDetect(SortedSet)} which contains
+ * the set of validators detected.
+ * <p/>
+ * See {@link BeanValidatorDetectorTest} for an example.
+ * <p/>
+ * Note : An implementation of this test should be produced in evry projects which
+ * defines some validation definitions just to test they are syntax valid.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.6.0
+ */
+public abstract class AbstractBeanValidatorDetectorTest {
+
+ /** Logger */
+ private static final Log log =
+ LogFactory.getLog(AbstractBeanValidatorDetectorTest.class);
+
+ protected static File basedir;
+
+ protected BeanValidatorDetector instance;
+
+ protected Class<?>[] classes;
+
+ protected Class<?> validatorClass;
+
+ protected File sourceRoot;
+
+ protected AbstractBeanValidatorDetectorTest(
+ File sourceRoot,
+ Class<?>... classes) {
+ this(BeanValidator.class, sourceRoot, classes);
+ }
+
+ protected AbstractBeanValidatorDetectorTest(
+ Class<?> validatorClass,
+ File sourceRoot,
+ Class<?>... classes) {
+ this.sourceRoot = sourceRoot;
+ this.classes = classes;
+ this.validatorClass = validatorClass;
+
+ if (log.isInfoEnabled()) {
+ log.info("sourceRoot " + sourceRoot);
+ log.info("validatorClass " + validatorClass);
+ log.info("classes " + Arrays.toString(classes));
+ }
+ }
+
+ protected AbstractBeanValidatorDetectorTest(
+ File sourceRoot,
+ Collection<Class<?>> classes) {
+ this(sourceRoot, classes.toArray(new Class<?>[classes.size()]));
+ }
+
+ public static void setUpClass() throws Exception {
+ String b = System.getenv("basedir");
+ if (b == null) {
+ b = new File("").getAbsolutePath();
+ }
+ basedir = new File(b);
+ if (log.isInfoEnabled()) {
+ log.info("basedir " + basedir);
+ }
+ }
+
+ @Before
+ public void setUp() {
+ instance = new BeanValidatorDetector();
+ }
+
+ @After
+ public void tearDown() {
+ instance = null;
+ }
+
+ /** Test of detect method, of class BeanValidatorDetector. */
+ @Test
+ public void testDetect() {
+ SortedSet<BeanValidator<?>> result = detect(sourceRoot, classes, null);
+ if (log.isInfoEnabled()) {
+ log.info(printValidators("testDetect : ", result));
+ }
+ assertDetect(result);
+ }
+
+ protected abstract void assertDetect(
+ SortedSet<BeanValidator<?>> validators);
+
+ protected SortedSet<BeanValidator<?>> detect(
+ File sourceRoot,
+ Class<?>[] classes,
+ Pattern contextPattern) {
+
+ SortedSet<BeanValidator<?>> result = instance.detect(
+ validatorClass,
+ sourceRoot,
+ contextPattern,
+ classes);
+ return result;
+ }
+
+ protected static void assertValidator(
+ Class<?> expectedBeanClass,
+ String expectedContextName,
+ BeanValidator<?> validator) {
+ assertEquals(expectedBeanClass, validator.getBeanClass());
+ assertEquals(expectedContextName, validator.getContextName());
+ }
+
+ protected static void assertValidatorSetWithSameContextName(
+ SortedSet<BeanValidator<?>> validators,
+ String contextName,
+ Class<?>... expectedClasses) {
+
+ assertEquals(expectedClasses.length, validators.size());
+ Iterator<BeanValidator<?>> itrV = validators.iterator();
+
+ for (Class<?> expectedClass : expectedClasses) {
+ assertValidator(expectedClass, contextName, itrV.next());
+ }
+ }
+
+ protected static void assertValidatorSetWithMultiContextName(
+ SortedSet<BeanValidator<?>> validators,
+ Object... expecteds) {
+
+ assertEquals(expecteds.length % 2, 0);
+ assertEquals(expecteds.length / 2, validators.size());
+ Iterator<BeanValidator<?>> itrV = validators.iterator();
+
+ for (int i = 0; i < expecteds.length / 2; i++) {
+ String contextName = (String) expecteds[2 * i];
+ Class<?> expectedClass = (Class<?>) expecteds[2 * i + 1];
+ assertValidator(expectedClass, contextName, itrV.next());
+ }
+
+ }
+
+ protected static String printValidators(
+ String prefix,
+ SortedSet<BeanValidator<?>> result) {
+ StringBuilder buffer;
+ buffer = new StringBuilder(result.size() * (prefix.length() + 50));
+ buffer.append(prefix).append(result.size()).append('\n');
+ for (BeanValidator<?> v : result) {
+ buffer.append(prefix).append(v).append('\n');
+ }
+ return buffer.toString();
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/AbstractBeanValidatorDetectorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,116 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.SortedSet;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class BeanValidatorDetectorTest extends AbstractBeanValidatorDetectorTest {
+
+ private static final Class<?>[] TYPES = new Class<?>[]{Object.class};
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ AbstractBeanValidatorDetectorTest.setUpClass();
+
+ }
+
+ public BeanValidatorDetectorTest() {
+ super(new File(basedir, "src" + File.separator + "test" + File.separator + "resources"), SimpleBean.class);
+ }
+
+ /** Test of detect method, of class BeanValidatorDetector. */
+ @Test
+ public void testDetectNothing() {
+
+ SortedSet<BeanValidator<?>> validators = instance.detect(sourceRoot, TYPES);
+ assertEquals(0, validators.size());
+ }
+
+ @Override
+ protected void assertDetect(SortedSet<BeanValidator<?>> validators) {
+ assertEquals(1, validators.size());
+ BeanValidator<?> validator = validators.iterator().next();
+ assertEquals(classes[0], validator.getBeanClass());
+ assertNull(validator.getContextName());
+ }
+
+ /** Test of getValidator method, of class BeanValidatorDetector. */
+ @Test
+ public void testGetValidator() {
+ Class<?>[] types = {SimpleBean.class};
+ SortedSet<BeanValidator<?>> result = instance.detect(sourceRoot, types);
+ assertEquals(1, result.size());
+ BeanValidator<?> validator = result.iterator().next();
+ assertEquals(types[0], validator.getBeanClass());
+ assertNull(validator.getContextName());
+
+ types = TYPES;
+ result = instance.detect(sourceRoot, types);
+ assertEquals(0, result.size());
+
+ }
+
+ /** Test of getClassDir method, of class BeanValidatorDetector. */
+ @Test
+ public void testGetClassDir() {
+ Class<?> clazz = classes[0];
+
+ File expected = new File(sourceRoot, "org" + File.separator + "nuiton" + File.separator + "validator");
+ File result = instance.getClassDir(sourceRoot, clazz);
+ assertEquals(expected, result);
+ }
+
+ /** Test of getContexts method, of class BeanValidatorDetector. */
+ @Test
+ public void testGetContexts() {
+
+ String[] expResult = {"fatal", "error", "info", "simple", "warning"};
+ Class<?> clazz = classes[0];
+ File dir = instance.getClassDir(sourceRoot, clazz);
+ String[] result = instance.getContexts(clazz, dir);
+ assertEquals(expResult.length, result.length);
+ }
+
+ /** Test of getContextsWithoutScopes method, of class BeanValidatorDetector. */
+ @Test
+ public void testGetContextsWithoutScopes() {
+
+ Class<?> clazz = SimpleBean.class;
+ String[] expResult = {""};
+ File dir = instance.getClassDir(sourceRoot, clazz);
+ String[] contexts = instance.getContexts(clazz, dir);
+ String[] result = instance.getContextsWithoutScopes(contexts);
+ assertEquals(expResult.length, result.length);
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorDetectorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,290 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class BeanValidatorTest {
+
+ /** Logger */
+ static protected final Log log = LogFactory.getLog(BeanValidator.class);
+
+ protected BeanValidator<SimpleBean> validator;
+
+ protected SimpleBean bean;
+
+ BeanValidatorListenerImpl fatalListener;
+
+ BeanValidatorListenerImpl errorListener;
+
+ BeanValidatorListenerImpl warningListener;
+
+ BeanValidatorListenerImpl infoListener;
+
+ @Before
+ public void setUp() {
+ bean = new SimpleBean();
+ validator = new BeanValidator<SimpleBean>(SimpleBean.class, null);
+ validator.addBeanValidatorListener(fatalListener = new BeanValidatorListenerImpl(BeanValidatorScope.FATAL));
+ validator.addBeanValidatorListener(errorListener = new BeanValidatorListenerImpl(BeanValidatorScope.ERROR));
+ validator.addBeanValidatorListener(warningListener = new BeanValidatorListenerImpl(BeanValidatorScope.WARNING));
+ validator.addBeanValidatorListener(infoListener = new BeanValidatorListenerImpl(BeanValidatorScope.INFO));
+ }
+
+ @After
+ public void tearDown() {
+ bean = null;
+ if (validator != null) {
+ validator.setBean(null);
+ validator = null;
+ }
+ }
+
+ private static final String STRING_VALUE_FATAL= "stringValue.fatal";
+
+ private static final String STRING_VALUE_ERROR = "stringValue.error";
+
+ private static final String STRING_VALUE_WARNING = "stringValue.warning";
+
+ private static final String INT_VALUE_FATAL = "intValue.fatal";
+
+ private static final String INT_VALUE_ERROR = "intValue.error";
+
+ private static final String INT_VALUE_INFO = "intValue.info";
+
+ @Test
+ public void testValidate() {
+
+ assertMessages(fatalListener);
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+ validator.setBean(bean);
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+ bean.setStringValue("one");
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+ bean.setStringValue("oneone");
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, INT_VALUE_ERROR);
+ assertMessages(warningListener);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+ bean.setIntValue(1);
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+ bean.setIntValue(10);
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+
+ bean.setStringValue(null);
+ bean.setIntValue(0);
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+
+ bean.setStringValue("5");
+ bean.setIntValue(5);
+ assertMessages(fatalListener);
+ assertMessages(errorListener);
+ assertMessages(warningListener,STRING_VALUE_WARNING);
+ assertMessages(infoListener,INT_VALUE_INFO);
+ }
+
+ @Test
+ public void testConvert() {
+
+
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+
+ validator.setBean(bean);
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+
+ Object value = validator.convert("intValue", "abc", Class.class);
+
+ Assert.assertNull(value);
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, STRING_VALUE_ERROR, "error.convertor.class");
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+ bean.setStringValue("one");
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, "error.convertor.class");
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+
+ value = validator.convert("intValue", "3", Integer.class);
+
+ bean.setIntValue((Integer) value);
+
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+
+ bean.setIntValue(-1);
+ assertMessages(fatalListener,STRING_VALUE_FATAL,INT_VALUE_FATAL);
+ assertMessages(errorListener, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ if (log.isInfoEnabled()) {
+ log.info("-----------------------------------------------");
+ }
+ }
+
+ void assertMessages(BeanValidatorListenerImpl listener,
+ String... expected) {
+ List<String> actual = listener.getMessages();
+ Assert.assertEquals(" shoudl have " +
+ Arrays.toString(expected) + " but had " + actual,
+ expected.length, actual.size());
+ for (String m : expected) {
+ Assert.assertEquals("could not find " + m + " in " + actual,
+ true, actual.contains(m));
+ }
+ }
+
+ class BeanValidatorListenerImpl implements BeanValidatorListener {
+
+ final BeanValidatorScope scope;
+
+ public BeanValidatorListenerImpl(BeanValidatorScope scope) {
+ this.scope = scope;
+ }
+
+ List<String> messages = new ArrayList<String>();
+
+ public List<String> getMessages() {
+ return messages;
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ if (scope != event.getScope()) {
+ return;
+ }
+ String[] messagesToDelete = event.getMessagesToDelete();
+ if (messagesToDelete != null && messagesToDelete.length > 0) {
+ if (log.isInfoEnabled()) {
+ log.info(event.getScope() + " messages to delete : " + Arrays.toString(messagesToDelete));
+ }
+ for (String m : messagesToDelete) {
+ messages.remove(m);
+ }
+ }
+ String[] messagesToAdd = event.getMessagesToAdd();
+ if (messagesToAdd != null && messagesToAdd.length > 0) {
+ if (log.isInfoEnabled()) {
+ log.info(event.getScope() + " messages to add : " + Arrays.toString(messagesToAdd));
+ }
+ messages.addAll(Arrays.asList(messagesToAdd));
+ }
+ }
+ }
+}
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/BeanValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,79 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+public class SimpleBean {
+
+ protected int intValue;
+
+ protected String stringValue;
+
+ final PropertyChangeSupport p;
+
+ public SimpleBean() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ String old = this.stringValue;
+ this.stringValue = stringValue;
+ p.firePropertyChange("stringValue", old, stringValue);
+ }
+
+ public void setIntValue(int intValue) {
+ int old = this.intValue;
+ this.intValue = intValue;
+ p.firePropertyChange("intValue", old, intValue);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/SimpleBean.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,182 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class XWorkBeanValidatorTest {
+
+ protected XWorkBeanValidator<SimpleBean> validator;
+
+ protected SimpleBean bean;
+
+ protected Map<String, List<String>> messages;
+
+ @Before
+ public void setUp() {
+ bean = new SimpleBean();
+ validator = new XWorkBeanValidator<SimpleBean>(SimpleBean.class, "simple");
+ }
+
+ @After
+ public void tearDown() {
+ bean = null;
+ messages = null;
+ }
+
+ @Test
+ public void testUnknownField() {
+ Assert.assertEquals(false, validator.containsField("fake_" + System.nanoTime()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testValidateNPE() {
+ validator.validate(null);
+ }
+
+ @Test
+ public void testValidate() {
+
+
+ messages = validator.validate(bean);
+
+ assertFieldInError("stringValue", "stringValue.null", true, messages);
+ assertFieldInError("intValue", "intValue.null", true, messages);
+
+ bean.setStringValue("notnull");
+ messages = validator.validate(bean);
+
+ assertFieldInError("stringValue", "stringValue.null", false, messages);
+ assertFieldInError("intValue", "intValue.null", true, messages);
+
+ bean.setIntValue(1);
+ messages = validator.validate(bean);
+
+ assertFieldInError("stringValue", "stringValue.null", false, messages);
+ assertFieldInError("intValue", "intValue.null", false, messages);
+
+ }
+
+ @Test
+ public void testSetContextName() {
+
+
+ String expected = "simple";
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "error");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "warning");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "info");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "fake_" + System.nanoTime());
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ }
+
+ @Test
+ public void testSetIncludeDefaultContext() {
+
+ validator.setIncludeDefaultContext(false);
+
+ String expected = "simple";
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "error");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "warning");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "info");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "fake_" + System.nanoTime());
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ }
+
+ protected void assertFieldInError(String fieldName, String error, boolean required, Map<String, List<String>> messages) {
+
+ Assert.assertEquals(true, validator.containsField(fieldName));
+ List<String> fieldMessages = messages.get(fieldName);
+ //Assert.assertEquals(true,validator.containsField(fieldName));
+ if (fieldMessages != null) {
+ for (String o : fieldMessages) {
+ if (o.equals(error)) {
+ Assert.assertTrue(required);
+ return;
+ }
+ }
+ }
+
+ // error was not found
+ Assert.assertFalse(required);
+ }
+}
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/XWorkBeanValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,127 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.nuiton.validator.BeanValidator;
+import org.nuiton.validator.BeanValidatorField;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+import java.io.File;
+
+/**
+ * Abstract class to test a specific validator.
+ * <p/>
+ * To implements a test on a new validator, just extends this class
+ * and implements the method {@link #testValidator()}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @param <B> the type of bean to validate.
+ */
+public abstract class AbstractFieldValidatorTest<B> extends Assert {
+
+ /** Logger */
+ static private final Log log =
+ LogFactory.getLog(AbstractFieldValidatorTest.class);
+
+ protected static BeanValidator<?> cacheValidator;
+
+ protected static File basedir;
+
+ protected final Class<B> type;
+
+ protected BeanValidator<B> validator;
+
+ protected B bean;
+
+ public AbstractFieldValidatorTest(Class<B> type) {
+ this.type = type;
+ }
+
+ /**
+ * the method to test the given validator on the given bean.
+ * <p/>
+ * When coming here a validator and bean were instanciated and the bean was
+ * setted into validator via setBean method.
+ *
+ * @throws Exception if any error ?
+ */
+ public abstract void testValidator() throws Exception;
+
+ @Before
+ @SuppressWarnings("unchecked")
+ public void setUp() throws Exception {
+ log.debug("start test " + getClass().getSimpleName());
+ bean = type.newInstance();
+ if (cacheValidator == null) {
+ validator = new BeanValidator<B>(type, null);
+ cacheValidator = validator;
+ } else {
+ validator = (BeanValidator<B>) cacheValidator;
+ }
+ validator.setBean(bean);
+ }
+
+ @After
+ @SuppressWarnings("unchecked")
+ public void tearDown() {
+ validator.setBean(null);
+ }
+
+ @AfterClass
+ public static void afterclass() throws Exception {
+ cacheValidator = null;
+ }
+
+ @BeforeClass
+ public static void initValidator() throws Exception {
+
+ String b = System.getenv("basedir");
+ if (b == null) {
+ b = new File("").getAbsolutePath();
+ }
+ basedir = new File(b);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void assertFieldInError(String fieldName, String error, boolean required) {
+ BeanValidatorField<B> field = validator.getField(fieldName);
+ if (field != null && field.getErrors() != null) {
+ for (String o : field.getErrors()) {
+ if (o.equals(error)) {
+ assertTrue("error " + error + " should not exist but was found.", required);
+ return;
+ }
+ }
+ }
+ // error was not found
+ assertFalse("error " + error + " should exist but was not found.", required);
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractFieldValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,38 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+/**
+ * Abstract class to test a specific validator for the {@link ValidatorBean}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public abstract class AbstractValidatorBeanFieldValidatorTest extends AbstractFieldValidatorTest<ValidatorBean> {
+
+ public AbstractValidatorBeanFieldValidatorTest() {
+ super(ValidatorBean.class);
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/AbstractValidatorBeanFieldValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,264 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.nuiton.validator.field.ValidatorBean.ValidatorBeanEntry;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class CollectionFieldExpressionValidatorTest extends AbstractValidatorBeanFieldValidatorTest {
+
+ protected static final String PROPERTY = "entries";
+
+ static protected ValidatorBeanEntry beanEntry0 = new ValidatorBeanEntry(0, "stringValue");
+
+ static protected ValidatorBeanEntry beanEntry0Bis = new ValidatorBeanEntry(0, "fake");
+
+ static protected ValidatorBeanEntry beanEntry1 = new ValidatorBeanEntry(1, "fake");
+
+ static protected ValidatorBeanEntry beanEntry3 = new ValidatorBeanEntry(3, "fake");
+
+ static protected ValidatorBeanEntry beanEntry5 = new ValidatorBeanEntry(5, "fake");
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+ assertNull(bean.getEntries());
+
+ // no entry
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none", false);
+
+
+ // add a matching etry
+ bean.setEntries(Arrays.asList(beanEntry0));
+
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none", true);
+
+ // two matching etries
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry0));
+
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none", true);
+
+ // add a none matching etry
+ bean.setEntries(Arrays.asList(beanEntry0Bis));
+
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none", false);
+
+ // add a none matching etry and a matching entry
+ bean.setEntries(Arrays.asList(beanEntry0Bis, beanEntry0));
+
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none", true);
+ }
+
+ @Test
+ public void testValidatorWithContext() throws Exception {
+ assertNull(bean.getEntries());
+
+ // no entry
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false);
+
+ // add a matching etry
+ bean.setEntries(Arrays.asList(beanEntry0));
+
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false);
+
+ // add a none matching etry
+ bean.setEntries(Arrays.asList(beanEntry0Bis));
+
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false);
+
+ // add a none matching etry and a matching entry
+ bean.setEntries(Arrays.asList(beanEntry0Bis, beanEntry0));
+
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1));
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false);
+
+ bean.setEntries(Arrays.asList(beanEntry1, beanEntry0));
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3));
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5));
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1));
+ assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", false);
+ assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false);
+ }
+
+ @Test
+ public void testValidatorWithContextAndFirst() throws Exception {
+ assertNull(bean.getEntries());
+ String message = "collectionFieldExpression.all.useFirst";
+
+ // no entry
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0));
+ assertFieldInError(PROPERTY, message, false);
+
+
+ bean.setEntries(Arrays.asList(beanEntry0Bis));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry1));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry1, beanEntry0));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1));
+ assertFieldInError(PROPERTY, message, true);
+ }
+
+ @Test
+ public void testValidatorWithContextAndLast() throws Exception {
+ assertNull(bean.getEntries());
+ String message = "collectionFieldExpression.all.useLast";
+
+ // no entry
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0));
+ assertFieldInError(PROPERTY, message, true);
+
+
+ bean.setEntries(Arrays.asList(beanEntry0Bis));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry1));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry1, beanEntry0));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry1, beanEntry3));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1));
+ assertFieldInError(PROPERTY, message, true);
+ }
+
+ @Test
+ public void testValidatorWithContextAndFirstAndLast() throws Exception {
+ assertNull(bean.getEntries());
+
+ String message = "collectionFieldExpression.all.useFirstAndLast";
+ // no entry
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0));
+ assertFieldInError(PROPERTY, message, true);
+
+
+ bean.setEntries(Arrays.asList(beanEntry0Bis));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry1));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry1, beanEntry0));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry1, beanEntry3));
+ assertFieldInError(PROPERTY, message, true);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5));
+ assertFieldInError(PROPERTY, message, false);
+
+ bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1));
+ assertFieldInError(PROPERTY, message, true);
+ }
+}
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionFieldExpressionValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,113 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.nuiton.validator.field.ValidatorBean.ValidatorBeanEntry;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class CollectionUniqueKeyValidatorTest extends AbstractValidatorBeanFieldValidatorTest {
+
+ static protected ValidatorBeanEntry beanEntry = new ValidatorBeanEntry(0, "stringValue");
+
+ static protected ValidatorBeanEntry beanEntry2 = new ValidatorBeanEntry(0, "fake");
+
+ static protected ValidatorBeanEntry beanEntry3 = new ValidatorBeanEntry(0, "stringValue", "stringValue2");
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+ assertNull(bean.getEntries());
+
+ // no entry
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.five.failed", false);
+
+ // add a entry
+ bean.setEntries(Arrays.asList(beanEntry));
+
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.five.failed", false);
+
+ // add violating property
+ bean.setEntry(beanEntry3);
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.five.failed", true);
+
+
+ // two entries with same key
+ bean.setEntries(Arrays.asList(beanEntry, beanEntry));
+
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", true);
+
+ // add a entry
+ bean.setEntries(Arrays.asList(beanEntry2));
+
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+
+ // add two entries (will violated unique key on intValue)
+ bean.setEntries(Arrays.asList(beanEntry2, beanEntry));
+
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+
+
+ // two entries with same key (except validator four)
+ bean.setEntries(Arrays.asList(beanEntry, beanEntry3));
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+
+ beanEntry.setStringValue2("stringValue2");
+ // two entries with same key
+ bean.setEntries(Arrays.asList(beanEntry, beanEntry3));
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", true);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", true);
+
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/CollectionUniqueKeyValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,56 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.junit.Test;
+
+import java.io.File;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class ExistingDirectoryFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest {
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+
+ assertNull(bean.getExistingDirectory());
+ assertFieldInError("existingDirectory", "existingDirectory.required", true);
+
+ bean.setExistingDirectory(new File(""));
+ assertFieldInError("existingDirectory", "existingDirectory.required", true);
+
+ // existing file
+ bean.setExistingDirectory(new File(basedir, "pom.xml"));
+ assertFieldInError("existingDirectory", "existingDirectory.required", false);
+ assertFieldInError("existingDirectory", "existingDirectory.not.exist", true);
+
+ // existing directory
+ bean.setExistingDirectory(basedir);
+ assertFieldInError("existingDirectory", "existingDirectory.required", false);
+ assertFieldInError("existingDirectory", "existingDirectory.not.exist", false);
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingDirectoryFieldValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,56 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.junit.Test;
+
+import java.io.File;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class ExistingFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest {
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+
+ assertNull(bean.getExistingFile());
+ assertFieldInError("existingFile", "existingFile.required", true);
+
+ bean.setExistingFile(new File(""));
+ assertFieldInError("existingFile", "existingFile.required", true);
+
+ // existing directory
+ bean.setExistingFile(basedir);
+ assertFieldInError("existingFile", "existingFile.required", false);
+ assertFieldInError("existingFile", "existingFile.not.exist", true);
+
+ // existing file
+ bean.setExistingFile(new File(basedir, "pom.xml"));
+ assertFieldInError("existingFile", "existingFile.required", false);
+ assertFieldInError("existingFile", "existingFile.not.exist", false);
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ExistingFileFieldValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,130 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class FieldExpressionBean {
+
+ protected final PropertyChangeSupport p;
+
+ protected boolean booleanValue;
+
+ protected short shortValue;
+
+ protected int intValue;
+
+ protected long longValue;
+
+ protected double doubleValue;
+
+ protected String stringValue;
+
+ public FieldExpressionBean() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ public boolean isBooleanValue() {
+ return booleanValue;
+ }
+
+ public double getDoubleValue() {
+ return doubleValue;
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public long getLongValue() {
+ return longValue;
+ }
+
+ public short getShortValue() {
+ return shortValue;
+ }
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setBooleanValue(boolean newValue) {
+ Object oldValue = booleanValue;
+ booleanValue = newValue;
+ firePropertyChange("booleanValue", oldValue, newValue);
+ }
+
+ public void setDoubleValue(double newValue) {
+ Object oldValue = doubleValue;
+ doubleValue = newValue;
+ firePropertyChange("doubleValue", oldValue, newValue);
+ }
+
+ public void setIntValue(int newValue) {
+ Object oldValue = stringValue;
+ intValue = newValue;
+ firePropertyChange("intValue", oldValue, newValue);
+ }
+
+ public void setLongValue(long newValue) {
+ Object oldValue = longValue;
+ longValue = newValue;
+ firePropertyChange("longValue", oldValue, newValue);
+ }
+
+ public void setShortValue(short newValue) {
+ Object oldValue = shortValue;
+ shortValue = newValue;
+ firePropertyChange("shortValue", oldValue, newValue);
+ }
+
+ public void setStringValue(String newValue) {
+ Object oldValue = stringValue;
+ stringValue = newValue;
+ firePropertyChange("stringValue", oldValue, newValue);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ p.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+}
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionBean.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,143 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.junit.Test;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class FieldExpressionWithParamsValidatorTest extends AbstractFieldValidatorTest<FieldExpressionBean> {
+
+ public static final String MESSAGE = "expression.too.big##100";
+
+ public static final String MESSAGE2 = "expression.too.big##100##2000";
+
+ public FieldExpressionWithParamsValidatorTest() {
+ super(FieldExpressionBean.class);
+ }
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+
+ testBooleanType();
+ testShortType();
+ testIntType();
+ testLongType();
+ testDoubleType();
+ testStringType();
+
+
+ }
+
+ protected void testBooleanType() {
+
+ assertEquals(false, bean.isBooleanValue());
+ assertFieldInError("booleanValue", "expression.boolean.not.equals##true", true);
+ assertFieldInError("booleanValue", "expression.boolean.not.equals##false", false);
+
+ bean.setBooleanValue(true);
+ assertFieldInError("booleanValue", "expression.boolean.not.equals##true", false);
+ assertFieldInError("booleanValue", "expression.boolean.not.equals##false", true);
+ }
+
+ protected void testShortType() {
+ assertEquals(0, bean.getShortValue());
+ assertFieldInError("shortValue", MESSAGE, false);
+ assertFieldInError("shortValue", MESSAGE2, false);
+ bean.setShortValue((short) 10);
+ assertFieldInError("shortValue", MESSAGE, false);
+ assertFieldInError("shortValue", MESSAGE2, false);
+ bean.setShortValue((short) 1000);
+ assertFieldInError("shortValue", MESSAGE, true);
+ assertFieldInError("shortValue", MESSAGE2, false);
+ bean.setShortValue((short) 3000);
+ assertFieldInError("shortValue", MESSAGE, true);
+ assertFieldInError("shortValue", MESSAGE2, true);
+ }
+
+ protected void testIntType() {
+ assertEquals(0, bean.getIntValue());
+ assertFieldInError("intValue", MESSAGE, false);
+ assertFieldInError("intValue", MESSAGE2, false);
+ bean.setIntValue(10);
+ assertFieldInError("intValue", MESSAGE, false);
+ assertFieldInError("intValue", MESSAGE2, false);
+ bean.setIntValue(1000);
+ assertFieldInError("intValue", MESSAGE, true);
+ assertFieldInError("intValue", MESSAGE2, false);
+ bean.setIntValue(3000);
+ assertFieldInError("intValue", MESSAGE, true);
+ assertFieldInError("intValue", MESSAGE2, true);
+ }
+
+ protected void testLongType() {
+ assertEquals(0, bean.getLongValue());
+ assertFieldInError("longValue", MESSAGE, false);
+ assertFieldInError("longValue", MESSAGE2, false);
+ bean.setLongValue(10);
+ assertFieldInError("longValue", MESSAGE, false);
+ assertFieldInError("longValue", MESSAGE2, false);
+ bean.setLongValue(1000);
+ assertFieldInError("longValue", MESSAGE, true);
+ assertFieldInError("longValue", MESSAGE2, false);
+ bean.setLongValue(3000);
+ assertFieldInError("longValue", MESSAGE, true);
+ assertFieldInError("longValue", MESSAGE2, true);
+ }
+
+ protected void testDoubleType() {
+ assertEquals(0.0, bean.getDoubleValue(), 0);
+ assertFieldInError("doubleValue", MESSAGE + ".0", false);
+ assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false);
+ bean.setDoubleValue(10);
+ assertFieldInError("doubleValue", MESSAGE + ".0", false);
+ assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false);
+ bean.setDoubleValue(1000);
+ assertFieldInError("doubleValue", MESSAGE + ".0", true);
+ assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false);
+ bean.setDoubleValue(3000);
+ assertFieldInError("doubleValue", MESSAGE + ".0", true);
+ assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", true);
+ }
+
+ protected void testStringType() {
+ assertEquals(null, bean.getStringValue());
+
+ assertFieldInError("stringValue", "expression.stringNotValue##1000", true);
+ assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", true);
+ bean.setStringValue("100");
+
+ assertFieldInError("stringValue", "expression.stringNotValue##1000", true);
+ assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", true);
+
+ bean.setStringValue("1000");
+ assertFieldInError("stringValue", "expression.stringNotValue##1000", false);
+ assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", false);
+
+ bean.setStringValue("3000");
+ assertFieldInError("stringValue", "expression.stringNotValue##1000", true);
+ assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", false);
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/FieldExpressionWithParamsValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.junit.Test;
+
+import java.io.File;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class NotExistingDirectoryFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest {
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+ assertNull(bean.getNotExistingDirectory());
+ assertFieldInError("notExistingDirectory", "notExistingDirectory.required", true);
+
+ bean.setNotExistingDirectory(new File(""));
+ assertFieldInError("notExistingDirectory", "notExistingDirectory.required", true);
+
+ // existing directory
+ bean.setNotExistingDirectory(basedir);
+ assertFieldInError("notExistingDirectory", "notExistingDirectory.required", false);
+ assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", true);
+
+ // existing file
+ bean.setNotExistingDirectory(new File(basedir, "pom.xml"));
+ assertFieldInError("notExistingDirectory", "notExistingDirectory.required", false);
+ assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", true);
+
+ // none existing directory
+ bean.setNotExistingDirectory(new File(basedir, "pom.xml-" + System.currentTimeMillis()));
+ assertFieldInError("notExistingDirectory", "notEexistingFile.required", false);
+ assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", false);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingDirectoryFieldValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,63 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.junit.Test;
+
+import java.io.File;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class NotExistingFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest {
+
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+
+ assertNull(bean.getNotExistingFile());
+ assertFieldInError("notExistingFile", "notExistingFile.required", true);
+
+ bean.setNotExistingFile(new File(""));
+ assertFieldInError("notExistingFile", "notExistingFile.required", true);
+
+ // existing directory
+ bean.setNotExistingFile(basedir);
+ assertFieldInError("notExistingFile", "notExistingFile.required", false);
+ assertFieldInError("notExistingFile", "notExistingFile.exist", true);
+
+ // existing file
+ bean.setNotExistingFile(new File(basedir, "pom.xml"));
+ assertFieldInError("notExistingFile", "notExistingFile.required", false);
+ assertFieldInError("notExistingFile", "notExistingFile.exist", true);
+
+ // none existing file
+ bean.setNotExistingFile(new File(basedir, "pom.xml-" + System.currentTimeMillis()));
+ assertFieldInError("notExistingFile", "notEexistingFile.required", false);
+ assertFieldInError("notExistingFile", "notExistingFile.exist", false);
+
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/NotExistingFileFieldValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,55 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import org.junit.Test;
+
+import java.io.File;
+
+/** @author tchemit <chemit(a)codelutin.com> */
+public class RequiredFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest {
+
+ @Test
+ @Override
+ public void testValidator() throws Exception {
+
+ assertNull(bean.getExistingFile());
+ assertFieldInError("existingFile", "existingFile.required", true);
+
+ bean.setExistingFile(new File(""));
+ assertFieldInError("existingFile", "existingFile.required", true);
+
+ bean.setExistingFile(basedir);
+ assertFieldInError("existingFile", "existingFile.required", false);
+
+ assertFieldInError("existingFile", "existingFile.not.exist", true);
+
+ bean.setExistingFile(new File(basedir, "pom.xml"));
+ assertFieldInError("existingFile", "existingFile.required", false);
+ assertFieldInError("existingFile", "existingFile.not.exist", false);
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/RequiredFileFieldValidatorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java
===================================================================
--- trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java (rev 0)
+++ trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,183 @@
+/*
+ * #%L
+ * JAXX :: Runtime
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.validator.field;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
+import java.util.Collection;
+
+public class ValidatorBean {
+
+ public static class ValidatorBeanEntry {
+
+ protected int intValue;
+
+ protected String stringValue;
+
+ protected String stringValue2;
+
+ public ValidatorBeanEntry(int intValue, String stringValue) {
+ this.intValue = intValue;
+ this.stringValue = stringValue;
+ }
+
+ public ValidatorBeanEntry(int intValue, String stringValue, String stringValue2) {
+ this.intValue = intValue;
+ this.stringValue = stringValue;
+ this.stringValue2 = stringValue2;
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ public String getStringValue2() {
+ return stringValue2;
+ }
+
+ public void setStringValue2(String stringValue2) {
+ this.stringValue2 = stringValue2;
+ }
+ }
+
+ protected File existingFile;
+
+ protected File notExistingFile;
+
+ protected File existingDirectory;
+
+ protected File notExistingDirectory;
+
+ protected Collection<ValidatorBeanEntry> entries;
+
+ protected String stringValue;
+
+ protected ValidatorBeanEntry entry;
+
+ PropertyChangeSupport p;
+
+ public ValidatorBean() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public File getExistingFile() {
+ return existingFile;
+ }
+
+ public File getNotExistingFile() {
+ return notExistingFile;
+ }
+
+ public File getExistingDirectory() {
+ return existingDirectory;
+ }
+
+ public File getNotExistingDirectory() {
+ return notExistingDirectory;
+ }
+
+ public ValidatorBeanEntry getEntry() {
+ return entry;
+ }
+
+ public Collection<ValidatorBeanEntry> getEntries() {
+ return entries;
+ }
+
+ public void setStringValue(String stringValue) {
+ String old = this.stringValue;
+ this.stringValue = stringValue;
+ p.firePropertyChange("stringValue", old, existingFile);
+ }
+
+ public void setExistingFile(File existingFile) {
+ File old = this.existingFile;
+ this.existingFile = existingFile;
+ p.firePropertyChange("existingFile", old, existingFile);
+ }
+
+ public void setNotExistingFile(File notExistingFile) {
+ File old = this.notExistingFile;
+ this.notExistingFile = notExistingFile;
+ p.firePropertyChange("notExistingFile", old, notExistingFile);
+ }
+
+ public void setExistingDirectory(File existingDirectory) {
+ File old = this.existingDirectory;
+ this.existingDirectory = existingDirectory;
+ p.firePropertyChange("existingDirectory", old, existingDirectory);
+ }
+
+ public void setNotExistingDirectory(File notExistingDirectory) {
+ File old = this.notExistingDirectory;
+ this.notExistingDirectory = notExistingDirectory;
+ p.firePropertyChange("notExistingDirectory", old, notExistingDirectory);
+ }
+
+ public void setEntries(Collection<ValidatorBeanEntry> entries) {
+ this.entries = entries;
+ // set null oldValue to always fire event
+ // otherwise it could been not sent...
+ p.firePropertyChange("entries", null, entries);
+ }
+
+ public void setEntry(ValidatorBeanEntry entry) {
+ this.entry = entry;
+ p.firePropertyChange("entry", null, entry);
+ }
+}
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/java/org/nuiton/validator/field/ValidatorBean.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/log4j.properties
===================================================================
--- trunk/nuiton-validator/src/test/resources/log4j.properties (rev 0)
+++ trunk/nuiton-validator/src/test/resources/log4j.properties 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,32 @@
+###
+# #%L
+# JAXX :: Runtime
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2008 - 2010 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+log4j.logger.org.nuiton=INFO
Property changes on: trunk/nuiton-validator/src/test/resources/log4j.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,43 @@
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="requiredstring">
+ <message>stringValue.error</message>
+ </field-validator>
+ </field>
+
+ <field name="intValue">
+ <field-validator type="int">
+ <param name="min">1</param>
+ <message>intValue.error</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,47 @@
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="fieldexpression">
+ <param name="expression">
+ <![CDATA[ stringValue != null && stringValue == "5"]]></param>
+ <message>stringValue.fatal</message>
+ </field-validator>
+ </field>
+
+
+ <field name="intValue">
+ <field-validator type="int">
+ <param name="min">5</param>
+ <param name="max">5</param>
+ <message>intValue.fatal</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-fatal-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,37 @@
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="intValue">
+ <field-validator type="int">
+ <param name="min">10</param>
+ <message>intValue.info</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-info-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,43 @@
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="requiredstring">
+ <message>stringValue.null</message>
+ </field-validator>
+ </field>
+
+ <field name="intValue">
+ <field-validator type="int">
+ <param name="min">1</param>
+ <message>intValue.null</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-simple-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,37 @@
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="fieldexpression">
+ <param name="expression"><![CDATA[ stringValue != null && stringValue.length() > 5]]></param>
+ <message>stringValue.warning</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/SimpleBean-warning-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,123 @@
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+<field name="booleanValue">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="booleanParams">boolean:true</param>
+ <param name="expression"><![CDATA[ booleanValue == booleans.boolean]]>
+ </param>
+ <message>expression.boolean.not.equals##${booleans.boolean}</message>
+ </field-validator>
+ <field-validator type="fieldexpressionwithparams">
+ <param name="booleanParams">boolean:false</param>
+ <param name="expression"><![CDATA[ booleanValue == booleans.boolean]]>
+ </param>
+ <message>expression.boolean.not.equals##${booleans.boolean}</message>
+ </field-validator>
+ </field>
+
+ <field name="shortValue">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="shortParams">short:100</param>
+ <param name="expression"><![CDATA[ shortValue < shorts.short]]>
+ </param>
+ <message>expression.too.big##${shorts.short}</message>
+ </field-validator>
+ <field-validator type="fieldexpressionwithparams">
+ <param name="shortParams">short:100|short2:2000</param>
+ <param name="expression"><![CDATA[ shortValue < shorts.short || shortValue < shorts.short2]]>
+ </param>
+ <message>expression.too.big##${shorts.short}##${shorts.short2}</message>
+ </field-validator>
+ </field>
+
+ <field name="intValue">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">int:100</param>
+ <param name="expression"><![CDATA[ intValue < ints.int]]>
+ </param>
+ <message>expression.too.big##${ints.int}</message>
+ </field-validator>
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">int:100|int2:2000</param>
+ <param name="expression"><![CDATA[ intValue < ints.int || intValue < ints.int2]]>
+ </param>
+ <message>expression.too.big##${ints.int}##${ints.int2}</message>
+ </field-validator>
+ </field>
+
+ <field name="longValue">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="longParams">long:100</param>
+ <param name="expression"><![CDATA[ longValue < longs.long]]>
+ </param>
+ <message>expression.too.big##${longs.long}</message>
+ </field-validator>
+ <field-validator type="fieldexpressionwithparams">
+ <param name="longParams">long:100|long2:2000</param>
+ <param name="expression"><![CDATA[ longValue < longs.long || longValue < longs.long2]]>
+ </param>
+ <message>expression.too.big##${longs.long}##${longs.long2}</message>
+ </field-validator>
+ </field>
+
+ <field name="doubleValue">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">double:100.0</param>
+ <param name="expression"><![CDATA[ doubleValue < doubles.double]]>
+ </param>
+ <message>expression.too.big##${doubles.double}</message>
+ </field-validator>
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">double:100.0|double2:2000.0</param>
+ <param name="expression"><![CDATA[ doubleValue < doubles.double || doubleValue < doubles.double2]]>
+ </param>
+ <message>expression.too.big##${doubles.double}##${doubles.double2}</message>
+ </field-validator>
+ </field>
+
+ <field name="stringValue">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="stringParams">string:1000</param>
+ <param name="expression"><![CDATA[ stringValue.equals(strings.string)]]>
+ </param>
+ <message>expression.stringNotValue##${strings.string}</message>
+ </field-validator>
+ <field-validator type="fieldexpressionwithparams">
+ <param name="stringParams">string:1000|string2:3000</param>
+ <param name="expression"><![CDATA[ stringValue.equals(strings.string) || stringValue.equals(strings.string2)]]>
+ </param>
+ <message>expression.stringNotValue##${strings.string}##${strings.string2}</message>
+ </field-validator>
+ </field>
+
+
+
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/FieldExpressionBean-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,179 @@
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>stringValue.required</message>
+ </field-validator>
+ </field>
+
+ <field name="existingFile">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>existingFile.required</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>existingFile.not.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="notExistingFile">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>notExistingFile.required</message>
+ </field-validator>
+ <field-validator type="notExistingFile" short-circuit="true">
+ <message>notExistingFile.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="existingDirectory">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>existingDirectory.required</message>
+ </field-validator>
+
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>existingDirectory.not.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="notExistingDirectory">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>notExistingDirectory.required</message>
+ </field-validator>
+
+ <field-validator type="notExistingDirectory" short-circuit="true">
+ <message>notExistingDirectory.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="entries">
+
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">intValue</param>
+ <message>collectionUniqueKey.one.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">stringValue</param>
+ <message>collectionUniqueKey.two.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">intValue,stringValue</param>
+ <message>collectionUniqueKey.three.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">intValue,stringValue,stringValue2</param>
+ <message>collectionUniqueKey.four.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">stringValue</param>
+ <param name="againstProperty">entry</param>
+ <message>collectionUniqueKey.five.failed</message>
+ </field-validator>
+
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">AT_LEAST_ONE</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]>
+ </param>
+ <message>collectionFieldExpression.atLeastOne</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">EXACTLY_ONE</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]>
+ </param>
+ <message>collectionFieldExpression.exactlyOne</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">ALL</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]>
+ </param>
+ <message>collectionFieldExpression.all</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">NONE</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]>
+ </param>
+ <message>collectionFieldExpression.none</message>
+ </field-validator>
+
+ <!-- useContext -->
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">AT_LEAST_ONE</param>
+ <param name="useSensitiveContext">true</param>
+ <param name="expression"><![CDATA[ size > 1 && previous != null && previous.intValue < current.intValue]]></param>
+ <message>collectionFieldExpression.atLeastOne.useSensitiveContext</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">EXACTLY_ONE</param>
+ <param name="useSensitiveContext">true</param>
+ <param name="expression"><![CDATA[ size > 1 && previous != null && ( previous.intValue == 2 + current.intValue || current.intValue == 2 + previous.intValue) ]]></param>
+ <message>collectionFieldExpression.exactlyOne.useSensitiveContext</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">ALL</param>
+ <param name="useSensitiveContext">true</param>
+ <param name="expression"><![CDATA[ size > 1 && (previous == null || previous.intValue < current.intValue)]]></param>
+ <message>collectionFieldExpression.all.useSensitiveContext</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">NONE</param>
+ <param name="useSensitiveContext">true</param>
+ <param name="expression"><![CDATA[ size > 1 && previous != null && ( current.intValue == 2 + previous.intValue)]]></param>
+ <message>collectionFieldExpression.none.useSensitiveContext</message>
+ </field-validator>
+
+ <!-- useFirst -->
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">ALL</param>
+ <param name="useSensitiveContext">true</param>
+ <param name="expressionForFirst"><![CDATA[ current.intValue == 0]]></param>
+ <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param>
+ <message>collectionFieldExpression.all.useFirst</message>
+ </field-validator>
+
+ <!-- useLast -->
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">ALL</param>
+ <param name="useSensitiveContext">true</param>
+ <param name="expressionForLast"><![CDATA[ current.intValue > 0]]></param>
+ <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param>
+ <message>collectionFieldExpression.all.useLast</message>
+ </field-validator>
+
+ <!-- useFirstAndLast -->
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">ALL</param>
+ <param name="useSensitiveContext">true</param>
+ <param name="expressionForFirst"><![CDATA[ current.intValue == 0]]></param>
+ <param name="expressionForLast"><![CDATA[ current.intValue > 0]]></param>
+ <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param>
+ <message>collectionFieldExpression.all.useFirstAndLast</message>
+ </field-validator>
+
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/org/nuiton/validator/field/ValidatorBean-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-validator/src/test/resources/validators.xml
===================================================================
--- trunk/nuiton-validator/src/test/resources/validators.xml (rev 0)
+++ trunk/nuiton-validator/src/test/resources/validators.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils :: Validator
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator Config 1.0//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd">
+<validators>
+ <!-- default validators from XWork framework -->
+ <validator name="required" class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/>
+ <validator name="requiredstring" class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/>
+ <validator name="int" class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/>
+ <validator name="long" class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/>
+ <validator name="short" class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/>
+ <validator name="double" class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/>
+ <validator name="date" class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/>
+ <validator name="expression" class="com.opensymphony.xwork2.validator.validators.ExpressionValidator"/>
+ <validator name="fieldexpression" class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/>
+ <validator name="email" class="com.opensymphony.xwork2.validator.validators.EmailValidator"/>
+ <validator name="url" class="com.opensymphony.xwork2.validator.validators.URLValidator"/>
+ <validator name="visitor" class="com.opensymphony.xwork2.validator.validators.VisitorFieldValidator"/>
+ <validator name="conversion" class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/>
+ <validator name="stringlength" class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/>
+ <validator name="regex" class="com.opensymphony.xwork2.validator.validators.RegexFieldValidator"/>
+ <validator name="conditionalvisitor"
+ class="com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator"/>
+
+ <!-- jaxx validators -->
+ <validator name="collectionFieldExpression" class="org.nuiton.validator.field.CollectionFieldExpressionValidator"/>
+ <validator name="collectionUniqueKey" class="org.nuiton.validator.field.CollectionUniqueKeyValidator"/>
+ <validator name="requiredFile" class="org.nuiton.validator.field.RequiredFileFieldValidator"/>
+ <validator name="existingFile" class="org.nuiton.validator.field.ExistingFileFieldValidator"/>
+ <validator name="notExistingFile" class="org.nuiton.validator.field.NotExistingFileFieldValidator"/>
+ <validator name="existingDirectory" class="org.nuiton.validator.field.ExistingDirectoryFieldValidator"/>
+ <validator name="notExistingDirectory" class="org.nuiton.validator.field.NotExistingDirectoryFieldValidator"/>
+ <validator name="fieldexpressionwithparams" class="org.nuiton.validator.field.FieldExpressionWithParamsValidator"/>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/nuiton-validator/src/test/resources/validators.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/pom.xml
===================================================================
--- trunk/pom.xml (rev 0)
+++ trunk/pom.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2004 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom4redmineAndCentral</artifactId>
+ <version>2.4.1</version>
+ </parent>
+
+ <artifactId>nuiton-utils-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+
+ <modules>
+ <module>nuiton-utils</module>
+ <module>nuiton-validator</module>
+ </modules>
+
+ <dependencyManagement>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ <version>${nuitonI18nVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jvnet.hudson.winstone</groupId>
+ <artifactId>winstone</artifactId>
+ <version>0.9.10-hudson-24</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>7.1.0.v20100505</version>
+ </dependency>
+
+ <!-- xworks dependencies -->
+
+ <dependency>
+ <groupId>com.opensymphony</groupId>
+ <artifactId>xwork</artifactId>
+ <version>2.1.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton Utils :: Parent</name>
+ <description>Parent of nuiton utils projects.</description>
+ <inceptionYear>2011</inceptionYear>
+ <url>http://maven-site.nuiton.org/nuiton-utils</url>
+
+ <developers>
+
+ <developer>
+ <name>Brendan Le Ny</name>
+ <id>bleny</id>
+ <email>bleny(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>developer</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Benjamin Poussin</name>
+ <id>bpoussin</id>
+ <email>poussin(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ <role>Debian packager</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Éric Chatellier</name>
+ <id>echatellier</id>
+ <email>chatellier(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Sylvain Letellier</name>
+ <id>sletellier</id>
+ <email>letellier(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Tony Chemit</name>
+ <id>tchemit</id>
+ <email>chemit(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>developer</role>
+ </roles>
+ </developer>
+
+ </developers>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>pom</packaging>
+
+ <properties>
+
+ <projectId>nuiton-utils</projectId>
+
+ <nuitonI18nVersion>2.0.1</nuitonI18nVersion>
+
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- plugin i18n -->
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>${nuitonI18nVersion}</version>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+ </build>
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <!-- Source control management. -->
+ <scm>
+ <connection>
+ scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk
+ </connection>
+ <developerConnection>
+ scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk
+ </developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/nuiton-utils/trunk</url>
+ </scm>
+
+</project>
Property changes on: trunk/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/site/apt/index.apt
===================================================================
--- trunk/src/site/apt/index.apt (rev 0)
+++ trunk/src/site/apt/index.apt 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,61 @@
+~~~
+~~ #%L
+~~ Nuiton Utils :: Parent
+~~
+~~ $Id$
+~~ $HeadURL$
+~~ %%
+~~ Copyright (C) 2004 - 2010 CodeLutin
+~~ %%
+~~ This program is free software: you can redistribute it and/or modify
+~~ it under the terms of the GNU Lesser General Public License as
+~~ published by the Free Software Foundation, either version 3 of the
+~~ License, or (at your option) any later version.
+~~
+~~ This program is distributed in the hope that it will be useful,
+~~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+~~ GNU General Lesser Public License for more details.
+~~
+~~ You should have received a copy of the GNU General Lesser Public
+~~ License along with this program. If not, see
+~~ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+~~ #L%
+~~~
+ ----
+ Nuiton utils
+ ----
+ ----
+ 2009-08-23
+ ----
+
+
+Présentation
+
+ Ensemble de projets utilitaires.
+
+Librairie Nuiton-utils
+
+ Librairie regroupant les utilitaires classiques sur les fichiers, les tableaux,
+ les collections, les maps, les chaînes de caractères, ... De plus elle intègre
+ un parser des arguments et des options pour les lignes de commande.
+
+Librairie Nuiton-utils-extra
+
+ TODO
+
+Librairie Nuiton-validator
+
+ TODO
+
+Librairie Nuiton-web
+
+ TODO
+
+Librairie Nuiton-rss
+
+ TODO
+
+
+ <Veuillez consulter la documentation de chaque sous projet pour de plus
+ amples détails sur les différentes librairies.>
Property changes on: trunk/src/site/apt/index.apt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml (rev 0)
+++ trunk/src/site/site_fr.xml 2010-12-30 09:44:04 UTC (rev 1998)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils Parent
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2004 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <poweredBy>
+ <logo href="http://maven.apache.org" name="Maven"
+ img="images/logos/maven-feather.png"/>
+ </poweredBy>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="modules"/>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: trunk/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
Author: tchemit
Date: 2010-12-30 00:16:21 +0100 (Thu, 30 Dec 2010)
New Revision: 1997
Url: http://nuiton.org/repositories/revision/nuiton-utils/1997
Log:
move nuiton-utils code to his module
Added:
trunk/nuiton-utils/LICENSE.txt
trunk/nuiton-utils/README.txt
trunk/nuiton-utils/changelog.txt
trunk/nuiton-utils/doc/
trunk/nuiton-utils/pom.xml
trunk/nuiton-utils/src/
Removed:
trunk/LICENSE.txt
trunk/README.txt
trunk/changelog.txt
trunk/doc/
trunk/pom.xml
trunk/src/
Deleted: trunk/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt 2010-12-29 23:14:38 UTC (rev 1996)
+++ trunk/LICENSE.txt 2010-12-29 23:16:21 UTC (rev 1997)
@@ -1,166 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
-
Deleted: trunk/README.txt
===================================================================
--- trunk/README.txt 2010-12-29 23:14:38 UTC (rev 1996)
+++ trunk/README.txt 2010-12-29 23:16:21 UTC (rev 1997)
@@ -1,2 +0,0 @@
-To deploy new version of pom: mvn deploy
-To install localy: mvn install
Deleted: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2010-12-29 23:14:38 UTC (rev 1996)
+++ trunk/changelog.txt 2010-12-29 23:16:21 UTC (rev 1997)
@@ -1,132 +0,0 @@
-1.1.3 xxx 201001xx
- * Use display-name from web.xml file as server name
-
-1.1.2 desbois 20091223
- * Add generic war launcher (winstone & jetty based)
- * Add new uncompress method with exclusion filters
- * [FEATURE] Force application configuration properties to be written sorted
- * [FEATURE] Add sed and grep method on FileUtil
-
-1.1.1 chemit 20090903
-
- * [FEATURE] #39 add a filterVersions method in VersionUtil
-
--- chemit -- Thu, 03 Sep 2009 18:51:54 +0200
-
-
-ver 1.1.0 20090830
- * can auto-load converters at runtime via a ServiceLoader mecanism (see org.nuiton.util.ConverterUtil#initConverters() )
- * migrate to org.nuiton groupId
-
-ver 1.0.6 chemit 20090511
- * bump versions (lutinproject, maven-license-switcher-plugin)
- * use doxia-modules-jrst instead of maven-jrst-plugin
- * improve download section on site
- * fix generics and javadoc
- * refactor i18n loading with a direct looding mode (see also i18n:bundle goal)
-
-ver 1.0.5 chatellier xxxxxx ?
- * Add Tar/bzip2 utility class
- * Add md5 creation on ZipUtil methods
- * Change MD5 implementation to http://ostermiller.org/utils/MD5.html one.
-
-ver 1.0.4 chemit 20090311
- * 20090305 [chemit] - improve FileUtil methods : now can specify the component's invoker (fix some focus bugs in fullscreen mode)
-
-ver 1.0.3 chemit 20090218
- * 20090218 [chemit] - use lutinproject 3.4
- * 20090209 [chemit] - add inputStreamToFile method in FileUtil + javadoc on this class
- - can now exclude some keys when saving configurations (for password, for example)
- * 20090208 [chemit] add PropertyChangedSupport in ApplicationConfig
- * 20090203 [chemit] fix StringUtil failed tests since to locale.
- * 20090126 [chemit] i18n Resource class
- * 20090121 [chemit] fix bug on Resource when a jar manifest classpath contains some XXX:// jar path
-
-ver 1.0.2 chemit 20090107
- * 20090105 [chemit] add getCurrentDirectory method in FileUtil
- * 20090104 [chemit] modify I18n loading to not override sentences with empty value are found and there is already a
- none empty value loaded
-
-ver 1.0.1 chatellier 20081210
-
-ver 1.0 chemit 20081210
- * 20081205 [chemit] use lutinproject 3.2
- * 20081120 [chatellier] Remove deprecated HashMapMultiKey
- * 20081120 [chatellier] Fix i18n lutinutil properties files
- * 20081118 [chemit] - use lutinproject 3.1
- - improve i18n loading : skip urls with no i18n directory
- - introduce ClassLoaderUtil class
- * 20081101 [chatellier] Remove deprecated I18n._ and replace by temporary code
-
-ver-0-31 chemit 2008????
- * always build javadoc
- * Change group id
- * utilisation de lutinproject 2.4 et nettoyage du pom
- * reorganisation du site
- * <poussin> ArgumentsParser.java marked deprecated
-
-ver-0-30 chemit 20080710
- * <chemit> passage en maven 2 layout directory
- * <chemit> utilisation de lutinproject 2.3
- * <chemit> suppression du code vcs du projet
- * <poussin> add ApplicationConfig class
- * <poussin> enhance ObjectUtil
- * <poussin> HashMapMultiKey marked deprecated
-
-ver-0-26 poussin 2007????
- * bug in concat(Object [] ...), better array type now work
- * add unaccent in StringUtil
-
-ver-0-25 poussin 20070425
- * add StringUtil.toArrayXXX(String ... s) methodes
- * use generic
-
-ver-0-24 poussin
- * ArgumentsParser have 1 as repetitionMax by default
- * ArgumentsParser use jdk 1.5 syntaxe (..., <>)
-
-ver-0-23 poussin 20061004
- * move i18n in lutinutil
- * add method Resource.getConfigProperties(String, Properties) to chains
- properties
-
-ver-0-22 poussin 20060913
- * use Generics in CategorisedListenerSet
- * add org.codelutin.log package (LutinLog, ...)
- * remove org.codelutin.util.Log
-
-ver-0-21 poussin 20060907
-
- * Add TransformedList
- * Add FileUtil.getTempFile(String):File
- * add FileUtil.getFile():File that prompt user
- * add FileUtil.getDirectory(): String that prompt user
- * add FileUtil.copyRecursively(File, File, String ... patternFilter)
- * add ZipUtil class to compress/uncompress zip file
- * Transparente*Reference accept null object
-
-ver-0-17 thimel 20050610
-
- * Ajout de BoundedList et BoundedListOutOfBoundsException
-
-ver-0-16 poussin 20050526
-
- * Ajout de la methode getConfigProperties dans Resource
-
-ver-0-9 poussin 20040728
-
- * Ajout de methode isJar, isZip, dans Resource
-
-ver-0-3 poussin 20040405
-
- * utilisation de maven pour la gestion du projet
- * Ajout de ExceptionUtil
-
-ver-0-2 poussin 20031021
-
- * ajout du parser d'argument, ArgumentsParser
- * ajout de StringUtil
-
-ver-0-1
-
- * premier version contient seulement Resource
Copied: trunk/nuiton-utils/LICENSE.txt (from rev 1995, trunk/LICENSE.txt)
===================================================================
--- trunk/nuiton-utils/LICENSE.txt (rev 0)
+++ trunk/nuiton-utils/LICENSE.txt 2010-12-29 23:16:21 UTC (rev 1997)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Copied: trunk/nuiton-utils/README.txt (from rev 1995, trunk/README.txt)
===================================================================
--- trunk/nuiton-utils/README.txt (rev 0)
+++ trunk/nuiton-utils/README.txt 2010-12-29 23:16:21 UTC (rev 1997)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Copied: trunk/nuiton-utils/changelog.txt (from rev 1995, trunk/changelog.txt)
===================================================================
--- trunk/nuiton-utils/changelog.txt (rev 0)
+++ trunk/nuiton-utils/changelog.txt 2010-12-29 23:16:21 UTC (rev 1997)
@@ -0,0 +1,132 @@
+1.1.3 xxx 201001xx
+ * Use display-name from web.xml file as server name
+
+1.1.2 desbois 20091223
+ * Add generic war launcher (winstone & jetty based)
+ * Add new uncompress method with exclusion filters
+ * [FEATURE] Force application configuration properties to be written sorted
+ * [FEATURE] Add sed and grep method on FileUtil
+
+1.1.1 chemit 20090903
+
+ * [FEATURE] #39 add a filterVersions method in VersionUtil
+
+-- chemit -- Thu, 03 Sep 2009 18:51:54 +0200
+
+
+ver 1.1.0 20090830
+ * can auto-load converters at runtime via a ServiceLoader mecanism (see org.nuiton.util.ConverterUtil#initConverters() )
+ * migrate to org.nuiton groupId
+
+ver 1.0.6 chemit 20090511
+ * bump versions (lutinproject, maven-license-switcher-plugin)
+ * use doxia-modules-jrst instead of maven-jrst-plugin
+ * improve download section on site
+ * fix generics and javadoc
+ * refactor i18n loading with a direct looding mode (see also i18n:bundle goal)
+
+ver 1.0.5 chatellier xxxxxx ?
+ * Add Tar/bzip2 utility class
+ * Add md5 creation on ZipUtil methods
+ * Change MD5 implementation to http://ostermiller.org/utils/MD5.html one.
+
+ver 1.0.4 chemit 20090311
+ * 20090305 [chemit] - improve FileUtil methods : now can specify the component's invoker (fix some focus bugs in fullscreen mode)
+
+ver 1.0.3 chemit 20090218
+ * 20090218 [chemit] - use lutinproject 3.4
+ * 20090209 [chemit] - add inputStreamToFile method in FileUtil + javadoc on this class
+ - can now exclude some keys when saving configurations (for password, for example)
+ * 20090208 [chemit] add PropertyChangedSupport in ApplicationConfig
+ * 20090203 [chemit] fix StringUtil failed tests since to locale.
+ * 20090126 [chemit] i18n Resource class
+ * 20090121 [chemit] fix bug on Resource when a jar manifest classpath contains some XXX:// jar path
+
+ver 1.0.2 chemit 20090107
+ * 20090105 [chemit] add getCurrentDirectory method in FileUtil
+ * 20090104 [chemit] modify I18n loading to not override sentences with empty value are found and there is already a
+ none empty value loaded
+
+ver 1.0.1 chatellier 20081210
+
+ver 1.0 chemit 20081210
+ * 20081205 [chemit] use lutinproject 3.2
+ * 20081120 [chatellier] Remove deprecated HashMapMultiKey
+ * 20081120 [chatellier] Fix i18n lutinutil properties files
+ * 20081118 [chemit] - use lutinproject 3.1
+ - improve i18n loading : skip urls with no i18n directory
+ - introduce ClassLoaderUtil class
+ * 20081101 [chatellier] Remove deprecated I18n._ and replace by temporary code
+
+ver-0-31 chemit 2008????
+ * always build javadoc
+ * Change group id
+ * utilisation de lutinproject 2.4 et nettoyage du pom
+ * reorganisation du site
+ * <poussin> ArgumentsParser.java marked deprecated
+
+ver-0-30 chemit 20080710
+ * <chemit> passage en maven 2 layout directory
+ * <chemit> utilisation de lutinproject 2.3
+ * <chemit> suppression du code vcs du projet
+ * <poussin> add ApplicationConfig class
+ * <poussin> enhance ObjectUtil
+ * <poussin> HashMapMultiKey marked deprecated
+
+ver-0-26 poussin 2007????
+ * bug in concat(Object [] ...), better array type now work
+ * add unaccent in StringUtil
+
+ver-0-25 poussin 20070425
+ * add StringUtil.toArrayXXX(String ... s) methodes
+ * use generic
+
+ver-0-24 poussin
+ * ArgumentsParser have 1 as repetitionMax by default
+ * ArgumentsParser use jdk 1.5 syntaxe (..., <>)
+
+ver-0-23 poussin 20061004
+ * move i18n in lutinutil
+ * add method Resource.getConfigProperties(String, Properties) to chains
+ properties
+
+ver-0-22 poussin 20060913
+ * use Generics in CategorisedListenerSet
+ * add org.codelutin.log package (LutinLog, ...)
+ * remove org.codelutin.util.Log
+
+ver-0-21 poussin 20060907
+
+ * Add TransformedList
+ * Add FileUtil.getTempFile(String):File
+ * add FileUtil.getFile():File that prompt user
+ * add FileUtil.getDirectory(): String that prompt user
+ * add FileUtil.copyRecursively(File, File, String ... patternFilter)
+ * add ZipUtil class to compress/uncompress zip file
+ * Transparente*Reference accept null object
+
+ver-0-17 thimel 20050610
+
+ * Ajout de BoundedList et BoundedListOutOfBoundsException
+
+ver-0-16 poussin 20050526
+
+ * Ajout de la methode getConfigProperties dans Resource
+
+ver-0-9 poussin 20040728
+
+ * Ajout de methode isJar, isZip, dans Resource
+
+ver-0-3 poussin 20040405
+
+ * utilisation de maven pour la gestion du projet
+ * Ajout de ExceptionUtil
+
+ver-0-2 poussin 20031021
+
+ * ajout du parser d'argument, ArgumentsParser
+ * ajout de StringUtil
+
+ver-0-1
+
+ * premier version contient seulement Resource
Copied: trunk/nuiton-utils/pom.xml (from rev 1995, trunk/pom.xml)
===================================================================
--- trunk/nuiton-utils/pom.xml (rev 0)
+++ trunk/nuiton-utils/pom.xml 2010-12-29 23:16:21 UTC (rev 1997)
@@ -0,0 +1,288 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Nuiton Utils
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2004 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom4redmineAndCentral</artifactId>
+ <version>2.4.1</version>
+ </parent>
+
+ <artifactId>nuiton-utils</artifactId>
+ <version>2.0-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <!--version>1.2.16</version-->
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-primitives</groupId>
+ <artifactId>commons-primitives</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ <version>${nuitonI18nVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jvnet.hudson.winstone</groupId>
+ <artifactId>winstone</artifactId>
+ <version>0.9.10-hudson-24</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>7.1.0.v20100505</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton Utils</name>
+ <description>Library of usefull class to be used in any project.</description>
+ <inceptionYear>2004</inceptionYear>
+ <url>http://maven-site.nuiton.org/nuiton-utils</url>
+
+ <developers>
+
+ <developer>
+ <name>Brendan Le Ny</name>
+ <id>bleny</id>
+ <email>bleny(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>developer</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Benjamin Poussin</name>
+ <id>bpoussin</id>
+ <email>poussin(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ <role>Debian packager</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Éric Chatellier</name>
+ <id>echatellier</id>
+ <email>chatellier(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Sylvain Letellier</name>
+ <id>sletellier</id>
+ <email>letellier(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+
+ <developer>
+ <name>Tony Chemit</name>
+ <id>tchemit</id>
+ <email>chemit(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>developer</role>
+ </roles>
+ </developer>
+
+ </developers>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <nuitonI18nVersion>2.0.1</nuitonI18nVersion>
+
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+
+ </properties>
+
+ <build>
+
+ <plugins>
+
+ <!-- plugin i18n -->
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>${nuitonI18nVersion}</version>
+ <configuration>
+ <silent>true</silent>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <!-- Source control management. -->
+ <scm>
+ <connection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/nuiton-utils/trunk</url>
+ </scm>
+
+ <profiles>
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <quiet>true</quiet>
+ <links>
+ <link>http://java.sun.com/javase/6/docs/api/</link>
+ </links>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ <!-- create assemblies at release time -->
+ <profile>
+ <id>assembly-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
Deleted: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-12-29 23:14:38 UTC (rev 1996)
+++ trunk/pom.xml 2010-12-29 23:16:21 UTC (rev 1997)
@@ -1,288 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- #%L
- Nuiton Utils
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2004 - 2010 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Lesser Public License for more details.
-
- You should have received a copy of the GNU General Lesser Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/lgpl-3.0.html>.
- #L%
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.nuiton</groupId>
- <artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.4.1</version>
- </parent>
-
- <artifactId>nuiton-utils</artifactId>
- <version>2.0-SNAPSHOT</version>
-
- <dependencies>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <!--version>1.2.16</version-->
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-primitives</groupId>
- <artifactId>commons-primitives</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>nuiton-i18n</artifactId>
- <version>${nuitonI18nVersion}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jvnet.hudson.winstone</groupId>
- <artifactId>winstone</artifactId>
- <version>0.9.10-hudson-24</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>7.1.0.v20100505</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>Nuiton Utils</name>
- <description>Library of usefull class to be used in any project.</description>
- <inceptionYear>2004</inceptionYear>
- <url>http://maven-site.nuiton.org/nuiton-utils</url>
-
- <developers>
-
- <developer>
- <name>Brendan Le Ny</name>
- <id>bleny</id>
- <email>bleny(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>developer</role>
- </roles>
- </developer>
-
- <developer>
- <name>Benjamin Poussin</name>
- <id>bpoussin</id>
- <email>poussin(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- <role>Debian packager</role>
- </roles>
- </developer>
-
- <developer>
- <name>Éric Chatellier</name>
- <id>echatellier</id>
- <email>chatellier(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- </roles>
- </developer>
-
- <developer>
- <name>Sylvain Letellier</name>
- <id>sletellier</id>
- <email>letellier(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- </roles>
- </developer>
-
- <developer>
- <name>Tony Chemit</name>
- <id>tchemit</id>
- <email>chemit(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>developer</role>
- </roles>
- </developer>
-
- </developers>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>jar</packaging>
-
- <properties>
-
- <nuitonI18nVersion>2.0.1</nuitonI18nVersion>
-
- <!-- extra files to include in release -->
- <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
-
- </properties>
-
- <build>
-
- <plugins>
-
- <!-- plugin i18n -->
- <plugin>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <version>${nuitonI18nVersion}</version>
- <configuration>
- <silent>true</silent>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>parserJava</goal>
- <goal>gen</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
-
- </build>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
-
- <!-- Source control management. -->
- <scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/nuiton-utils/trunk</url>
- </scm>
-
- <profiles>
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <reporting>
- <plugins>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <quiet>true</quiet>
- <links>
- <link>http://java.sun.com/javase/6/docs/api/</link>
- </links>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
- </profile>
-
- <!-- create assemblies at release time -->
- <profile>
- <id>assembly-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
-
- <!-- launch in a release the assembly automaticly -->
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>create-assemblies</id>
- <phase>verify</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <attach>false</attach>
- <descriptorRefs>
- <descriptorRef>deps</descriptorRef>
- <descriptorRef>full</descriptorRef>
- </descriptorRefs>
- </configuration>
- </plugin>
-
- </plugins>
-
- </build>
- </profile>
-
- </profiles>
-
-</project>
1
0
Author: tchemit
Date: 2010-12-30 00:14:38 +0100 (Thu, 30 Dec 2010)
New Revision: 1996
Url: http://nuiton.org/repositories/revision/nuiton-utils/1996
Log:
prepare multi-module
Added:
trunk/nuiton-utils/
1
0