Index: topia-service/src/java/org/codelutin/topia/migration/TopiaMigrationServiceImpl.java diff -u topia-service/src/java/org/codelutin/topia/migration/TopiaMigrationServiceImpl.java:1.4 topia-service/src/java/org/codelutin/topia/migration/TopiaMigrationServiceImpl.java:1.5 --- topia-service/src/java/org/codelutin/topia/migration/TopiaMigrationServiceImpl.java:1.4 Tue Apr 24 10:19:50 2007 +++ topia-service/src/java/org/codelutin/topia/migration/TopiaMigrationServiceImpl.java Thu Apr 26 13:13:24 2007 @@ -19,7 +19,9 @@ package org.codelutin.topia.migration; import java.io.File; +import java.net.URL; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.SortedMap; @@ -35,6 +37,7 @@ import org.codelutin.topia.migration.kernel.ConfigurationAdapter; import org.codelutin.topia.migration.kernel.ConfigurationHelper; import org.codelutin.topia.migration.kernel.Transformer; +import org.codelutin.util.Resource; import org.hibernate.cfg.Configuration; /** @@ -46,9 +49,9 @@ * @author Chevallereau Benjamin * @author Eon Sébastien * @author Trève Vincent - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ * - * Last update : $Date: 2007/04/24 10:19:50 $ + * Last update : $Date: 2007/04/26 13:13:24 $ */ public class TopiaMigrationServiceImpl implements TopiaMigrationService { @@ -426,35 +429,30 @@ */ private Map loadOldConfigurations(Version vdbVersion) { // schema des noms de dossier de version - final Pattern pattern = Pattern.compile("([0-9]+(\\.[0-9]+)*)"); + final Pattern pattern = Pattern.compile(mappingsDirectory + File.separator + "([0-9]+(\\.[0-9]+)*)"); - // instancie la map ordonée + // instancie la map ordonee Map mVersionAndConfigurationMap = null; - // parcourt du dossier mappingsDirectory - File mappingBaseDir = new File(mappingsDirectory); + List urls = null; + urls = Resource.getURLs(".*" + mappingsDirectory + File.separator + ".*"); - // pour tous les dossiers qui ont un nom genre "x" (x est une version) - File[] filesInIt = mappingBaseDir.listFiles(); - - if (filesInIt != null && filesInIt.length > 0) { + if (urls != null && urls.size() > 0) { mVersionAndConfigurationMap = new HashMap(); - // ensemble ordonnée des version a charger apres + // ensemble ordonnee des version a charger apres TreeSet tsEnsembleVersionACharger = new TreeSet(); - for(File fileInIt : filesInIt) { - if(fileInIt.isDirectory()) { - Matcher matcher = pattern.matcher(fileInIt.getName()); + for(URL url : urls) { + Matcher matcher = pattern.matcher(url.getFile()); - if(matcher.find()) { - // group(1) est ce qui match entre le premier niveau de parentheses - String sVersion = matcher.group(1); - //logger.debug("Directory " + fileInIt.getName() + " matches, version = " + sVersion); + if(matcher.find()) { + // group(1) est ce qui match entre le premier niveau de parentheses + String sVersion = matcher.group(1); + //logger.debug("Directory " + fileInIt.getName() + " matches, version = " + sVersion); - tsEnsembleVersionACharger.add(new Version(sVersion)); - } + tsEnsembleVersionACharger.add(new Version(sVersion)); } } @@ -468,7 +466,7 @@ else { logger.debug("Loading mapping for version " + v.getVersion()); - String mappingVersionDir = mappingsDirectory + "/" + v.getVersion(); + String mappingVersionDir = mappingsDirectory + File.separator + v.getVersion(); Configuration cfgForVersion = cfgHelper.getConfigurationInDirectory(mappingVersionDir); mVersionAndConfigurationMap.put(v, cfgForVersion); @@ -476,7 +474,7 @@ } } else { - logger.error("There is nothing in directory " + mappingBaseDir.getAbsolutePath() + "; can't load old mappings"); + logger.error("No mapping found in classpath '" + mappingsDirectory + "'; can't load old mappings"); } return mVersionAndConfigurationMap;