List of usage examples for org.springframework.web.bind.support SessionStatus setComplete
void setComplete();
From source file:nl.surfnet.coin.teams.control.EditTeamController.java
@RequestMapping(value = "/doeditteam.shtml", method = RequestMethod.POST) public RedirectView editTeam(ModelMap modelMap, HttpServletRequest request, @ModelAttribute(TokenUtil.TOKENCHECK) String sessionToken, @RequestParam() String token, SessionStatus status) throws UnsupportedEncodingException { // Check if the token is valid TokenUtil.checkTokens(sessionToken, token, status); Person person = (Person) request.getSession().getAttribute(LoginInterceptor.PERSON_SESSION_KEY); String teamId = request.getParameter("team"); String teamDescription = request.getParameter("description"); Team team = getTeam(request);/* w w w .ja va 2 s . co m*/ String teamName = team.getName(); // the name does not change on edit // Check if a user has the privileges to edit the team if (!controllerUtil.hasUserAdminPrivileges(person, team.getId())) { throw new RuntimeException("Member (" + person.getId() + ") does not have the correct privileges to edit team " + "(" + team.getName() + ")"); } // If viewablilityStatus is set this means that the team should be public boolean viewable = StringUtils.hasText(request.getParameter("viewabilityStatus")); // Update the team info grouperTeamService.updateTeam(teamId, teamName, teamDescription, person.getId()); grouperTeamService.setVisibilityGroup(teamId, viewable); AuditLog.log( "User {} edited team details of team {}. Original name, description, viewability: '{}', '{}', {}. New: '{}', '{}', {}.", person.getId(), teamId, team.getName(), team.getDescription(), team.isViewable(), teamName, teamDescription, viewable); status.setComplete(); modelMap.clear(); return new RedirectView("detailteam.shtml?team=" + URLEncoder.encode(teamId, "utf-8") + "&view=" + ViewUtil.getView(request)); }
From source file:edu.uchicago.duo.web.DuoDeviceMgmtController.java
@RequestMapping(method = RequestMethod.GET) public String initForm(HttpServletRequest request, Principal principal, ModelMap model, @ModelAttribute DuoPersonObj duoperson, HttpSession session, SessionStatus status) { //Below getting SSO Attributes for Shibboleth Support(UChicago) // duoperson.setUsername(principal.getName()); // duoperson.setFullName(request.getHeader("givenName")+ " " + request.getHeader("sn")); // duoperson.setEmail(request.getHeader("mail")); // duoperson.setChicagoID(request.getHeader("chicagoID")); //Below setting Static Attributes for Local Testing duoperson.setUsername("DuoTestUser"); duoperson.setFullName("DUO Testuser"); duoperson.setEmail("testuser@duotest.com"); logger.info("2FA Info - " + getIPForLog(request) + " - " + "Username:" + duoperson.getUsername() + "|SID:" + request.getSession().getId()); String userId = null;// w w w . j a v a 2 s .com //Check whether User is already registered in the DUO DB, if yes, record that ID, if not, forward them to first timer portal page. if (session.getAttribute("duoUserId") == null) { userId = duoUsrService.getObjByParam(duoperson.getUsername(), null, "userId"); if (userId == null) { logger.info("2FA Info - " + getIPForLog(request) + " - " + duoperson.getUsername() + " landed on DeviceMgmt Page without registering with DUO!?"); status.setComplete(); return "redirect:/secure"; } //Session Attribute "Duo User ID" - ADDED session.setAttribute("duoUserId", userId); logger.debug("2FA Debug - " + "Username:" + duoperson.getUsername() + "|DuoUserID:" + userId + "retrieved via DUO API Query"); } else { userId = session.getAttribute("duoUserId").toString(); logger.debug("2FA Debug - " + "Username:" + duoperson.getUsername() + "|DuoUserID:" + userId + "retrieved via Session Variable"); } //Set Duo UserId duoperson.setUser_id(userId); //Retrieve all Devices that the user have duoperson.setPhones(duoPhoneService.getAllPhones(userId)); duoperson.setTablets(duoTabletService.getAllTablets(userId)); duoperson.setTokens(duoTokenService.getAllTokens(userId)); //Set DISPLAY model attributes, display related table only if device > 0 if (duoperson.getPhones().size() > 0) { model.addAttribute("displayPhones", true); logger.debug("2FA Debug - " + getIPForLog(request) + " - " + duoperson.getUsername() + " has " + duoperson.getPhones().size() + " phones"); } if (duoperson.getTablets().size() > 0) { model.addAttribute("displayTablets", true); logger.debug("2FA Debug - " + getIPForLog(request) + " - " + duoperson.getUsername() + " has " + duoperson.getPhones().size() + " tablets"); } if (duoperson.getTokens().size() > 0) { model.addAttribute("displayTokens", true); logger.debug("2FA Debug - " + getIPForLog(request) + " - " + duoperson.getUsername() + " has " + duoperson.getPhones().size() + " tokens"); } //Sync Up All the attributes and push them back into Session Model Attribute model.addAttribute("DuoPerson", duoperson); //Route DUO Registered User who do not have any devices back to First timer Portal if (duoperson.getPhones().isEmpty() && duoperson.getTablets().isEmpty() && duoperson.getTokens().isEmpty()) { //return form view logger.debug("2FA Debug - " + getIPForLog(request) + " - " + duoperson.getUsername() + " has NO registered devices in DUO"); return "redirect:/secure"; } //return form view return "DuoDeviceMgmt"; }
From source file:com.stormpath.tooter.controller.SignUpController.java
@RequestMapping(method = RequestMethod.POST) public String processSubmit(@ModelAttribute("customer") User user, ModelMap model, BindingResult result, SessionStatus status) { singUpValidator.validate(user, result); Map<String, String> groupMap = null; try {/*from ww w . ja va 2s . c om*/ if (result.hasErrors()) { model.addAttribute("ADMINISTRATOR_URL", administratorGroupURL); model.addAttribute("PREMIUM_URL", premiumGroupURL); setGroupsToModel(groupMap, model); return "signUp"; } String userName = user.getFirstName().toLowerCase() + user.getLastName().toLowerCase(); // For account creation, we should get an instance of Account from the DataStore, // set the account properties and create it in the proper directory. Account account = stormpath.getDataStore().instantiate(Account.class); account.setEmail(user.getEmail()); account.setGivenName(user.getFirstName()); account.setSurname(user.getLastName()); account.setPassword(user.getPassword()); account.setUsername(userName); // Saving the account to the Directory where the Tooter application belongs. Directory directory = stormpath.getDirectory(); directory.createAccount(account); if (user.getGroupUrl() != null && !user.getGroupUrl().isEmpty()) { account.addGroup(stormpath.getDataStore().getResource(user.getGroupUrl(), Group.class)); } user.setUserName(userName); customerDao.saveCustomer(user); status.setComplete(); } catch (RuntimeException re) { model.addAttribute("ADMINISTRATOR_URL", administratorGroupURL); model.addAttribute("PREMIUM_URL", premiumGroupURL); setGroupsToModel(groupMap, model); result.addError(new ObjectError("password", re.getMessage())); re.printStackTrace(); return "signUp"; } catch (Exception e) { e.printStackTrace(); } //form success return "redirect:/login/message?loginMsg=registered"; }
From source file:com.benfante.minimark.controllers.QuestionController.java
@RequestMapping @Validation(view = EDIT_VIEW)//from w w w.j a va 2 s .c o m public String save(@ModelAttribute(QUESTION_ATTR_NAME) QuestionBean questionBean, BindingResult result, SessionStatus status) { Question question = null; if (questionBean.getId() == null) { if ("open".equals(questionBean.getType())) { question = new OpenQuestion(); } else if ("closed".equals(questionBean.getType())) { question = new ClosedQuestion(); } else { throw new IllegalArgumentException("Unknown question type"); } question.setCourse(questionBean.getCourse()); } else { question = questionDao.get(questionBean.getId()); } userProfileBo.checkEditAuthorization(question.getCourse()); question.setTitle(questionBean.getTitle()); question.setContent(questionBean.getContent()); question.setContentFilter(questionBean.getContentFilter()); question.setVisualization(questionBean.getVisualization()); question.setWeight(questionBean.getWeight()); question.setTagList(questionBean.getTags()); if (question instanceof OpenQuestion) { OpenQuestion openQuestion = (OpenQuestion) question; openQuestion.setAnswerMaxLength(questionBean.getAnswerMaxLength()); } else if (question instanceof ClosedQuestion) { ClosedQuestion closedQuestion = (ClosedQuestion) question; for (FixedAnswer fixedAnswer : questionBean.getFixedAnswers()) { fixedAnswer.setQuestion(closedQuestion); } closedQuestion.setFixedAnswers(questionBean.getFixedAnswers()); } questionBo.save(question); status.setComplete(); return "redirect:list.html?course.id=" + questionBean.getCourse().getId(); }
From source file:fi.koku.kks.controller.CollectionController.java
@ActionMapping(params = "action=saveCollection") public void save(PortletSession session, @ModelAttribute(value = "child") Person child, @ModelAttribute(value = "collectionForm") CollectionForm collectionForm, BindingResult bindingResult, @RequestParam(required = false) String multiValueId, @RequestParam(required = false) String type, @RequestParam(value = "valueId", required = false) String valueId, Model model, ActionResponse response, SessionStatus sessionStatus) { LOG.debug("save collection"); KKSCollection collection = (KKSCollection) session.getAttribute("kks.collection"); collection.setEntries(collectionForm.getEntries()); boolean success = kksService.updateKksCollection(collection, child.getPic(), Utils.getPicFromSession(session)); if (!success) { response.setRenderParameter("error", "collection.update.failed"); response.setRenderParameter("action", "showCollection"); response.setRenderParameter("pic", child.getPic()); response.setRenderParameter("collection", collection.getId()); } else {/*from w ww . ja v a 2 s.c om*/ if (StringUtils.isNotBlank(type)) { response.setRenderParameter("action", "showMultivalue"); response.setRenderParameter("pic", child.getPic()); response.setRenderParameter("collection", collection.getId()); response.setRenderParameter("entryType", type); response.setRenderParameter("valueId", valueId == null ? "" : valueId); if (multiValueId != null && !"".equals(multiValueId)) { response.setRenderParameter("entryId", multiValueId); } } else { response.setRenderParameter("action", "showChild"); response.setRenderParameter("pic", child.getPic()); session.removeAttribute("kks.collection"); } sessionStatus.setComplete(); } }
From source file:egovframework.oe1.cms.mrm.web.EgovOe1ResveMtgController.java
/** * ? ./*from www. j a v a2 s . com*/ * @param egovOe1ResveMtgVO - VO * @param status * @return "forward:/cms/mrm/selectResveMtgList.do" * @exception Exception */ @RequestMapping("/cms/mrm/removeResveMtgOK.do") public String removeResveMtgOK(@RequestParam("selectedId") String selectedId, @ModelAttribute("egovOe1ResveMtgVO") EgovOe1ResveMtgVO egovOe1ResveMtgVO, SessionStatus status, Model model) throws Exception { log.debug(this.getClass().getName() + " ==> ? "); Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated(); if (!isAuthenticated) { return "/cms/com/EgovLoginUsr"; //? ?? } //? ? ??. model.addAttribute("searchMode", egovOe1ResveMtgVO); egovOe1ResveMtgVO.setMtgRoomResId(selectedId); if (!"".equals(egovOe1ResveMtgVO.getAtchFileId())) { EgovOe1FileVO fileVo = new EgovOe1FileVO(); fileVo.setAtchFileId(egovOe1ResveMtgVO.getAtchFileId());// ? ID fileMngService.deleteAllFileInf(fileVo); } egovOe1ResveMtgService.deleteMtGattenInfo(egovOe1ResveMtgVO); egovOe1ResveMtgService.deleteResveMtg(egovOe1ResveMtgVO); status.setComplete(); if (status.isComplete()) { model.addAttribute("resultMsg", "? "); } else { model.addAttribute("resultMsg", "? "); } return "forward:/cms/mrm/selectResveMtgList.do"; }
From source file:nl.surfnet.coin.teams.control.AddExternalGroupController.java
@RequestMapping(value = "/doaddexternalgroup.shtml", method = RequestMethod.POST) public RedirectView addExternalGroups(@ModelAttribute(TokenUtil.TOKENCHECK) String sessionToken, @ModelAttribute("team") Team team, @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); String personId = person.getId(); if (!controllerUtil.hasUserAdministrativePrivileges(person, team.getId())) { throw new RuntimeException("Requester (" + person.getId() + ") is not member or does not have the correct " + "privileges to add external groups"); }//from w ww . j a v a 2 s.com final List<ExternalGroup> myExternalGroups = getExternalGroups(personId, request); Map<String, ExternalGroup> map = new HashMap<String, ExternalGroup>(); for (ExternalGroup e : myExternalGroups) { map.put(e.getIdentifier(), e); } final String[] chosenGroups = request.getParameterValues(EXTERNAL_GROUPS_SESSION_KEY); List<TeamExternalGroup> teamExternalGroups = new ArrayList<TeamExternalGroup>(); for (String identifier : chosenGroups) { TeamExternalGroup t = new TeamExternalGroup(); t.setGrouperTeamId(team.getId()); ExternalGroup externalGroup = map.get(identifier); t.setExternalGroup(externalGroup); teamExternalGroups.add(t); teamExternalGroupDao.saveOrUpdate(t); AuditLog.log("User {} added external group to team {}: {}", personId, team, externalGroup); } request.getSession().removeAttribute(EXTERNAL_GROUPS_SESSION_KEY); status.setComplete(); modelMap.clear(); return new RedirectView("detailteam.shtml?team=" + URLEncoder.encode(team.getId(), UTF_8) + "&view=" + ViewUtil.getView(request), false, true, false); }
From source file:org.jasig.portlet.announcements.controller.AdminAnnouncementController.java
/** * Saves the announcement/*from w ww . j av a 2 s . c om*/ * @param req * @param res * @throws PortletException */ @RequestMapping(params = "action=addAnnouncement") public void actionAddAnnouncementForm(@ModelAttribute("announcement") Announcement announcement, BindingResult result, SessionStatus status, ActionRequest req, ActionResponse res) throws PortletException { // First verify the user has AUTHOR permission for this topic UserPermissionChecker upChecker = userPermissionCheckerFactory.createUserPermissionChecker(req, announcement.getParent()); if (!(upChecker.isAdmin() || upChecker.isModerator() || upChecker.isAuthor())) { throw new UnauthorizedException("You do not have permission to create an announcement in this topic"); } // Next validate the announcement new AnnouncementValidator(getAllowOpenEndDate(req), getAllowEmptyMessage(req)).validate(announcement, result); if (result.hasErrors()) { res.setRenderParameter("action", "addAnnouncement"); return; } // Before we save, be sure the user isn't sneaking in a disallowed attachment through clever request hacking... PortletPreferences prefs = req.getPreferences(); final boolean useAttachments = Boolean .valueOf(prefs.getValue(PREFERENCE_USE_ATTACHMENTS, DEFAULT_USE_ATTACHMENTS)); if (!useAttachments) { announcement.setAttachments(Collections.emptySet()); } if (!result.hasErrors()) { if (!announcement.hasId()) { // add the automatic data announcement.setAuthor(req.getRemoteUser()); announcement.setCreated(new Date()); announcementService.addOrSaveAnnouncement(announcement); } else { announcementService.mergeAnnouncement(announcement); } status.setComplete(); res.setRenderParameter("topicId", announcement.getParent().getId().toString()); res.setRenderParameter("action", "showTopic"); } }
From source file:com.stormpath.tooter.controller.LoginController.java
@RequestMapping(method = RequestMethod.POST) public String processSubmit(@ModelAttribute("customer") User customer, BindingResult result, SessionStatus status, HttpSession session) { loginValidator.validate(customer, result); String returnStr = "login"; if (!result.hasErrors()) { try {/*from w w w .ja v a2s. com*/ // For authentication the only thing we need to do is call Application.authenticate(), // instantiating the proper AuthenticationRequest (UsernamePasswordRequest in this case), // providing the account's credentials. AuthenticationRequest request = new UsernamePasswordRequest(customer.getUserName(), customer.getPassword()); AuthenticationResult authcResult = stormpath.getApplication().authenticateAccount(request); Account account = authcResult.getAccount(); User user = new User(account); // If the customer queried from the database does not exist // we create it in the application's internal database, // so we don't have to go through the process of signing a user up // that has already been authenticated in the previous call to the Stormpath API. // This is because the application uses an in-memory database (HSQLDB) // that only persists while the application is up. User dbCustomer = customerDao.getCustomerByUserName(customer.getUserName()); if (dbCustomer == null) { customerDao.saveCustomer(user); } if (dbCustomer != null) { user.setId(dbCustomer.getId()); } session.setAttribute("sessionUser", user); session.setAttribute("permissionUtil", permissionUtil); returnStr = "redirect:/tooter"; status.setComplete(); } catch (ResourceException re) { result.addError(new ObjectError("userName", re.getMessage())); re.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } return returnStr; }