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:csns.web.controller.ForumTopicControllerS.java

@RequestMapping(value = "/department/{dept}/forum/topic/create", method = RequestMethod.POST)
public String create(@ModelAttribute Post post, @PathVariable String dept,
        @RequestParam(value = "file", required = false) MultipartFile[] uploadedFiles, BindingResult result,
        SessionStatus sessionStatus) {
    messageValidator.validate(post, result);
    if (result.hasErrors())
        return "forum/topic/create";

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

    post.setAuthor(user);/*from  www .j  av  a2s. co m*/
    post.setDate(new Date());
    user.incrementNumOfForumPosts();
    Topic topic = post.getTopic();
    topic.addPost(post);
    Forum forum = topic.getForum();
    forum.incrementNumOfTopics();
    forum.incrementNumOfPosts();
    forum.setLastPost(post);
    topic = topicDao.saveTopic(topic);

    subscriptionDao.subscribe(topic, user);

    String subject = "New Topic in CSNS Forum - " + forum.getShortName();
    String vTemplate = "notification.new.forum.topic.vm";
    Map<String, Object> vModels = new HashMap<String, Object>();
    vModels.put("topic", topic);
    vModels.put("dept", dept);
    notificationService.notifiy(forum, subject, vTemplate, vModels, false);

    logger.info(user.getUsername() + " created topic " + topic.getId());

    sessionStatus.setComplete();
    return "redirect:/department/" + dept + "/forum/topic/view?id=" + topic.getId();
}

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

/**
 * ? /? .//from   ww w.jav a 2 s .  com
 * @param submitVO
 *        
 * @param status
 * @return ? 
 * @throws Exception
 */
