Example usage for org.springframework.web.bind.support SessionStatus setComplete

List of usage examples for org.springframework.web.bind.support SessionStatus setComplete

Introduction

In this page you can find the example usage for org.springframework.web.bind.support SessionStatus setComplete.

Prototype

void setComplete();

Source Link

Document

Mark the current handler's session processing as complete, allowing for cleanup of session attributes.

Usage

From source file:it.jugpadova.controllers.PasswordRecoveryController.java

@RequestMapping(method = RequestMethod.POST)
@Validation(view = FORM_VIEW)//from  w  ww.  j a  v a2s  .  co  m
protected ModelAndView send(@ModelAttribute(PASSWORD_RECOVERY_ATTRIBUTE) PasswordRecovery passwordRecovery,
        BindingResult result, HttpServletRequest req, SessionStatus status) throws Exception {

    String email = passwordRecovery.getEmail();
    logger.debug("email: " + email);
    Jugger jugger = juggerBo.searchByEmail(email);
    if (jugger == null) {
        result.rejectValue("email", "juggerNotFoundByEmail");
        return new ModelAndView(FORM_VIEW);
    }
    if (jugger.getUser().isEnabled() == false) {
        result.rejectValue("email", "juggerBlocked");
        return new ModelAndView(FORM_VIEW);
    }
    juggerBo.passwordRecovery(jugger, Utilities.getBaseUrl(req));
    ModelAndView mv = new ModelAndView("redirect:/home/message.html?messageCode=jugger.pwdchng.sentMail");
    Utilities.addMessageArguments(mv, jugger.getEmail());
    status.setComplete();
    return mv;
}

From source file:kr.co.exsoft.common.controller.SessionController.java

/***
 * // w  ww  .j  a v  a2s  .c  om
 * <pre>
 * 1.  :  
 * 2.  :
 * </pre>
 * @Method Name : logout
 * @param sessionVO
 * @param sessionStatus
 * @param request
 * @return String
 */
@RequestMapping("/logout.do")
public String logout(@ModelAttribute SessionVO sessionVO, SessionStatus sessionStatus,
        HttpServletRequest request) {

    // session listener 
    HttpSession session = request.getSession();
    session.setAttribute("externalCheck", "F");//valueunbound   flag
    session.removeAttribute("listener");
    sessionStatus.setComplete();

    HashMap<String, Object> param = new HashMap<String, Object>();

    try {

        param.put("cert_yn", Constant.NOTHING);
        param.put("login_type", Constant.NORMAL_LOGIN_TYPE);
        param.put("connect_type", Constant.CONNECT_TYPE_LOGOUT);

        sessionService.sessionOut(session, sessionVO, request, param);

    } catch (Exception e) {
        logger.error(e.getMessage());
    }

    ///return "layout/loginForm";
    return "redirect:/login.do";
}

From source file:org.sloth.web.account.FirstStartController.java

/**
 * Handles the {@code POST}-Request, validates the registration form,
 * creates a new {@code User} and authorizes the {@code HttpSession}.
 *//*from   www  . j  a  v  a 2s  .  c  o  m*/
@RequestMapping(method = POST)
public String submit(@ModelAttribute(USER_ATTRIBUTE) RegistrationFormAction action, BindingResult result,
        SessionStatus status, HttpSession session, HttpServletResponse response) throws IOException {
    if (isFirstStart()) {
        this.registrationFormValidator.validate(action, result);
        if (result.hasErrors()) {
            return VIEW;
        } else {
            try {
                User u = action.createUser();
                u.setUserGroup(Group.ADMIN);
                this.userService.registrate(u);
                auth(session, u);
            } catch (Exception e) {
                logger.warn("Unexpected Exception", e);
                return internalErrorView(response);
            } finally {
                status.setComplete();
            }
            return "redirect:/";
        }
    } else {
        return forbiddenView(response);
    }

}

From source file:csns.web.controller.WikiControllerS.java

