List of usage examples for org.springframework.web.multipart MultipartFile transferTo
default void transferTo(Path dest) throws IOException, IllegalStateException
From source file:com.github.cherimojava.orchidae.controller.PictureController.java
/** * uploads multiple files into the system for the current user * /*from ww w .j a v a 2 s. c o m*/ * @param request * request with pictures to store * @return {@link org.springframework.http.HttpStatus#CREATED} if the upload was successful or * {@link org.springframework.http.HttpStatus#OK} if some of the pictures couldn't be uploaded together with * information which pictures couldn't be uploaded * @since 1.0.0 */ @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity<String> handleFileUpload(MultipartHttpServletRequest request) { List<String> badFiles = Lists.newArrayList(); User user = userUtil .getUser((String) SecurityContextHolder.getContext().getAuthentication().getPrincipal()); for (Iterator<String> it = request.getFileNames(); it.hasNext();) { MultipartFile file = request.getFile(it.next()); // Create uuid and Picture entity Picture picture = factory.create(Picture.class); picture.setUser(user); picture.setTitle(StringUtils.split(file.getOriginalFilename(), ".")[0]); picture.setId(generateId()); picture.setOriginalName(file.getOriginalFilename()); picture.setUploadDate(DateTime.now()); String type = StringUtils.substringAfterLast(file.getOriginalFilename(), "."); try { File storedPicture = fileUtil.getFileHandle(picture.getId()); // save picture file.transferTo(storedPicture); // read some some properties from it BufferedImage image = ImageIO.read(storedPicture); picture.setHeight(image.getHeight()); picture.setWidth(image.getWidth()); picture.setAccess(Access.PRIVATE);// TODO for now only private access createSmall(picture.getId(), image, type); LOG.info("Uploaded {} and assigned id {}", file.getOriginalFilename(), picture.getId()); checkBatch(picture, request); picture.save(); } catch (Exception e) { LOG.warn("failed to store picture", e); badFiles.add(file.getOriginalFilename()); } } if (badFiles.isEmpty()) { return new ResponseEntity<>("You successfully uploaded!", HttpStatus.CREATED); } else { return new ResponseEntity<>( "Could not upload all files. Failed to upload: " + Joiner.on(",").join(badFiles), HttpStatus.OK); } }
From source file:com.test.mvc.FileUploadController.java
@RequestMapping(value = "/generateOutput", method = RequestMethod.POST) public String generateOutput(@RequestParam("file") MultipartFile file, ModelMap model) { MonkParser monkParser = new MonkParser(); MasterTemplateUtil masterTemplate = new MasterTemplateUtil(); masterTemplate.buildMasterForAllSegement(); masterTemplate.buildMSHSegment();/*from w ww .j a v a 2s . c om*/ masterTemplate.buildEVNSegment(); masterTemplate.buildPIDSegment(); masterTemplate.buildPV1Segment(); masterTemplate.buildPV2Segment(); masterTemplate.buildDG1Segment(); masterTemplate.buildIN1Segment(); masterTemplate.buildNTESegment(); masterTemplate.buildOBRSegment(); masterTemplate.buildORCSegment(); masterTemplate.buildOBXSegment(); String fileName = file.getOriginalFilename(); String filePath = System.getProperty("java.io.tmpdir") + "\\" + fileName; try { file.transferTo(new File(filePath)); } catch (IOException | IllegalStateException ex) { Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex); } monkParser.setFilePath(filePath); String resultPath = monkParser.getResultPath(); TemplateGenerator templateGenerator = new TemplateGenerator(resultPath); try { monkParser.readFile(); monkParser.constructFinalLogic(masterTemplate); templateGenerator.generateTemplateWithHL7Standards(masterTemplate); } catch (FileNotFoundException ex) { System.out.println("Was Not able to find file: " + ex); } catch (IOException ex) { System.out.println("Reading File has some difficulties: " + ex); } model.addAttribute("fileName", "Legacy_" + fileName.split("\\.")[0] + "_TR"); model.addAttribute("resultPath", templateGenerator.getDestinationFilePath()); model.addAttribute("contentType", file.getContentType()); return "generateOutput"; }
From source file:it.geosolutions.opensdi.operations.FileBrowserOperationController.java
/** * Shows the list of files inside the selected folder after a file upload * /*from w ww . ja v a 2s. c o m*/ * @param model * @return */ // @RequestMapping(value = "/files", method = RequestMethod.POST) public String saveFileAndList(@ModelAttribute("uploadFile") FileUpload uploadFile, ModelMap model) { List<MultipartFile> files = uploadFile.getFiles(); List<String> fileNames = new ArrayList<String>(); HashMap<String, List<Operation>> availableOperations = getAvailableOperations(); if (null != files && files.size() > 0) { for (MultipartFile multipartFile : files) { String fileName = multipartFile.getOriginalFilename(); if (!"".equalsIgnoreCase(fileName)) { // Handle file content - multipartFile.getInputStream() try { multipartFile.transferTo(new File(getRunTimeDir() + fileName)); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } fileNames.add(fileName); } LOGGER.debug(fileName); } } model.addAttribute("uploadedFiles", fileNames); model.addAttribute("accept", accept); FileBrowser fb = null; if (Boolean.TRUE.equals(this.showRunInformation)) { fb = new ExtendedFileBrowser(); ((ExtendedFileBrowser) fb).setAvailableOperations(availableOperations); ((ExtendedFileBrowser) fb).setGeoBatchClient(geoBatchClient); } else { fb = new FileBrowser(); } fb.setBaseDir(getRunTimeDir()); fb.setRegex(fileRegex); fb.setScanDiretories(canNavigate); model.addAttribute("fileBrowser", fb); model.addAttribute("showRunInformation", showRunInformation); model.addAttribute("operations", availableOperations); model.addAttribute("context", operationJSP); ControllerUtils.setCommonModel(model); return "template"; }
From source file:com.mobileman.projecth.web.controller.patient.OnlineFragebogenController.java
@RequestMapping(method = RequestMethod.POST, value = "/patient/online_fragebogen_enter_data/fileupload") public String onlineFragebogenEnterData1(HttpServletRequest request, Model model, @RequestParam("file") MultipartFile file) { // save into session OnlineFragebogenData data = new OnlineFragebogenData(request.getSession()); data.storeData(request);/*from w ww . j ava2 s. c o m*/ //store image if any if (file != null && file.getSize() > 0) { //save to temporary file try { File tmp = File.createTempFile("projecth", "imgupload"); String ct = file.getContentType(); //remember in the session file name file.transferTo(tmp); request.getSession().setAttribute(FILE_KEY, tmp.getCanonicalPath()); request.getSession().setAttribute(FILE_KEY_CONTENT_TYPE, ct); } catch (IOException e) { e.printStackTrace(); } } // prepare data for rendering prepareDiseaseData(data, new DataHolder(request), model); return "patient/online_fragebogen_confirm_data"; }
From source file:com.emaxcore.emaxdata.modules.testdrive.pub.web.TestdriveUploadSignatureController.java
/** * ???????//from w w w . j av a2 s . c o m * * @param model * @param request * @param response * @return * @throws Exception */ @RequestMapping(value = "uploadSignature") @ResponseBody public String uploadSignature(ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException { if (isDebugLogger) { logger.debug(" ??------uploadSignature-------start--------"); } response.setContentType(TestdrivePubConstant.ENCODED); Map<?, ?> jsonMap = null; // ? // ??????? StringBuilder idcardDriveProtocol = new StringBuilder(); // ??????? CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver( request.getSession().getServletContext()); if (multipartResolver.isMultipart(request)) { MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request; // json String jsonDataStr = multiRequest.getParameter(TestdrivePubConstant.VALUE); if (Global.isSecretMode()) { if (isDebugLogger) { logger.debug("app ?---------- Start------{}---------", jsonDataStr); } AES256EncryptionUtils des = AES256EncryptionUtils.getInstance(); String jsonData = des.decrypt(jsonDataStr); jsonMap = JsonMapper.nonDefaultMapper().fromJson(jsonData, HashMap.class); } else { jsonMap = JsonMapper.nonDefaultMapper().fromJson(jsonDataStr, HashMap.class); } if (isDebugLogger) { logger.debug("uploadSignature?----------jsonMap---{}---------", jsonMap); } // ? TestDriveApplyInfo testDriveApplyInfo = new TestDriveApplyInfo(); //??-- String userFristName = TestdrivePubUtils.readJsonMapValue("fristName", jsonMap); if (StringUtils.isBlank(userFristName)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "fristName", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } testDriveApplyInfo.setFirstName(userFristName); //??-- String userLastName = TestdrivePubUtils.readJsonMapValue("lastName", jsonMap); if (StringUtils.isBlank(userLastName)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "lastName", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } testDriveApplyInfo.setLastName(userLastName); //?? String userName = userFristName + userLastName; testDriveApplyInfo.setName(userName); //telephone String telephone = TestdrivePubUtils.readJsonMapValue("telephone", jsonMap); if (StringUtils.isBlank(telephone)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "telephone", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } testDriveApplyInfo.setMobile(telephone); //appellation String appellation = TestdrivePubUtils.readJsonMapValue("appellation", jsonMap); if (StringUtils.isBlank(appellation)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "appellation", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } testDriveApplyInfo.setSex(appellation); //motorcycleType String motorcycleType = TestdrivePubUtils.readJsonMapValue("motorcycleType", jsonMap); if (StringUtils.isBlank(motorcycleType)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "motorcycleType", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } testDriveApplyInfo.setVehiclesType(motorcycleType); // String widthName = TestdrivePubUtils.readJsonMapValue("userName", jsonMap); if (StringUtils.isBlank(widthName)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "userName", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } testDriveApplyInfo.setWidthName(widthName); // ?MD5 String idCarMD5Hash = TestdrivePubUtils.readJsonMapValue("IDCarMD5Hash", jsonMap); // MD5 String driveMD5Hash = TestdrivePubUtils.readJsonMapValue("driveMD5Hash", jsonMap); // ????MD5 String protocolMD5Hash = TestdrivePubUtils.readJsonMapValue("protocolMD5Hash", jsonMap); // ??? String cidNumber = TestdrivePubUtils.readJsonMapValue("IDNumber", jsonMap); if (StringUtils.isBlank(cidNumber)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "???", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } testDriveApplyInfo.setIdNumber(cidNumber); // ?D:\apache-tomcat-7.0.47\webapps\benz String path = TestdrivePubUtils.getRealPath(request); // ????/mnt/sdc1/data/benzsite String savePath = Global.getUserfilesBaseDir(); // ?/userfiles/app/login ??login String signaturePicAddressPre = TestdrivePubConstant.APP_USER_FILES_PATH + userName; String filePath = ""; // /benz String projectPath = request.getContextPath(); if (StringUtils.isBlank(savePath)) { // ?D:\apache-tomcat-7.0.47\webapps\benz/userfiles/app/login filePath = path + signaturePicAddressPre; } else { filePath = savePath + projectPath + signaturePicAddressPre; } Iterator<String> iter = multiRequest.getFileNames(); while (iter.hasNext()) { MultipartFile file = multiRequest.getFile((String) iter.next()); if (file != null && !file.isEmpty()) { String fileName = file.getOriginalFilename(); FileEmaxDataUtils.createDirectory(filePath); String fileNamePath = filePath + File.separator + fileName; String relativePath = projectPath + signaturePicAddressPre + File.separator + fileName; File localFile = new File(fileNamePath); file.transferTo(localFile); String md5Hash = MD5Utils.getFileMD5String(localFile); // ? if (fileName.startsWith(TestdrivePubConstant.IDCARD_PREFIX)) { if (!idCarMD5Hash.equals(md5Hash)) { idcardDriveProtocol.append(card); boolean deletFlag = localFile.delete(); if (deletFlag) { logger.info("??"); } } else { testDriveApplyInfo.setIdentityCardScanningFile(relativePath); } } // if (fileName.startsWith(TestdrivePubConstant.DRIVE_PREFIX)) { if (!driveMD5Hash.equals(md5Hash)) { idcardDriveProtocol.append(drive); boolean deletFlag = localFile.delete(); if (deletFlag) { logger.info("?!"); } } else { testDriveApplyInfo.setDriversLicenseScanningFile(relativePath); } } // ???? if (fileName.startsWith(TestdrivePubConstant.PROTOCOL_PREFIX)) { if (!protocolMD5Hash.equals(md5Hash)) { idcardDriveProtocol.append(protocol); boolean deletFlag = localFile.delete(); if (deletFlag) { logger.info("?????"); } } else { testDriveApplyInfo.setNumberSignature(relativePath); } } } } // ????1?1? String driveStatus = testDriveApplyInfo.getDriveStatus(); if ((StringUtils.isNotBlank(driveStatus) && (Integer.parseInt(driveStatus) < 1)) || StringUtils.isBlank(driveStatus)) { testDriveApplyInfo.setDriveStatus("1");// ?? } testDriveApplyInfoService.save(testDriveApplyInfo); } else { jsonMap = this.saveJson(TestdrivePubConstant.SUCCESS_STATE, "??", ""); return TestdrivePubUtils.loggerJsonMap(jsonMap); } if (StringUtils.isNotBlank(idcardDriveProtocol)) { jsonMap = this.saveJson(TestdrivePubConstant.ERROR_STATE, "", idcardDriveProtocol.toString()); return TestdrivePubUtils.loggerJsonMap(jsonMap); } else { jsonMap = this.saveJson(TestdrivePubConstant.SUCCESS_STATE, TestdrivePubConstant.SUCCESS, idcardDriveProtocol.toString()); } String appJson = TestdrivePubUtils.loggerJsonMap(jsonMap); if (isDebugLogger) { logger.debug("??--uploadSignature----end---"); } return appJson; }
From source file:cn.newgxu.lab.info.controller.NoticeController.java
private void fileUpload(Notice info, String fileName, MultipartFile file) { try {//w w w .j av a 2s . c o m if (!file.isEmpty()) { uploadable(file); String originName = file.getOriginalFilename(); Calendar now = Calendar.getInstance(); String path = now.get(Calendar.YEAR) + "/" + (now.get(Calendar.MONTH) + 1); File dir = new File(Config.UPLOAD_ABSOLUTE_DIR + Config.UPLOAD_RELATIVE_DIR + path + "/"); if (!dir.exists()) { if (!dir.mkdirs()) { throw new RuntimeException("????"); } } String savedFileName = now.getTimeInMillis() + RegexUtils.getFileExt(originName); file.transferTo(new File(dir.getAbsolutePath() + "/" + savedFileName)); info.setDocUrl(Config.UPLOAD_RELATIVE_DIR + path + "/" + savedFileName); info.setDocName(fileName); } } catch (IllegalStateException e) { L.error("?", e); throw new RuntimeException("?", e); } catch (IOException e) { L.error("?", e); throw new RuntimeException("?", e); } }
From source file:org.davidmendoza.fileUpload.web.VideoController.java
@RequestMapping(value = "/upload", method = RequestMethod.POST) public @ResponseBody Map upload(MultipartHttpServletRequest request, HttpServletResponse response) { log.debug("upload Post called"); Iterator<String> itr = request.getFileNames(); MultipartFile mpf; List<Video> list = new LinkedList<>(); while (itr.hasNext()) { mpf = request.getFile(itr.next()); log.debug("Uploading {}", mpf.getOriginalFilename()); String newFilenameBase = UUID.randomUUID().toString(); String originalFileExtension = mpf.getOriginalFilename() .substring(mpf.getOriginalFilename().lastIndexOf(".")); String newFilename = newFilenameBase + originalFileExtension; String storageDirectory = getRealPath(request); String contentType = mpf.getContentType(); File newFile = new File(storageDirectory + "/" + newFilename); try {//from w ww. j a v a 2 s. c o m mpf.transferTo(newFile); Video video = new Video(); video.setName(mpf.getOriginalFilename()); video.setNewFilename(newFilename); video.setContentType(contentType); video.setSize(mpf.getSize()); video = videoDao.create(video); video.setDeleteUrl("/video/delete/" + video.getId()); video.setDeleteType("DELETE"); list.add(video); } catch (IOException e) { log.error("Could not upload file " + mpf.getOriginalFilename(), e); } } Map<String, Object> files = new HashMap<>(); files.put("files", list); return files; }
From source file:ru.org.linux.topic.AddTopicController.java
private String processUploadImage(HttpServletRequest request) throws IOException, ScriptErrorException { if (request instanceof MultipartHttpServletRequest) { MultipartFile multipartFile = ((MultipartRequest) request).getFile("image"); if (multipartFile != null && !multipartFile.isEmpty()) { File uploadedFile = File.createTempFile("preview", "", new File(configuration.getPathPrefix() + "/linux-storage/tmp/")); String image = uploadedFile.getPath(); if ((uploadedFile.canWrite() || uploadedFile.createNewFile())) { try { logger.debug("Transfering upload to: " + image); multipartFile.transferTo(uploadedFile); return image; } catch (Exception e) { throw new ScriptErrorException("Failed to write uploaded file", e); }/*from w ww. ja v a 2 s . c om*/ } else { logger.info("Bad target file name: " + image); } } } return null; }
From source file:it.geosolutions.opensdi.operations.FileBrowserOperationController.java
@Override public String getJsp(ModelMap model, HttpServletRequest request, List<MultipartFile> files) { registerManager();/*from w ww . j a v a 2 s . co m*/ LOGGER.debug("getJSP di FileBrowser"); // update key String update = request.getParameter("update"); HashMap<String, List<Operation>> availableOperations = getAvailableOperations(); String baseDir = getRunTimeDir(); FileBrowser fb = null; if (Boolean.TRUE.equals(this.showRunInformation)) { fb = new ExtendedFileBrowser(); ((ExtendedFileBrowser) fb).setAvailableOperations(availableOperations); ((ExtendedFileBrowser) fb).setGeoBatchClient(geoBatchClient); ((ExtendedFileBrowser) fb).setUpdateStatus(update != null); } else { fb = new FileBrowser(); } Object gotParam = model.get("gotParam"); @SuppressWarnings("unchecked") Map<String, String[]> parameters = request.getParameterMap(); for (String key : parameters.keySet()) { LOGGER.debug(key); // debug String[] vals = parameters.get(key); for (String val : vals) // debug LOGGER.debug(" -> " + val); // debug if (key.equalsIgnoreCase(DIRECTORY_KEY)) { String dirString = parameters.get(key)[0].trim(); dirString = ControllerUtils.preventDirectoryTrasversing(dirString); if (dirString.startsWith(SEPARATOR)) { dirString = dirString.substring(1); } // remove last slash if (dirString.lastIndexOf(SEPARATOR) >= 0 && dirString.lastIndexOf(SEPARATOR) == (dirString.length() - 1)) { LOGGER.debug("stripping last slash"); // debug dirString = dirString.substring(0, dirString.length() - 1); } // second check if (dirString.lastIndexOf(SEPARATOR) >= 0) { model.addAttribute("directoryBack", dirString.substring(0, dirString.lastIndexOf(SEPARATOR))); } else { model.addAttribute("directoryBack", ""); } dirString = dirString.concat(SEPARATOR); baseDir = baseDir + dirString; model.addAttribute("directory", dirString); model.addAttribute("jsDirectory", dirString.replace(SEPARATOR, "/")); } } if (gotParam != null) { LOGGER.debug(gotParam); // debug } String gotAction = request.getParameter("action"); String fileToDel = request.getParameter("toDel"); if (gotAction != null && gotAction.equalsIgnoreCase("delete") && fileToDel != null) { String deleteFileString = baseDir + fileToDel; boolean res = deleteFile(deleteFileString); LOGGER.debug("Deletted " + deleteFileString + ": " + res); // debug } model.addAttribute("operationName", this.operationName); model.addAttribute("operationRESTPath", this.getRESTPath()); fb.setBaseDir(baseDir); fb.setRegex(fileRegex); fb.setScanDiretories(canNavigate); if (null != files && files.size() > 0) { List<String> fileNames = new ArrayList<String>(); for (MultipartFile multipartFile : files) { if (multipartFile == null) continue; String fileName = multipartFile.getOriginalFilename(); if (!"".equalsIgnoreCase(fileName)) { try { multipartFile.transferTo(new File(baseDir + fileName)); } catch (IllegalStateException e) { LOGGER.error(e.getMessage()); } catch (IOException e) { e.printStackTrace(); } fileNames.add(fileName); } LOGGER.debug("filename: " + fileName); // debug } } model.addAttribute("fileBrowser", fb); model.addAttribute("operations", availableOperations); model.addAttribute("canDelete", this.canDelete); model.addAttribute("canUpload", this.canUpload); model.addAttribute("uploadMethod", this.uploadMethod.name()); model.addAttribute("maxFileSize", this.maxFileSize); model.addAttribute("chunkSize", this.chunkSize); model.addAttribute("extensionFilter", this.extensionFilter); model.addAttribute("showRunInformation", this.showRunInformation); model.addAttribute("showRunInformationHistory", this.showRunInformationHistory); model.addAttribute("canManageFolders", this.canManageFolders); model.addAttribute("canDownloadFiles", this.canDownloadFiles); model.addAttribute("containerId", uniqueKey.toString().substring(0, 8)); model.addAttribute("formId", uniqueKey.toString().substring(27, 36)); model.addAttribute("accept", accept); return operationJSP; }
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;// w w w.j a v a2s . c om 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"); }