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:com.iana.dver.controller.RegistrationController.java

@RequestMapping(method = RequestMethod.POST)
public String completeDverRegistration(HttpServletRequest request, HttpServletResponse response,
        final RedirectAttributes redirectAttributes,
        @ModelAttribute("registrationVO") DverRegistrationVO registrationVO, BindingResult result,
        SessionStatus status, @RequestParam("_page") int currentPage, Model model)
        throws IOException, DocumentException, AddressException {

    logger.info("Complete Registration Process....");

    try {//from www  .  ja va 2s .co  m
        Map<Integer, String> registerationPages = new HashMap<Integer, String>();
        request.getSession().getAttribute("registrationVO");
        registerationPages.put(0, "step1");
        registerationPages.put(1, "step2");
        registerationPages.put(2, "step3");
        if (request.getParameter("_cancel") != null) {
            registrationVO = DverRegistrationVO.resetOrPrepareNew();
            redirectAttributes.addFlashAttribute("error", "DVER Registration Cancelled by User.");
            return "redirect:/login";
        } else if (request.getParameter("_finish") != null) {
            this.registrationValidator.validate(registrationVO, result);
            if (!result.hasErrors()) {
                String country = this.countries().get(registrationVO.getDverUserVO().getCountryId());
                registrationVO.getDverUserVO().setCountry(country);
                DverUsers dverUser = dverRegistrationService.saveRegistrationDetails(registrationVO);
                if (dverUser != null) {
                    sendRegDetailEmail(registrationVO.getDverUserVO(), registrationVO.getDverUserLoginVO(),
                            registrationVO.getDverConfigVO());
                }
                redirectAttributes.addFlashAttribute("successMsg", "DVER Registration completed successfully.");
                status.setComplete();
                return "redirect:/login";
            } else {
                return registerationPages.get(currentPage);
            }
        } else {
            int targetPage = WebUtils.getTargetPage(request, "_target", currentPage);

            if (targetPage > currentPage) {
                switch (currentPage) {
                case 0:
                    this.registrationValidator.validateStep1(registrationVO.getDverUserVO(), result);
                    break;
                case 1:
                    this.registrationValidator.validateStep2(registrationVO.getDverUserLoginVO(), result);
                    break;
                case 2:
                    this.registrationValidator.validateStep3(registrationVO.getDverConfigVO(), result);
                    break;
                }

                if (result.hasErrors()) {
                    return registerationPages.get(currentPage);
                } else {
                    if (targetPage == 2) {
                        logger.info("copying the values from First Screen.. :-P");
                        DverConfigVO configVO = new DverConfigVO();
                        configVO.setFirstName(registrationVO.getDverUserVO().getFirstName());
                        configVO.setLastName(registrationVO.getDverUserVO().getLastName());
                        configVO.setEmail(registrationVO.getDverUserVO().getEmail());
                        configVO.setTitle(registrationVO.getDverUserVO().getTitle());
                        configVO.setPhone(registrationVO.getDverUserVO().getPhone());
                        configVO.setFax(registrationVO.getDverUserVO().getFax());
                        registrationVO.setDverConfigVO(configVO);
                    }
                    return registerationPages.get(targetPage);
                }

            } else {
                return registerationPages.get(targetPage);
            }
        }
    } catch (Exception ex) {

        DVERUtil.sendExceptionEmails("completeDverRegistration method of RegistrationController \n " + ex);
        logger.error("Error in completeDverRegistration....." + ex);
        return "error";
    }
}

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