@RequestMapping(value = "/wiki/discuss", method = RequestMethod.POST)
public String discuss(@ModelAttribute Post post, @RequestParam Long pageId,
        @RequestParam(value = "file", required = false) MultipartFile[] uploadedFiles, BindingResult result,
        SessionStatus sessionStatus) {
    messageValidator.validate(post, result);
    if (result.hasErrors())
        return "wiki/discuss";

    User user = SecurityUtils.getUser();
    if (uploadedFiles != null)
        post.getAttachments().addAll(fileIO.save(uploadedFiles, user, true));

    post.setAuthor(user);/*from   ww  w.  j av a2 s  .co m*/
    post.setDate(new Date());
    Topic topic = post.getTopic();
    topic.addPost(post);
    Forum forum = topic.getForum();
    forum.incrementNumOfTopics();
    forum.incrementNumOfPosts();
    forum.setLastPost(post);
    topic = topicDao.saveTopic(topic);
    sessionStatus.setComplete();

    Page page = pageDao.getPage(pageId);
    page.getDiscussions().add(topic);
    pageDao.savePage(page);

    subscriptionDao.subscribe(page, user);

    String subject = "New Discussion of Wiki Page " + page.getPath();
    String vTemplate = "notification.new.wiki.discussion.vm";
    Map<String, Object> vModels = new HashMap<String, Object>();
    vModels.put("page", page);
    vModels.put("author", user);
    vModels.put("topic", topic);
    notificationService.notifiy(page, subject, vTemplate, vModels, false);

    return "redirect:/wiki/discussions?id=" + page.getId();
}

From source file:fi.koku.kks.controller.CollectionController.java

@ActionMapping(params = "action=addMultivalue")
public void saveMultivalue(PortletSession session, @ModelAttribute(value = "child") Person child,
        @RequestParam(value = "entryType") String entryType,
        @RequestParam(value = "collection") String collection,
        @RequestParam(value = "entryId", required = false) String entry,
        @RequestParam(value = "valueId", required = false) String valueId, EntryValue value,
        BindingResult bindingResult, ActionResponse response, SessionStatus sessionStatus) {
    LOG.debug("save multivalue");

    String id = kksService.addKksEntry(collection, child.getPic(), entry, entryType, valueId, value.getValue(),
            Utils.getPicFromSession(session));

    if (id == null) {
        response.setRenderParameter("error", "collection.entry.update.failed");
    }// w w  w . j  a  v a  2 s  .c o  m

    response.setRenderParameter("action", "showCollection");
    response.setRenderParameter("pic", child.getPic());
    response.setRenderParameter("collection", collection);

    sessionStatus.setComplete();
}

From source file:org.hydroponics.web.controller.AddImage.java

