List of usage examples for org.apache.commons.io FileUtils copyDirectory
public static void copyDirectory(File srcDir, File destDir) throws IOException
From source file:de.peran.dependency.ChangedTestClassesHandler.java
public void saveOldClasses() { try {//from w w w. jav a 2 s . c o m if (lastSourcesFolder.exists()) { FileUtils.deleteDirectory(lastSourcesFolder); } lastSourcesFolder.mkdir(); FileUtils.copyDirectory(new File(projectFolder, "src"), new File(lastSourcesFolder, "main")); } catch (final IOException e) { e.printStackTrace(); } }
From source file:net.mindengine.blogix.BlogixMain.java
private static void initWebsiteFromTemplate(File templateDir) throws IOException { FileUtils.copyDirectory(templateDir, new File(".")); }
From source file:com.cubeia.maven.plugin.firebase.FirebaseRunPlugin.java
private void copyOverlayToFirebaseDir(File firebaseDir) throws MojoFailureException, MojoExecutionException { if (overlaysEnabled) { getLog().info("Firebase overlays enabled, source: " + overlaySourceDirectory + ", target directory: " + firebaseDir);//from w ww . j av a 2s . co m try { FileUtils.copyDirectory(overlaySourceDirectory, firebaseDir); } catch (IOException e) { // throw new MojoExecutionException("Failed to copy overlay files ["+overlaySourceDirectory+"] to Firebase base directory ["+firebaseDir+"]", e); getLog().warn("Failed to copy overlay files [" + overlaySourceDirectory + "] to Firebase base directory [" + firebaseDir + "]. Firebase overlay is ignored."); } } else { getLog().debug("Firebase overlays disabled"); } }
From source file:ml.shifu.shifu.ShifuCLITest.java
@Test public void testRunExport() throws Exception { File originModel = new File( "src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ModelConfig.json"); File tmpModel = new File("ModelConfig.json"); File originColumn = new File( "src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ColumnConfig.json"); File tmpColumn = new File("ColumnConfig.json"); File modelsDir = new File("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/models"); File tmpModelsDir = new File("models"); FileUtils.copyFile(originModel, tmpModel); FileUtils.copyFile(originColumn, tmpColumn); FileUtils.copyDirectory(modelsDir, tmpModelsDir); // run evaluation set ShifuCLI.exportModel(null, null);/*from w w w.j av a 2s. c om*/ File pmml = new File("./pmmls/cancer-judgement0.pmml"); Assert.assertTrue(pmml.exists()); FileUtils.deleteQuietly(tmpModel); FileUtils.deleteQuietly(tmpColumn); FileUtils.deleteQuietly(new File("./pmmls")); FileUtils.deleteDirectory(tmpModelsDir); }
From source file:edu.isi.wings.portal.classes.domains.Domain.java
public static File exportDomain(Domain fromdom, Config config) { Properties props = config.getProperties(fromdom); DataCreationAPI dc = DataFactory.getCreationAPI(props); ComponentCreationAPI acc = ComponentFactory.getCreationAPI(props, false); ComponentCreationAPI ccc = ComponentFactory.getCreationAPI(props, true); TemplateCreationAPI tc = TemplateFactory.getCreationAPI(props); ResourceAPI rc = ResourceFactory.getAPI(props); File tempdir;/*from w ww.j a v a2s . co m*/ try { tempdir = File.createTempFile("domain-", "-temp"); if (!tempdir.delete() || !tempdir.mkdirs()) return null; } catch (IOException e1) { return null; } Domain todom = Domain.createDefaultDomain(fromdom.getDomainName(), tempdir.getAbsolutePath(), config.getExportUserUrl()); todom.setUseSharedTripleStore(false); todom.saveDomain(); props = config.getProperties(todom); DataCreationAPI todc = DataFactory.getCreationAPI(props); ComponentCreationAPI toacc = ComponentFactory.getCreationAPI(props, false); ComponentCreationAPI toccc = ComponentFactory.getCreationAPI(props, true); TemplateCreationAPI totc = TemplateFactory.getCreationAPI(props); ResourceAPI torc = ResourceFactory.getAPI(props); // Copy into non-triple-store apis todc.copyFrom(dc); toacc.copyFrom(acc); toccc.copyFrom(ccc); totc.copyFrom(tc); if (rc != null && torc != null) torc.copyFrom(rc, ccc); // Copy legacy data/code directories to new data/code storage directory File srcDataDir = new File( fromdom.getDomainDirectory() + fsep + fromdom.getDataLibrary().getStorageDirectory()); File destDataDir = new File( todom.getDomainDirectory() + fsep + todom.getDataLibrary().getStorageDirectory()); File srcCodeDir = new File( fromdom.getDomainDirectory() + fsep + fromdom.getConcreteComponentLibrary().getStorageDirectory()); File destCodeDir = new File( todom.getDomainDirectory() + fsep + todom.getConcreteComponentLibrary().getStorageDirectory()); File srcBeamerDir = new File(fromdom.getDomainDirectory() + fsep + "beamer"); File destBeamerDir = new File(todom.getDomainDirectory() + fsep + "beamer"); try { if (srcDataDir.isDirectory()) FileUtils.copyDirectory(srcDataDir, destDataDir); if (srcCodeDir.isDirectory()) { FileUtils.copyDirectory(srcCodeDir, destCodeDir); // FIXME: Setting executable permissions on all files for now for (File f : FileUtils.listFiles(destCodeDir, null, true)) { f.setExecutable(true); } } if (srcBeamerDir.isDirectory()) FileUtils.copyDirectory(srcBeamerDir, destBeamerDir); } catch (IOException e) { e.printStackTrace(); } // Copy domain url File domUriFile = new File(todom.getDomainDirectory() + fsep + "domain.url"); try { FileUtils.write(domUriFile, todom.getDomainUrl()); } catch (IOException e) { e.printStackTrace(); } return tempdir; }
From source file:com.edgenius.core.repository.SimpleRepositoryServiceImpl.java
public void copy(ITicket fromTicket, String fromType, String fromIdentifierUuid, ITicket toTicket, String toType, String toIdentifierUuid) throws RepositoryException, RepositoryTiemoutExcetpion { if (!fromTicket.isAllowRead()) { String error = "Workspace has not read permission " + fromTicket.getSpacename(); log.warn(error);//from www. j a v a2 s . c o m throw new RepositoryException("Permission denied: " + error); } if (!toTicket.isAllowRead()) { String error = "Workspace has not write permission " + toTicket.getSpacename(); log.warn(error); throw new RepositoryException("Permission denied: " + error); } String msg = "Copy Identifier " + fromIdentifierUuid + " from space " + fromTicket.getSpacename() + " to " + toTicket.getSpacename() + " to Identifier " + toIdentifierUuid; try { acquireLock(toTicket.getSpacename(), toIdentifierUuid, null); CrWorkspace crWFrom = getCrWorkspace(fromTicket); CrWorkspace crWTo = getCrWorkspace(toTicket); log.info(msg); String srcDir = FileUtil.getFullPath(homeDir, crWFrom.getSpaceUuid(), fromType, fromIdentifierUuid); String toDir = FileUtil.getFullPath(homeDir, crWTo.getSpaceUuid(), toType, toIdentifierUuid); //copy physical files FileUtils.copyDirectory(new File(srcDir), new File(toDir)); //copy records in DB List<CrFileNode> fromList = crFileNodeDAO.getIdentifierNodes(fromType, fromIdentifierUuid); for (CrFileNode crFileNode : fromList) { CrFileNode node = (CrFileNode) crFileNode.clone(); //treat this as TO rather than PO node.setUid(null); node.setIdentifierUuid(toIdentifierUuid); node.setNodeType(toType); node.setSpaceUname(toTicket.getSpacename()); //need update the target directory to new nodeUUID, which is unique for a file node (but could have version). String oldNodeUuid = node.getNodeUuid(); String newNodeUuid = UUID.randomUUID().toString(); String oldFileNodeDir = FileUtil.getFullPath(toDir, oldNodeUuid); String newFileNodeDir = FileUtil.getFullPath(toDir, newNodeUuid); if (FileUtil.rename(oldFileNodeDir, newFileNodeDir)) { node.setNodeUuid(newNodeUuid); crFileNodeDAO.saveOrUpdate(node); } else { log.error("Some file node can not be rename to new. Lost data.old NodeUuid" + oldNodeUuid + " new NodeUuid" + newNodeUuid); } } } catch (IOException e) { log.error("Copy node failed:" + msg, e); throw new RepositoryException(msg); } finally { releaseLock(toTicket.getSpacename(), toIdentifierUuid, null); } }
From source file:com.collective.celos.CelosClientServerTest.java
@Test public void testGetWorkflowStatusTransitionToSuccessRunning() throws Exception { File src = new File(Thread.currentThread().getContextClassLoader() .getResource("com/collective/celos/client/wf-list").toURI()); FileUtils.copyDirectory(src, workflowsDir); celosClient.iterateScheduler();// w w w .j a v a 2 s . c om celosClient.iterateScheduler(); celosClient.iterateScheduler(); celosClient.iterateScheduler(); List<SlotState> slotStates = celosClient.getWorkflowStatus(new WorkflowID("workflow-2")).getSlotStates(); Assert.assertEquals(slotStates.size(), SLOTS_IN_CELOS_SERVER_SLIDING_WINDOW); SlotState slotStateLst = slotStates.get(slotStates.size() - 1); Assert.assertEquals(slotStateLst.getStatus(), SlotState.Status.SUCCESS); Assert.assertNotNull(slotStateLst.getExternalID()); Assert.assertEquals(slotStateLst.getRetryCount(), 0); SlotState slotStatePreLst = slotStates.get(slotStates.size() - 2); Assert.assertEquals(slotStatePreLst.getStatus(), SlotState.Status.RUNNING); Assert.assertNotNull(slotStatePreLst.getExternalID()); Assert.assertEquals(slotStatePreLst.getRetryCount(), 0); slotStates = slotStates.subList(0, slotStates.size() - 2); for (SlotState slotState : slotStates) { Assert.assertEquals(slotState.getStatus(), SlotState.Status.READY); Assert.assertNull(slotState.getExternalID()); Assert.assertEquals(slotState.getRetryCount(), 0); } }
From source file:com.apress.dwrprojects.fileman.FileSystemFunctions.java
/** * This method is called to copy or move a file. * * @param inSourcePath The path to the file/directory to copy/move. * @param inSourceName The name of the file/directory to copy/move. * @param inDestinationPath The path of the destination for the * file/directory. * @param inOperation Whether to do a "copy" or a "move". * @param inType Whether the object being moved is a "file" or * "directory". * @throws Exception If anything goes wrong. *//*from w ww .ja va 2 s .c o m*/ public void copyMoveFile(final String inSourcePath, final String inSourceName, final String inDestinationPath, final String inOperation, final String inType) throws Exception { boolean outcome = true; try { File src = new File(inSourcePath + File.separator + inSourceName); File dest = new File(inDestinationPath + File.separator + (inOperation.equals("copy") ? "copy_of_" : "") + inSourceName); // Different copy method based on whether copying file or directory. if (inType.equals("file")) { FileUtils.copyFile(src, dest); } else { FileUtils.copyDirectory(src, dest); } // Delete the original file if doing a cut. if (inOperation.equals("cut")) { deleteFile(inSourcePath + File.separator + inSourceName); } } catch (Exception e) { e.printStackTrace(); throw new Exception("Exception occurred: " + e); } if (!outcome) { throw new Exception("File/directory could not be copied/moved\n\n" + "(Does the file/directory already exist in the destination?)"); } }
From source file:com.enderville.enderinstaller.util.InstallScript.java
/** * Installs the mod specified by folder. * * @param modDir The directory of the mod to install. * @param jarDir The temp directory with the contents of the jar. * @param mcDir The target minecraft installation folder. * @throws IOException/* w w w .j av a2 s. c om*/ */ private static void installMod(File modDir, File jarDir, File mcDir) throws IOException { for (File dir : modDir.listFiles()) { if (!dir.isDirectory()) { continue; } if (dir.getName().equals("jar")) { FileUtils.copyDirectory(dir, jarDir); } else if (dir.getName().equals("resources")) { FileUtils.copyDirectory(dir, mcDir); } } }
From source file:com.bladecoder.engineeditor.ui.PackageDialog.java
private String packageAdv() throws IOException { String msg = "Package generated SUCCESSFULLY"; String projectName = getAppName(); if (projectName == null) Ctx.project.getProjectDir().getName(); String versionParam = "-Pversion=" + version.getText() + " "; Ctx.project.getProjectConfig().setProperty(Config.VERSION_PROP, version.getText()); if (arch.getText().equals("desktop")) { String jarDir = Ctx.project.getProjectDir().getAbsolutePath() + "/desktop/build/libs/"; String jarName = projectName + "-desktop-" + version.getText() + ".jar"; msg = genDesktopJar(projectName, versionParam, jarDir, jarName); if (type.getText().equals(TYPES[0])) { // BUNDLE JRE if (os.getText().equals("linux64")) { packr(Platform.linux64, linux64JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText());// w ww . ja va2 s. c o m } else if (os.getText().equals("linux32")) { packr(Platform.linux32, linux32JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } else if (os.getText().equals("windows")) { packr(Platform.windows, winJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } else if (os.getText().equals("macOSX")) { packr(Platform.mac, osxJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } else if (os.getText().equals("all")) { packr(Platform.linux64, linux64JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); packr(Platform.linux32, linux32JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); packr(Platform.windows, winJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); packr(Platform.mac, osxJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } } } else if (arch.getText().equals("android")) { String params = versionParam + "-PversionCode=" + androidVersionCode.getText() + " " + "-Pkeystore=" + androidKeyStore.getText() + " " + "-PstorePassword=" + androidKeyStorePassword.getText() + " " + "-Palias=" + androidKeyAlias.getText() + " " + "-PkeyPassword=" + androidKeyAliasPassword.getText() + " "; // UPDATE 'local.properties' with the android SDK location. if (androidSDK.getText() != null && !androidSDK.getText().trim().isEmpty()) { String sdk = androidSDK.getText(); Properties p = new Properties(); p.setProperty("sdk.dir", sdk); p.store(new FileOutputStream( new File(Ctx.project.getProjectDir().getAbsolutePath(), "local.properties")), null); } if (RunProccess.runGradle(Ctx.project.getProjectDir(), params + "android:assembleRelease")) { String apk = Ctx.project.getProjectDir().getAbsolutePath() + "/android/build/outputs/apk/android-release.apk"; File f = new File(apk); // FileUtils.copyFileToDirectory(f, new File(dir.getText())); FileUtils.copyFile(f, new File(dir.getText(), projectName + "-" + version.getText() + ".apk")); } else { msg = "Error Generating package"; } } else if (arch.getText().equals("ios")) { if (RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:createIPA")) { FileUtils.copyDirectory( new File(Ctx.project.getProjectDir().getAbsolutePath() + "/ios/build/robovm/"), new File(dir.getText())); } else { msg = "Error Generating package"; } } else if (arch.getText().equals("html")) { if (RunProccess.runGradle(Ctx.project.getProjectDir(), "html:dist")) { FileUtils.copyDirectory( new File(Ctx.project.getProjectDir().getAbsolutePath() + "/html/build/dist"), new File(dir.getText())); } else { msg = "Error Generating package"; } } return msg; }