@RequestMapping(value = "/section/roster/import", method = RequestMethod.POST)
public String importRoster(@ModelAttribute RosterImporter rosterImporter,
        @RequestParam("_page") int currentPage, HttpServletRequest request, SessionStatus sessionStatus,
        ModelMap models) {/*ww w .ja  v a  2 s.c  om*/
    Map<Integer, String> views = new HashMap<Integer, String>();
    views.put(0, "section/roster/import0");
    views.put(1, "section/roster/import1");
    views.put(2, "section/roster/import2");

    if (request.getParameter("_finish") == null) {
        int targetPage = WebUtils.getTargetPage(request, "_target", currentPage);
        return views.get(targetPage);
    }

    Section section = sectionDao.getSection(rosterImporter.getSection().getId());
    for (ImportedUser importedStudent : rosterImporter.getImportedStudents()) {
        String cin = importedStudent.getCin();
        User student = userDao.getUserByCin(cin);
        if (student == null) {
            student = new User();
            student.setCin(cin);
            student.setLastName(importedStudent.getLastName());
            student.setFirstName(importedStudent.getFirstName());
            student.setMiddleName(importedStudent.getMiddleName());
            student.setUsername(cin);
            String password = passwordEncoder.encodePassword(cin, null);
            student.setPassword(password);
            student.setPrimaryEmail(cin + "@localhost");
            student.setTemporary(true);
            student = userDao.saveUser(student);
            enrollmentDao.saveEnrollment(new Enrollment(section, student));
            importedStudent.setNewAccount(true);
            importedStudent.setNewEnrollment(true);
        } else if (!section.isEnrolled(student)) {
            enrollmentDao.saveEnrollment(new Enrollment(section, student));
            importedStudent.setNewAccount(false);
            importedStudent.setNewEnrollment(true);
        } else {
            importedStudent.setNewAccount(false);
            importedStudent.setNewEnrollment(false);
        }
    }

    models.put("rosterImporter", rosterImporter);

    logger.info(SecurityUtils.getUser() + " imported roster for section " + section.getId());

    sessionStatus.setComplete();
    return views.get(2);
}

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

/**
 * ? ? ?? .//from  ww w.j  a  va  2  s  . c  o  m
 * @param submitVO
 *        ??
 * @param bindingResult
 * @param model
 * @param status
 * @return ?? 
 * @throws Exception
 */
@RequestMapping("/cms/cmm/addSanctionDraftingWriting.do")
public String addSanctionDraftingWriting(final MultipartHttpServletRequest multiRequest,
        @ModelAttribute EgovOe1SanctionSubmitVO submitVO, BindingResult bindingResult, Model model,
        SessionStatus status) throws Exception {

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

    // Server-Side Validation
    beanValidator.validate(submitVO, bindingResult);

    if (bindingResult.hasErrors()) {
        model.addAttribute("sanctionSubmitVO", submitVO);
        return "/cms/sys/egovSanctnDrftWritng";
    }

    // ?  ?ID ?
    List<EgovOe1FileVO> _result = null;
    String _atchFileId = "";
    final Map<String, MultipartFile> files = multiRequest.getFileMap();
    if (!files.isEmpty()) {
        _result = fileUtil.parseFileInf(files, "DSCH_", 0, "", "");
        _atchFileId = fileMngService.insertFileInfs(_result); // ??
        // ??
        // ??
        // ?
        // ID
        // .
    }
    // ? ?ID ..
    submitVO.setAtchFileId(_atchFileId); // ? ID

    log.debug(this.getClass() + " addSanctionDraftingWriting() submitVO : " + submitVO.toString());
    String drftSn = consentService.actionSanctionDrafting(submitVO);

    log.debug(this.getClass() + " addSanctionDraftingWriting drftSn : " + drftSn);

    status.setComplete();

    return "forward:/cms/cmm/inquirySubmitList.do";
}

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