@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@ModelAttribute ImageEditBean imageEditBean, BindingResult result,
        SessionStatus status, String formAction) {
    logger.info(new StringBuffer("process submit:").append(imageEditBean).append("\n\tBindResult:")
            .append(result).append("\n\tSessionState:").append(status).append("\n\tFormAction:")
            .append(formAction).toString());

    if (formAction != null && formAction.equals(Constants.ACTION_SUBMIT)) {
        imageValidator.validate(imageEditBean, result);
        if (result.hasErrors()) {
            return Constants.PAGE_ADD_IMAGE;
        } else {//from  w w w. j av a2s .c om
            try {
                int grow = (Integer) this.hydroponicsDao.getCurrentGrow().get(Constants.ID);
                this.hydroponicsDao.saveImage(grow, imageEditBean.getFile());
                status.setComplete();
                return Constants.REDIRECT_MAIN;
            } catch (Exception ex) {
                logger.log(Level.SEVERE, ex.toString(), ex);
                throw new RuntimeException(ex);
            }
        }
    } 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:csns.web.controller.OnlineSubmissionControllerS.java

@RequestMapping(value = "/submission/online/edit", method = RequestMethod.POST)
public String edit(@ModelAttribute("submission") OnlineSubmission submission, @RequestParam int sectionIndex,
        HttpServletRequest request, ModelMap models, SessionStatus sessionStatus) {
    if (submission.isPastDue()) {
        models.put("message", "error.assignment.pastdue");
        models.put("backUrl", "/section/taken");
        return "error";
    }/*from www.  j a  v a2 s .  c  o  m*/

    if (request.getParameter("save") != null)
        submission.setSaved(true);
    if (request.getParameter("finish") != null)
        submission.setFinished(true);
    submission.getAnswerSheet().setDate(new Date());
    submission = (OnlineSubmission) submissionDao.saveSubmission(submission);

    logger.info(SecurityUtils.getUser().getUsername() + " edited online submission " + submission.getId());

    if (request.getParameter("finish") != null) {
        sessionStatus.setComplete();
        models.put("message", "status.assignment.completed");
        models.put("backUrl", "/section/taken#section-" + submission.getAssignment().getSection().getId());
        return "status";
    }

    if (request.getParameter("prev") != null)
        --sectionIndex;
    if (request.getParameter("next") != null)
        ++sectionIndex;

    models.put("submission", submission);
    models.put("sectionIndex", sectionIndex);
    return "submission/online/edit";
}

From source file:csns.web.controller.OnlineAssignmentControllerS.java

@RequestMapping(value = "/assignment/online/addQuestion", method = RequestMethod.POST)
public String addQuestion(@ModelAttribute("question") Question question, @RequestParam Long assignmentId,
        @RequestParam int sectionIndex, BindingResult result, SessionStatus sessionStatus) {
    questionValidator.validate(question, result);
    if (result.hasErrors())
        return "assignment/online/addQuestion";

    OnlineAssignment assignment = (OnlineAssignment) assignmentDao.getAssignment(assignmentId);
    if (!assignment.isPublished()) {
        assignment.getQuestionSheet().getSections().get(sectionIndex).getQuestions().add(question);
        assignment.calcTotalPoints();/* ww w  .jav  a  2  s  .  c  o m*/
        assignmentDao.saveAssignment(assignment);

        logger.info(SecurityUtils.getUser().getUsername() + " added a question to online assignment "
                + assignmentId);
    }

    sessionStatus.setComplete();
    return "redirect:/assignment/online/editQuestionSheet?assignmentId=" + assignmentId + "&sectionIndex="
            + sectionIndex;
}

From source file:org.sloth.web.user.DeleteUserController.java

/**
 * Handles all {@code POST} requests and deletes a {@code User}.
 *///  w  ww  .j a  v  a  2s.co  m
@RequestMapping(method = POST)
public String processSubmit(@PathVariable Long id, HttpSession session, HttpServletResponse response,
        SessionStatus status) throws IOException {
    if (isAuth(session)) {
        boolean self = getUser(session).getId().equals(id);
        if (self || isAdmin(session)) {
            try {
                if (self) {
                    deAuth(session);
                    this.userService.delete(id);
                    return "redirect:/";
                } else {
                    this.userService.delete(id);
                    return "redirect:/u";
                }
            } catch (Exception e) {
                logger.warn("Unexpected Exception", e);
                return internalErrorView(response);
            } finally {
                status.setComplete();
            }
        }
    }
    return forbiddenView(response);
}

From source file:csns.web.controller.AssignmentControllerS.java

@RequestMapping(value = "/assignment/edit", method = RequestMethod.POST)
public String edit(@ModelAttribute Assignment assignment,
        @RequestParam(value = "file", required = false) MultipartFile uploadedFile, HttpServletRequest request,
        BindingResult result, SessionStatus sessionStatus) {
    assignmentValidator.validate(assignment, uploadedFile, result);
    if (result.hasErrors())
        return assignment.isOnline() ? "assignment/online/edit" : "assignment/edit";

    if (!assignment.isOnline()) {
        Resource description = assignment.getDescription();
        if (description.getType() == ResourceType.NONE)
            assignment.setDescription(null);
        else if (description.getType() == ResourceType.FILE && uploadedFile != null && !uploadedFile.isEmpty())
            description.setFile(fileIO.save(uploadedFile, SecurityUtils.getUser(), false));
    }/*from  w w  w.java2s.  c o  m*/

    assignment = assignmentDao.saveAssignment(assignment);
    sessionStatus.setComplete();

    logger.info(SecurityUtils.getUser().getUsername() + " edited assignment " + assignment.getId());

    return assignment.isOnline() && request.getParameter("next") != null
            ? "redirect:/assignment/online/editQuestionSheet?assignmentId=" + assignment.getId()
            : "redirect:/section/taught#section-" + assignment.getSection().getId();
}