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:ru.org.linux.spring.AddRemoveBoxesController.java

@RequestMapping(value = "/remove-box.jsp", method = RequestMethod.POST)
public String doRemove(@ModelAttribute("form") EditBoxesForm form, BindingResult result, SessionStatus status,
        HttpServletRequest request) throws Exception {
    Template t = Template.getTemplate(request);

    if (!t.isSessionAuthorized()) {
        throw new AccessViolationException("Not authorized");
    }//from   ww w  .ja v  a 2s .  c  o  m

    new EditBoxesFormValidator().validate(form, result);
    ValidationUtils.rejectIfEmptyOrWhitespace(result, "position", "position.empty",
            "? a ? ?");
    if (result.hasErrors()) {
        return "remove-box";
    }

    if (result.hasErrors()) {
        return "remove-box";
    }

    String objectName = getObjectName(form, request);
    List<String> boxlets = new ArrayList<String>(t.getProf().getList(objectName));

    if (!boxlets.isEmpty()) {
        if (boxlets.size() > form.position) {
            boxlets.remove(form.position.intValue());
            t.getProf().setList(objectName, boxlets);
            t.writeProfile(t.getProfileName());
        }
    }

    status.setComplete();
    return "redirect:/edit-boxes.jsp";
}

From source file:ru.org.linux.spring.AddRemoveBoxesController.java

@RequestMapping(value = "/add-box.jsp", method = RequestMethod.POST)
public String doAdd(@ModelAttribute("form") EditBoxesForm form, BindingResult result, SessionStatus status,
        HttpServletRequest request)//www  . j a  v a 2  s.c o m
        throws IOException, UtilException, AccessViolationException, StorageException {

    new EditBoxesFormValidator().validate(form, result);
    ValidationUtils.rejectIfEmptyOrWhitespace(result, "boxName", "boxName.empty",
            "?  ?");
    if (StringUtils.isNotEmpty(form.getBoxName()) && !DefaultProfile.isBox(form.getBoxName())) {
        result.addError(new FieldError("boxName", "boxName.invalid", "? ?"));
    }
    if (result.hasErrors()) {
        return "add-box";
    }
    Template t = Template.getTemplate(request);

    if (result.hasErrors()) {
        return "add-box";
    }

    if (form.getPosition() == null) {
        form.setPosition(0);
    }

    String objectName = getObjectName(form, request);
    List<String> boxlets = new ArrayList<String>(t.getProf().getList(objectName));

    CollectionUtils.filter(boxlets, DefaultProfile.getBoxPredicate());

    if (boxlets.size() > form.position) {
        boxlets.add(form.position, form.boxName);
    } else {
        boxlets.add(form.boxName);
    }

    t.getProf().setList(objectName, boxlets);
    t.writeProfile(t.getProfileName());

    status.setComplete();
    return "redirect:/edit-boxes.jsp";
}

From source file:ru.org.linux.user.AddRemoveBoxesController.java

@RequestMapping(value = "/remove-box.jsp", method = RequestMethod.POST)
public String doRemove(@ModelAttribute("form") EditBoxesRequest form, BindingResult result,
        SessionStatus status, HttpServletRequest request) throws Exception {
    Template t = Template.getTemplate(request);

    if (!t.isSessionAuthorized()) {
        throw new AccessViolationException("Not authorized");
    }/*ww  w.j a v  a  2 s . co  m*/

    new EditBoxesRequestValidator().validate(form, result);
    ValidationUtils.rejectIfEmptyOrWhitespace(result, "position", "position.empty",
            "? a ? ?");
    if (result.hasErrors()) {
        return "remove-box";
    }

    if (result.hasErrors()) {
        return "remove-box";
    }

    String objectName = getObjectName(form, request);
    List<String> boxlets = new ArrayList<String>(t.getProf().getList(objectName));

    if (!boxlets.isEmpty()) {
        if (boxlets.size() > form.position) {
            boxlets.remove(form.position.intValue());
            t.getProf().setList(objectName, boxlets);
            t.writeProfile(t.getProfileName());
        }
    }

    status.setComplete();
    return "redirect:/edit-boxes.jsp";
}

From source file:ru.org.linux.user.AddRemoveBoxesController.java

@RequestMapping(value = "/add-box.jsp", method = RequestMethod.POST)
public String doAdd(@ModelAttribute("form") EditBoxesRequest form, BindingResult result, SessionStatus status,
        HttpServletRequest request) throws IOException, AccessViolationException, StorageException {

    new EditBoxesRequestValidator().validate(form, result);
    ValidationUtils.rejectIfEmptyOrWhitespace(result, "boxName", "boxName.empty",
            "?  ?");
    if (StringUtils.isNotEmpty(form.getBoxName()) && !DefaultProfile.isBox(form.getBoxName())) {
        result.addError(new FieldError("boxName", "boxName.invalid", "? ?"));
    }/*from   ww  w . j  a v  a2s  .c  om*/
    if (result.hasErrors()) {
        return "add-box";
    }
    Template t = Template.getTemplate(request);

    if (result.hasErrors()) {
        return "add-box";
    }

    if (form.getPosition() == null) {
        form.setPosition(0);
    }

    String objectName = getObjectName(form, request);
    List<String> boxlets = new ArrayList<String>(t.getProf().getList(objectName));

    CollectionUtils.filter(boxlets, DefaultProfile.getBoxPredicate());

    if (boxlets.size() > form.position) {
        boxlets.add(form.position, form.boxName);
    } else {
        boxlets.add(form.boxName);
    }

    t.getProf().setList(objectName, boxlets);
    t.writeProfile(t.getProfileName());

    status.setComplete();
    return "redirect:/edit-boxes.jsp";
}

From source file:ubic.gemma.web.controller.common.description.bibref.PubMedQueryControllerImpl.java

@Override
@RequestMapping(method = RequestMethod.POST)
public ModelAndView onSubmit(HttpServletRequest request, PubMedSearchCommand command, BindingResult result,
        SessionStatus status) {

    // in the future we can search in other ways.
    String accession = command.getAccession();

    if (StringUtils.isBlank(accession)) {

        result.rejectValue("search", "errors.pubmed.noaccession", "Accession was missing");
        return new ModelAndView("bibRefSearch");
    }//from  w  w  w . ja va  2  s .com

    // first see if we already have it in the system.
    BibliographicReference bibRefFound = bibliographicReferenceService.findByExternalId(accession);
    if (bibRefFound != null) {
        request.setAttribute("existsInSystem", Boolean.TRUE);
        this.saveMessage(request, "bibliographicReference.alreadyInSystem", accession, "Already in Gemma");
    } else {
        request.setAttribute("existsInSystem", Boolean.FALSE);
        try {
            bibRefFound = this.pubMedXmlFetcher.retrieveByHTTP(Integer.parseInt(accession));

            if (bibRefFound == null) {
                log.debug(accession + " not found in NCBI");

                result.rejectValue("accession", "bibliographicReference.notfoundInNCBI", "Not found in NCBI");
                return new ModelAndView("bibRefSearch", result.getModel());
            }

            this.saveMessage(request, "bibliographicReference.found", accession, "Found");

        } catch (NumberFormatException e) {
            result.rejectValue("accession", "error.integer", "Not a number");
            return new ModelAndView("bibRefSearch", result.getModel());
        }
    }

    status.setComplete();
    return new ModelAndView("bibRefView").addObject("bibliographicReference", bibRefFound);
}