protected ModelAndView onSubmit( HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException, IOException, Exception { // cast the bean. i only care about the File property in this controller UploadMasterBean bean = (UploadMasterBean) command; MultipartFile multipartFile = bean.getFile(); if (multipartFile != null) { System.out.println("name " + multipartFile.getOriginalFilename()); System.out.println("size " + multipartFile.getSize()); File fileOut = new File(FileUtils.createTempDir(), multipartFile.getOriginalFilename()); System.out.println("File written to " + fileOut.getCanonicalPath()); multipartFile.transferTo(fileOut); String path = fileOut.getCanonicalPath(); String extension = FileUtils.getFileExtension(path); if (("png".equals(extension)) || ("PNG".equals(extension)) || ("jpg".equals(extension)) || ("JPG".equals(extension)) || ("gif".equals(extension)) || ("GIF".equals(extension))) { // TODO check and warn if this isn't transparent. Alpha? catalogManager.addWatermark(fileOut); } else { System.out.println(path + " not imported."); } } // return new ModelAndView("uploadResults", "model", model); return new ModelAndView("redirect:listWatermarks.html"); }
protected void respondAdmin(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/xml"); StringBuffer buf = new StringBuffer(); String _details = req.getParameter("details"); boolean details = (_details != null && _details.equals("1")); ConnectionGroup.dumpGroupsXML(buf, details); String appName = req.getParameter("application"); if (appName != null && !appName.equals("")) { if (appName.equals("*")) { Application.dumpApplicationsXML(buf, details); } else { Application application = Application.getApplication(appName, false); if (application != null) application.toString(); } } ConnectionAgent.dumpAgentsXML(buf, details); ServletOutputStream out = res.getOutputStream(); try { out.println( "<connection-info " + " max-message-length=\"" + HTTPConnection.getMaxMessageLen() + "\"" + " connection-length=\"" + HTTPConnection.getConnectionLength() + "\"" + " reconnection-wait-interval=\"" + HTTPConnection.getReconnectionWaitInterval() + "\"" + " >"); out.println(buf.toString()); out.println("</connection-info>"); } finally { FileUtils.close(out); } }