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:org.openmrs.module.sync.web.controller.OverviewController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    log.debug("in processFormSubmission");

    ModelAndView result = new ModelAndView(new RedirectView(getSuccessView()));

    if (!Context.isAuthenticated())
        throw new APIAuthenticationException("Not authenticated!");

    HttpSession httpSession = request.getSession();
    String success = "";
    String error = "";
    MessageSourceAccessor msa = getMessageSourceAccessor();

    String action = ServletRequestUtils.getStringParameter(request, "action", "");

    log.debug("action is " + action);

    if (!success.equals(""))
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success);

    if (!error.equals(""))
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error);

    return result;
}

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

public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {

    // Auto-login if "user" and "password" parameters are given.
    String username = request.getParameter("user");
    String password = request.getParameter("password");
    if (username != null && password != null) {
        username = StringUtil.urlEncode(username);
        password = StringUtil.urlEncode(password);
        return new ModelAndView(new RedirectView("j_acegi_security_check?j_username=" + username
                + "&j_password=" + password + "&_acegi_security_remember_me=checked"));
    }//from  w w  w .  jav  a  2s  .  co  m

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("logout", request.getParameter("logout") != null);
    map.put("error", request.getParameter("error") != null);
    map.put("brand", settingsService.getBrand());
    map.put("loginMessage", settingsService.getLoginMessage());

    User admin = securityService.getUserByName(User.USERNAME_ADMIN);
    if (User.USERNAME_ADMIN.equals(admin.getPassword())) {
        map.put("insecure", true);
    }

    return new ModelAndView("login", "model", map);
}

From source file:de.otto.mongodb.profiler.web.CollectionProfileController.java

@RequestMapping(method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
public View showCollectionProfiles(@PathVariable("connectionId") final String connectionId,
        @PathVariable("databaseName") final String databaseName,
        final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException {

    final String uri = uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}")
            .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString();

    return new RedirectView(uri);
}

From source file:puma.application.webapp.users.AuthenticationController.java

@RequestMapping(value = "/user/login", method = RequestMethod.GET)
public RedirectView login(ModelMap model,
        @RequestParam(value = "RelayState", defaultValue = "") String relayState,
        @RequestParam(value = "Tenant", defaultValue = "") String tenant, HttpSession session,
        UriComponentsBuilder builder) {//from   ww w  .j a v a  2s.  c  o  m
    String targetURI = PUMA_AUTHENTICATION_ENDPOINT;

    // add the RelayState. If none given, use the default.
    if (relayState.isEmpty()) {
        relayState = builder.path("/user/login-callback").build().toString();
    }
    try {
        relayState = URLEncoder.encode(relayState, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    targetURI += "?RelayState=" + relayState;

    // add the Tenant if given
    if (!(tenant == null || tenant.isEmpty())) {
        // TODO get the tenant from the domain if a tenant has a sub-domain?
        targetURI += "&Tenant=" + tenant;
    }

    //      model.addAttribute("output", targetURI);
    //      return "test";

    return new RedirectView(targetURI); // "redirect:..." would always be relative to the current context path, we do not want that...
}

From source file:edu.mayo.xsltserver.controller.AdminController.java

/**
 * upload.//  w  w w  .  j av a2 s  . c om
 *
 * @param request the request
 * @param response the response
 * @return the redirect view
 * @throws Exception the exception
 */
@RequestMapping(value = "/admin/files", method = RequestMethod.POST)
public RedirectView upload(HttpServletRequest request, HttpServletResponse response) throws Exception {

    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    MultipartFile multipartFile = multipartRequest.getFile("file");

    String fileName = multipartFile.getOriginalFilename();
    fileService.store(fileName, multipartFile.getBytes());

    RedirectView view = new RedirectView("../admin");
    view.setExposeModelAttributes(false);

    return view;
}

From source file:net.mindengine.oculus.frontend.web.controllers.user.LoginController.java

@SuppressWarnings("unchecked")
@Override//from w  w  w  . j av  a  2s.  c om
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {
    LoginData loginData = (LoginData) command;

    User user = userDAO.authorizeUser(loginData.getLogin(), loginData.getPassword());
    if (user != null) {
        logger.info("Authorization Allowed for user:[" + user.getId() + "," + user.getEmail() + "]");
        user.updatePermissions(getPermissionList());
        Auth.setUserCookieToResponse(response, user);

        String redirectUrl = "../user/profile-" + user.getLogin();

        ModelAndView mav = new ModelAndView(new RedirectView(redirectUrl));
        return mav;
    } else {
        logger.info("Authorization Denied");
        errors.reject(null, "Wrong credentials");
        Map model = errors.getModel();
        ModelAndView mav = new ModelAndView("login", model);
        mav.addObject("login", loginData);
        mav.addObject("title", "Login");
        return mav;
    }
}

From source file:ru.org.linux.group.GroupController.java

@RequestMapping("/group.jsp")
public ModelAndView topics(@RequestParam("group") int groupId,
        @RequestParam(value = "offset", required = false) Integer offsetObject) throws Exception {
    Group group = groupDao.getGroup(groupId);

    if (offsetObject != null) {
        return new ModelAndView(new RedirectView(group.getUrl() + "?offset=" + offsetObject.toString()));
    } else {//from   w ww  .  j ava  2 s.  co m
        return new ModelAndView(new RedirectView(group.getUrl()));
    }
}

From source file:edu.northwestern.bioinformatics.studycalendar.web.admin.PurgeStudyController.java

@Override
protected ModelAndView onSubmit(Object o) throws Exception {
    PurgeStudyCommand c = (PurgeStudyCommand) o;

    Map<String, Object> model = new HashMap<String, Object>();

    String msg;//from  w  w  w  . j a v  a  2  s. c  om
    if (isNotBlank(c.getStudyAssignedIdentifier())) {
        String identifier = c.getStudyAssignedIdentifier();
        Study toPurge = studyDao.getByAssignedIdentifier(identifier);
        if (toPurge != null) {
            studyService.purge(toPurge);
            msg = "Study " + identifier + " has been successfully purged";
        } else {
            msg = "Study " + identifier + " failed to be purged because it could not be found";
        }
    } else {
        msg = "Please select a study";
    }

    model.put("status", msg);
    logger.debug(msg);

    return new ModelAndView(new RedirectView(getSuccessView()), model);
}

From source file:com.ut.healthelink.controller.adminSysHL7Controller.java

/**
 * The '/create' POST request save all the hl7 custom settings
 *//*  www .j  a v a  2  s .  co  m*/
@RequestMapping(value = "/create", method = RequestMethod.POST)
public ModelAndView saveHL7(@ModelAttribute(value = "HL7Details") mainHL7Details HL7Details,
        RedirectAttributes redirectAttr) throws Exception {

    /* Update the details of the hl7 */
    int hl7Id = sysAdminManager.createHL7(HL7Details);

    redirectAttr.addFlashAttribute("savedStatus", "created");
    ModelAndView mav = new ModelAndView(new RedirectView("details?hl7Id=" + hl7Id));
    return mav;

}