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:egovframework.oe1.cms.sim.web.EgovOe1ChangeRequestManageController.java

/**
 *  /*from  w w w  . j a va  2 s  .c  om*/
 * @param    EgovOe1ChangeRequestVO
 * @return "/cms/sim/gnrl/getChangeRequestList.do"
 * @exception Exception
 */
@RequestMapping("/cms/sim/gnrl/deleteRequestInfo.do")
public String deleteChangeRequest(@ModelAttribute("changeRequestvo") EgovOe1ChangeRequestVO changeRequestVo,
        SessionStatus status) throws Exception {

    /*?  ? ID  N */
    if (changeRequestVo.getAtchFileId() != "") {
        EgovOe1FileVO fileVo = new EgovOe1FileVO();
        fileVo.setAtchFileId(changeRequestVo.getAtchFileId());// ? ID
        fileMngService.deleteAllFileInf(fileVo);
    }

    /**/
    changeRequestManageService.deleteChangeRequest(changeRequestVo);

    status.setComplete();
    return "forward:/cms/sim/gnrl/getChangeRequestList.do";
}

From source file:org.motechproject.server.omod.web.controller.DemoEnrollController.java

@RequestMapping(method = RequestMethod.POST)
public String submitForm(@ModelAttribute("enrollpatient") WebPatient webPatient, Errors errors, ModelMap model,
        SessionStatus status, HttpSession session) {

    log.debug("Enroll Demo Patient");

    ValidationUtils.rejectIfEmpty(errors, "motechId", "motechmodule.motechId.required");

    Patient patient = null;//from   ww  w .  java2  s  .  co m
    if (webPatient.getMotechId() != null) {
        patient = openmrsBean.getPatientByMotechId(webPatient.getMotechId().toString());
        if (patient == null) {
            errors.rejectValue("motechId", "motechmodule.motechId.notexist");
        }
    }

    if (!Boolean.TRUE.equals(webPatient.getConsent())) {
        errors.rejectValue("consent", "motechmodule.consent.required");
    }

    if (!errors.hasErrors()) {
        registrarBean.demoEnrollPatient(patient);

        model.addAttribute("successMsg", "motechmodule.Demo.Patient.enroll.success");

        status.setComplete();

        session.removeAttribute("demoLastMotechId");

        return "redirect:/module/motechmodule/demo-success.htm";
    }

    return "/module/motechmodule/demo-enrollpatient";
}

From source file:org.dspace.webmvc.controller.admin.CollectionController.java

@RequestMapping(params = "update", method = RequestMethod.POST)
public String processCollectionUpdate(@RequestAttribute Context context,
        @RequestParam(value = "communityID", required = false) Integer communityID,
        @RequestParam(value = "collectionID", required = false) Integer collectionID,
        @RequestParam(value = "createNew", required = false) String createNew,
        @ModelAttribute("collectionMetadataForm") @Valid CollectionMetadataForm collectionMetadataForm,
        BindingResult bindingResult, SessionStatus status)
        throws SQLException, AuthorizeException, IOException {
    if (bindingResult.hasErrors()) {
        return "pages/admin/collectionEdit";
    } else {//w  ww.jav a2 s .  c o m
        Collection collection;
        if (createNew != null) {
            //Create
            assert communityID != null;
            Community community = Community.find(context, communityID);
            collection = community.createCollection();
        } else {
            //Edit
            assert collectionID != null;
            collection = Collection.find(context, collectionID);
        }

        collectionMetadataForm.setCollectionID(collection.getID());
        collectionMetadataForm.save(context);
        status.setComplete();

        return "redirect:/handle/" + collection.getHandle();
    }
}

From source file:edu.uchicago.duo.web.DuoEnrollController.java