@RequestMapping(method = RequestMethod.POST)
public void submitForm(@ModelAttribute("patient") WebPatient webPatient, Errors errors, ModelMap model,
        SessionStatus status) {

    log.debug("Edit Patient");

    Patient patient = null;//w  w  w.  j  a  v  a 2 s  .  co m
    if (webPatient.getId() != null) {
        patient = registrarBean.getPatientById(webPatient.getId());
        if (patient == null) {
            errors.reject("motechmodule.id.notexist");
        }
    } else {
        errors.reject("motechmodule.id.required");
    }

    Community community = null;
    if (webPatient.getCommunityId() != null) {
        community = registrarBean.getCommunityById(webPatient.getCommunityId());
        if (community == null) {
            errors.rejectValue("communityId", "motechmodule.communityId.notexist");
        }
    }

    Facility facility = registrarBean.getFacilityById(webPatient.getFacility());

    Patient mother = null;
    if (webPatient.getMotherMotechId() != null) {
        mother = openmrsBean.getPatientByMotechId(webPatient.getMotherMotechId().toString());
        if (mother == null) {
            errors.rejectValue("motherMotechId", "motechmodule.motechId.notexist");
        }
    }

    if (webPatient.getPhoneNumber() != null
            && !webPatient.getPhoneNumber().matches(MotechConstants.PHONE_REGEX_PATTERN)) {
        errors.rejectValue("phoneNumber", "motechmodule.phoneNumber.invalid");
    }

    if (!errors.hasErrors()) {
        registrarBean.editPatient(patient, webPatient.getFirstName(), webPatient.getMiddleName(),
                webPatient.getLastName(), webPatient.getPrefName(), webPatient.getBirthDate(),
                webPatient.getBirthDateEst(), webPatient.getSex(), webPatient.getInsured(),
                webPatient.getNhis(), webPatient.getNhisExpDate(), mother, community, webPatient.getAddress(),
                webPatient.getPhoneNumber(), webPatient.getDueDate(), webPatient.getEnroll(),
                webPatient.getConsent(), webPatient.getPhoneType(), webPatient.getMediaType(),
                webPatient.getLanguage(), webPatient.getDayOfWeek(), webPatient.getTimeOfDay(), facility);

        model.addAttribute("successMsg", "motechmodule.Patient.edit.success");
        status.setComplete();
    }

    JSONLocationSerializer.populateJavascriptMaps(model, webPatient.getPreferredLocation());
}

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

@RequestMapping(method = RequestMethod.POST)
public String onSubmit(@ModelAttribute("reportType") BirtReportType reportType, BindingResult bindingResult,
        HttpServletRequest request, SessionStatus status) {
    new BirtReportTypeValidator().validate(reportType, bindingResult);
    if (bindingResult.hasErrors()) {
        return "/module/report/report/reportType";
    } else {/*www  . j  av a2s  . c  o m*/
        BirtReportService birtReportService = Context.getService(BirtReportService.class);
        BirtReportConfig config = ReportConstants.getConfig();
        String tempPath = config.getRealPath();
        if (StringUtils.isBlank(tempPath)) {
            Throwable th = new Throwable("Not exist realpath for save file report!");

        }
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("reportFile");
        if (file != null && file.getBytes() != null && file.isEmpty() == false) {
            long temp = new Date().getTime();
            //String nameReport = org.openmrs.module.report.util.StringUtils.replaceSpecialWithUnderLineCharacter(reportType.getBirtReport().getName());
            //String nameReportType = org.openmrs.module.report.util.StringUtils.replaceSpecialWithUnderLineCharacter(reportType.getName());
            String fileName = reportType.getBirtReport().getId() + "_" + temp + ".rptdesign";
            String reportFilename = tempPath + "/" + fileName;
            reportFilename = reportFilename.replaceAll("//", "/");

            try {
                FileCopyUtils.copy(file.getInputStream(), new FileOutputStream(reportFilename));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            reportType.setPath(fileName);
        } else if (reportType.getId() != null && reportType.getId().intValue() > 0) {
            reportType.setPath(birtReportService.getBirtReportTypeById(reportType.getId()).getPath());
        }

        reportType.setCreatedBy(Context.getAuthenticatedUser().getGivenName());
        reportType.setCreatedOn(new Date());
        birtReportService.saveBirtReportType(reportType);
        status.setComplete();
        return "redirect:/module/report/reportType.form?reportId=" + reportType.getBirtReport().getId();
    }
}

From source file:com.denimgroup.threadfix.webapp.controller.EditDefectTrackerController.java

@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@PathVariable("defectTrackerId") int defectTrackerId,
        @Valid @ModelAttribute DefectTracker defectTracker, BindingResult result, SessionStatus status,
        Model model) {//  w ww  . j  a va 2  s .  c  om

    DefectTracker databaseDefectTracker = null;

    if (defectTracker == null || defectTracker.getName() == null
            || defectTracker.getName().trim().equals("") && !result.hasFieldErrors("name")) {
        result.rejectValue("name", null, null, "This field cannot be blank");
    } else {
        databaseDefectTracker = defectTrackerService.loadDefectTracker(defectTracker.getName().trim());
        if (databaseDefectTracker != null && !databaseDefectTracker.getId().equals(defectTracker.getId())) {
            result.rejectValue("name", "errors.nameTaken");
        } else if (!defectTrackerService.checkUrl(defectTracker, result)) {
            if (!result.hasFieldErrors("url")) {
                result.rejectValue("url", "errors.invalid", new String[] { "URL" }, null);
            } else if (result.getFieldError("url").getDefaultMessage() != null && result.getFieldError("url")
                    .getDefaultMessage().equals(AbstractDefectTracker.INVALID_CERTIFICATE)) {
                model.addAttribute("showKeytoolLink", true);
            }
        }
    }

    if (result.hasErrors()) {
        return "config/defecttrackers/form";
    } else {
        databaseDefectTracker = defectTrackerService.loadDefectTracker(defectTrackerId);
        if (databaseDefectTracker != null && databaseDefectTracker.getDefectTrackerType() != null
                && defectTracker != null && defectTracker.getDefectTrackerType() != null
                && defectTracker.getDefectTrackerType().getId() != null && !defectTracker.getDefectTrackerType()
                        .getId().equals(databaseDefectTracker.getDefectTrackerType().getId())) {
            defectService.deleteByDefectTrackerId(defectTrackerId);
        }

        defectTrackerService.storeDefectTracker(defectTracker);

        String user = SecurityContextHolder.getContext().getAuthentication().getName();
        if (defectTracker != null) {
            log.debug("The DefectTracker " + defectTracker.getName() + " (id=" + defectTracker.getId()
                    + ") has been edited by user " + user);
        }

        status.setComplete();
        return "redirect:/configuration/defecttrackers/" + defectTrackerId;
    }
}

