diff --git a/src/bzh/plealog/dbmirror/ui/LocalDBPanel.java b/src/bzh/plealog/dbmirror/ui/LocalDBPanel.java index 6981f89..99d84b1 100755 --- a/src/bzh/plealog/dbmirror/ui/LocalDBPanel.java +++ b/src/bzh/plealog/dbmirror/ui/LocalDBPanel.java @@ -80,6 +80,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import com.jgoodies.forms.builder.DefaultFormBuilder; +import com.jgoodies.forms.layout.FormLayout; +import com.plealog.genericapp.api.EZEnvironment; +import com.plealog.genericapp.api.file.EZFileManager; + import bzh.plealog.dbmirror.fetcher.DBServerConfig; import bzh.plealog.dbmirror.fetcher.PFTPLoaderDescriptor; import bzh.plealog.dbmirror.fetcher.PLocalLoader; @@ -90,7 +95,6 @@ import bzh.plealog.dbmirror.ui.resources.DBMSMessages; import bzh.plealog.dbmirror.util.Utils; import bzh.plealog.dbmirror.util.conf.DBMSAbstractConfig; -import bzh.plealog.dbmirror.util.conf.DBMSConfigurator; import bzh.plealog.dbmirror.util.conf.DBMirrorConfig; import bzh.plealog.dbmirror.util.descriptor.DBDescriptor; import bzh.plealog.dbmirror.util.descriptor.DBDescriptorUtils; @@ -103,11 +107,6 @@ import bzh.plealog.dbmirror.util.sequence.SequenceValidatorTaxon; import bzh.plealog.dbmirror.util.sequence.TaxonMatcherHelper; -import com.jgoodies.forms.builder.DefaultFormBuilder; -import com.jgoodies.forms.layout.FormLayout; -import com.plealog.genericapp.api.EZEnvironment; -import com.plealog.genericapp.api.file.EZFileManager; - /** * This class implements a panel enabling a user to use the KDMS Lucene Indexer * system given a set of data files. @@ -1351,7 +1350,7 @@ public void actionPerformed(ActionEvent e) { // In case of a previous filter, takes the filtered files final File current = new File(file); - foundFiles = new File(DBMSConfigurator.TMP_FILTER_DIRECTORY) + foundFiles = new File(DBMSAbstractConfig.getWorkingFilterPath()) .list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { @@ -1359,7 +1358,7 @@ public boolean accept(File dir, String name) { } }); if ((foundFiles != null) && (foundFiles.length == 1)) { - databankFiles.add(new File(DBMSConfigurator.TMP_FILTER_DIRECTORY, + databankFiles.add(new File(DBMSAbstractConfig.getWorkingFilterPath(), foundFiles[0])); } else { diff --git a/src/bzh/plealog/dbmirror/util/conf/DBMSAbstractConfig.java b/src/bzh/plealog/dbmirror/util/conf/DBMSAbstractConfig.java index 2f2acc3..f3d44f3 100755 --- a/src/bzh/plealog/dbmirror/util/conf/DBMSAbstractConfig.java +++ b/src/bzh/plealog/dbmirror/util/conf/DBMSAbstractConfig.java @@ -60,6 +60,7 @@ public class DBMSAbstractConfig { private static String _logAppFileName; private static String _logAppFile; private static String _workingTmpPath; + private static String _filterWorkingTmpPath; private static String _externalBinPath; private static String _confPath; private static String _startDate; @@ -87,15 +88,15 @@ public class DBMSAbstractConfig { public static final String CONF_PATH_NAME = "conf"; public static final String EXT_PATH_NAME = "external"; public static final String BIN_PATH_NAME = "bin"; - private static final String APP_HOME_PROP_KEY = "KL_HOME"; - private static final String APP_WORKING_DIR_PROP_KEY = "KL_WORKING_DIR"; - private static final String APP_CONF_DIR_PROP_KEY = "KL_CONF_DIR"; - public static final String APP_DEBUG_MODE_PROP_KEY = "KL_DEBUG"; - private static final String APP_LOG_FILE_PROP_KEY = "KL_LOG_FILE"; - private static final String LCL_MIRROR_PROP_KEY = "MIRROR_HOME"; + public static final String APP_KEY_PREFIX = "KL_"; + private static final String APP_HOME_PROP_KEY = APP_KEY_PREFIX+"HOME"; + private static final String APP_WORKING_DIR_PROP_KEY = APP_KEY_PREFIX+"WORKING_DIR"; + private static final String APP_CONF_DIR_PROP_KEY = APP_KEY_PREFIX+"CONF_DIR"; + public static final String APP_DEBUG_MODE_PROP_KEY = APP_KEY_PREFIX+"DEBUG"; + private static final String APP_LOG_FILE_PROP_KEY = APP_KEY_PREFIX+"LOG_FILE"; private static final String USER_DIR_PROP_KEY = "user.dir"; - private static final String DEF_DB_PATH = "biobanks"; + private static final String DEF_DB_PATH = "beedeem_banks_repository"; // file containing the DB_XREFs definition public static final String DB_XREF_CONF_FILE = "dbxrefsForFasta.config"; @@ -167,7 +168,7 @@ public static String getLocalMirrorPath() { if (_localMirrorPath != null) return _localMirrorPath; - String path = pruneQuotes(System.getProperty(LCL_MIRROR_PROP_KEY)); + String path = pruneQuotes(System.getProperty(APP_KEY_PREFIX+DBMSConfigurator.MIRROR_PATH)); if (path != null) { _localMirrorPath = path; } else { @@ -278,11 +279,27 @@ public static String getWorkingPath() { return _workingTmpPath; } - public static void setWorkingPath(String path) { - _workingTmpPath = Utils.terminatePath(path); - LOGGER.debug("working path: " + _workingTmpPath); + public static String getWorkingFilterPath() { + if (_filterWorkingTmpPath != null) + return _filterWorkingTmpPath; + _filterWorkingTmpPath = Utils.terminatePath(getWorkingPath()+"filter"); + File f = new File(_filterWorkingTmpPath); + if (!f.exists()) { + f.mkdirs(); + } else { + try { + FileUtils.cleanDirectory(f); + } catch (IOException e) { + // do not throw exception for this + LoggerCentral.warn( + LOGGER, + "Unable to manage the tmp filter directory in '" + + _filterWorkingTmpPath + "' : " + + e.getMessage()); + } + } + return _filterWorkingTmpPath; } - /** * Returns the path pointing to external binaries. The path specifically * points to the OS localized dir (linux, windows or macos). @@ -501,31 +518,7 @@ public static void initializeConfigurator(String kdmsConfFile) { LoggerCentral.info(LOGGER, "*** START APPLICATION *** " + new Date()); LoggerCentral.info(LOGGER, "Configuration:"); _configurator.dumpContent(LOGGER); - - // manage the tmp filter directory - try { - DBMSConfigurator.TMP_FILTER_DIRECTORY = DBMSExecNativeCommand - .formatNativePath( - (Utils.terminatePath(DBMSAbstractConfig.getLocalMirrorPath()) + "tmp") - .replace(File.separatorChar, '|'), false, false).replace( - '|', File.separatorChar); - File tmpFilterDirectory = new File( - DBMSConfigurator.TMP_FILTER_DIRECTORY); - if (!tmpFilterDirectory.exists()) { - tmpFilterDirectory.mkdirs(); - } else { - FileUtils.cleanDirectory(tmpFilterDirectory); - } - } catch (IOException e) { - // do not throw exception for this - LoggerCentral.warn( - LOGGER, - "Unable to manage the tmp filter directory in '" - + DBMSConfigurator.TMP_FILTER_DIRECTORY + "' : " - + e.getMessage()); - } } - } /** diff --git a/src/bzh/plealog/dbmirror/util/conf/DBMSConfigurator.java b/src/bzh/plealog/dbmirror/util/conf/DBMSConfigurator.java index 54c2899..8b0e703 100755 --- a/src/bzh/plealog/dbmirror/util/conf/DBMSConfigurator.java +++ b/src/bzh/plealog/dbmirror/util/conf/DBMSConfigurator.java @@ -77,11 +77,6 @@ public static enum LUCENE_LK_VALUES {LK_DEFAULT, LK_NATIVE, LK_SIMPLE}; LONG_FILE_NAME, FDB_PRG_NAME, FDB_PATH_NAME, UI_SHOW_PATH, COPY_WORKERS, FASTA_VOLSIZE, LUCENE_FS, LUCENE_LOCK, ASPERA_KEY, ASPERA_BIN}; - public static String TMP_FILTER_DIRECTORY = Utils - .terminatePath(DBMSAbstractConfig - .getLocalMirrorPath()) - + "tmp"; - public DBMSConfigurator() { try { _pConfig = new PropertiesConfiguration(); @@ -153,7 +148,9 @@ public void load(String path, boolean listenReload) throws IOException { * @see java.util.Properties#getProperty(java.lang.String) */ public String getProperty(String key) { - return _pConfig.getString(key); + //this was added to enable overriding config file properties using java -D arguments. + String value = DBMSAbstractConfig.pruneQuotes(System.getProperty(DBMSAbstractConfig.APP_KEY_PREFIX+key)); + return value !=null ? value : _pConfig.getString(key); } /** diff --git a/src/bzh/plealog/dbmirror/util/sequence/SequenceFileManager.java b/src/bzh/plealog/dbmirror/util/sequence/SequenceFileManager.java index 78855da..401f1a8 100755 --- a/src/bzh/plealog/dbmirror/util/sequence/SequenceFileManager.java +++ b/src/bzh/plealog/dbmirror/util/sequence/SequenceFileManager.java @@ -35,7 +35,7 @@ import org.apache.commons.logging.Log; import bzh.plealog.dbmirror.util.Utils; -import bzh.plealog.dbmirror.util.conf.DBMSConfigurator; +import bzh.plealog.dbmirror.util.conf.DBMSAbstractConfig; import bzh.plealog.dbmirror.util.descriptor.DatabankFormat; import bzh.plealog.dbmirror.util.log.LoggerCentral; @@ -108,7 +108,7 @@ public void abortProcess() { public SequenceFileManager(String sequenceFilepath, DatabankFormat databankFormat, Log logger, JProgressBar progressBar) throws IOException { - setTmpFileDirectory(DBMSConfigurator.TMP_FILTER_DIRECTORY); + setTmpFileDirectory(DBMSAbstractConfig.getWorkingFilterPath()); this.sequenceFile = new File(sequenceFilepath); this.databankFormat = databankFormat; this.progressBar = progressBar; @@ -142,7 +142,7 @@ public SequenceFileManager(String sequenceFilepath, */ public SequenceFileManager(BufferedReader reader, BufferedWriter writer, DatabankFormat databankFormat, Log logger) { - setTmpFileDirectory(DBMSConfigurator.TMP_FILTER_DIRECTORY); + setTmpFileDirectory(DBMSAbstractConfig.getWorkingFilterPath()); this.databankFormat = databankFormat; this.logger = logger; this.validators = new ArrayList();