@RequestMapping(method = RequestMethod.POST, params = "enrollsteps")
public String processPage(@RequestParam("_page") final int nextPage,
        @ModelAttribute("DuoPerson") DuoPersonObj duoperson, HttpServletRequest request, Principal principal,
        BindingResult result, HttpSession session, SessionStatus status, ModelMap model)
        throws UnsupportedEncodingException, JSONException, Exception {

    //Redirect for Enroll Another Device
    if (nextPage == 0) {
        status.setComplete();
        return "redirect:/secure/enrollment";
    }/*from  w ww.  j  a v a2 s.c  o  m*/

    if (nextPage == 2) {
        String userId = duoUsrService.getObjByParam(duoperson.getUsername(), null, "userId");
        duoperson.setUser_id(userId);

        if (userId != null) {
            //Session Attribute "Duo User ID" - UPDATED (Depends)
            session.setAttribute("duoUserId", userId);
            model.put("existingUser", true);
        }
    }

    //Redirect Depends on the type of Device that is being enroll
    if (nextPage == 3) {
        switch (duoperson.getChoosenDevice()) {
        case "tablet":
            duoperson.setDeviceOS(null);
            return "DuoEnrollTablet";
        case "token":
            return "DuoEnrollToken";
        }

    }

    if (nextPage == 31) {
        validator.validate(duoperson, result, DuoPersonObj.TabletInfoValidation.class);
        if (result.hasErrors()) {
            return "DuoEnrollTablet";
        }
        return "DuoEnrollStep5";
    }

    if (nextPage == 32) {
        validator.validate(duoperson, result, DuoPersonObj.TokenInfoValidation.class);
        if (result.hasErrors()) {
            return "DuoEnrollToken";
        }
        return processEnroll(request, duoperson, result, session, status, model);
    }

    //Validation on Submission of Phone Number, to make sure Phone Number has not been registered or belong to someone else
    if (nextPage == 4) {

        validator.validate(duoperson, result, DuoPersonObj.PhoneNumberValidation.class);
        if (result.hasErrors()) {
            return "DuoEnrollStep3";
        }

        deviceExistDuoValidator.validate(duoperson, result);
        if (result.hasErrors()) {
            return "DuoEnrollStep3";
        }

        if (duoperson.getChoosenDevice().equals("landline")) {
            return "DuoPhoneVerify";
        }
    }

    if (nextPage == 5) {
        if (duoperson.getDeviceOS().equals("unknown")) {
            return "DuoPhoneVerify";
        }
    }

    //Check on Activation Status on DUO Mobile App, don't let user move on until confirm the device has been activated
    if (nextPage == 6) {
        String activeStatus;
        activeStatus = duoPhoneService.getObjStatusById(duoperson.getPhone_id());

        if (activeStatus.equals("false")) {
            if (duoperson.getQRcode() == null) {
                String qrCode = duoPhoneService.objActionById(duoperson.getPhone_id(), "qrCode");
                duoperson.setQRcode(qrCode);
            }
            logger.error("2FA Error - " + getIPForLog(request) + " - " + duoperson.getUsername() + "|DeviceID: "
                    + duoperson.getPhone_id() + " NOT ACTIVATED");
            model.put("deviceNotActive", true);
            return "DuoActivationQR";
        }
        model.put("deviceActive", "Yes");
        logger.info("2FA Info - " + getIPForLog(request) + " - " + duoperson.getUsername()
                + " Successfully Registered: PhoneNumber:" + duoperson.getPhonenumber() + " Tablet Name:"
                + duoperson.getTabletName());
        return "DuoEnrollSuccess";
    }

    //Traverse Multipage Form, DuoEnrollStep*.jsp
    return "DuoEnrollStep" + nextPage;
}

From source file:org.motechproject.server.omod.web.controller.EditFacilityController.java

@RequestMapping(value = "/module/motechmodule/editfacility", method = RequestMethod.POST)
public String saveFacility(Facility facility, Errors errors, ModelMap model, SessionStatus status) {

    log.debug("Saving Facility");

    if (isInValidPhoneNumber(facility.getPhoneNumber(), true)) {
        errors.rejectValue("phoneNumber", "motechmodule.phoneNumber.invalid");
    }// w w w  .  java2 s.  co m

    if (isInValidPhoneNumber(facility.getAdditionalPhoneNumber1(), false)) {
        errors.rejectValue("additionalPhoneNumber1", "motechmodule.phoneNumber.invalid");
    }

    if (isInValidPhoneNumber(facility.getAdditionalPhoneNumber2(), false)) {
        errors.rejectValue("additionalPhoneNumber2", "motechmodule.phoneNumber.invalid");
    }

    if (isInValidPhoneNumber(facility.getAdditionalPhoneNumber3(), false)) {
        errors.rejectValue("additionalPhoneNumber3", "motechmodule.phoneNumber.invalid");
    }

    if (!errors.hasErrors()) {
        contextService.getMotechService().saveFacility(facility);
        status.setComplete();
        return "redirect:/module/motechmodule/facility.form";
    }
    return "/module/motechmodule/editfacility";
}

