Author: chatellier Date: 2010-12-24 16:28:42 +0000 (Fri, 24 Dec 2010) New Revision: 449 Log: Retrait des fichier de validation du classpath. Ajout d'un classloader pour les retrouver. Added: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java trunk/coser-business/src/main/resources/validators/ trunk/coser-business/src/main/resources/validators/fr/ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Catch-error-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-error-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-fatal-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Length-error-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Strata-error-validation.xml Removed: trunk/coser-business/src/main/resources/fr/ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/bean/ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Catch-error-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-error-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-fatal-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Length-error-validation.xml trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Strata-error-validation.xml trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserClassLoader.java Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java (from rev 207, trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserClassLoader.java) =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java (rev 0) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java 2010-12-24 16:28:42 UTC (rev 449) @@ -0,0 +1,92 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package fr.ifremer.coser; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Coser class loader. + * + * Used to load custom xwork validation file. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class CoserClassLoader extends ClassLoader { + + private static final Log log = LogFactory.getLog(CoserClassLoader.class); + + protected File validatorsDirectory; + + public CoserClassLoader(ClassLoader parent) { + super(parent); + } + + public void setValidatorsDirectory(File validatorsDirectory) { + this.validatorsDirectory = validatorsDirectory; + } + + @Override + public URL getResource(String name) { + + URL result = null; + + if (name.matches("/fr/ifremer/coser/.+\\.xml")) { + + // cherche sur le disque + File valFile = new File(validatorsDirectory, name); + if (valFile.isFile()) { + + if (log.isDebugEnabled()) { + log.debug("Locating resources " + name + " to " + valFile.getAbsolutePath()); + } + + try { + result = valFile.toURI().toURL(); + } catch (MalformedURLException ex) { + throw new RuntimeException("Can't get validator url", ex); + } + } + + // cherche dans le classpath + if (result == null) { + result = super.getResource("validators" + name); + } + } + + // sinon, recherche par default + if (result == null) { + result = super.getResource(name); + } + return result; + } +} Deleted: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Catch-error-validation.xml =================================================================== --- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Catch-error-validation.xml 2010-11-10 17:31:36 UTC (rev 207) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Catch-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -1,69 +0,0 @@ -<!-- - #%L - Coser :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Lesser Public License for more details. - - You should have received a copy of the GNU General Lesser Public - License along with this program. If not, see - <http://www.gnu.org/licenses/lgpl-3.0.html>. - #L% - --> -<!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="survey"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a campagne name.</message> - </field-validator> - </field> - <field name="year"> - <field-validator type="regex"> - <param name="expression">[0-9]{4}</param> - <message>year is not valid</message> - </field-validator> - </field> - <field name="haul"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a trait name.</message> - </field-validator> - </field> - <field name="species"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a espece name.</message> - </field-validator> - </field> - <field name="numberAsString"> - <field-validator type="checkDouble"> - <param name="notAvailable">NA</param> - <message>Number attribute is not a valid double</message> - </field-validator> - </field> - <field name="weightAsString"> - <field-validator type="checkDouble"> - <param name="notAvailable">NA</param> - <message>Weight attribute is not a valid double</message> - </field-validator> - </field> - <validator type="coserExpression"> - <param name="expression"><![CDATA[ (weight > 0 && number > 0) || weight == 0]]></param> - <message><![CDATA[coser.business.control.error.noCatchNumberWithWeight]]></message> - </validator> -</validators> \ No newline at end of file Copied: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Catch-error-validation.xml (from rev 448, trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Catch-error-validation.xml) =================================================================== --- trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Catch-error-validation.xml (rev 0) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Catch-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -0,0 +1,70 @@ +<!-- + #%L + Coser :: Business + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!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="survey"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>Missing survey name</message> + </field-validator> + </field> + <field name="year"> + <field-validator type="regex"> + <param name="expression">[0-9]{4}(\.[0-9]{1,2})?</param> + <message>year is not valid (4 digits.2 digits)</message> + </field-validator> + </field> + <field name="haul"> + <field-validator type="regex"> + <param name="expression">[0-9a-z]+</param> + <param name="caseSensitive">false</param> + <message>haul name is not valid</message> + </field-validator> + </field> + <field name="species"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>Missing species name</message> + </field-validator> + </field> + <field name="numberAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>number attribute is not a valid double</message> + </field-validator> + </field> + <field name="weightAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>weight attribute is not a valid double</message> + </field-validator> + </field> + <validator type="coserExpression"> + <param name="expression"><![CDATA[ (weight > 0 && number > 0) || weight == 0]]></param> + <message>coser.business.control.error.noCatchNumberWithWeight</message> + </validator> +</validators> \ No newline at end of file Deleted: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-error-validation.xml =================================================================== --- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-error-validation.xml 2010-11-10 17:31:36 UTC (rev 207) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -1,75 +0,0 @@ -<!-- - #%L - Coser :: Business - - $Id$ - $HeadURL$ - %% - Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Lesser Public License for more details. - - You should have received a copy of the GNU General Lesser Public - License along with this program. If not, see - <http://www.gnu.org/licenses/lgpl-3.0.html>. - #L% - --> -<!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="survey"> - <field-validator type="requiredstring"> - <message>You must enter a survey name.</message> - </field-validator> - </field> - <field name="year"> - <field-validator type="regex"> - <param name="expression">[0-9]{4}</param> - <message>year is not valid</message> - </field-validator> - </field> - <field name="haul"> - <field-validator type="requiredstring"> - <message>You must enter a haul name.</message> - </field-validator> - </field> - <field name="month"> - <field-validator type="requiredstring"> - <message>You must enter a month name.</message> - </field-validator> - </field> - <field name="stratum"> - <field-validator type="requiredstring"> - <message>You must enter a stratum name.</message> - </field-validator> - </field> - <field name="sweptSurface"> - <field-validator type="checkDouble" short-circuit="true"> - <message>sweptSurface attribute is not a valid double</message> - </field-validator> - </field> - <field name="lat"> - <field-validator type="checkDouble" short-circuit="true"> - <message>lat attribute is not a valid double</message> - </field-validator> - </field> - <field name="long"> - <field-validator type="checkDouble" short-circuit="true"> - <message>long attribute is not a valid double</message> - </field-validator> - </field> - <field name="depth"> - <field-validator type="checkDouble" short-circuit="true"> - <message>Depth attribute is not a valid double</message> - </field-validator> - </field> -</validators> \ No newline at end of file Copied: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-error-validation.xml (from rev 410, trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-error-validation.xml) =================================================================== --- trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-error-validation.xml (rev 0) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -0,0 +1,87 @@ +<!-- + #%L + Coser :: Business + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!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="survey"> + <field-validator type="requiredstring"> + <message>Missing survey name</message> + </field-validator> + </field> + <field name="year"> + <field-validator type="regex"> + <param name="expression">[0-9]{4}(\.[0-9]{1,2})?</param> + <message>year is not valid (4 digits.2 digits)</message> + </field-validator> + </field> + <field name="haul"> + <field-validator type="regex"> + <param name="expression">[0-9a-z]+</param> + <param name="caseSensitive">false</param> + <message>haul name is not valid</message> + </field-validator> + </field> + <field name="month"> + <field-validator type="regex"> + <param name="expression">[0-9]{1,2}</param> + <message>month is not valid (2 digits)</message> + </field-validator> + </field> + <field name="stratum"> + <field-validator type="requiredstring"> + <message>Missing stratum name</message> + </field-validator> + </field> + <field name="sweptSurfaceAsString"> + <field-validator type="requiredstring"> + <message>Missing sweptSurface attribute</message> + </field-validator> + </field> + <field name="sweptSurfaceAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>sweptSurface attribute is not a valid double</message> + </field-validator> + </field> + <field name="latAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>lat attribute is not a valid double</message> + </field-validator> + </field> + <field name="longAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>long attribute is not a valid double</message> + </field-validator> + </field> + <field name="depthAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>depth attribute is not a valid double</message> + </field-validator> + </field> +</validators> \ No newline at end of file Deleted: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-fatal-validation.xml =================================================================== --- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-fatal-validation.xml 2010-11-10 17:31:36 UTC (rev 207) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-fatal-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -1,47 +0,0 @@ -<!-- - #%L - Coser :: Business - - $Id$ - $HeadURL$ - %% - Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Lesser Public License for more details. - - You should have received a copy of the GNU General Lesser Public - License along with this program. If not, see - <http://www.gnu.org/licenses/lgpl-3.0.html>. - #L% - --> -<!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="sweptSurface"> - <field-validator type="regex"> - <param name="expression">\-?[0-9]+\.[0-9]{3,}</param> - <message>lat must contains at least 5 decimal</message> - </field-validator> - </field> - <field name="lat"> - <field-validator type="regex"> - <param name="expression">\-?[0-9]+\.[0-9]{3,}</param> - <message>lat must contains at least 5 decimal</message> - </field-validator> - </field> - <field name="long"> - <field-validator type="regex"> - <param name="expression">\-?[0-9]+\.[0-9]{3,}</param> - <message>long must contains at least 5 decimal</message> - </field-validator> - </field> -</validators> \ No newline at end of file Copied: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-fatal-validation.xml (from rev 410, trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-fatal-validation.xml) =================================================================== --- trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-fatal-validation.xml (rev 0) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Haul-fatal-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -0,0 +1,47 @@ +<!-- + #%L + Coser :: Business + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!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="sweptSurface"> + <field-validator type="regex"> + <param name="expression">\-?[0-9]+\.[0-9]{3,}</param> + <message>sweptSurface must contain at least 3 decimals</message> + </field-validator> + </field> + <field name="lat"> + <field-validator type="regex"> + <param name="expression">\-?[0-9]+\.[0-9]{4,}</param> + <message>lat must contain at least 4 decimals</message> + </field-validator> + </field> + <field name="long"> + <field-validator type="regex"> + <param name="expression">\-?[0-9]+\.[0-9]{4,}</param> + <message>long must contain at least 4 decimals</message> + </field-validator> + </field> +</validators> \ No newline at end of file Deleted: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Length-error-validation.xml =================================================================== --- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml 2010-11-10 17:31:36 UTC (rev 207) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Length-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -1,85 +0,0 @@ -<!-- - #%L - Coser :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Lesser Public License for more details. - - You should have received a copy of the GNU General Lesser Public - License along with this program. If not, see - <http://www.gnu.org/licenses/lgpl-3.0.html>. - #L% - --> -<!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="survey"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a campagne name.</message> - </field-validator> - </field> - <field name="year"> - <field-validator type="regex"> - <param name="expression">[0-9]{4}</param> - <message>year is not valid</message> - </field-validator> - </field> - <field name="haul"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a trait name.</message> - </field-validator> - </field> - <field name="species"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a espece name.</message> - </field-validator> - </field> - <field name="sex"> - <field-validator type="requiredstring"> - <message>Sex is mandatory</message> - </field-validator> - </field> - <field name="maturity"> - <field-validator type="requiredstring"> - <message>Maturity attribute is required</message> - </field-validator> - </field> - <field name="length"> - <field-validator type="checkDouble"> - <message>length attribute is not a valid double</message> - </field-validator> - </field> - <field name="number"> - <field-validator type="checkDouble"> - <param name="notAvailable">NA</param> - <message>number attribute is not a valid double</message> - </field-validator> - </field> - <field name="weight"> - <field-validator type="checkDouble"> - <param name="notAvailable">NA</param> - <message>Weight attribute is not a valid double</message> - </field-validator> - </field> - <field name="age"> - <field-validator type="requiredstring"> - <message>Age attribute is required</message> - </field-validator> - </field> -</validators> \ No newline at end of file Copied: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Length-error-validation.xml (from rev 448, trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml) =================================================================== --- trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Length-error-validation.xml (rev 0) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Length-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -0,0 +1,91 @@ +<!-- + #%L + Coser :: Business + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!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="survey"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>Missing survey name</message> + </field-validator> + </field> + <field name="year"> + <field-validator type="regex"> + <param name="expression">[0-9]{4}(\.[0-9]{1,2})?</param> + <message>year is not valid (4 digits.2 digits)</message> + </field-validator> + </field> + <field name="haul"> + <field-validator type="regex"> + <param name="expression">[0-9a-z]+</param> + <param name="caseSensitive">false</param> + <message>haul name is not valid</message> + </field-validator> + </field> + <field name="species"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>Missing species name</message> + </field-validator> + </field> + <field name="sex"> + <field-validator type="requiredstring"> + <message>Missing sex attribute</message> + </field-validator> + </field> + <field name="maturity"> + <field-validator type="requiredstring"> + <message>Missing maturity attribute</message> + </field-validator> + </field> + <field name="lengthAsString"> + <field-validator type="checkDouble"> + <message>length attribute is not a valid double</message> + </field-validator> + </field> + <field name="numberAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>number attribute is not a valid double</message> + </field-validator> + </field> + <field name="weightAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>weight attribute is not a valid double</message> + </field-validator> + </field> + <field name="age"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>age attribute is not a valid double</message> + </field-validator> + </field> + <validator type="coserExpression"> + <param name="expression"><![CDATA[ (weight > 0 && number > 0) || weight == 0]]></param> + <message>coser.business.control.error.noCatchNumberWithWeight</message> + </validator> +</validators> \ No newline at end of file Deleted: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Strata-error-validation.xml =================================================================== --- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Strata-error-validation.xml 2010-11-10 17:31:36 UTC (rev 207) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Strata-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -1,47 +0,0 @@ -<!-- - #%L - Coser :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Lesser Public License for more details. - - You should have received a copy of the GNU General Lesser Public - License along with this program. If not, see - <http://www.gnu.org/licenses/lgpl-3.0.html>. - #L% - --> -<!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="survey"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a campagne name.</message> - </field-validator> - </field> - <field name="stratum"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a strata name.</message> - </field-validator> - </field> - <field name="surface"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message>You must enter a trait name.</message> - </field-validator> - </field> -</validators> \ No newline at end of file Copied: trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Strata-error-validation.xml (from rev 448, trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Strata-error-validation.xml) =================================================================== --- trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Strata-error-validation.xml (rev 0) +++ trunk/coser-business/src/main/resources/validators/fr/ifremer/coser/data/Strata-error-validation.xml 2010-12-24 16:28:42 UTC (rev 449) @@ -0,0 +1,47 @@ +<!-- + #%L + Coser :: Business + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!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="survey"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>Missing survey name</message> + </field-validator> + </field> + <field name="stratum"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>Missing stratum name</message> + </field-validator> + </field> + <field name="surfaceAsString"> + <field-validator type="checkDouble"> + <param name="notAvailable">NA</param> + <message>surface attribute is not a valid double</message> + </field-validator> + </field> +</validators> \ No newline at end of file Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java =================================================================== --- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-12-24 14:25:00 UTC (rev 448) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-12-24 16:28:42 UTC (rev 449) @@ -42,6 +42,7 @@ import fr.ifremer.coser.CoserBusinessConfig; import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.CoserClassLoader; import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.bean.Project; @@ -63,6 +64,15 @@ protected static File testDirectory; @BeforeClass + public static void setUpClassLoader() { + // declare new classloader because validation files are not + // in classpath + ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); + CoserClassLoader coserClassLoader = new CoserClassLoader(currentClassLoader); + Thread.currentThread().setContextClassLoader(coserClassLoader); + } + + @BeforeClass public static void initConfig() throws IOException { String tmpDir = System.getProperty("java.io.tmpdir"); testDirectory = new File(tmpDir, "coser"); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2010-12-24 14:25:00 UTC (rev 448) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2010-12-24 16:28:42 UTC (rev 449) @@ -38,10 +38,10 @@ import org.nuiton.util.ArgumentsParserException; import org.nuiton.widget.SwingSession; -import fr.ifremer.coser.services.PublicationService; +import fr.ifremer.coser.services.ControlService; import fr.ifremer.coser.services.ImportService; import fr.ifremer.coser.services.ProjectService; -import fr.ifremer.coser.services.ControlService; +import fr.ifremer.coser.services.PublicationService; import fr.ifremer.coser.ui.CoserFrame; import fr.ifremer.coser.ui.util.ErrorHelper; Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserClassLoader.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserClassLoader.java 2010-12-24 14:25:00 UTC (rev 448) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserClassLoader.java 2010-12-24 16:28:42 UTC (rev 449) @@ -1,79 +0,0 @@ -/* - * #%L - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 Codelutin, Chatellier Eric - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -package fr.ifremer.coser; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Enumeration; - -/** - * Coser class loader. - * - * Used to load custom work validation file. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class CoserClassLoader extends ClassLoader { - - protected File validatorsDirectory; - - public CoserClassLoader(ClassLoader parent) { - super(parent); - } - - public void setValidatorsDirectory(File validatorsDirectory) { - this.validatorsDirectory = validatorsDirectory; - } - - @Override - public URL getResource(String name) { - return super.getResource(name); - } - - @Override - public Enumeration<URL> getResources(String name) throws IOException { - return super.getResources(name); - } - - @Override - protected URL findResource(String name) { - return super.findResource(name); - } - - @Override - protected Enumeration<URL> findResources(String name) throws IOException { - return super.findResources(name); - } - - @Override - public InputStream getResourceAsStream(String name) { - return super.getResourceAsStream(name); - } -}