List of usage examples for org.apache.commons.io FileUtils copyFileToDirectory
public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) throws IOException
From source file:com.virtualparadigm.packman.processor.JPackageManagerBU.java
public static boolean createPackage(String packageName, String packageVersion, File packageOutputFile, File oldStateDir, File newStateDir, File licenseFile, File autorunInstallDir, File autorunUninstallDir, boolean developmentMode) { logger.info(//from www .j av a2s .c om "PackageManager::createPackage - creating package: " + packageName + " version: " + packageVersion); boolean status = false; if (packageName != null && packageVersion != null) { File tempDir = new File(TEMP_CREATE_PACKAGE_DIR_NAME); File tempMetadataDir = new File( JPackageManagerBU.TEMP_CREATE_PACKAGE_DIR_NAME + "/" + JPackageManagerBU.METADATA_DIR_NAME); File tempPatchDir = new File( JPackageManagerBU.TEMP_CREATE_PACKAGE_DIR_NAME + "/" + JPackageManagerBU.PATCH_DIR_NAME); File tempPatchFilesDir = new File(JPackageManagerBU.TEMP_CREATE_PACKAGE_DIR_NAME + "/" + JPackageManagerBU.PATCH_DIR_NAME + "/" + JPackageManagerBU.PATCH_FILES_DIR_NAME); File tempAutorunDir = new File( JPackageManagerBU.TEMP_CREATE_PACKAGE_DIR_NAME + "/" + JPackageManagerBU.AUTORUN_DIR_NAME); File tempAutorunInstallDir = new File(JPackageManagerBU.TEMP_CREATE_PACKAGE_DIR_NAME + "/" + JPackageManagerBU.AUTORUN_DIR_NAME + "/" + JPackageManagerBU.INSTALL_DIR_NAME); File tempAutorunUninstallDir = new File(JPackageManagerBU.TEMP_CREATE_PACKAGE_DIR_NAME + "/" + JPackageManagerBU.AUTORUN_DIR_NAME + "/" + JPackageManagerBU.UNINSTALL_DIR_NAME); tempMetadataDir.mkdirs(); tempPatchFilesDir.mkdirs(); tempAutorunInstallDir.mkdirs(); tempAutorunUninstallDir.mkdirs(); try { FileUtils.copyFileToDirectory(licenseFile, tempMetadataDir, true); FileUtils.copyDirectory(autorunInstallDir, tempAutorunInstallDir, true); FileUtils.copyDirectory(autorunUninstallDir, tempAutorunUninstallDir, true); String strPackageProperties = JPackageManagerBU.PACKAGE_NAME_KEY + "=" + packageName + "\n" + JPackageManagerBU.PACKAGE_VERSION_KEY + "=" + packageVersion; FileUtils.writeStringToFile(new File( tempMetadataDir.getAbsolutePath() + "/" + JPackageManagerBU.PACKAGE_PROPERTIES_FILE_NAME), strPackageProperties, "UTF-8"); JPatchManager directoryPatchManager = new JPatchManager(); // directoryPatchManager.makePatch(newStateDir, oldStateDir, new File(tempPatchDir.getAbsolutePath() + "/" + JPackageManagerBU.PATCH_FILE_NAME), tempPatchFilesDir); directoryPatchManager.makePatch(oldStateDir, newStateDir, new File(tempPatchDir.getAbsolutePath()), null); if (packageOutputFile == null) { packageOutputFile = new File(packageName + "-" + packageVersion + ".zip"); } ZipUtils.createZipFile(packageOutputFile.getAbsolutePath(), new File[] { tempAutorunDir, tempMetadataDir, tempPatchDir }, 1024); status = true; } catch (Exception e) { logger.error("", e); // e.printStackTrace(); } if (!developmentMode) { JPackageManagerBU.cleanup(tempDir); } } return status; }
From source file:generadorqr.jifrNuevoQr.java
Boolean CopiaArchivos(String home, String destiny, String[] multimedia, String nombre, Integer indice) { File origen = new File(home); File destino = new File(destiny); try {/* w w w . j a va2s.c o m*/ //Localisa la carpeta de origen y ubica la carpeta d destino File rutaPrincipalImagenes = new File(multimedia[indice]); if (!rutaPrincipalImagenes.exists()) rutaPrincipalImagenes.mkdir(); FileUtils.copyFileToDirectory(origen, destino, false); File nombreOriginal = new File(destiny + "\\" + tempNombreArchivo[indice]); File nombreModificado = new File(destiny + "\\" + nombre); Boolean cambioNombre = nombreOriginal.renameTo(nombreModificado); if (!cambioNombre) { JOptionPane.showMessageDialog(this, "El renombrado no se pudo realizar"); return false; } } catch (Exception e) { } return true; }
From source file:com.virtualparadigm.packman.processor.JPackageManagerOld.java
public static boolean createPackage(String packageName, String packageVersion, File packageOutputFile, File oldStateDir, File newStateDir, File licenseFile, File autorunInstallDir, File autorunUninstallDir, File tempDir, boolean developmentMode) { logger.info(// w w w . ja v a2 s . c o m "PackageManager::createPackage - creating package: " + packageName + " version: " + packageVersion); boolean status = false; if (packageName != null && packageVersion != null) { if (tempDir == null) { tempDir = new File(TEMP_CREATE_PACKAGE_DIR_NAME); } File tempMetadataDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.METADATA_DIR_NAME); File tempPatchDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.PATCH_DIR_NAME); File tempPatchFilesDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.PATCH_DIR_NAME + "/" + JPackageManagerOld.PATCH_FILES_DIR_NAME); File tempAutorunDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.AUTORUN_DIR_NAME); File tempAutorunInstallDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.AUTORUN_DIR_NAME + "/" + JPackageManagerOld.INSTALL_DIR_NAME); File tempAutorunUninstallDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.AUTORUN_DIR_NAME + "/" + JPackageManagerOld.UNINSTALL_DIR_NAME); tempMetadataDir.mkdirs(); tempPatchFilesDir.mkdirs(); tempAutorunInstallDir.mkdirs(); tempAutorunUninstallDir.mkdirs(); try { FileUtils.copyFileToDirectory(licenseFile, tempMetadataDir, true); FileUtils.copyDirectory(autorunInstallDir, tempAutorunInstallDir, true); FileUtils.copyDirectory(autorunUninstallDir, tempAutorunUninstallDir, true); String strPackageProperties = JPackageManagerOld.PACKAGE_NAME_KEY + "=" + packageName + "\n" + JPackageManagerOld.PACKAGE_VERSION_KEY + "=" + packageVersion; FileUtils.writeStringToFile(new File( tempMetadataDir.getAbsolutePath() + "/" + JPackageManagerOld.PACKAGE_PROPERTIES_FILE_NAME), strPackageProperties, "UTF-8"); JPatchManager directoryPatchManager = new JPatchManager(); // directoryPatchManager.makePatch(oldStateDir, newStateDir, new File(tempPatchDir.getAbsolutePath() + "/" + JPackageManager.PATCH_FILE_NAME), tempPatchFilesDir); directoryPatchManager.makePatch(oldStateDir, newStateDir, new File(tempPatchDir.getAbsolutePath()), null); if (packageOutputFile == null) { packageOutputFile = new File(packageName + "-" + packageVersion + ".zip"); } ZipUtils.createZipFile(packageOutputFile.getAbsolutePath(), new File[] { tempAutorunDir, tempMetadataDir, tempPatchDir }, 1024); status = true; } catch (Exception e) { logger.error("", e); } if (!developmentMode) { JPackageManagerOld.cleanup(tempDir); } } return status; }
From source file:com.virtualparadigm.packman.processor.JPackageManager.java
public static boolean createPackage(String packageName, String packageVersion, File packageOutputFile, File oldStateDir, File newStateDir, File licenseFile, File autorunInstallDir, File autorunUninstallDir, File tempDir, boolean developmentMode) { logger.info(/* w w w . ja v a2 s .co m*/ "PackageManager::createPackage - creating package: " + packageName + " version: " + packageVersion); boolean status = false; if (packageName != null && packageVersion != null) { if (tempDir == null) { tempDir = new File(TEMP_CREATE_PACKAGE_DIR_NAME); } File tempMetadataDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManager.METADATA_DIR_NAME); File tempPatchDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManager.PATCH_DIR_NAME); File tempPatchFilesDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManager.PATCH_DIR_NAME + "/" + JPackageManager.PATCH_FILES_DIR_NAME); File tempAutorunDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManager.AUTORUN_DIR_NAME); File tempAutorunInstallDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManager.AUTORUN_DIR_NAME + "/" + JPackageManager.INSTALL_DIR_NAME); File tempAutorunUninstallDir = new File(tempDir.getAbsolutePath() + "/" + JPackageManager.AUTORUN_DIR_NAME + "/" + JPackageManager.UNINSTALL_DIR_NAME); tempMetadataDir.mkdirs(); tempPatchFilesDir.mkdirs(); tempAutorunInstallDir.mkdirs(); tempAutorunUninstallDir.mkdirs(); try { FileUtils.copyFileToDirectory(licenseFile, tempMetadataDir, true); FileUtils.copyDirectory(autorunInstallDir, tempAutorunInstallDir, true); FileUtils.copyDirectory(autorunUninstallDir, tempAutorunUninstallDir, true); String strPackageProperties = JPackageManager.PACKAGE_NAME_KEY + "=" + packageName + "\n" + JPackageManager.PACKAGE_VERSION_KEY + "=" + packageVersion; FileUtils.writeStringToFile(new File( tempMetadataDir.getAbsolutePath() + "/" + JPackageManager.PACKAGE_PROPERTIES_FILE_NAME), strPackageProperties, "UTF-8"); JPatchManager directoryPatchManager = new JPatchManager(); // directoryPatchManager.makePatch(oldStateDir, newStateDir, new File(tempPatchDir.getAbsolutePath() + "/" + JPackageManager.PATCH_FILE_NAME), tempPatchFilesDir); directoryPatchManager.makePatch(oldStateDir, newStateDir, new File(tempPatchDir.getAbsolutePath()), null); if (packageOutputFile == null) { packageOutputFile = new File(packageName + "-" + packageVersion + ".zip"); } ZipUtils.createZipFile(packageOutputFile.getAbsolutePath(), new File[] { tempAutorunDir, tempMetadataDir, tempPatchDir }, 1024); status = true; } catch (Exception e) { logger.error("", e); } if (!developmentMode) { JPackageManager.cleanup(tempDir); } } return status; }
From source file:generadorqr.jifrNuevoQr.java
Boolean CopiaArchivos(String home, String destiny, String nombre, Integer indice) { File origen = new File(home); File destino = new File(destiny); try {//from w w w . j a va 2 s .co m //Localisa la carpeta de origen y ubica la carpeta d destino File rutaPrincipalMultimedia = new File(destiny); if (!rutaPrincipalMultimedia.exists()) rutaPrincipalMultimedia.mkdir(); FileUtils.copyFileToDirectory(origen, destino, false); File nombreOriginal = new File(destiny + "\\" + tempNombreMultimedia[indice]); File nombreModificado = new File(destiny + "\\" + nombre); Boolean cambioNombre = nombreOriginal.renameTo(nombreModificado); if (!cambioNombre) { JOptionPane.showMessageDialog(this, "El renombrado no se pudo realizar"); return false; } } catch (Exception e) { } return true; }
From source file:com.thoughtworks.go.plugin.activation.DefaultGoPluginActivatorIntegrationTest.java
@Test public void shouldNotFailToRegisterOtherClassesIfAClassCannotBeLoadedBecauseOfWrongPath() throws Exception { File bundleWithActivator = createBundleWithActivator(BUNDLE_DIR_WHICH_HAS_PROPER_ACTIVATOR, DummyTestPlugin.class); File sourceClassFile = new File(bundleWithActivator, "com/thoughtworks/go/plugin/activation/test/DummyTestPlugin.class"); File destinationFile = new File(bundleWithActivator, "ABC-DEF/com/thoughtworks/go/plugin/activation/test/"); FileUtils.copyFileToDirectory(sourceClassFile, destinationFile, true); Bundle bundle = installBundleFoundInDirectory(bundleWithActivator); assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); }
From source file:edu.unc.lib.dl.admin.collect.DepositBinCollector.java
/** * Moves a list of files to a destination location after verifying that they were safely copied * * @param targetFiles/* ww w. j a va2 s . c o m*/ * @param destination * @throws IOException */ private void moveFiles(List<File> targetFiles, DepositInfo depositInfo, DepositBinConfiguration config) throws IOException { try { // Copy the specified files into the destination path for (File file : targetFiles) { FileUtils.copyFileToDirectory(file, depositInfo.dataDir, true); } // Verify that the original files all copied over to the destination for (File file : targetFiles) { File destinationFile = new File(depositInfo.dataDir, file.getName()); if (!FileUtils.contentEquals(file, destinationFile)) { throw new IOException("Copied file " + destinationFile.toString() + " did not match the original file " + file.getAbsolutePath()); } } } catch (Exception e) { FileUtils.deleteDirectory(depositInfo.depositDir); throw new IOException("Failed to copy bin files to deposit directory, aborting and cleaning up", e); } // Clean up the original copies of the files for (File file : targetFiles) { boolean success = file.delete(); if (!success) { log.warn("Failed to cleanup file {}", file.getAbsolutePath()); } } }
From source file:com.jivesoftware.os.upena.uba.service.NannyDeployCallable.java
private boolean deploy(String deployablecoordinate, List<RemoteRepository> remoteRepos, RepositorySystem system, RepositorySystemSession session, File dir) { String[] versionParts = deployablecoordinate.trim().split(":"); if (versionParts.length != 4) { System.out.println(//from w w w . ja va 2 s . c om "deployable coordinates must be of the following form: groupId:artifactId:packaging:version"); return false; } String groupId = versionParts[0]; String artifactId = versionParts[1]; String packaging = versionParts[2]; String version = versionParts[3]; Artifact artifact = new DefaultArtifact(groupId, artifactId, packaging, version); ArtifactRequest artifactRequest = new ArtifactRequest(); artifactRequest.setArtifact(artifact); artifactRequest.setRepositories(remoteRepos); ArtifactResult artifactResult; try { System.out.println("------------------------------------------------------------"); System.out.println(" Resolving: " + deployablecoordinate); System.out.println("------------------------------------------------------------"); artifactResult = system.resolveArtifact(session, artifactRequest); artifact = artifactResult.getArtifact(); System.out.println(artifact + " resolved to " + artifact.getFile()); } catch (ArtifactResolutionException x) { deployLog.log("Nanny", "failed to resolve artifact:", x); return false; } try { if (packaging.equals("tar.gz") || packaging.equals("tgz")) { File tarGzip = instancePath.artifactFile("." + packaging); System.out.println("------------------------------------------------------------"); System.out.println(" Upacking:" + tarGzip); System.out.println("------------------------------------------------------------"); FileUtils.copyFile(artifact.getFile(), tarGzip, true); deployLog.log("Nanny", "deployed " + tarGzip, null); if (!explodeArtifact(tarGzip)) { return false; } } artifact = new DefaultArtifact(groupId + ":" + artifactId + ":" + version); artifactRequest = new ArtifactRequest(); artifactRequest.setArtifact(artifact); artifactRequest.setRepositories(remoteRepos); artifactResult = system.resolveArtifact(session, artifactRequest); artifact = artifactResult.getArtifact(); deployLog.log("Nanny", "deployed " + artifact.getFile() + " to " + dir, null); FileUtils.copyFileToDirectory(artifact.getFile(), dir, true); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(artifact, "")); collectRequest.setRepositories(remoteRepos); CollectResult collectResult = system.collectDependencies(session, collectRequest); DeployArtifactDependencies deployArtifactDependencies = new DeployArtifactDependencies(deployLog, system, session, remoteRepos, dir); collectResult.getRoot().accept(deployArtifactDependencies); boolean successfulDeploy = deployArtifactDependencies.successfulDeploy(); deployLog.log("Nanny", "SUCCESS " + successfulDeploy, null); return successfulDeploy; } catch (IOException | ArtifactResolutionException | DependencyCollectionException x) { deployLog.log("Nanny", "failed to deploy artifact:", x); return false; } }
From source file:com.teotigraphix.caustk.sound.SoundSource.java
@Override public File saveSongAs(File file) throws IOException { File song = saveSong(file.getName().replace(".caustic", "")); FileUtils.copyFileToDirectory(song, file.getParentFile(), true); song.delete();//from ww w .jav a 2s .com return file; }
From source file:ctd.services.getCleanData2.java
public String cleanData() { String message = ""; String timestamp = new java.util.Date().getTime() + ""; try {/*ww w.j av a 2 s . co m*/ CleanDataResult result = new CleanDataResult(); String error_message = ""; //get parameters. ResourceBundle res = ResourceBundle.getBundle("settings"); ResourceBundle cdf_list = ResourceBundle.getBundle("cdf"); //Base directory ftp folder: Here the temporary subfolders are found for each set of CEL-files, and the final assaytoken-based folder. String ftp_folder = res.getString("ws.upload_folder"); String rscript_cleandata = res.getString("ws.rscript_cleandata"); String rscript = res.getString("ws.rscript"); //db String db_username = res.getString("db.username"); String db_password = res.getString("db.password"); String db_database = res.getString("db.database"); //retrieve the information on the assignment from the database SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session = sessionFactory.openSession(); Transaction tr = session.beginTransaction(); Query q = session.createQuery( "from Ticket where password='" + getPassword() + "' AND ctd_REF='" + getCTD_REF() + "'"); Ticket ticket = null; String closed = ""; if (q.list().size() != 0) { ticket = (Ticket) q.list().get(0); closed = ticket.getClosed(); } if (ticket == null) { error_message = "Ticket password and CTD_REF don't match."; } if (closed.equals("yes")) { error_message = "Ticket is already used for normalization of these CEL-files."; ticket = null; } if (ticket != null) { //get the folder String folder = ticket.getFolder(); String zip_folder = ftp_folder + folder; //get contents File dir = new File(zip_folder); //find the zip file. File[] files = dir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile(); } }); String cel_zip_file = ""; String zip_file = ""; String gct_file = ""; for (int i = 0; i < files.length; i++) { String file = files[i].getName(); if (file.contains("zip")) { // Add the timestamp to the zip files[i].renameTo(new File(zip_folder + "/" + timestamp + "_zip.zip")); file = timestamp + "_zip.zip"; cel_zip_file = file; zip_file = zip_folder + "/" + cel_zip_file; gct_file = zip_folder + "/" + timestamp + "_gctfile"; } } Process p3 = Runtime.getRuntime().exec("chmod 777 " + zip_file); ////////////////////////////////////////////////////////////////// //Do a system call to normalize. R. (zip_folder zip_file gct_file rscript) String args = rscript + " --verbose --vanilla " + rscript_cleandata + " -i" + zip_file + " -o" + gct_file + " -w" + zip_folder; Logger.getLogger(getTicket.class.getName()).log(Level.INFO, timestamp + ": Running: " + args); Process p = Runtime.getRuntime().exec(args); // Check if CEL files are unzipped allready // This is done by checking every 5 seconds for the existence of a .chip file // This is a bad way of doing this, in future versions of CTD // the output of the R scripts should be parsed boolean do_loop = true; while (do_loop) { File dir2 = new File(zip_folder); String[] files2 = dir2.list(); //Check if CEL files are allready there for (int i = 0; i < files2.length; i++) { String file = files2[i]; if (file.endsWith("chip")) { do_loop = false; try { Thread.sleep(5000); } catch (InterruptedException ex) { Logger.getLogger(getCleanData.class.getName()).log(Level.SEVERE, null, timestamp + ": " + ex); } } } } Logger.getLogger(getTicket.class.getName()).log(Level.INFO, timestamp + ": rscript has finished."); File dir2 = new File(zip_folder); String[] files2 = dir2.list(); String chip_file = ""; String chip_file_db = ""; ArrayList<String> unziped_files = new ArrayList<String>(); for (int i = 0; i < files2.length; i++) { String file = files2[i]; if (file.endsWith("CEL")) { unziped_files.add(file); } if (file.endsWith("chip")) { chip_file = file; chip_file_db = chip_file.split("_CDF_")[1]; File fileFile = new File(chip_file); fileFile.renameTo(new File(zip_folder + "/" + chip_file_db)); //Making the file correspond to the database entry. Duplicates can be safely overwritten, and will be. } } //Check if all CEL files are derived from the same chip. //This is essential for normalization. //initiate check hashmap. This map contains all the unique chip definition file names. There should be only one per analysis. ArrayList<StudySampleAssay> map = new ArrayList<StudySampleAssay>(); for (int i = 0; i < unziped_files.size(); i++) { String cel_file = unziped_files.get(i); StudySampleAssay ssa = new StudySampleAssay(); // Open the file that is the first // command line parameter //String cel_file_path = zip_folder + "/" + cel_file; String name = cel_file; ssa.setNameRawfile(name); ssa.setXREF(getCTD_REF()); map.add(ssa); } ticket.getStudySampleAssaies().addAll(map); session.saveOrUpdate(ticket); session.persist(ticket); tr.commit(); session.close(); //Storage chip definition file (CDF), creation gct file and database storage. SessionFactory sessionFactory1 = new Configuration().configure().buildSessionFactory(); Session session1 = sessionFactory1.openSession(); //check if cdf (chip definition file) is allready stored, if not, store it. List<ChipAnnotation> chip_annotation = null; Query q2 = session1.createQuery("from Chip Where Name='" + chip_file_db + "'"); if (q2.uniqueResult() != null) { Chip chip = (Chip) q2.list().get(0); chip_annotation = chip.getChipAnnotation(); } if (q2.uniqueResult() == null) { //Add this chip and its annotation Chip chip_new = new Chip(); chip_new.setName(chip_file_db); //read chip file String chip_file_path = zip_folder + "/" + chip_file; chip_annotation = readChip(chip_file_path); //Store the whole chip_new.getChipAnnotation().addAll(chip_annotation); Transaction tr1 = session1.beginTransaction(); session1.save(chip_new); session1.persist(chip_new); tr1.commit(); session1.close(); } //create the temp file for storage of the data_insert file. String data_file = zip_folder + "/expression.txt"; FileOutputStream out = null; PrintStream pr = null; out = new FileOutputStream(data_file); pr = new PrintStream(out); //create array data input file for the database table, find correct foreign keys. //get the study_sample_assay id and the probeset ids. SessionFactory sessionFactory2 = new Configuration().configure().buildSessionFactory(); Session session2 = sessionFactory2.openSession(); //Get the cip_annotation_id Query q3 = session2.createQuery("from Chip Where Name='" + chip_file_db + "'"); Chip chip = (Chip) q3.list().get(0); chip_annotation = chip.getChipAnnotation(); Iterator it2 = chip_annotation.iterator(); //for speed, put the chip annotation id in a hashmap HashMap<String, String> chip_annotation_ids = new HashMap<String, String>(); while (it2.hasNext()) { ChipAnnotation ca = (ChipAnnotation) it2.next(); String id = ca.getId().toString(); String ps = ca.getProbeset(); chip_annotation_ids.put(ps, id); } //Create the .gct-files try { Query qt = session2.createQuery("from Ticket where password='" + getPassword() + "' AND ctd_REF='" + getCTD_REF() + "'"); ticket = null; if (qt.list().size() != 0) { ticket = (Ticket) qt.list().get(0); } Iterator it3 = ticket.getStudySampleAssaies().iterator(); while (it3.hasNext()) { StudySampleAssay ssa = (StudySampleAssay) it3.next(); String name_raw_file = ssa.getNameRawfile(); String sampleToken = getSampletokens().get(name_raw_file); String ssa_id = ssa.getId().toString(); error_message = error_message + name_raw_file; String gct_file_generated = gct_file + ".gct"; ArrayList<Double> values = writeFile(pr, chip_annotation_ids, ssa_id, gct_file_generated, name_raw_file.replaceAll(".CEL", "")); Statistics stat = new Statistics(); stat.setData(values); Double average = stat.getAverage(); Double std = stat.getSTD(); ssa.setXREF(getCTD_REF()); ssa.setAverage(average); ssa.setStudyToken(getStudytoken()); ssa.setSampleToken(sampleToken); ssa.setStd(std); } } catch (IOException e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2: " + e.getMessage() + " " + e.getLocalizedMessage()); } pr.close(); out.close(); //update ticket Transaction tr2 = session2.beginTransaction(); session2.update(ticket); session2.persist(ticket); tr2.commit(); session2.close(); //import the data into the database String u = "--user=" + db_username; String passw = "--password=" + db_password; String[] commands = new String[] { "mysqlimport", u, passw, "--local", db_database, data_file }; Process p4 = Runtime.getRuntime().exec(commands); message = message + " RMA and GRSN on the CEL-files is done, data is stored."; //close the ticket when finished, normalization can only be performed once by the client. CloseTicket(); //Remove zip and data file (expression.txt) File fileFolderOld = new File(zip_folder); File fileFolderDest = new File(res.getString("ws.upload_folder") + getCTD_REF()); File[] listOfFiles = fileFolderOld.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].getPath().toLowerCase().endsWith(".zip") || listOfFiles[i].getPath().toLowerCase().endsWith("expression.txt")) { try { listOfFiles[i].delete(); } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2 (try to delete): " + e.toString()); } } else { try { FileUtils.copyFileToDirectory(listOfFiles[i], fileFolderDest, false); listOfFiles[i].delete(); } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2 (try to copy): " + e.toString()); } } } // Remove temporary folder try { fileFolderOld.delete(); } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2: " + e.toString()); } // -------------------------------------------- // This piece of code is added in order to cleanup all the files // of aborted upload procedures. It checks for these old folders // (more than a day old and a temporaty name (which is just a number // from 1 upwards. It is assumed that a temporary folder has a // name shorter than 10 chars) and removes these files and folders File folderData = new File(res.getString("ws.upload_folder")); long lngTimestamp = new java.util.Date().getTime(); listOfFiles = folderData.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].lastModified() < (lngTimestamp - 10000) && listOfFiles[i].getName().length() < 10) { // This folder is more than a day old // We know it is a temporary folder because the name is less than 10 chars long File[] lstDelete = listOfFiles[i].listFiles(); for (int j = 0; j < lstDelete.length; j++) { // Delete all content of the old folder lstDelete[j].delete(); } // Delete the old folder if (!listOfFiles[i].delete()) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, "delSample(): Folder deletion failed: " + listOfFiles[i].getName()); } } } // -------------------------------------------- } // set the messages of the response result.setErrorMessage(error_message); result.setMessage(message); // Use SKARINGA in order to create the JSON response ObjectTransformer trans = null; try { trans = ObjectTransformerFactory.getInstance().getImplementation(); message = trans.serializeToString(result); } catch (NoImplementationException ex) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, "SKARINGA ERROR IN getCleanData2: " + ex.getLocalizedMessage()); } } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2: " + e.toString()); } return message; }