From source file:egovframework.oe1.cms.sys.web.EgovOe1MenuMngController.java

/**
 *   ?//  w  ww .  j  ava  2s .co  m
 * @param EgovOe1MenuMngVO
 * @return /cms/sys/selectMenuMng.do
 * @exception Exception
 */
@RequestMapping(value = "/cms/sys/EgovOe1MenuMngRegist.do")
public String insertMenuMng(@ModelAttribute("MenuMngVO") EgovOe1MenuMngVO menuMngVO,
        BindingResult bindingResult, ModelMap model, SessionStatus status) throws Exception {

    String sLocationUrl = "";

    // Spring Security
    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
        return "/cms/com/EgovLoginUsr";
    }

    // server-side validation
    beanValidator.validate(menuMngVO, bindingResult);
    // bindingResult error
    if (bindingResult.hasErrors()) {
        model.addAttribute("menuMngVO", menuMngVO);
        sLocationUrl = "/cms/sys/EgovMenuMngRegist";
        return sLocationUrl;
    }

    egovOe1MenuMngService.insertMenuMng(menuMngVO);

    sLocationUrl = "redirect:/cms/sys/EgovOe1SelectMenuMngList.do";
    status.setComplete();

    return sLocationUrl;
}

From source file:org.openmrs.module.patientflags.web.FindFlaggedPatientsEmailController.java

/**
 *  Handle the request to create an flag email
 *//*from  w w w  .ja v  a 2s  . c  o  m*/

@RequestMapping(method = RequestMethod.GET)
public ModelAndView processRequest(@ModelAttribute("flag") Flag flag, BindingResult result,
        SessionStatus status) {

    if (result.hasErrors()) {
        throw new APIException("Invalid parameter passed to FindFlaggedPatientsEmailController");
    }

    // get all Patients that trigger the selected Flag
    FlagService flagService = Context.getService(FlagService.class);
    flag = flagService.getFlag(flag.getFlagId());
    Cohort flaggedPatients = flagService.getFlaggedPatients(flag);
    Cohort allPatients = Context.getPatientSetService().getAllPatients();

    // create the model map
    ModelMap model = new ModelMap();
    model.addAttribute("flag", flag);
    model.addAttribute("allPatients", allPatients);
    if (flaggedPatients != null) {
        model.addAttribute("flaggedPatients", flaggedPatients.getMemberIds());
    } else {
        model.addAttribute("flaggedPatients", null);
    }

    // clears the command object from the session
    status.setComplete();

    // displays the query results
    return new ModelAndView("/module/patientflags/findFlaggedPatientsEmailResults", model);
}

From source file:nl.surfnet.coin.teams.control.DetailTeamController.java

