Index: topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java diff -u topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java:1.2 topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java:1.3 --- topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java:1.2 Thu Apr 19 10:02:38 2007 +++ topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java Thu Apr 19 16:05:37 2007 @@ -22,7 +22,6 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; -import java.util.ArrayList; import java.util.List; import javax.xml.parsers.DocumentBuilder; @@ -31,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codelutin.util.FileUtil; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.DocumentException; @@ -50,9 +50,9 @@ * @author Chevallereau Benjamin * @author Eon Sébastien * @author Trève Vincent - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Last update : $Date: 2007/04/19 10:02:38 $ + * Last update : $Date: 2007/04/19 16:05:37 $ */ public class ConfigurationHelper { @@ -94,25 +94,21 @@ } logger.debug("Loading mappings in " + mappingDir.getAbsolutePath()); - // TODO chagement 20070419 fonction a tester - List filesInIt = recursiveListFiles(mappingDir); + List filesInIt = FileUtil.find(mappingDir,regexFilename); if (filesInIt != null && filesInIt.size() > 0) { // s'il y a des fichier a charger configuration = new Configuration(); for(File fileInIt : filesInIt) { - if(fileInIt.getName().matches(regexFilename)){ - - String xmlmapping = ConfigurationHelper.getEntityMappingFromFile(fileInIt.getAbsolutePath()); - - // lit le fichier avec lutin xml - org.w3c.dom.Document domDoc = getDocumentResolvedByHibernate(xmlmapping); - - configuration.addDocument(domDoc); - - logger.debug("Local mapping added : " + fileInIt.getName()); - } + String xmlmapping = ConfigurationHelper.getEntityMappingFromFile(fileInIt.getAbsolutePath()); + + // lit le fichier avec lutin xml + org.w3c.dom.Document domDoc = getDocumentResolvedByHibernate(xmlmapping); + + configuration.addDocument(domDoc); + + logger.debug("Local mapping added : " + fileInIt.getName()); } } else { @@ -121,30 +117,6 @@ return configuration; } - - /** - * Liste recursivement les fichiers d'un repertoire un les filtrant - * via leur nom - * - * @param mappingDir le dossier a lister - * @param regexFilename le filtre - * @return une liste de fichier - */ - private List recursiveListFiles(File currentDir) { - - List localFiles = new ArrayList(); - for(File f : currentDir.listFiles()) { - // dossier - if(f.isDirectory()) { - localFiles.addAll(recursiveListFiles(f)); - } - else { - // ou fichier - localFiles.add(f); - } - } - return localFiles; - } /** * Charge un fichier et retourne un mapping valide pour etre manipule via les map