Example usage for org.springframework.web.servlet.view RedirectView RedirectView

List of usage examples for org.springframework.web.servlet.view RedirectView RedirectView

Introduction

In this page you can find the example usage for org.springframework.web.servlet.view RedirectView RedirectView.

Prototype

public RedirectView(String url) 

Source Link

Document

Create a new RedirectView with the given URL.

Usage

From source file:net.sourceforge.subsonic.controller.MusicFolderSettingsController.java

@Override
protected ModelAndView onSubmit(Object comm) throws Exception {
    MusicFolderSettingsCommand command = (MusicFolderSettingsCommand) comm;

    for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) {
        if (musicFolderInfo.isDelete()) {
            settingsService.deleteMusicFolder(musicFolderInfo.getId());
        } else {//from   w  w  w .  j  a  va  2  s  . co m
            MusicFolder musicFolder = musicFolderInfo.toMusicFolder();
            if (musicFolder != null) {
                settingsService.updateMusicFolder(musicFolder);
            }
        }
    }

    MusicFolder newMusicFolder = command.getNewMusicFolder().toMusicFolder();
    if (newMusicFolder != null) {
        settingsService.createMusicFolder(newMusicFolder);
    }

    settingsService.setIndexCreationInterval(Integer.parseInt(command.getInterval()));
    settingsService.setIndexCreationHour(Integer.parseInt(command.getHour()));
    settingsService.setFastCacheEnabled(command.isFastCache());
    settingsService.setOrganizeByFolderStructure(command.isOrganizeByFolderStructure());
    settingsService.save();

    mediaScannerService.schedule();
    return new ModelAndView(new RedirectView(getSuccessView() + ".view?reload"));
}

From source file:com.bsg.pcms.provision.contract.ContractController.java

@RequestMapping(value = "deleteAction")
public ModelAndView deleteAction(ContractDTOEx cde) {
    // rv.setExposeModelAttributes(false);
    ModelAndView mav = new ModelAndView(new RedirectView("list.do"));

    // contract_id 
    int result;//from  ww  w . java  2  s.  c  o m
    try {
        result = contractService.deleteContract(cde);
    } catch (SQLException e) {
        result = 0;
        e.printStackTrace();
    }
    mav.addObject("result", result);

    return mav;
}

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

private static ModelAndView redirectToProfile(User user) throws UnsupportedEncodingException {
    return new ModelAndView(new RedirectView(getNoCacheLinkToProfile(user)));
}

From source file:net.mindengine.oculus.frontend.web.controllers.test.TestEditController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {
    verifyPermissions(request);//from www  .j  av a  2 s  . c o m
    Long id = new Long(request.getParameter("id"));
    User user = getUser(request);
    user.verifyPermission("test_managment");

    Test test = (Test) command;
    test.setId(id);
    testDAO.updateTest(id, test);
    updateTestCustomizationValues(request, test);
    testParametersDAO.saveTestParameters(request, test);

    return new ModelAndView(new RedirectView("../test/edit?id=" + id));
}

From source file:org.openmrs.web.controller.user.PrivilegeListController.java

/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db//w  w w . j  a  va2 s.c  o  m
 *
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    //Locale locale = request.getLocale();
    String view = getFormView();
    if (Context.isAuthenticated()) {
        StringBuilder success = new StringBuilder();
        String error = "";

        MessageSourceAccessor msa = getMessageSourceAccessor();

        String[] privilegeList = request.getParameterValues("privilegeId");
        if (privilegeList != null) {
            UserService us = Context.getUserService();
            String deleted = msa.getMessage("general.deleted");
            String notDeleted = msa.getMessage("Privilege.cannot.delete");
            for (String p : privilegeList) {
                //TODO convenience method deletePrivilege(String) ??
                try {
                    us.purgePrivilege(us.getPrivilege(p));
                    if (!"".equals(success.toString())) {
                        success.append("<br/>");
                    }
                    success.append(p).append(" ").append(deleted);
                } catch (DataIntegrityViolationException e) {
                    error = handlePrivilegeIntegrityException(e, error, notDeleted);
                } catch (APIException e) {
                    error = handlePrivilegeIntegrityException(e, error, notDeleted);
                }
            }
        } else {
            error = msa.getMessage("Privilege.select");
        }

        view = getSuccessView();
        if (!"".equals(success.toString())) {
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString());
        }
        if (!"".equals(error)) {
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error);
        }
    }

    return new ModelAndView(new RedirectView(view));
}

From source file:org.openmrs.web.controller.user.RoleFormController.java

/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db/*  w ww  .  j  a  va2 s.c o m*/
 * 
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    String view = getFormView();

    if (Context.isAuthenticated()) {
        Role role = (Role) obj;
        try {
            Context.getUserService().saveRole(role);
            view = getSuccessView();
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Role.saved");
        } catch (APIException e) {
            errors.reject(e.getMessage());
            return showForm(request, response, errors);
        }
    }

    return new ModelAndView(new RedirectView(view));
}

From source file:fr.hoteia.qalingo.web.mvc.controller.order.OrderController.java

