Refactoring: rename duplicated Util classes
[jabaws.git] / engine / compbio / engine / Configurator.java
index dd90ff4..1aa18ea 100644 (file)
@@ -29,6 +29,7 @@ import compbio.engine.client.ConfExecutable;
 import compbio.engine.client.ConfiguredExecutable;\r
 import compbio.engine.client.Executable;\r
 import compbio.engine.client.PathValidator;\r
+import compbio.engine.client.EngineUtil;\r
 import compbio.engine.cluster.drmaa.AsyncJobRunner;\r
 import compbio.engine.cluster.drmaa.JobRunner;\r
 import compbio.engine.conf.DirectoryManager;\r
@@ -43,16 +44,15 @@ import compbio.util.Util;
 public class Configurator {\r
 \r
        private static Logger log = Logger.getLogger(Configurator.class);\r
-\r
-       private static final PropertyHelper ph = PropertyHelperManager\r
-                       .getPropertyHelper();\r
+       private static final PropertyHelper ph = PropertyHelperManager.getPropertyHelper();\r
 \r
        public static final boolean IS_LOCAL_ENGINE_ENABLED = initBooleanValue("engine.local.enable");\r
        public static final boolean IS_CLUSTER_ENGINE_ENABLED = initBooleanValue("engine.cluster.enable");\r
-\r
        public final static String LOCAL_WORK_DIRECTORY = initLocalDirectory();\r
        public final static String CLUSTER_WORK_DIRECTORY = initClusterWorkDirectory();\r
 \r
+\r
+\r
        private static boolean initBooleanValue(String key) {\r
                assert key != null;\r
                String status = ph.getProperty(key);\r
@@ -84,17 +84,15 @@ public class Configurator {
 \r
        private static String initLocalDirectory() {\r
                String tmp_dir = ph.getProperty("local.tmp.directory");\r
-               // Use system temp directory is local.tmp.directory is not defined\r
+               // Use system temporary directory if local.tmp.directory is not defined\r
                if (Util.isEmpty(tmp_dir)) {\r
                        tmp_dir = SysPrefs.getSystemTmpDir();\r
-                       log.debug("local.tmp.directory is not defined using system tmp: "\r
-                                       + tmp_dir);\r
+                       log.debug("local.tmp.directory is not defined using system tmp: " + tmp_dir);\r
                }\r
                if (!PathValidator.isAbsolutePath(tmp_dir)) {\r
                        log.debug("local.tmp.directory path is relative! " + tmp_dir);\r
-                       tmp_dir = compbio.engine.client.Util.convertToAbsolute(tmp_dir);\r
-                       log.debug("local.tmp.directory path changed to absolute: "\r
-                                       + tmp_dir);\r
+                       tmp_dir = EngineUtil.convertToAbsolute(tmp_dir);\r
+                       log.debug("local.tmp.directory path changed to absolute: " + tmp_dir);\r
                }\r
                return tmp_dir.trim();\r
        }\r
@@ -146,8 +144,7 @@ public class Configurator {
                        }\r
                }\r
                // We are here if executable can be executed on both Cluster and Local\r
-               // engines\r
-               // i.e. provider = Any\r
+               // engines i.e. provider = Any\r
                // If we still here executable supports All exec environments\r
                // Check whether we work on windows\r
                if (SysPrefs.isWindows) {\r
@@ -287,9 +284,8 @@ public class Configurator {
 \r
        static boolean isTargetedForLocalExecution(\r
                        ConfiguredExecutable<?> executable) {\r
-               // In the uncommon case that the cluster and local execution temp\r
-               // directories are the same,\r
-               // in this case the method return true anyway\r
+               // In the uncommon case that the cluster and local execution temporary\r
+               // directories are the same, in this case the method return true anyway\r
 \r
                /*\r
                 * Could have done this String taskDir = executable.getWorkDirectory();\r
@@ -308,7 +304,7 @@ public class Configurator {
                if (Util.isEmpty(taskId)) {\r
                        throw new NullPointerException("TaskId must be provided!");\r
                }\r
-               if (!compbio.engine.client.Util.isValidJobId(taskId)) {\r
+               if (!EngineUtil.isValidJobId(taskId)) {\r
                        throw new InvalidParameterException("TaskId is not valid!");\r
                }\r
                return !taskId.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX);\r
@@ -316,7 +312,7 @@ public class Configurator {
 \r
        public static String getWorkDirectory(String taskId) {\r
                assert !compbio.util.Util.isEmpty(taskId);\r
-               assert compbio.engine.client.Util.isValidJobId(taskId);\r
+               assert EngineUtil.isValidJobId(taskId);\r
                log.info("Getting workdirectory for TaskID: " + taskId);\r
                if (taskId.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) {\r
                        return CLUSTER_WORK_DIRECTORY + File.separator + taskId;\r