private RedirectView doHandleJoinRequest(ModelMap modelMap, HttpServletRequest request, String sessionToken,
        String token, String teamId, SessionStatus status, boolean approve)
        throws UnsupportedEncodingException {
    TokenUtil.checkTokens(sessionToken, token, status);
    String memberId = URLDecoder.decode(request.getParameter(MEMBER_PARAM), UTF_8);

    if (!StringUtils.hasText(teamId) || !StringUtils.hasText(memberId)) {
        status.setComplete();
        modelMap.clear();//w w w . j  a va  2 s.co  m
        throw new RuntimeException("Missing parameters for team or member");
    }

    Team team = grouperTeamService.findTeamById(teamId);
    if (team == null) {
        status.setComplete();
        modelMap.clear();
        throw new RuntimeException("Cannot find team with id " + teamId);
    }

    /**
     * In order to avoid a security exception in OpenSocial we need to ask the
     * question to the teampersonservice as memberId and not as the currently
     * logged-in user
     */
    Person personToAddAsMember = apiClient.getPerson(memberId, null);
    if (personToAddAsMember == null) {
        status.setComplete();
        modelMap.clear();
        throw new RuntimeException("Cannot retrieve Person data for id " + memberId);
    }

    JoinTeamRequest pendingRequest = joinTeamRequestService.findPendingRequest(personToAddAsMember, team);

    Person loggedInPerson = (Person) request.getSession().getAttribute(LoginInterceptor.PERSON_SESSION_KEY);

    // Check if there is an invitation for this approval request
    if (pendingRequest == null) {
        status.setComplete();
        modelMap.clear();
        throw new RuntimeException("Member (" + loggedInPerson.getId() + ") is trying to add a member " + "("
                + personToAddAsMember.getId() + ") without a membership request");
    }

    // Check if the user has the correct privileges
    if (!controllerUtil.hasUserAdministrativePrivileges(loggedInPerson, teamId)) {
        status.setComplete();
        modelMap.clear();
        return new RedirectView("detailteam.shtml?team=" + URLEncoder.encode(teamId, UTF_8)
                + "&mes=error.NotAuthorizedForAction" + "&view=" + ViewUtil.getView(request));
    }

    if (approve) {
        grouperTeamService.addMember(teamId, personToAddAsMember);
        grouperTeamService.addMemberRole(teamId, memberId, Role.Member, teamEnvironment.getGrouperPowerUser());
        AuditLog.log("User {} approved join-team-request of user {} in team {}", loggedInPerson.getId(),
                personToAddAsMember.getId(), teamId);
    }

    // Cleanup request
    joinTeamRequestService.delete(pendingRequest);
    AuditLog.log("Deleted join-team-request for user {} in team {}", pendingRequest.getPersonId(), teamId);

    Locale locale = localeResolver.resolveLocale(request);
    if (approve) {
        sendAcceptMail(personToAddAsMember, team, locale);
    } else {
        sendDeclineMail(personToAddAsMember, team, locale);
    }

    status.setComplete();
    modelMap.clear();
    return new RedirectView(
            "detailteam.shtml?team=" + URLEncoder.encode(teamId, UTF_8) + "&view=" + ViewUtil.getView(request));
}

From source file:org.openmrs.module.report.web.controller.report.ReportController.java

@RequestMapping(method = RequestMethod.POST)
public String onSubmit(@ModelAttribute("report") BirtReport report, BindingResult bindingResult,
        HttpServletRequest request, SessionStatus status) {
    new BirtReportValidator().validate(report, bindingResult);
    if (bindingResult.hasErrors()) {
        return "/module/report/report/report";
    } else {// w ww . j a v a  2s . c o m
        BirtReportService birtReportService = Context.getService(BirtReportService.class);
        if (report.getId() != null && report.getId().intValue() > 0) {
            BirtReport reportCurrent = birtReportService.getBirtReportById(report.getId());
            if (reportCurrent != null && CollectionUtils.isNotEmpty(reportCurrent.getReportTypes())) {
                report.setReportTypes(reportCurrent.getReportTypes());
                report.setReportRoles(reportCurrent.getReportRoles());
            }
        }
        report.setCreatedBy(Context.getAuthenticatedUser().getGivenName());
        report.setCreatedOn(new Date());
        birtReportService.saveReport(report);
        status.setComplete();
        return "redirect:/module/report/reportList.form";
    }
}

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

@RequestMapping(value = "/department/{dept}/mft/import", method = RequestMethod.POST)
public String importScoreReport(@ModelAttribute("importer") MFTScoreImporter importer,
        @PathVariable String dept, @RequestParam("_page") int currentPage, HttpServletRequest request,
        BindingResult result, SessionStatus sessionStatus, ModelMap models) {
    int targetPage = WebUtils.getTargetPage(request, "_target", currentPage);

    if (targetPage == 0) {
        importer.clear();//from www .  j av a  2 s.co  m
        return "mft/import0";
    }

    if (targetPage == 1) {
        importerValidator.validate(importer, result);
        if (result.hasErrors())
            return "mft/import0";

        importer.setDepartment(departmentDao.getDepartment(dept));
        mftScoreParser.parse(importer);
        return "mft/import1";
    }

    for (MFTScore score : importer.getScores())
        mftScoreDao.saveScore(score);

    String date = (new SimpleDateFormat("yyyy-MM-dd")).format(importer.getDate());
    logger.info(SecurityUtils.getUser().getUsername() + " imported " + importer.getScores().size()
            + " mft scores for [" + dept + "," + date + "].");

    sessionStatus.setComplete();
    return "redirect:/department/" + dept + "/mft/score?date=" + date;
}