List of usage examples for org.apache.commons.io FileUtils moveFileToDirectory
public static void moveFileToDirectory(File srcFile, File destDir, boolean createDestDir) throws IOException
From source file:com.dominion.salud.nomenclator.negocio.service.impl.tools.BuzonSucesosServiceImpl.java
@Override public void upload(MultipartFile file) { logger.info("INICIANDO la carga de la base de datos de AEMPS"); BuzonSucesos buzonSucesos = null;//from w w w.j a va2 s . co m File zip = null; File dest = null; try { logger.debug(" Procesando el fichero: " + file.getOriginalFilename()); zip = new File(NOMENCLATORConstantes._TEMP + file.getOriginalFilename()); file.transferTo(zip); dest = new File(NOMENCLATORConstantes._TEMP); ZipUtil.unZip(zip, dest); //DICCIONARIO_ATC try { logger.debug(" Iniciando la carga de " + DICCIONARIO_ATC); atcService.load( new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_ATC)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_ATC + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_ATC); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_ATC + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_DCP try { logger.debug(" Iniciando la carga de " + DICCIONARIO_DCP); dcpService.load( new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_DCP)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_DCP + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_DCP); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_DCP + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_DCPF try { logger.debug(" Iniciando la carga de " + DICCIONARIO_DCPF); dcpfService.load( new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_DCPF)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_DCPF + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_DCPF); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_DCPF + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_DCSA try { logger.debug(" Iniciando la carga de " + DICCIONARIO_DCSA); dcsaService.load( new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_DCSA)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_DCSA + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_DCSA); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_DCSA + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_ENVASES try { logger.debug(" Iniciando la carga de " + DICCIONARIO_ENVASES); envasesService.load(new File( dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_ENVASES)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_ENVASES + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_ENVASES); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_ENVASES + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_EXCIPIENTES_DECL_OBLIGATORIA try { logger.debug(" Iniciando la carga de " + DICCIONARIO_EXCIPIENTES_DECL_OBLIGATORIA); excipientesService.load(new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_EXCIPIENTES_DECL_OBLIGATORIA)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_EXCIPIENTES_DECL_OBLIGATORIA + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_EXCIPIENTES_DECL_OBLIGATORIA); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje( "No se ha podido cargar " + DICCIONARIO_EXCIPIENTES_DECL_OBLIGATORIA + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_FORMA_FARMACEUTICA_SIMPLIFICADAS try { logger.debug(" Iniciando la carga de " + DICCIONARIO_FORMA_FARMACEUTICA_SIMPLIFICADAS); formasFarSimpService.load(new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_FORMA_FARMACEUTICA_SIMPLIFICADAS)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_FORMA_FARMACEUTICA_SIMPLIFICADAS + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_FORMA_FARMACEUTICA_SIMPLIFICADAS); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_FORMA_FARMACEUTICA_SIMPLIFICADAS + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_FORMA_FARMACEUTICA try { logger.debug(" Iniciando la carga de " + DICCIONARIO_FORMA_FARMACEUTICA); formasFarService.load(new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_FORMA_FARMACEUTICA)); } catch (Exception e) { logger.warn( " No se ha podido cargar " + DICCIONARIO_FORMA_FARMACEUTICA + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_FORMA_FARMACEUTICA); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje( "No se ha podido cargar " + DICCIONARIO_FORMA_FARMACEUTICA + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_LABORATORIOS try { logger.debug(" Iniciando la carga de " + DICCIONARIO_LABORATORIOS); laboratoriosService.load(new File( dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_LABORATORIOS)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_LABORATORIOS + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_LABORATORIOS); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_LABORATORIOS + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_PRINCIPIOS_ACTIVOS try { logger.debug(" Iniciando la carga de " + DICCIONARIO_PRINCIPIOS_ACTIVOS); principiosActivosService.load(new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_PRINCIPIOS_ACTIVOS)); } catch (Exception e) { logger.warn( " No se ha podido cargar " + DICCIONARIO_PRINCIPIOS_ACTIVOS + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_PRINCIPIOS_ACTIVOS); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje( "No se ha podido cargar " + DICCIONARIO_PRINCIPIOS_ACTIVOS + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_SITUACION_REGISTRO try { logger.debug(" Iniciando la carga de " + DICCIONARIO_SITUACION_REGISTRO); situacionRegistroService.load(new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_SITUACION_REGISTRO)); } catch (Exception e) { logger.warn( " No se ha podido cargar " + DICCIONARIO_SITUACION_REGISTRO + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_SITUACION_REGISTRO); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje( "No se ha podido cargar " + DICCIONARIO_SITUACION_REGISTRO + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_UNIDAD_CONTENIDO try { logger.debug(" Iniciando la carga de " + DICCIONARIO_UNIDAD_CONTENIDO); unidadesContenidoService.load(new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_UNIDAD_CONTENIDO)); } catch (Exception e) { logger.warn( " No se ha podido cargar " + DICCIONARIO_UNIDAD_CONTENIDO + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_UNIDAD_CONTENIDO); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos .setMensaje("No se ha podido cargar " + DICCIONARIO_UNIDAD_CONTENIDO + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_UNIDAD_DOSIS try { logger.debug(" Iniciando la carga de " + DICCIONARIO_UNIDAD_DOSIS); unidadesDosisService.load(new File( dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_UNIDAD_DOSIS)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_UNIDAD_DOSIS + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_UNIDAD_DOSIS); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + DICCIONARIO_UNIDAD_DOSIS + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_VIAS_ADMINISTRACION try { logger.debug(" Iniciando la carga de " + DICCIONARIO_VIAS_ADMINISTRACION); viasAdminService.load(new File(dest.getAbsolutePath() + System.getProperty("file.separator") + DICCIONARIO_VIAS_ADMINISTRACION)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + DICCIONARIO_VIAS_ADMINISTRACION + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_VIAS_ADMINISTRACION); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje( "No se ha podido cargar " + DICCIONARIO_VIAS_ADMINISTRACION + ": " + e.toString()); save(buzonSucesos); } //DICCIONARIO_MEDICAMENTOS try { logger.debug(" Iniciando la carga de " + PRESCRIPCION); medicamentosService.load( new File(dest.getAbsolutePath() + System.getProperty("file.separator") + PRESCRIPCION)); } catch (Exception e) { logger.warn(" No se ha podido cargar " + PRESCRIPCION + ": " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.DICCIONARIO_MEDICAMENTOS); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos.setMensaje("No se ha podido cargar " + PRESCRIPCION + ": " + e.toString()); save(buzonSucesos); } logger.debug(" Fichero: " + file.getOriginalFilename() + " procesado correctamente"); } catch (Exception e) { logger.error("Se han producido errores al cargar la base de datos de AEMPS: " + e.toString()); buzonSucesos = new BuzonSucesos(); buzonSucesos.setCodProceso(BuzonSucesos.AEMPS); buzonSucesos.setFecIni(new Date()); buzonSucesos.setFecFin(new Date()); buzonSucesos .setMensaje("Se han producido errores al cargar la base de datos de AEMPS: " + e.toString()); save(buzonSucesos); } finally { if (zip != null && zip.isFile()) { logger.debug(" Moviendo el fichero: " + zip.getName() + " al directorio: " + NOMENCLATORConstantes._TEMP + "old" + System.getProperty("file.separator")); try { FileUtils.moveFileToDirectory(zip, new File(NOMENCLATORConstantes._TEMP + "old" + System.getProperty("file.separator")), true); } catch (Exception e) { logger.warn(" No se ha podido mover el fichero al directorio OLD: " + e.toString()); } } if (dest != null && dest.isDirectory()) { logger.debug(" Eliminando ficheros temporales del directorio: " + dest.getAbsolutePath()); File[] ficheros = dest.listFiles(); for (int i = 0; i < ficheros.length; i++) { if (ficheros[i] != null && ficheros[i].isFile()) { ficheros[i].delete(); } } } } logger.info("FINALIZANDO la carga de la base de datos de AEMPS"); }
From source file:com.silverpeas.templatedesigner.control.TemplateDesignerSessionController.java
private void saveLayer(String filePath, String dir) throws PublicationTemplateException { try {/* w ww . j a v a2 s .c o m*/ File file = new File(dir, FilenameUtils.getName(filePath)); if (file.exists()) { file.delete(); } FileUtils.moveFileToDirectory(new File(filePath), new File(dir), false); } catch (IOException ioe) { throw new PublicationTemplateException("PublicationTemplateImpl.saveLayer()", "form.EX_ERR_CANT_SAVE_LAYER", "Publication Template FileName : " + filePath, ioe); } }
From source file:kr.co.leem.system.FileSystemUtils.java
/** * ? ??.//from w ww . ja v a 2 s . c o m * * @param srcFile ? ? . * @param destFile ?? ? . * @param createDestDir ? . * @see FileUtils#moveFileToDirectory(File, File, boolean) */ public static void moveFileToDirectory(final String srcFile, final String destDir, final boolean createDestDir) { processIO(new IOCallback<Object>() { public Object doInProcessIO() throws IOException, NullPointerException { FileUtils.moveFileToDirectory(new File(srcFile), new File(destDir), createDestDir); return null; } }); }
From source file:it.drwolf.ridire.session.async.Mapper.java
private void moveResourceInAttic(CrawledResource cr, File f) throws IOException { File atticDir = new File( FilenameUtils.getFullPath(f.getCanonicalPath().replaceAll("__\\d+", "")) + Mapper.ATTICDIR); File resourceDir = new File(FilenameUtils.getFullPath(f.getCanonicalPath().replaceAll("__\\d+", "")) + JobMapperMonitor.RESOURCESDIR); File toBeMoved = new File(resourceDir, cr.getDigest() + ".gz"); FileUtils.moveFileToDirectory(toBeMoved, atticDir, true); toBeMoved = new File(resourceDir, cr.getDigest() + ".txt"); if (toBeMoved != null) { FileUtils.moveFileToDirectory(toBeMoved, atticDir, true); }/*w w w . j av a2s. c om*/ // System.out.println("Resource moved in attic: " + cr.getUrl()); }
From source file:com.daphne.es.maintain.editor.web.controller.OnlineEditorController.java
@RequestMapping("move") public String move(@RequestParam(value = "descPath") String descPath, @RequestParam(value = "paths") String[] paths, @RequestParam(value = "conflict") String conflict, RedirectAttributes redirectAttributes) throws IOException { String rootPath = sc.getRealPath(ROOT_DIR); descPath = URLDecoder.decode(descPath, Constants.ENCODING); for (int i = 0, l = paths.length; i < l; i++) { String path = paths[i];/*w w w . j a va 2s . c o m*/ path = URLDecoder.decode(path, Constants.ENCODING); paths[i] = (rootPath + File.separator + path).replace("\\", "/"); } try { File descPathFile = new File(rootPath + File.separator + descPath); for (String path : paths) { File sourceFile = new File(path); File descFile = new File(descPathFile, sourceFile.getName()); if (descFile.exists() && "ignore".equals(conflict)) { continue; } FileUtils.deleteQuietly(descFile); if (sourceFile.isDirectory()) { FileUtils.moveDirectoryToDirectory(sourceFile, descPathFile, true); } else { FileUtils.moveFileToDirectory(sourceFile, descPathFile, true); } } redirectAttributes.addFlashAttribute(Constants.MESSAGE, "??"); } catch (Exception e) { redirectAttributes.addFlashAttribute(Constants.ERROR, e.getMessage()); } redirectAttributes.addAttribute("path", URLEncoder.encode(descPath, Constants.ENCODING)); return redirectToUrl(viewName("list")); }
From source file:de.uzk.hki.da.sb.SIPFactory.java
/** * Moves the given archived SIP file to the collection folder * /*from w w w . j av a2 s . com*/ * @param jobId * The job ID * @param archiveFile * The SIP file * @return The method result as a Feedback enum */ private Feedback moveSipToCollectionFolder(int jobId, File archiveFile) { try { FileUtils.moveFileToDirectory(archiveFile, new File(collectionFolder, "data"), false); } catch (IOException e) { logger.error("Failed to move file " + archiveFile.getAbsolutePath() + " to folder " + collectionFolder.getAbsolutePath(), e); return Feedback.MOVE_TO_COLLECTION_FOLDER_ERROR; } return Feedback.SUCCESS; }
From source file:javaapplication3.ZCorpDialog.java
private void submitBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitBtnActionPerformed if (validateForm()) { Integer day = Integer.parseInt(days.getSelectedItem().toString()); Integer hr = Integer.parseInt(hours.getSelectedItem().toString()); Integer min = Integer.parseInt(minutes.getSelectedItem().toString()); buildTime = day + ":" + hr + ":" + min; String buildPath = BPath.getText(); buildName = new File(buildPath).getName(); buildPath = buildPath.replace("\\", "\\\\"); //File file = new File(buildPath); //buildName = file.getName(); modelAmount = Integer.parseInt(numOfModels.getText()); comments = comment.getText();/*from w ww . j av a 2s. c om*/ //hideErrorFields(); //this is stuff about price ResultSet res = ZCorpMain.dba.searchPrinterSettings("zcorp"); try { if (res.next()) { monoPrice = Double.parseDouble(res.getString("materialCostPerUnit")); yellowPrice = Double.parseDouble(res.getString("materialCostPerUnit2")); magentaPrice = Double.parseDouble(res.getString("materialCostPerUnit3")); cyanPrice = Double.parseDouble(res.getString("materialCostPerUnit4")); } } catch (SQLException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } //now dealing with buildCost try { buildCost = Calculations.ZcorpCost(cubicInches); } catch (Exception e) { errFree = false; } //Checks if there were errors if (errFree) { try { //This is where we would add the call to the method that udpates things in completed Jobs //Updates project cost in pending ZCorpMain.calc.BuildtoProjectCost(buildName, "Zcorp", buildCost); ResultSet res2 = ZCorpMain.dba.searchPendingByBuildName(buildName); ArrayList list = new ArrayList(); try { while (res2.next()) { list.add(res2.getString("buildName")); } } catch (SQLException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } Iterator itr = list.iterator(); //Date date = Calendar.getInstance().getTime(); //SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); while (itr.hasNext()) { ResultSet res3 = ZCorpMain.dba.searchPendingByBuildName(itr.next().toString()); if (res3.next()) { System.out.println("Now doing this shiz"); String ID = res3.getString("idJobs"); System.out.println(ID); String Printer = res3.getString("printer"); String firstName = res3.getString("firstName"); String lastName = res3.getString("lastName"); String course = res3.getString("course"); String section = res3.getString("section"); String fileName = res3.getString("fileName"); System.out.println(fileName); File newDir = new File(ZCorpMain.getInstance().getZcorpPrinted()); FileUtils.moveFileToDirectory( new File(ZCorpMain.getInstance().getZcorpToPrint() + fileName), newDir, true); String filePath = newDir.getAbsolutePath().replace("\\", "\\\\"); //Needs to be changed String dateStarted = res3.getString("dateStarted"); String Status = "completed"; String Email = res3.getString("Email"); String Comment = res3.getString("comment"); String nameOfBuild = res3.getString("buildName"); double volume = Double.parseDouble(res3.getString("volume")); double cost = Double.parseDouble(res3.getString("cost")); ZCorpMain.dba.insertIntoCompletedJobs(ID, Printer, firstName, lastName, course, section, fileName, filePath, dateStarted, Status, Email, Comment, nameOfBuild, volume, cost); ZCorpMain.dba.delete("pendingjobs", ID); //In Open Builds, it should go back and change status to complete so it doesn't show up again if submitted } } // if there is no matching record ZCorpMain.dba.insertIntoZcorp(buildName, monoBinder, yellowBinder, magentaBuilder, cyanBuilder, cubicInches, modelAmount, comments, buildCost, "complete"); } catch (IOException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } else { System.out.println("ERRORS"); JOptionPane.showMessageDialog(null, "There were errors that prevented your build information from being submitted to the database. \nPlease consult the red error text on screen."); } } }
From source file:javaapplication3.ObjetDialog.java
private void submitBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitBtnActionPerformed if (validateForm()) { Integer day = Integer.parseInt(days.getSelectedItem().toString()); Integer hr = Integer.parseInt(hours.getSelectedItem().toString()); Integer min = Integer.parseInt(minutes.getSelectedItem().toString()); buildTime = day + ":" + hr + ":" + min; String buildPath = BPath.getText(); buildName = new File(buildPath).getName(); buildPath = buildPath.replace("\\", "\\\\"); //File file = new File(buildPath); //buildName = file.getName(); modelAmount = Integer.parseInt(numOfModels.getText()); String comments = comment.getText(); //hideErrorFields(); //now dealing with buildCost try {//from w w w. j av a 2 s .c om buildCost = (double) Calculations.ObjetCost(BuildConsumed, material.getSelectedItem().toString()); } catch (Exception e) { errFree = true; e.printStackTrace(); } //Checks if there were errors if (errFree) { try { //This is where we would add the call to the method that udpates things in completed Jobs //Updates project cost in pending ObjetMain.calc.BuildtoProjectCost(buildName, "Objet", buildCost); ResultSet res2 = ObjetMain.dba.searchPendingByBuildName(buildName); ArrayList list = new ArrayList(); try { while (res2.next()) { list.add(res2.getString("buildName")); } } catch (SQLException ex) { } Iterator itr = list.iterator(); //Date date = Calendar.getInstance().getTime(); //SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); while (itr.hasNext()) { ResultSet res3 = ObjetMain.dba.searchPendingByBuildName(itr.next().toString()); if (res3.next()) { System.out.println("Now doing this shiz"); String ID = res3.getString("idJobs"); System.out.println(ID); String Printer = res3.getString("printer"); String firstName = res3.getString("firstName"); String lastName = res3.getString("lastName"); String course = res3.getString("course"); String section = res3.getString("section"); String fileName = res3.getString("fileName"); System.out.println(fileName); File newDir = new File(ObjetMain.getInstance().getObjetPrinted()); FileUtils.moveFileToDirectory( new File(ObjetMain.getInstance().getObjetToPrint() + fileName), newDir, true); String filePath = newDir.getAbsolutePath().replace("\\", "\\\\"); //Needs to be changed String dateStarted = res3.getString("dateStarted"); String Status = "completed"; String Email = res3.getString("Email"); String Comment = res3.getString("comment"); String nameOfBuild = res3.getString("buildName"); double volume = Double.parseDouble(res3.getString("volume")); double cost = Double.parseDouble(res3.getString("cost")); ObjetMain.dba.insertIntoCompletedJobs(ID, Printer, firstName, lastName, course, section, fileName, filePath, dateStarted, Status, Email, Comment, nameOfBuild, volume, cost); ObjetMain.dba.delete("pendingjobs", ID); //In Open Builds, it should go back and change status to complete so it doesn't show up again if submitted } } // if there is no matching record ObjetMain.dba.insertIntoObjet(buildName, BuildConsumed, SupportConsumed, modelAmount, materialType, Resolution, comments, buildCost); } catch (IOException ex) { Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } else { System.out.println("ERRORS"); JOptionPane.showMessageDialog(null, "There were errors that prevented your build information from being submitted to the database. \nPlease consult the red error text on screen."); } } }
From source file:de.quadrillenschule.azocamsyncd.astromode.gui.AstroModeJPanel.java
@Override public void receiveNotification(FTPConnectionStatus status, String message, int progress) { if (status == FTPConnectionStatus.NEW_LOCAL_FILE) { updateTablejButtonActionPerformed(null); PhotoSerie myPS = null;/* w ww . ja v a 2 s . c o m*/ for (PhotoSerie p : jobList) { if (p.getTriggered() > p.getReceived()) { myPS = p; break; } } if (myPS == null) { return; } File receivedFile = new File(message); File targetFolder = new File( gp.getProperty(CamSyncProperties.LAST_ASTRO_FOLDER) + System.getProperty("file.separator") + myPS.getProject() + System.getProperty("file.separator") + myPS.getSeriesName()); createFolderAndParents(targetFolder); boolean moved = false; int fileexistscounter = 0; while (!moved) { try { try { if (Boolean.parseBoolean(gp.getProperty(CamSyncProperties.ASTRO_MOVE_FILES))) { FileUtils.moveFileToDirectory(receivedFile, targetFolder, true); } moved = true; } catch (FileExistsException fee) { fileexistscounter++; int extInedx = receivedFile.getAbsolutePath().lastIndexOf("."); String newFileName = receivedFile.getAbsolutePath().substring(0, extInedx) + "_" + fileexistscounter + receivedFile.getAbsolutePath().substring(extInedx); receivedFile.renameTo(new File(newFileName)); receivedFile = new File(newFileName); } } catch (IOException ex) { Logger.getLogger(AstroModeJPanel.class.getName()).log(Level.SEVERE, null, ex); } } if (message.toUpperCase().endsWith(".NEF")) { myPS.setReceived(myPS.getReceived() + 1); SmartPhoneWrapper.SmartPhoneStatus smartPhoneStatus; do { try { smartPhoneStatus = SmartPhoneWrapper.update(myPS); } catch (IOException ex) { Logger.getLogger(AstroModeJPanel.class.getName()).log(Level.SEVERE, null, ex); smartPhoneStatus = SmartPhoneWrapper.SmartPhoneStatus.ERROR; SmartPhoneWrapper.checkConnection(); } } while (smartPhoneStatus != SmartPhoneWrapper.SmartPhoneStatus.CONNECTED); } finalizeCompletelyFinishedJobs(); gp.saveStoredAstroJobList(jobList); updateTablejButtonActionPerformed(null); } }
From source file:it.geosolutions.geobatch.imagemosaic.ImageMosaicUpdater.java
/** * Method to backup granules that have been removed from the index. * //from ww w .j a v a 2 s . c o m * <P> * The provided backup dire must exist and be writable for the process. * * @param filesToBackup {@link List} of files to backup, that is move to the backup directory * @param backUpDirectory target directory for the process * @return <code>false</code> in case we manage to move the files, <code>false</code> otherwise. */ static boolean backUpGranulesFiles(final List<File> filesToBackup, final File backUpDirectory) { //checks on dir if (backUpDirectory == null) { throw new IllegalArgumentException("Provided null back up directory"); } if (!backUpDirectory.exists() || !backUpDirectory.isDirectory() || !backUpDirectory.canWrite()) { if (LOGGER.isErrorEnabled()) { LOGGER.error("Provided directory does not exist or it is not writable"); } return false; } if (filesToBackup == null || filesToBackup.size() == 0) { if (LOGGER.isInfoEnabled()) { LOGGER.info("Provided list of files to backup is empty"); } return true; } // now the magic boolean retValue = true; for (File granule : filesToBackup) { // move try { FileUtils.moveFileToDirectory(granule, backUpDirectory, false); } catch (IOException e) { if (LOGGER.isInfoEnabled()) { LOGGER.info(e.getLocalizedMessage(), e); } // if we fail we try to remove the afterwards retValue = false; } } return retValue; }