@RequestMapping(value = BoUrls.ORDER_DETAILS_URL, method = RequestMethod.GET)
public ModelAndView orderDetails(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            BoUrls.ORDER_DETAILS.getVelocityPage());

    final String currentOrderCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_ORDER_CODE);
    final Order order = orderService.getOrderById(currentOrderCode);

    if (order != null) {
        initOrderDetailsPage(request, model, modelAndView, order);
    } else {/*from   w w  w  . j  a v  a2 s .c o m*/
        final String url = requestUtil.getLastRequestUrl(request);
        return new ModelAndView(new RedirectView(url));
    }

    return modelAndView;
}

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

@RequestMapping(value = "/doeditteam.shtml", method = RequestMethod.POST)
public RedirectView editTeam(ModelMap modelMap, HttpServletRequest request,
        @ModelAttribute(TokenUtil.TOKENCHECK) String sessionToken, @RequestParam() String token,
        SessionStatus status) throws UnsupportedEncodingException {
    // Check if the token is valid
    TokenUtil.checkTokens(sessionToken, token, status);

    Person person = (Person) request.getSession().getAttribute(LoginInterceptor.PERSON_SESSION_KEY);
    String teamId = request.getParameter("team");
    String teamDescription = request.getParameter("description");

    Team team = getTeam(request);/*from  w  ww  .j  a  va 2s  .c  om*/
    String teamName = team.getName(); // the name does not change on edit

    // Check if a user has the privileges to edit the team
    if (!controllerUtil.hasUserAdminPrivileges(person, team.getId())) {
        throw new RuntimeException("Member (" + person.getId()
                + ") does not have the correct privileges to edit team " + "(" + team.getName() + ")");
    }

    // If viewablilityStatus is set this means that the team should be public
    boolean viewable = StringUtils.hasText(request.getParameter("viewabilityStatus"));

    // Update the team info
    grouperTeamService.updateTeam(teamId, teamName, teamDescription, person.getId());
    grouperTeamService.setVisibilityGroup(teamId, viewable);
    AuditLog.log(
            "User {} edited team details of team {}. Original name, description, viewability: '{}', '{}', {}. New: '{}', '{}', {}.",
            person.getId(), teamId, team.getName(), team.getDescription(), team.isViewable(), teamName,
            teamDescription, viewable);

    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.conceptsearch.web.controller.ConceptNameTagListController.java

/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db/*w w  w.j  a va  2s . com*/
 * 
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    String view = getFormView();
    if (Context.isAuthenticated()) {
        String success = "";
        String error = "";

        MessageSourceAccessor msa = getMessageSourceAccessor();

        String[] conceptNameTagList = request.getParameterValues("conceptNameTagId");
        if (conceptNameTagList != null) {
            ConceptService cs = Context.getConceptService();
            ConceptSearchService css = (ConceptSearchService) Context.getService(ConceptSearchService.class);

            String deleted = msa.getMessage("general.deleted");
            String notDeleted = msa.getMessage("ConceptNameTag.cannot.delete");
            for (String nameTag : conceptNameTagList) {
                try {
                    css.purgeConceptNameTag(cs.getConceptNameTag(Integer.valueOf(nameTag)));
                    if (!success.equals(""))
                        success += "<br/>";
                    success += nameTag + " " + deleted;
                } catch (DataIntegrityViolationException e) {
                    error = handleConceptNameTagIntegrityException(e, error, notDeleted);
                } catch (APIException e) {
                    error = handleConceptNameTagIntegrityException(e, error, notDeleted);
                }
            }
        } else
            error = msa.getMessage("ConceptNameTag.select");

        view = getSuccessView();
        if (!success.equals(""))
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success);
        if (!error.equals(""))
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error);
    }

    return new ModelAndView(new RedirectView(view));
}

From source file:com.rr.generic.ui.importexport.importExportController.java

@RequestMapping(value = "", method = RequestMethod.GET)
public ModelAndView importExport(HttpSession session, RedirectAttributes redirectAttr) throws Exception {

    /* Get a list of completed surveys the logged in user has access to */
    User userDetails = (User) session.getAttribute("userDetails");

    /* Get user permissions */
    userProgramModules modulePermissions = usermanager.getUserModulePermissions(programId, userDetails.getId(),
            moduleId);/*from w  ww . j  a va  2s . c  o  m*/

    if (userDetails.getRoleId() == 2) {
        allowImport = false; //Import is not a feature for this registry
        allowExport = true;
        allowDelete = true;
    } else {
        allowImport = false; //Import is not a feature for this registry
        allowExport = modulePermissions.isAllowExport();
        allowDelete = modulePermissions.isAllowDelete();
    }

    if (allowImport == true) {
        ModelAndView mav = new ModelAndView(new RedirectView("/import-export/import"));
        return mav;

    } else if (allowExport == true) {
        ModelAndView mav = new ModelAndView(new RedirectView("/import-export/export"));
        return mav;

    } else {
        ModelAndView mav = new ModelAndView(new RedirectView("/import-export/export"));
        return mav;
    }

}