From source file:com.stormpath.tooter.controller.ProfileController.java

@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@ModelAttribute("user") User user, BindingResult result, SessionStatus status,
        HttpSession session, ModelMap model) {

    model.addAttribute("ADMINISTRATOR_URL", administratorGroupURL);
    model.addAttribute("PREMIUM_URL", premiumGroupURL);

    profileValidator.validate(user, result);

    if (!result.hasErrors()) {

        try {/*w  w w .  jav  a 2  s.  com*/

            // For account update, we just retrieve the current account and
            // call Account.save() after setting the modified properties.
            // An account can also be retrieved from the DataStore,
            // like the way we do it to get an Application or Directory object,
            // if the account's Rest URL is known to the application.

            User sessionUser = (User) session.getAttribute("sessionUser");
            Account account = sessionUser.getAccount();
            account.setGivenName(user.getFirstName());
            account.setSurname(user.getLastName());
            account.setEmail(user.getEmail());
            account.setUsername(user.getFirstName().toLowerCase() + user.getLastName().toLowerCase());

            String existingGroupUrl = null;
            if (account.getGroupMemberships().iterator().hasNext()) {
                GroupMembership groupMembership = account.getGroupMemberships().iterator().next();
                existingGroupUrl = groupMembership.getGroup().getHref();
                if (!existingGroupUrl.equals(user.getGroupUrl())) {
                    groupMembership.delete();
                    existingGroupUrl = null;
                }
            }

            if (user.getGroupUrl() != null && !user.getGroupUrl().isEmpty() && existingGroupUrl == null) {
                account.addGroup(stormpath.getDataStore().getResource(user.getGroupUrl(), Group.class));
            }

            account.save();

            user.setAccount(account);
            user.setUserName(sessionUser.getUserName());
            user.setTootList(sessionUser.getTootList());

            model.addAttribute("messageKey", "updated");
            model.addAttribute("user", user);
        } catch (ResourceException re) {
            ObjectError error = new ObjectError("user", re.getMessage());
            result.addError(error);
            re.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

        status.setComplete();
    }
    return "profile";
}

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

/**
 * ? ? ./* w  w  w  . j  a v a  2  s .  c  om*/
 * @param submitVO
 *        ??
 * @param bindingResult
 * @param model
 * @param status
 * @return ?? 
 * @throws Exception
 */
@RequestMapping("/cms/cmm/modifySanctionDraftingWriting.do")
public String modifySanctionDraftingWriting(final MultipartHttpServletRequest multiRequest,
        @ModelAttribute EgovOe1SanctionSubmitVO submitVO, BindingResult bindingResult, Model model,
        SessionStatus status) throws Exception {

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

    // Server-Side Validation
    beanValidator.validate(submitVO, bindingResult);

    if (bindingResult.hasErrors()) {
        model.addAttribute("sanctionSubmitVO", submitVO);
        return "/cms/sys/EgovSanctnDrftUpdt";
    }

    // ??
    String _atchFileId = submitVO.getAtchFileId();

    final Map<String, MultipartFile> files = multiRequest.getFileMap();

    if (!files.isEmpty()) {
        if ("".equals(_atchFileId) || _atchFileId == null) {
            List<EgovOe1FileVO> _result = fileUtil.parseFileInf(files, "", 0, _atchFileId, "");
            _atchFileId = fileMngService.insertFileInfs(_result);
            submitVO.setAtchFileId(_atchFileId);
        } else {
            EgovOe1FileVO fvo = new EgovOe1FileVO();
            fvo.setAtchFileId(_atchFileId);
            int _cnt = fileMngService.getMaxFileSN(fvo);
            List<EgovOe1FileVO> _result = fileUtil.parseFileInf(files, "", _cnt, _atchFileId, "");
            fileMngService.updateFileInfs(_result);
        }
    }

    submitVO.setAtchFileId(_atchFileId);

    submitVO.setDrftSttusCode("1"); // 1 : 
    submitVO.setDeleteYn("N"); // N : (? ??)

    log.debug(this.getClass() + " modifySanctionDraftingWriting() submitVO : " + submitVO);

    consentService.actionSanctionDraftingUpdt(submitVO);

    status.setComplete();
    return "forward:/cms/cmm/inquirySubmitList.do";
}

From source file:de.fhg.fokus.odp.portal.managedatasets.controller.MetaDataController.java

/**
 * Creates the metadata.//  w ww  .j a  va2  s . c om
 * 
 * @param metaData
 *            the meta data
 * @param bindingResult
 *            the binding result
 * @param action
 *            the action
 * @param response
 *            the response
 * @param sessionStatus
 *            the session status
 * @param request
 *            the request
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws PortalException
 *             the portal exception
 * @throws SystemException
 *             the system exception
 * @throws ParseException
 *             the parse exception
 */
@SuppressWarnings("rawtypes")
@ActionMapping(params = "ocAction=metaDataAction")
public void createMetadata(@ModelAttribute("metaData") MetaDataBean metaData, BindingResult bindingResult,
        @RequestParam("action") String action, ActionResponse response, SessionStatus sessionStatus,
        ActionRequest request) throws IOException, PortalException, SystemException, ParseException {

    metaDataValidator.validate(metaData, bindingResult);

    if (bindingResult.hasErrors()) {
        response.setRenderParameter("ocAction", "createMetaDataRender");
        response.setRenderParameter("action", action);
        return;
    }

    Date dateNow = new Date();
    ThemeDisplay td = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    User user = UserLocalServiceUtil.getUserById(td.getUserId());

    metaData.setMaintainer(user.getFullName());
    metaData.setMaintainer_email(user.getEmailAddress());

    if (action.contains("createMetaData")) {
        metaData.setMetadata_created(dateNow);
        ckanGateway.createDataSet(HashMapUtils.metaDataToMap(metaData));
    } else {
        // Restore Linked Data
        MetaDataBean metaDatalinkedData = HashMapUtils
                .mapToMetaData((Map) ckanGateway.getDataSetDetails(metaData.getCkanId()));
        List<Resource> linkedDataList = new ArrayList<Resource>();
        Iterator<Resource> it = metaDatalinkedData.getResources().iterator();
        while (it.hasNext()) {
            Resource resource = it.next();
            if (resource.getFormat().equalsIgnoreCase("RDF")) {
                linkedDataList.add(resource);
            }
        }
        metaData.getResources().addAll(linkedDataList);

        metaData.setDate_updated(dateNow);
        metaData.setMetadata_modified(dateNow);
        ckanGateway.updateDataSet(metaData.getCkanId(), HashMapUtils.metaDataToMap(metaData));
    }

    PortletURL url = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(request),
            "defhgfokusodpportaldataset_WAR_defhgfokusodpportaldatasetportlet",
            Long.valueOf(PropsUtil.get("page.datasets.plid")), PortletRequest.ACTION_PHASE);

    Map newPackage = (Map) ckanGateway.getDataSetDetails(metaData.getName());

    String id = (String) newPackage.get("id");
    url.setParameter("packageId", id);
    url.setParameter("action", "packageDetailsAction");

    sessionStatus.setComplete();
    response.sendRedirect(url.toString());

}

