@SkipValidation public String addTool() { try { System.out.println("addTool"); File f = new File("newFile.txt"); f.createNewFile(); logger.debug("addTool"); toolBean.setManufacturer(manufacturer); toolBean.setName(name); toolBean.setUpload(upload); toolBean.setUploadFileName(manufacturer + "-" + uploadFileName); String filePath = req.getRealPath("/"); logger.debug("Server Path = " + filePath); String fullFileName = filePath + "Uploads\\" + manufacturer + "-" + getUploadFileName(); logger.debug("FullFileName = " + fullFileName); File theFile = new File(fullFileName); theFile.createNewFile(); FileUtils.copyFile(toolBean.getUpload(), theFile); toolService.addTool(toolBean); addActionMessage("Insertion successful"); return SUCCESS; } catch (Exception e) { addActionError("There was a problem while inserting tool information.Please Contact Admin"); logger.error(e.getMessage(), e); return ERROR; } }
@SkipValidation public String getAllTools() { try { toolBean.setAllTools(toolService.getAllTools()); return SUCCESS; } catch (Exception e) { addActionError("There was a problem while retrieving tool information.Please Contact Admin"); logger.error(e.getMessage(), e); return ERROR; } }
@SkipValidation public String deleteTool() { try { int tid = toolBean.getTID(); String fileName = toolService.getFileName(tid); String filePath = req.getRealPath("/"); String fullFileName = filePath + "Uploads\\" + fileName; logger.debug("Deleting file : " + fullFileName); File theFile = new File(fullFileName); logger.debug("isFile : " + theFile.isFile()); logger.debug("File removed = " + theFile.delete()); toolService.deleteTool(tid); addActionMessage("Deletion Successful"); return getAllTools(); } catch (Exception e) { addActionError("There was a problem while retrieving tool information.Please Contact Admin"); logger.error(e.getMessage(), e); return ERROR; } }