public static void createDirectory(MappingTool tool, Scenario sc) throws DAOException { try { File directoryTool = new File(sc.getOutPath() + File.separator + tool.getName()); directoryTool.mkdirs(); // if (tool.getFileScript() != null && !tool.getFileScript().equals("")) { // logger.debug("There is File script"); // String script = // tool.getFileScript().substring(tool.getFileScript().lastIndexOf(File.separator) + 1); // copyFile(directoryTool, script); // } createFileProperties(tool, directoryTool); tool.setDirectory(directoryTool.getAbsolutePath()); } catch (Exception ex) { logger.error(ex.getMessage()); throw new DAOException(ex); } }
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) { } } } }