@RequestMapping("/cms/cmm/deleteSanctionDispatch.do")
public String deleteSanctionDispatch(@ModelAttribute EgovOe1SanctionSubmitVO submitVO, SessionStatus status)
        throws Exception {

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

    log.debug(this.getClass() + " deleteSanctionDispatch() " + submitVO.toString());
    int resultDelete = consentService.updateSanctionConfirmDelete(submitVO);

    log.debug(this.getClass() + " deleteSanctionDispatch() result is " + resultDelete);

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

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

/**
 * ?? /? ./*from   w ww .j  av a  2  s  .  c om*/
 * @param submitVO
 *        ?
 * @param status
 * @return ?? 
 * @throws Exception
 */
@RequestMapping("/cms/cmm/deleteSanctionSubmit.do")
public String deleteSanctionDrafting(@ModelAttribute EgovOe1SanctionSubmitVO submitVO, SessionStatus status)
        throws Exception {

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

    log.debug(this.getClass() + " deleteSanctionDrafting() " + submitVO.toString());

    int resultDelete = consentService.updateSanctionDraftingDelete(submitVO);

    log.debug(this.getClass() + " deleteSanctionDrafting() resultDelete : " + resultDelete);

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

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

/**
 * ? /? .//from w  w  w.  j a  va  2 s  .  c o m
 * @param submitVO
 *        
 * @param status
 * @return ? 
 * @throws Exception
 */
@RequestMapping("/cms/cmm/deleteSanction.do")
public String deleteSanction(@ModelAttribute EgovOe1SanctionSubmitVO submitVO, SessionStatus status)
        throws Exception {

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

    log.debug(this.getClass() + " deleteSanctionDrafting() " + submitVO.toString());

    int resultDelete = consentService.updateSanctionDraftingDelete(submitVO);

    log.debug(this.getClass() + " deleteSanctionDrafting() resultDelete : " + resultDelete);

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

From source file:nl.surfnet.coin.selfservice.control.requests.LinkrequestController.java

private ModelAndView doSubmitConfirm(Map<String, Object> m, AbstractAction abstractAction, BindingResult result,
        InstitutionIdentityProvider selectedIdp, SessionStatus sessionStatus, String errorViewName,
        String successViewName, String thanksTextKey) {
    if (result.hasErrors()) {
        LOG.debug("Errors in data binding, will return to form view: {}", result.getAllErrors());
        return new ModelAndView(errorViewName, m);
    } else {/*from w w w.  j  a  va  2  s.co m*/
        final CoinUser currentUser = SpringSecurity.getCurrentUser();
        String content = abstractAction instanceof LinkRequest ? ((LinkRequest) abstractAction).getNotes()
                : ((Question) abstractAction).getBody();
        Action action = new Action(currentUser.getUid(), currentUser.getEmail(), currentUser.getUsername(),
                abstractAction.getType(), content, selectedIdp.getId(), abstractAction.getServiceProviderId(),
                selectedIdp.getInstitutionId());
        if (abstractAction.getType().equals(JiraTask.Type.QUESTION)) {
            action.setSubject(((Question) abstractAction).getSubject());
        }
        Action createdAction = csa.createAction(action);
        String issueKey = createdAction.getJiraKey();
        m.put("issueKey", issueKey);
        m.put("abstractAction", abstractAction);
        m.put("thanksTextKey", thanksTextKey);
    }
    sessionStatus.setComplete();
    return new ModelAndView(successViewName, m);
}

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

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

    if (formAction != null && formAction.equals(Constants.ACTION_SUBMIT)) {
        schedulesValidator.validate(schedulesEditBean, result);
        if (result.hasErrors()) {
            return Constants.PAGE_EDIT_SCHEDULES;
        } else {// w w w .  j a va2 s  .  c o m
            logger.info("SAVE:" + schedulesEditBean);
            if (schedulesEditBean.getName() != null) {
                hydroponicsDao.saveSwitchName(schedulesEditBean.getNumber(), schedulesEditBean.getName());
            }

            SchedulesEditBean oldSchedule = hydroponicsClientHandler.getSwitch(schedulesEditBean.getNumber());
            if (schedulesEditBean.getMode() != oldSchedule.getMode()
                    || !schedulesEditBean.getSchedules().equals(oldSchedule.getSchedules())) {

                logger.info("Schedules changed.");
                hydroponicsClientHandler.saveSwitch(schedulesEditBean);

            } else if (logger.isLoggable(Level.INFO)) {
                logger.info("Schedules unchanged.");
            }

            status.setComplete();
            return Constants.REDIRECT_MAIN;
        }
    } else if (formAction != null && formAction.equals(Constants.ACTION_CANCEL)) {
        return Constants.REDIRECT_MAIN;
    } else {
        throw new RuntimeException("unknown form action:" + formAction);
    }
}

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

/**
 * Gets the meta data.//from  w w  w .  j a v a2s  . co m
 * 
 * @param value
 *            the value
 * @param pId
 *            the id
 * @param sessionStatus
 *            the session status
 * @param response
 *            the response
 * @param request
 *            the request
 * @return the meta data
 * @throws ParseException
 *             the parse exception
 */
@SuppressWarnings({ "rawtypes" })
@ModelAttribute(value = "metaData")
public MetaDataBean getMetaData(@RequestParam(required = false, value = "ocAction") String value,
        @RequestParam(required = false, value = "packageId") String pId, SessionStatus sessionStatus,
        PortletResponse response, PortletRequest request) throws ParseException {
    MetaDataBean metaData = new MetaDataBean();

    if (value != null && value.equals("editMetaDataRender")) {
        init(request);
        metaData = HashMapUtils.mapToMetaData((Map) ckanGateway.getDataSetDetails(pId));
        List<Resource> toDelete = new ArrayList<Resource>();
        Iterator<Resource> it = metaData.getResources().iterator();
        while (it.hasNext()) {
            Resource resource = it.next();
            if (resource.getFormat().equalsIgnoreCase("RDF")) {
                toDelete.add(resource);
            }
        }
        for (Resource resource : toDelete) {
            metaData.getResources().remove(resource);
        }
    }

    metaData.getResources().add(new Resource());
    metaData.getResources().add(new Resource());
    metaData.getResources().add(new Resource());
    metaData.getResources().add(new Resource());
    metaData.getResources().add(new Resource());
    sessionStatus.setComplete();

    return metaData;
}

From source file:org.parancoe.plugin.configuration.controllers.ConfigurationController.java

@RequestMapping(value = "/{propertyId}/store", method = { RequestMethod.PUT, RequestMethod.POST })
public String store(@ModelAttribute("pluginConfigurationProperty") @Valid Property property,
        BindingResult result, SessionStatus status, HttpServletRequest req) {
    String value = property.getValue();
    if (PropertyType.STRING.equals(property.getType())) {
        if (value != null && value.length() > 255) {
            result.rejectValue("value", "PluginConfiguration_Error_MaxLengthExceeded",
                    new Object[] { Integer.valueOf(255), Integer.valueOf(value.length()) },
                    "You exceeded the max length (255)");
        }/* ww w. j  a va 2  s .  c  om*/
    } else if (PropertyType.INTEGER.equals(property.getType())) {
        try {
            property.getValueAsInteger();
        } catch (NumberFormatException numberFormatException) {
            result.rejectValue("value", "PluginConfiguration_Error_NotAnInteger", new Object[] { value },
                    "The value must be an integer number.");
        }
    } else if (PropertyType.REAL.equals(property.getType())) {
        try {
            Double.valueOf(value);
        } catch (NumberFormatException numberFormatException) {
            result.rejectValue("value", "PluginConfiguration_Error_NotAReal", new Object[] { value },
                    "The value must be a real number.");
        }
    }
    if (result.hasErrors()) {
        return "plugin/configuration/edit";
    }
    configurationService.store(property);
    FlashHelper.setRedirectNotice(req, "PluginConfiguration_flash_PropertyUpdated");
    status.setComplete();
    return "redirect:..";
}

From source file:org.jasig.portlet.announcements.controller.AdminTopicController.java

/**
 * Saves the Topic that was submitted//from w ww . j  av  a 2s. c  om
 * @param topic
 * @param result
 * @param status
 * @param request
 * @param response
 * @throws PortletException
 */
@RequestMapping(params = "action=addTopic")
public void actionAddTopicForm(@ModelAttribute("topic") Topic topic, BindingResult result, SessionStatus status,
        ActionRequest request, ActionResponse response) throws PortletException {

    if (!UserPermissionChecker.isPortalAdmin(request)) {
        throw new UnauthorizedException("You do not have access to create a topic");
    }

    new TopicValidator().validate(topic, result);
    if (result.hasErrors()) {
        if (log.isDebugEnabled())
            log.debug("Error in form: " + result.toString());
        response.setRenderParameter("action", "addTopic");
        return;
    }

    if (!result.hasErrors() && topic != null) {
        if (log.isDebugEnabled())
            log.debug("No errors in form");

        // no id has been assigned by hibernate, so this must be a new topic
        if (!topic.hasId()) {
            topic.setCreator(request.getRemoteUser());
        } else {
            Long id = topic.getId();
            Topic oldTopic = announcementService.getTopic(id);

            topic.setCreator(oldTopic.getCreator());
            topic.setAdmins(oldTopic.getAdmins());
            topic.setAudience(oldTopic.getAudience());
            topic.setModerators(oldTopic.getModerators());
            topic.setAuthors(oldTopic.getAuthors());
        }
        announcementService.addOrSaveTopic(topic);
        status.setComplete();

        response.setRenderParameter("action", "baseAdmin");
    }

}

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

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

    if (result.hasErrors()) {
        return new ModelAndView("/module/patientflags/findFlaggedPatients");
    }/*from   w ww .j a  v a  2s . c o  m*/

    // 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);
    List<Map<String, Object>> fpl = new ArrayList<Map<String, Object>>();

    if (flaggedPatients != null) {
        Set<Integer> idsFp = flaggedPatients.getMemberIds();
        for (Integer patientId : idsFp) {
            Map<String, Object> mapFp = new HashMap<String, Object>();

            mapFp.put("patientId", patientId);
            mapFp.put("flagMessage", flag.evalMessage(patientId));

            fpl.add(mapFp);
        }
    }

    model.addAttribute("flaggedPatients", fpl);

    model.addAttribute("patientLink", Context.getAdministrationService()
            .getGlobalProperty("patientflags.defaultPatientLink", PatientFlagsConstants.DEFAULT_PATIENT_LINK));

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

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