From source file:eu.scidipes.toolkits.pawebapp.web.ItemsController.java

@RequestMapping(value = { "/edit", "/{formID}/edit", "/new" }, method = RequestMethod.POST)
public String saveItem(@ModelAttribute final SaveAction saveAction, @ModelAttribute final Form form,
        final BindingResult result, final SessionStatus status, final RedirectAttributes redirectAttrs,
        @RequestPart(value = "dataHolder", required = false) final MultipartFile dataFile,
        @MatrixVariable(value = "fn", required = false, pathVar = "datasetName") final String formName) {

    formValidator.validate(form, result);
    if (result.hasErrors()) {
        boolean fixErrors = true;

        final List<FieldError> dataHolderErrors = result.getFieldErrors("dataHolder");

        /*/*from w  w w.  j av a  2  s.co  m*/
         * Only ignore errors under very specific conditions, i.e. when there is a single no-file-supplied error and
         * a current file exists
         */
        if (result.getErrorCount() == 1 && dataHolderErrors != null && dataHolderErrors.size() == 1) {

            final FieldError dataHolderError = dataHolderErrors.get(0);
            if (FormValidator.FILE_REQ_ERR_CODE.equals(dataHolderError.getCode())
                    && !form.getDataHolderMetadata().isEmpty() && form.getDataHolderType() == BYTESTREAM) {
                fixErrors = false;
            }

        }

        if (fixErrors) {
            return "datasets/items/edit";
        }
    }

    /* Ensure that the dataHolder field is not overwritten when its an empty upload (i.e. re-save) */
    if (form.getDataHolderType() == BYTESTREAM && dataFile != null && !dataFile.isEmpty()) {
        LOG.debug("incoming dataFile: {}", dataFile);
        form.getDataHolderMetadata().put(FILE_NAME, dataFile.getOriginalFilename());
        form.getDataHolderMetadata().put(FILE_SIZE, String.valueOf(dataFile.getSize()));
        form.getDataHolderMetadata().put(FILE_MIMETYPE, dataFile.getContentType());
    } else if (form.getDataHolderType() == URI && !StringUtils.isEmpty(form.getDataHolder())) {
        LOG.debug("incoming dataHolder: {}", form.getDataHolder());
        form.getDataHolderMetadata().clear();
    }

    final FormsBundleImpl dataset = datasetRepo.findOne(form.getParentBundle().getDatasetName());

    if (saveAction == ADD_NEW) {
        dataset.addForm(form);
    } else {
        dataset.setForm(form);
    }

    final FormsBundle savedDataset = datasetRepo.save(dataset);
    final Form savedForm = savedDataset.getForms().get(savedDataset.getForms().indexOf(form));

    status.setComplete();
    redirectAttrs.addFlashAttribute("msgKey", "items.edit.messages.savesuccess");

    final String formNameMatrixVar = StringUtils.isEmpty(formName) ? "" : ";fn=" + formName;
    return "redirect:/datasets/" + savedDataset.getDatasetName() + formNameMatrixVar + "/items/"
            + savedForm.getFormID() + "/edit";
}