예제 #1
0
 public static MappingTool loadTool(String toolDirectory) throws DAOException {
   MappingTool tool = new MappingTool();
   Properties prop = new Properties();
   FileInputStream in = null;
   try {
     // load a properties file
     in = new FileInputStream(toolDirectory + "/" + "tool.properties");
     prop.load(in);
     tool.setName(toolDirectory.substring(toolDirectory.lastIndexOf(File.separator) + 1));
     tool.setMappingFilePath(
         Utils.toAbsolutePath(toolDirectory, prop.getProperty(tool.getName() + ".mapping_file")));
     tool.setTranslatedInstancePath(
         Utils.toAbsolutePath(
             toolDirectory, prop.getProperty(tool.getName() + ".instance_translated_file")));
     String script = prop.getProperty(tool.getName() + ".script_file");
     if (script != null) {
       tool.setFileScript(Utils.toAbsolutePath(toolDirectory, script));
     }
     tool.setDirectory(toolDirectory);
     in.close();
     return tool;
   } catch (FileNotFoundException fe) {
     logger.error("File tool.properties not found: " + fe.getLocalizedMessage());
     return null;
   } catch (IOException ex) {
     logger.error(ex.getLocalizedMessage());
     throw new DAOException("Problem to load the tool.properties file");
   } finally {
     if (in != null) {
       try {
         in.close();
       } catch (IOException ex) {
       }
     }
   }
 }