List of usage examples for org.springframework.web.bind.support SessionStatus setComplete
void setComplete();
From source file:csns.web.controller.SiteBlockControllerS.java
@RequestMapping(value = "/site/{qtr}/{cc}-{sn}/block/editItem", method = RequestMethod.POST) public String editItem(@PathVariable String qtr, @PathVariable String cc, @PathVariable int sn, @ModelAttribute Block block, @RequestParam Long newBlockId, @ModelAttribute Item item, @RequestParam(value = "uploadedFile", required = false) MultipartFile uploadedFile, BindingResult bindingResult, SessionStatus sessionStatus) { itemValidator.validate(item, uploadedFile, bindingResult); if (bindingResult.hasErrors()) return "site/block/editItem"; User user = SecurityUtils.getUser(); Resource resource = item.getResource(); if (resource.getType() == ResourceType.FILE && uploadedFile != null && !uploadedFile.isEmpty()) resource.setFile(fileIO.save(uploadedFile, user, true)); if (newBlockId.equals(block.getId())) block = blockDao.saveBlock(block); else {// w w w .java2s . c o m block.removeItem(item.getId()); block = blockDao.saveBlock(block); Block newBlock = blockDao.getBlock(newBlockId); newBlock.getItems().add(item); newBlock = blockDao.saveBlock(newBlock); } sessionStatus.setComplete(); logger.info(user.getUsername() + " edited item " + item.getId() + " in block " + block.getId()); return "redirect:list"; }
From source file:nl.surfnet.coin.teams.control.AddExternalGroupController.java
@RequestMapping(value = "/deleteexternalgroup.shtml") public RedirectView deleteTeamExternalGroupLink(@ModelAttribute(TokenUtil.TOKENCHECK) String sessionToken, @RequestParam String teamId, @RequestParam String groupIdentifier, @RequestParam String token, ModelMap modelMap, SessionStatus status, HttpServletRequest request) throws UnsupportedEncodingException { TokenUtil.checkTokens(sessionToken, token, status); Person person = (Person) request.getSession().getAttribute(LoginInterceptor.PERSON_SESSION_KEY); if (!controllerUtil.hasUserAdminPrivileges(person, teamId)) { throw new RuntimeException("Requester (" + person.getId() + ") is not member or does not have the correct " + "privileges to remove external groups"); }//from w ww . j av a2 s . c o m TeamExternalGroup teamExternalGroup = teamExternalGroupDao .getByTeamIdentifierAndExternalGroupIdentifier(teamId, groupIdentifier); if (teamExternalGroup != null) { teamExternalGroupDao.delete(teamExternalGroup); AuditLog.log("User {} deleted external group from team {}: {}", person.getId(), teamId, teamExternalGroup.getExternalGroup()); } status.setComplete(); modelMap.clear(); return new RedirectView( "detailteam.shtml?team=" + URLEncoder.encode(teamId, UTF_8) + "&view=" + ViewUtil.getView(request), false, true, false); }
From source file:csns.web.controller.ProfileControllerS.java
@RequestMapping(value = "/profile/edit", method = RequestMethod.POST) public String edit(@ModelAttribute("user") User cmd, @RequestParam(value = "file", required = false) MultipartFile uploadedFile, HttpServletRequest request, BindingResult bindingResult, SessionStatus sessionStatus) { editUserValidator.validate(cmd, bindingResult); if (bindingResult.hasErrors()) return "profile/edit"; User user = userDao.getUser(SecurityUtils.getUser().getId()); user.copySelfEditableFieldsFrom(cmd); String password = cmd.getPassword1(); if (StringUtils.hasText(password)) user.setPassword(passwordEncoder.encodePassword(password, null)); user = userDao.saveUser(user);// w w w . j a va2 s. co m logger.info(user.getUsername() + " edited profile."); if (uploadedFile != null && !uploadedFile.isEmpty()) { File picture0 = fileIO.save(uploadedFile, user, true); File picture1 = imageUtils.resizeToProfilePicture(picture0); File picture2 = imageUtils.resizeToProfileThumbnail(picture0); user.setOriginalPicture(picture0); user.setProfilePicture(picture1); user.setProfileThumbnail(picture2); user = userDao.saveUser(user); logger.info("Saved profile picture for " + user.getUsername()); } sessionStatus.setComplete(); return "redirect:/profile"; }
From source file:it.jugpadova.controllers.AddParticipantController.java
@RequestMapping(method = RequestMethod.POST) @Validation(view = FORM_VIEW, continueOnErrors = true) protected ModelAndView onSubmit(HttpServletRequest req, @ModelAttribute(REGISTRATION_ATTRIBUTE) Registration registration, BindingResult result, SessionStatus status) throws Exception { // validator.validate(registration, result); if (result.hasErrors()) { req.setAttribute(REGISTRATION_ATTRIBUTE, registration); req.setAttribute("event", registration.getEvent()); req.setAttribute("participants", registration.getEvent().getParticipants()); req.setAttribute("showAddNewPartecipantDiv", "true"); return new ModelAndView(FORM_VIEW); }/* w w w. j ava2 s. c om*/ List<Participant> prevParticipant = eventBo.searchParticipantByEmailAndEventId( registration.getParticipant().getEmail(), registration.getEvent().getId()); if (prevParticipant.size() == 0) { eventBo.addParticipant(registration.getEvent(), registration.getParticipant()); } else { Participant p = prevParticipant.get(0); p.setConfirmed(Boolean.TRUE); participantDao.store(p); logger.info("Confirmed participant with id=" + p.getId()); } ModelAndView mv = new ModelAndView("redirect:participants.html?id=" + registration.getEvent().getId()); status.setComplete(); return mv; }
From source file:com.osc.edu.chapter4.customers.CustomersController.java
@RequestMapping("/updateCustomers") public String updateCustomers(@RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @ModelAttribute @Valid CustomersDto customers, BindingResult results, SessionStatus status, HttpSession session) {/* www . j a v a 2 s . co m*/ if (results.hasErrors()) { logger.debug("results : [{}]", results); return "customers/form"; } try { if (imgFile != null && !imgFile.getOriginalFilename().equals("")) { String fileName = imgFile.getOriginalFilename(); String destDir = session.getServletContext().getRealPath("/upload"); File dirPath = new File(destDir); if (!dirPath.exists()) { boolean created = dirPath.mkdirs(); if (!created) { throw new Exception("Fail to create a directory for movie image. [" + destDir + "]"); } } IOUtils.copy(imgFile.getInputStream(), new FileOutputStream(new File(destDir, fileName))); logger.debug("Upload file({}) saved to [{}].", fileName, destDir); } customersService.updateCustomers(customers); status.setComplete(); } catch (Exception e) { logger.debug("Exception has occurred. ", e); } return "redirect:/customers/getCustomersList.do"; }
From source file:com.osc.edu.chapter4.customers.CustomersController.java
@RequestMapping("/insertCustomers") public String insertCustomers(@RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @ModelAttribute @Valid CustomersDto customers, BindingResult results, SessionStatus status, HttpSession session) {/*from w ww . j a v a 2s . c o m*/ if (results.hasErrors()) { logger.debug("results : [{}]", results); return "customers/form"; } try { if (imgFile != null && !imgFile.getOriginalFilename().equals("")) { String fileName = imgFile.getOriginalFilename(); String destDir = session.getServletContext().getRealPath("/upload"); File dirPath = new File(destDir); if (!dirPath.exists()) { boolean created = dirPath.mkdirs(); if (!created) { throw new Exception("Fail to create a directory for movie image. [" + destDir + "]"); } } IOUtils.copy(imgFile.getInputStream(), new FileOutputStream(new File(destDir, fileName))); logger.debug("Upload file({}) saved to [{}].", fileName, destDir); } customersService.insertCustomers(customers); status.setComplete(); } catch (Exception e) { logger.debug("Exception has occurred. ", e); } return "redirect:/customers/getCustomersList.do"; }
From source file:com.osc.edu.chapter4.employees.EmployeesController.java
@RequestMapping("/insertEmployees") public String insertEmployees(@RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @ModelAttribute @Valid EmployeesDto employees, BindingResult results, SessionStatus status, HttpSession session) {/* w w w. j ava 2 s . c o m*/ if (results.hasErrors()) { logger.debug("results : [{}]", results); return "employees/form"; } try { if (imgFile != null && !imgFile.getOriginalFilename().equals("")) { String fileName = imgFile.getOriginalFilename(); String destDir = session.getServletContext().getRealPath("/upload"); File dirPath = new File(destDir); if (!dirPath.exists()) { boolean created = dirPath.mkdirs(); if (!created) { throw new Exception("Fail to create a directory for movie image. [" + destDir + "]"); } } IOUtils.copy(imgFile.getInputStream(), new FileOutputStream(new File(destDir, fileName))); logger.debug("Upload file({}) saved to [{}].", fileName, destDir); } employeesService.insertEmployees(employees); status.setComplete(); } catch (Exception e) { logger.debug("Exception has occurred. ", e); } return "redirect:/employees/getEmployeesList.do"; }
From source file:com.osc.edu.chapter4.employees.EmployeesController.java
@RequestMapping("/updateEmployees") public String updateEmployees(@RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @ModelAttribute @Valid EmployeesDto employees, BindingResult results, SessionStatus status, HttpSession session) {/*from w w w . j a v a2s .c o m*/ if (results.hasErrors()) { logger.debug("results : [{}]", results); return "employees/form"; } try { if (imgFile != null && !imgFile.getOriginalFilename().equals("")) { String fileName = imgFile.getOriginalFilename(); String destDir = session.getServletContext().getRealPath("/upload"); File dirPath = new File(destDir); if (!dirPath.exists()) { boolean created = dirPath.mkdirs(); if (!created) { throw new Exception("Fail to create a directory for movie image. [" + destDir + "]"); } } IOUtils.copy(imgFile.getInputStream(), new FileOutputStream(new File(destDir, fileName))); logger.debug("Upload file({}) saved to [{}].", fileName, destDir); } employeesService.updateEmployees(employees); status.setComplete(); } catch (Exception e) { logger.debug("Exception has occurred. ", e); } return "redirect:/employees/getEmployeesList.do"; }
From source file:org.hydroponics.web.controller.EditGrow.java
@RequestMapping(method = RequestMethod.POST) public String processSubmit(@ModelAttribute GrowEditBean growEditBean, BindingResult result, SessionStatus status, String formAction) { logger.info(new StringBuffer("process submit:").append(growEditBean).append("\n\tBindResult:") .append(result).append("\n\tSessionState:").append(status).append("\n\tFormAction:") .append(formAction).toString()); if (formAction != null && formAction.equals(Constants.ACTION_SUBMIT)) { growValidator.validate(growEditBean, result); if (result.hasErrors()) { return Constants.PAGE_EDIT_GROW; } else {/*from w ww . jav a 2 s. c om*/ Map<String, Object> grow = new HashMap<String, Object>(); grow.put(Constants.ID, growEditBean.getId()); grow.put(Constants.NAME, growEditBean.getName()); grow.put(Constants.VEGETATION, growEditBean.getVegetation()); grow.put(Constants.FLOWER_DATE, growEditBean.getFlower()); grow.put(Constants.END_DATE, growEditBean.getEnd()); grow.put(Constants.PLANTS, growEditBean.getPlants()); grow.put(Constants.RESULT, growEditBean.getResult()); this.hydroponicsDao.saveGrow(grow); status.setComplete(); return Constants.REDIRECT_MAIN; } } else if (formAction != null && formAction.equals(Constants.ACTION_DELETE)) { this.hydroponicsDao.deleteGrow(growEditBean.getId()); status.setComplete(); return Constants.REDIRECT_MAIN; } else if (formAction != null && formAction.equals(Constants.ACTION_CANCEL)) { status.setComplete(); return Constants.REDIRECT_MAIN; } else { throw new RuntimeException("unknown form action:" + formAction); } }
From source file:com.stormpath.tooter.controller.TootController.java
@RequestMapping(method = RequestMethod.POST, value = "/tooter") public String processSubmit(@ModelAttribute("toot") Toot toot, BindingResult result, SessionStatus status, HttpSession session) {// w w w .ja v a 2s.c o m tootValidator.validate(toot, result); User sessionUser = (User) session.getAttribute("sessionUser"); if (!result.hasErrors()) { User persistCustomer = new User(sessionUser); List<Toot> tootList; Toot persistToot = new Toot(); persistToot.setTootMessage(toot.getTootMessage()); persistToot.setCustomer(persistCustomer); try { tootDao.saveToot(persistToot); toot.setTootId(persistToot.getTootId()); tootList = tootDao.getTootsByUserId(persistCustomer.getId()); for (Toot itemToot : tootList) { itemToot.setCustomer(sessionUser); } Collections.sort(tootList); sessionUser.setTootList(tootList); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } toot.setTootMessage(""); toot.setCustomer(sessionUser); status.setComplete(); //form success return "tooter"; }