List of usage examples for org.springframework.util FileSystemUtils copyRecursively
public static void copyRecursively(Path src, Path dest) throws IOException
From source file:com.josescalia.tumblr.form.TumblrImageViewer.java
private void btnDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadActionPerformed frame = (MainFrame) this.getTopLevelAncestor(); form = this;//from ww w .java2 s . co m /*since the application using cache, all we need is only copying target file to destination folder*/ //busy cursor and progress bar panel and frame form.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.startProgressBar("Downloading"); new SwingWorker<String, String>() { @Override protected String doInBackground() throws Exception { int successCount = 0; int failedCount = 0; for (DownloadableImage image : imgList) { String fileName = image.getUrl().substring(image.getUrl().lastIndexOf("/") + 1); String downloadUrl = image.getUrl(); File targetFile = new File(BinaryCacheUtil.getBinaryImagePath(".cache", fileName, downloadUrl)); try { FileSystemUtils.copyRecursively(targetFile, new File(downloadPath + "//" + fileName)); successCount++; } catch (IOException e) { logger.error("Copy Failed Exception : " + e.getMessage()); failedCount++; } } return "Download file finished : \n" + successCount + " file(s) downloaded successfully \n" + failedCount + "failed to download"; } @Override protected void done() { try { UIAlert.showInformation(null, get()); } catch (InterruptedException e) { logger.error(e); } catch (ExecutionException e) { logger.error(e); } form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.stopProgressBar(""); } }.execute(); }
From source file:org.openspaces.pu.container.servicegrid.PUServiceBeanImpl.java
private long copyPu(String puPath, File puWorkFolder) throws IOException { String puDeployPath = context.getServiceBeanManager().getOperationalStringManager().getDeployPath() + "/" + puPath;/*from w ww . ja va 2s . c o m*/ File src = new File(puDeployPath); logger.info("Copying from GSM [" + puDeployPath + "] to " + "[" + deployPath + "] ..."); FileSystemUtils.copyRecursively(src, puWorkFolder); return src.getTotalSpace(); }
From source file:org.openspaces.pu.container.servicegrid.PUServiceBeanImpl.java
private void prepareWebApplication(File deployPath, ClusterInfo clusterInfo, BeanLevelProperties beanLevelProperties) throws Exception { if (!(new File(deployPath, "WEB-INF/web.xml").exists())) { return;/*from w ww . j a va2s . c o m*/ } BootstrapWebApplicationContextListener.prepareForBoot(deployPath, clusterInfo, beanLevelProperties); // if we download, we can delete JSpaces and jini jars from the WEB-INF/lib (they are already in the // common class loader). File webInfLib = new File(deployPath, "WEB-INF/lib"); webInfLib.mkdirs(); if (webInfLib.exists()) { String gsRequired = Locator.getLibRequired(); String gsOptional = Locator.getLibOptional(); String gsPlatform = Locator.getLibPlatform(); try { FileSystemUtils.copyRecursively(new File(gsRequired), new File(deployPath, "WEB-INF/lib")); FileSystemUtils.copyRecursively(new File(gsOptional + "/spring"), new File(deployPath, "WEB-INF/lib")); FileSystemUtils.copyRecursively(new File(gsOptional + "/security"), new File(deployPath, "WEB-INF/lib")); if (ScalaIdentifier.isScalaLibInClassPath()) { FileSystemUtils.copyRecursively(new File(gsPlatform + "/scala/gs-openspaces-scala.jar"), new File(deployPath, "WEB-INF/lib/gs-openspaces-scala.jar")); } logger.debug(logMessage("Added spring jars to web application")); } catch (IOException e) { // don't copy it } File[] wenInfJars = BootIOUtils.listFiles(webInfLib); ArrayList<String> deleted = new ArrayList<String>(); for (File webInfJarFile : wenInfJars) { boolean delete = false; if (webInfJarFile.getName().startsWith("gs-runtime")) { delete = true; } if (delete) { deleted.add(webInfJarFile.getName()); webInfJarFile.delete(); } } if (!deleted.isEmpty()) { logger.debug(logMessage("Deleted the following jars from the web application: " + deleted)); } } }
From source file:org.springframework.cloud.config.server.JGitEnvironmentRepository.java
private Git copyFromLocalRepository() throws IOException { Git git;/*from w ww. ja va 2 s . com*/ FileSystemUtils.copyRecursively(new UrlResource(uri).getFile(), basedir); git = Git.open(basedir); return git; }