List of usage examples for org.apache.commons.io FileUtils forceMkdir
public static void forceMkdir(File directory) throws IOException
From source file:com.blockwithme.longdb.bdb.BDBBackend.java
@Override protected void openInternal(final Map<String, BDBDatabase> theDatabase) { theDatabase.clear();// w ww . ja v a2s. c om try { final File dataRoot = new File(config.filePath()); if (!dataRoot.exists()) FileUtils.forceMkdir(dataRoot); final String[] dataDirectories = dataRoot.list(DirectoryFileFilter.INSTANCE); for (final String dir : dataDirectories) { final BDBDatabase bdb = new BDBDatabase(this, this.connect(dir), dir); theDatabase.put(dir.toLowerCase(), bdb); } } catch (final Exception e) { LOG.error("Exception Occurred in - " + "openInternal(Map<String,BDBDatabase> databases=" + theDatabase + ")", e); throw new DBException("Error creating connection.", e); } }
From source file:com.goodformobile.build.mobile.GenerateRAPCMojoTest.java
private void setupBuildDirectory(File buildDirectory) throws IOException { if (!buildDirectory.exists()) { FileUtils.forceMkdir(buildDirectory); }//from ww w . j ava 2s.c o m FileUtils.cleanDirectory(buildDirectory); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.LoadAnnotationListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub this.pathToFile = this.loadAnnotationUI.getPathToFile(); this.platformId = this.loadAnnotationUI.getPlatformId(); this.annotationDate = this.loadAnnotationUI.getAnnotationDate(); this.annotationRelease = this.loadAnnotationUI.getAnnotationRelease(); this.annotationTitle = this.loadAnnotationUI.getAnnotationTitle(); this.loadAnnotationUI.openLoadingShell(); Thread thread = new Thread() { public void run() { try { //initiate kettle environment KettleEnvironment.init(false); //find the kettle job to initiate the loading URL jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_annotation.kjb"); jobUrl = FileLocator.toFileURL(jobUrl); String jobPath = jobUrl.getPath(); //create a new job from the kettle file JobMeta jobMeta = new JobMeta(jobPath, null); Job job = new Job(null, jobMeta); //find the other files needed for this job and put them in the cache jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/extract_AFFY_annotation_from_file.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/extract_GEO_annotation_from_file.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_annotation_to_lt.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/run_i2b2_load_annotation_deapp.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/extract_annotation_from_file.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_annotation_to_de_gpl_info.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); job.getJobMeta().setParameterValue("DATA_LOCATION", pathToFile); File sort = new File( StudySelectionController.getWorkspace().getAbsoluteFile() + File.separator + ".sort"); if (!sort.exists()) { FileUtils.forceMkdir(sort); }/*from w w w . j ava 2s . c om*/ job.getJobMeta().setParameterValue("SORT_DIR", sort.getAbsolutePath()); job.getJobMeta().setParameterValue("DATA_SOURCE", "A"); //check if gpl id is not empty if (platformId == null) { loadAnnotationUI.setMessage("Please provide the platform identifier"); loadAnnotationUI.setIsLoading(false); return; } job.getJobMeta().setParameterValue("GPL_ID", platformId); job.getJobMeta().setParameterValue("SKIP_ROWS", "1"); job.getJobMeta().setParameterValue("GENE_ID", "4"); job.getJobMeta().setParameterValue("GENE_SYMBOL_COL", "3"); job.getJobMeta().setParameterValue("ORGANISM_COL", "5"); job.getJobMeta().setParameterValue("PROBE_COL", "2"); if (annotationDate != null) { job.getJobMeta().setParameterValue("ANNOTATION_DATE", annotationDate); } if (annotationRelease != null) { job.getJobMeta().setParameterValue("ANNOTATION_RELEASE", annotationRelease); } //check if annotation title is not empty if (annotationTitle == null) { loadAnnotationUI.setMessage("Please provide the annotation title"); loadAnnotationUI.setIsLoading(false); return; } job.getJobMeta().setParameterValue("ANNOTATION_TITLE", annotationTitle); job.getJobMeta().setParameterValue("LOAD_TYPE", "I"); job.getJobMeta().setParameterValue("TM_CZ_DB_SERVER", PreferencesHandler.getDbServer()); job.getJobMeta().setParameterValue("TM_CZ_DB_NAME", PreferencesHandler.getDbName()); job.getJobMeta().setParameterValue("TM_CZ_DB_PORT", PreferencesHandler.getDbPort()); job.getJobMeta().setParameterValue("TM_CZ_DB_USER", PreferencesHandler.getTm_czUser()); job.getJobMeta().setParameterValue("TM_CZ_DB_PWD", PreferencesHandler.getTm_czPwd()); job.getJobMeta().setParameterValue("TM_LZ_DB_SERVER", PreferencesHandler.getDbServer()); job.getJobMeta().setParameterValue("TM_LZ_DB_NAME", PreferencesHandler.getDbName()); job.getJobMeta().setParameterValue("TM_LZ_DB_PORT", PreferencesHandler.getDbPort()); job.getJobMeta().setParameterValue("TM_LZ_DB_USER", PreferencesHandler.getTm_lzUser()); job.getJobMeta().setParameterValue("TM_LZ_DB_PWD", PreferencesHandler.getTm_lzPwd()); job.getJobMeta().setParameterValue("DEAPP_DB_SERVER", PreferencesHandler.getDbServer()); job.getJobMeta().setParameterValue("DEAPP_DB_NAME", PreferencesHandler.getDbName()); job.getJobMeta().setParameterValue("DEAPP_DB_PORT", PreferencesHandler.getDbPort()); job.getJobMeta().setParameterValue("DEAPP_DB_USER", PreferencesHandler.getDeappUser()); job.getJobMeta().setParameterValue("DEAPP_DB_PWD", PreferencesHandler.getDeappPwd()); job.start(); job.waitUntilFinished(3000000); job.interrupt(); //job.waitUntilFinished(5000000); @SuppressWarnings("unused") Result result = job.getResult(); Log4jBufferAppender appender = CentralLogStore.getAppender(); String logText = appender.getBuffer(job.getLogChannelId(), false).toString(); Pattern pattern = Pattern.compile( ".*run_i2b2_load_annotation_deapp - Dispatching started for transformation \\[run_i2b2_load_annotation_deapp\\].*", Pattern.DOTALL); Matcher matcher = pattern.matcher(logText); if (matcher.matches()) { String connectionString = "jdbc:oracle:thin:@" + PreferencesHandler.getDbServer() + ":" + PreferencesHandler.getDbPort() + ":" + PreferencesHandler.getDbName(); Connection con = DriverManager.getConnection(connectionString, PreferencesHandler.getTm_czUser(), PreferencesHandler.getTm_czPwd()); Statement stmt = con.createStatement(); //remove rows for this study before adding new ones ResultSet rs = stmt.executeQuery( "select max(JOB_ID) from CZ_JOB_AUDIT where STEP_DESC='Starting i2b2_load_annotation_deapp'"); int jobId; if (rs.next()) { jobId = rs.getInt("max(JOB_ID)"); } else { con.close(); loadAnnotationUI.setIsLoading(false); return; } logText += "\nOracle job id:\n" + String.valueOf(jobId); rs = stmt.executeQuery( "select job_status from cz_job_master where job_id=" + String.valueOf(jobId)); if (rs.next()) { if (rs.getString("job_status").compareTo("Running") == 0) { loadAnnotationUI.setMessage( "Kettle job time out because the stored procedure is not over. Please check in a while if loading has succeed"); loadAnnotationUI.setIsLoading(false); return; } } rs = stmt.executeQuery( "select ERROR_MESSAGE from CZ_JOB_ERROR where JOB_ID=" + String.valueOf(jobId)); String procedureErrors = ""; if (rs.next()) { procedureErrors = rs.getString("ERROR_MESSAGE"); } con.close(); if (procedureErrors.compareTo("") == 0) { loadAnnotationUI.setMessage("Platform annotation has been loaded"); } else { loadAnnotationUI.setMessage("Error during procedure: " + procedureErrors); } } else { loadAnnotationUI.setMessage("Error in Kettle job: see log file"); } writeLog(logText); CentralLogStore.discardLines(job.getLogChannelId(), false); // loadAnnotationUI.setIsLoading(false); } catch (Exception e1) { loadAnnotationUI.setMessage("Error: " + e1.getLocalizedMessage()); loadAnnotationUI.setIsLoading(false); //this.write(e1.getMessage()); e1.printStackTrace(); } loadAnnotationUI.setIsLoading(false); } }; thread.start(); this.loadAnnotationUI.waitForThread(); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:hu.bme.mit.sette.tools.spf.SpfGenerator.java
private void createGeneratedFiles() throws IOException { // generate main() for each snippet for (SnippetContainer container : getSnippetProject().getModel().getContainers()) { // skip container with higher java version than supported if (container.getRequiredJavaVersion().compareTo(getTool().getSupportedJavaVersion()) > 0) { // TODO error handling System.err.println("Skipping container: " + container.getJavaClass().getName() + " (required Java version: " + container.getRequiredJavaVersion() + ")"); continue; }/* ww w .j av a 2 s .c om*/ for (Snippet snippet : container.getSnippets().values()) { Method method = snippet.getMethod(); Class<?> javaClass = method.getDeclaringClass(); Class<?>[] parameterTypes = method.getParameterTypes(); // create .jpf descriptor JPFConfig jpfConfig = new JPFConfig(); jpfConfig.target = javaClass.getName() + '_' + method.getName(); String symbMethod = javaClass.getName() + '.' + method.getName() + '(' + StringUtils.repeat("sym", "#", parameterTypes.length) + ')'; jpfConfig.symbolicMethod.add(symbMethod); jpfConfig.classpath = "build/"; for (File libraryFile : getSnippetProject().getFiles().getLibraryFiles()) { jpfConfig.classpath += ',' + getSnippetProjectSettings().getLibraryDirectoryPath() + '/' + libraryFile.getName(); } jpfConfig.listener = JPFConfig.SYMBOLIC_LISTENER; jpfConfig.symbolicDebug = JPFConfig.ON; jpfConfig.searchMultipleErrors = JPFConfig.TRUE; jpfConfig.decisionProcedure = JPFConfig.DP_CORAL; // generate main() JavaClassWithMain main = new JavaClassWithMain(); main.setPackageName(javaClass.getPackage().getName()); main.setClassName(javaClass.getSimpleName() + '_' + method.getName()); main.imports().add(javaClass.getName()); String[] parameterLiterals = new String[parameterTypes.length]; int i = 0; for (Class<?> parameterType : parameterTypes) { parameterLiterals[i] = SpfGenerator.getParameterLiteral(parameterType); i++; } main.codeLines().add(javaClass.getSimpleName() + '.' + method.getName() + '(' + StringUtils.join(parameterLiterals, ", ") + ");"); // save files String relativePath = JavaFileUtils.packageNameToFilename(main.getFullClassName()); String relativePathJPF = relativePath + '.' + JPFConfig.JPF_CONFIG_EXTENSION; String relativePathMain = relativePath + '.' + JavaFileUtils.JAVA_SOURCE_EXTENSION; File targetJPFFile = new File(getRunnerProjectSettings().getGeneratedDirectory(), relativePathJPF); FileUtils.forceMkdir(targetJPFFile.getParentFile()); FileUtils.write(targetJPFFile, jpfConfig.generate().toString()); File targetMainFile = new File(getRunnerProjectSettings().getGeneratedDirectory(), relativePathMain); FileUtils.forceMkdir(targetMainFile.getParentFile()); FileUtils.write(targetMainFile, main.generateJavaCode().toString()); } } }
From source file:com.uwsoft.editor.data.manager.DataManager.java
private void initWorkspace() { try {/*from w w w . jav a 2 s .c om*/ editorConfigVO = getEditorConfig(); String myDocPath = getMyDocumentsLocation(); workspacePath = myDocPath + "/" + DEFAULT_FOLDER; FileUtils.forceMkdir(new File(workspacePath)); currentWorkingPath = workspacePath; } catch (IOException e) { e.printStackTrace(); } }
From source file:com.github.hadoop.maven.plugin.pack.PackMojo.java
/** * Create the hadoop deploy artifacts/* w w w.j a va 2s . c om*/ * * @throws IOException * @return File that contains the root of jar file to be packed. * @throws InvalidDependencyVersionException * @throws ArtifactNotFoundException * @throws ArtifactResolutionException */ private File createHadoopDeployArtifacts() throws IOException { FileUtils.deleteDirectory(outputDirectory); final File rootDir = new File(outputDirectory.getAbsolutePath() + File.separator + "root"); FileUtils.forceMkdir(rootDir); final File jarlibdir = new File(rootDir.getAbsolutePath() + File.separator + "lib"); FileUtils.forceMkdir(jarlibdir); final File classesdir = new File(project.getBuild().getDirectory() + File.separator + "classes"); FileUtils.copyDirectory(classesdir, rootDir); final Set<Artifact> filteredArtifacts = this.filterArtifacts(this.artifacts); getLog().info(""); getLog().info("Dependencies of this project independent of hadoop classpath " + filteredArtifacts); getLog().info(""); for (final Artifact artifact : filteredArtifacts) { FileUtils.copyFileToDirectory(artifact.getFile(), jarlibdir); } return rootDir; }
From source file:com.o2d.pkayjava.editor.proxy.ProjectManager.java
public void createEmptyProject(String projectName, int width, int height, int pixelPerWorldUnit) throws IOException { if (workspacePath.endsWith(File.separator)) { workspacePath = workspacePath.substring(0, workspacePath.length() - 1); }//from ww w. ja v a 2 s . c om String projPath = workspacePath + File.separator + projectName; currentWorkingPath = workspacePath; FileUtils.forceMkdir(new File(projPath)); FileUtils.forceMkdir(new File(projPath + File.separator + "export")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets")); FileUtils.forceMkdir(new File(projPath + File.separator + "scenes")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/images")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/particles")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/animations")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/pack")); // create project file ProjectVO projVo = new ProjectVO(); projVo.projectName = projectName; projVo.projectVersion = ProjectVersionMigrator.dataFormatVersion; // create project info file ProjectInfoVO projInfoVo = new ProjectInfoVO(); projInfoVo.originalResolution.name = "orig"; projInfoVo.originalResolution.width = width; projInfoVo.originalResolution.height = height; projInfoVo.pixelToWorld = pixelPerWorldUnit; //TODO: add project orig resolution setting currentProjectVO = projVo; currentProjectInfoVO = projInfoVo; SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME); sceneDataManager.createNewScene("MainScene"); FileUtils.writeStringToFile(new File(projPath + "/project.pit"), projVo.constructJsonString(), "utf-8"); FileUtils.writeStringToFile(new File(projPath + "/project.dt"), projInfoVo.constructJsonString(), "utf-8"); }
From source file:com.uwsoft.editor.proxy.ProjectManager.java
public void createEmptyProject(String projectPath, int width, int height, int pixelPerWorldUnit) throws IOException { /*/*from www .j a v a2s .c o m*/ if (workspacePath.endsWith(File.separator)) { workspacePath = workspacePath.substring(0, workspacePath.length() - 1); } String projPath = workspacePath + File.separator + projectName; */ String projectName = new File(projectPath).getName(); String projPath = FilenameUtils.normalize(projectPath); FileUtils.forceMkdir(new File(projPath)); FileUtils.forceMkdir(new File(projPath + File.separator + "export")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets")); FileUtils.forceMkdir(new File(projPath + File.separator + "scenes")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/images")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/particles")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/animations")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig/pack")); // create project file ProjectVO projVo = new ProjectVO(); projVo.projectName = projectName; projVo.projectVersion = ProjectVersionMigrator.dataFormatVersion; // create project info file ProjectInfoVO projInfoVo = new ProjectInfoVO(); projInfoVo.originalResolution.name = "orig"; projInfoVo.originalResolution.width = width; projInfoVo.originalResolution.height = height; projInfoVo.pixelToWorld = pixelPerWorldUnit; //TODO: add project orig resolution setting currentProjectVO = projVo; currentProjectInfoVO = projInfoVo; currentProjectPath = projPath; SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME); sceneDataManager.createNewScene("MainScene"); FileUtils.writeStringToFile(new File(projPath + "/project.pit"), projVo.constructJsonString(), "utf-8"); FileUtils.writeStringToFile(new File(projPath + "/project.dt"), projInfoVo.constructJsonString(), "utf-8"); }
From source file:com.alibaba.jstorm.cluster.StormConfig.java
private static String supervisor_local_dir(Map conf) throws IOException { String ret = String.valueOf(conf.get(Config.STORM_LOCAL_DIR)) + FILE_SEPERATEOR + "supervisor"; FileUtils.forceMkdir(new File(ret)); return ret;/*from w ww . ja v a 2 s. c o m*/ }
From source file:edu.ku.brc.util.FileCache.java
/** * Does all of the work of constructing a FileCache. * /*from w w w . ja v a 2 s . c o m*/ * @param dir the directory in which to place the cached files and the mapping files * @throws IOException if the given directory doesn't exist */ protected void init(final String dir) throws IOException { cacheDir = new File(dir); if (!cacheDir.exists()) { FileUtils.forceMkdir(cacheDir); } //log.debug("Creating FileCache using [" + dir + "] directory"); handleToFilenameHash = new Properties(); if (mappingFilename != null) { loadCacheMappingFile(); calculateTotalCacheSize(); } prefix = defaultPrefix; suffix = defaultSuffix; enforceMaxSize = true; maxCacheMB = 30; // 30MB maxRententionDays = 5; // days purgeFiles(); }