org.springframework.web.servlet.view.RedirectView Java Examples

The following examples show how to use org.springframework.web.servlet.view.RedirectView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminFacultyFormController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute("facultyForm") FacultyForm facultyForm, BindingResult bindingResult){
	model.addAttribute("facultyForm", facultyForm);
	
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	redirectView.setUrl("/smp/admin_add_faculty.html");
	
	List<Tblfaculty> faculty = reportService.getAllFaculty();
	model.addAttribute("faculty", faculty);
	
    references(model);
    
	if(bindingResult.hasErrors()) {
		facultyForm = new FacultyForm();
		model.addAttribute("facultyForm", facultyForm);
		
	} else{
		managementService.addFaculty(facultyForm);
		facultyForm = new FacultyForm();
		model.addAttribute("facultyForm", facultyForm);
		
	}
	return redirectView;
}
 
Example #2
Source File: WechatController.java    From cloud-service with MIT License 6 votes vote down vote up
/**
 * 授权后,微信跳转到此接口
 *
 * @return
 */
@GetMapping(value = "/{app}/back", params = {"code", "state"})
public RedirectView wechatBack(HttpServletRequest request, @PathVariable String app, String code, String state,
                               @RequestParam String toUrl) {
    if (StringUtils.isBlank(code)) {
        throw new IllegalArgumentException("code不能为空");
    }

    if (StringUtils.isBlank(state)) {
        throw new IllegalArgumentException("state不能为空");
    }

    WechatUserInfo wechatUserInfo = wechatService.getWechatUserInfo(app, request, code, state);

    toUrl = wechatService.getToUrl(toUrl, wechatUserInfo);

    return new RedirectView(toUrl);
}
 
Example #3
Source File: AdminController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping("/smp/admin_logout.html")
public RedirectView logout(Model model, HttpServletRequest req){
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	redirectView.setUrl("/smp/admin_login.html");
	long end = 0;
	long start = 0;
	try{
		end = (Long) req.getSession().getAttribute("timeUsed");
		start = (Long) req.getSession().getAttribute("timeStarted");
	}catch(NullPointerException e){
		end = 0;
		start = 0;
	}
	
	long accessTime = (start-end)/1000;
	model.addAttribute("accessTime", accessTime);
	
	return redirectView;
}
 
Example #4
Source File: LoginController.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
 * @Title: top
 * @Description: bootstrap头部菜单请求
 * @param request
 * @return ModelAndView
 * @throws
 */
@RequestMapping(params = "top")
public ModelAndView top(HttpServletRequest request) {
	TSUser user = ResourceUtil.getSessionUserName();
	HttpSession session = ContextHolderUtils.getSession();
	// 登陆者的权限
	if (user.getId() == null) {
		session.removeAttribute(Globals.USER_SESSION);
		return new ModelAndView(
				new RedirectView("loginController.do?login"));
	}
	request.setAttribute("menuMap", getFunctionMap(user));
	List<TSConfig> configs = userService.loadAll(TSConfig.class);
	for (TSConfig tsConfig : configs) {
		request.setAttribute(tsConfig.getCode(), tsConfig.getContents());
	}
	return new ModelAndView("main/bootstrap_top");
}
 
Example #5
Source File: StudentLoginController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm studLoginForm, BindingResult bindingResult){
	model.addAttribute("studLoginForm", studLoginForm);
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	
	if(bindingResult.hasErrors()) {
		studLoginForm = new LoginForm();
		redirectView.setUrl("/smp/stud_login.html");
		model.addAttribute("studLoginForm", studLoginForm);
	} else{
		Login login = new Login();
		login.setUserName(studLoginForm.getUsername());
		login.setPassWord(studLoginForm.getPassword());
		if(loginService.isStudentUser(login.getUserName(), login.getPassWord())){
			redirectView.setUrl("/smp/stud_enroll.html");
			model.addAttribute("studId", reportService.getStudentId(login.getUserName()).getStudentId());
		}else{
			studLoginForm = new LoginForm();
			redirectView.setUrl("/smp/stud_login.html");
		}
	}
	return redirectView;
}
 
Example #6
Source File: AdminCourseFormController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute("courseForm") CourseForm courseForm, BindingResult bindingResult){
	model.addAttribute("courseForm", courseForm);
	
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	redirectView.setUrl("/smp/admin_add_course.html");
	
	List<Tblcourses> courses = reportService.getAllCourses();
	model.addAttribute("courses", courses);
	
    references(model);
    
	if(bindingResult.hasErrors()) {
		courseForm =  new CourseForm();
		model.addAttribute("courseForm", courseForm);
		
	} else{
		managementService.addCourse(courseForm);
		courseForm =  new CourseForm();	
		model.addAttribute("courseForm", courseForm);
		
	}
	return redirectView;
}
 
Example #7
Source File: AdminCategory.java    From fenixedu-cms with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "{slugSite}/{slugCategory}", method = RequestMethod.POST)
public RedirectView editCategory(@PathVariable String slugSite, @PathVariable String slugCategory,
                                 @RequestParam LocalizedString name,
                                 @RequestParam(required = false, defaultValue = "false") boolean privileged) {
    Site s = Site.fromSlug(slugSite);
    Category c = s.categoryForSlug(slugCategory);
    FenixFramework.atomic(()->{
        ensureCanDoThis(s, Permission.LIST_CATEGORIES, Permission.EDIT_CATEGORY);
        if(c.getPrivileged()) {
            ensureCanDoThis(s, Permission.USE_PRIVILEGED_CATEGORY, Permission.EDIT_PRIVILEGED_CATEGORY);
        }
        c.setPrivileged(privileged);
        c.setName(name);
    });
    Signal.emit(Category.SIGNAL_EDITED, new DomainObjectEvent<>(c));
    return new RedirectView("/cms/categories/" + s.getSlug() + "/" + c.getSlug(), true);
}
 
Example #8
Source File: WebController.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
@GetMapping("/pull")
public RedirectView pull(@RequestParam("subscription1") String subscriptionName) {

	Collection<AcknowledgeablePubsubMessage> messages = this.pubSubTemplate.pull(subscriptionName, 10, true);

	if (messages.isEmpty()) {
		return buildStatusView("No messages available for retrieval.");
	}

	RedirectView returnView;
	try {
		ListenableFuture<Void> ackFuture = this.pubSubTemplate.ack(messages);
		ackFuture.get();
		returnView = buildStatusView(String.format("Pulled and acked %s message(s)", messages.size()));
	}
	catch (Exception ex) {
		LOGGER.warn("Acking failed.", ex);
		returnView = buildStatusView("Acking failed");
	}

	return returnView;
}
 
Example #9
Source File: FacultyLoginController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm facultyLoginForm, BindingResult bindingResult){
	model.addAttribute("facultyLoginForm", facultyLoginForm);
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	
	if(bindingResult.hasErrors()) {
		facultyLoginForm = new LoginForm();
		redirectView.setUrl("/smp/faculty_login.html");
		model.addAttribute("facultyLoginForm", facultyLoginForm);
	} else{
		Login login = new Login();
		login.setUserName(facultyLoginForm.getUsername());
		login.setPassWord(facultyLoginForm.getPassword());
		if(loginService.isFacultyUser(login)){
			model.addAttribute("facultyId", reportService.getFacultyId(login.getUserName()).getFacultyId());
			redirectView.setUrl("/smp/faculty_masterlist.html");
		}else{
			facultyLoginForm = new LoginForm();
			redirectView.setUrl("/smp/faculty_login.html");
		}
	}
	return redirectView;
}
 
Example #10
Source File: MultiController.java    From subsonic with GNU General Public License v3.0 6 votes vote down vote up
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"));
        }

        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);
    }
 
Example #11
Source File: AdminFacultyFormController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute("facultyForm") FacultyForm facultyForm, BindingResult bindingResult){
	model.addAttribute("facultyForm", facultyForm);
	
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	redirectView.setUrl("/smp/admin_add_faculty.html");
	
	List<Tblfaculty> faculty = reportService.getAllFaculty();
	model.addAttribute("faculty", faculty);
	
    references(model);
    
	if(bindingResult.hasErrors()) {
		facultyForm = new FacultyForm();
		model.addAttribute("facultyForm", facultyForm);
		
	} else{
		managementService.addFaculty(facultyForm);
		facultyForm = new FacultyForm();
		model.addAttribute("facultyForm", facultyForm);
		
	}
	return redirectView;
}
 
Example #12
Source File: LogoutActionTest.java    From web-sso with Apache License 2.0 6 votes vote down vote up
@Test
public void testLogoutWithCredentialAndService() throws IOException {
	String servce  = "http://app.com/logoutSucess.do";
	
	MockHttpServletRequest request = new MockHttpServletRequest();
	request.setParameter(WebConstants.SERVICE_PARAM_NAME, servce);
	MockHttpServletResponse response = new MockHttpServletResponse();
	HttpSession session = request.getSession();
	CredentialResolver credentialResolver = Mockito.mock(CredentialResolver.class);
	logoutAction.setCredentialResolver(credentialResolver);
	Ki4soService ki4soService = Mockito.mock(Ki4soService.class);
	logoutAction.setKi4soService(ki4soService);
	
	//测试存在cookie,登出后要清除cookie值,但是service参数的值是null的情况。
	request.setCookies(new Cookie(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY, "dddsd"));
	
	ModelAndView mv = logoutAction.logout(request, response,session);
	Assert.assertEquals(1, response.getCookies().length);
	Assert.assertEquals(0, response.getCookies()[0].getMaxAge());
	RedirectView view = (RedirectView) mv.getView();
	Assert.assertEquals(servce, view.getUrl());
}
 
Example #13
Source File: AdminLoginController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm adminLoginForm, BindingResult bindingResult){
	model.addAttribute("adminLoginForm", adminLoginForm);
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	
	if(bindingResult.hasErrors()) {
		adminLoginForm = new LoginForm();
		redirectView.setUrl("/smp/admin_login.html");
		model.addAttribute("adminLoginForm", adminLoginForm);
	} else{
		Login login = new Login();
		login.setUserName(adminLoginForm.getUsername());
		login.setPassWord(adminLoginForm.getPassword());
		if(loginService.isAdminUser(login)){
			redirectView.setUrl("/smp/admin_pending.html");
		}else{
			adminLoginForm = new LoginForm();
			redirectView.setUrl("/smp/admin_login.html");
		}
	}
	return redirectView;
}
 
Example #14
Source File: AdminMenu.java    From fenixedu-cms with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "{slugSite}/{slugMenu}/down", method = RequestMethod.POST)
public RedirectView moveMenuDown(Model model, @PathVariable String slugSite, @PathVariable String slugMenu) {
    FenixFramework.atomic(() -> {
        Site site = Site.fromSlug(slugSite);
        ensureCanDoThis(site, Permission.LIST_MENUS, Permission.EDIT_MENU);
        Menu menu = site.menuForSlug(slugMenu);
        if(menu.getPrivileged()) {
            ensureCanDoThis(site, EDIT_PRIVILEGED_MENU,
                    Permission.DELETE_PRIVILEGED_MENU);
        }
        Integer oldOrder = menu.getOrder();
        if(oldOrder<site.getMenusSet().size()) {
            site.getOrderedMenusSet().stream().filter(m -> m.getOrder() == oldOrder + 1).forEach(m -> m.setOrder(oldOrder));
            menu.setOrder(oldOrder + 1);
        }
    });
    return new RedirectView("/cms/menus/" + slugSite, true);
}
 
Example #15
Source File: LoginController.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
 * @Title: top
 * @author gaofeng
 * @Description: shortcut头部菜单请求
 * @param request
 * @return ModelAndView
 * @throws
 */
@RequestMapping(params = "shortcut_top")
public ModelAndView shortcut_top(HttpServletRequest request) {
	TSUser user = ResourceUtil.getSessionUserName();
	HttpSession session = ContextHolderUtils.getSession();
	// 登陆者的权限
	if (user.getId() == null) {
		session.removeAttribute(Globals.USER_SESSION);
		return new ModelAndView(
				new RedirectView("loginController.do?login"));
	}
	request.setAttribute("menuMap", getFunctionMap(user));
	List<TSConfig> configs = userService.loadAll(TSConfig.class);
	for (TSConfig tsConfig : configs) {
		request.setAttribute(tsConfig.getCode(), tsConfig.getContents());
	}
	return new ModelAndView("main/shortcut_top");
}
 
Example #16
Source File: TopicController.java    From forum with MIT License 6 votes vote down vote up
@PostMapping("topic")
public View addAnswer(@RequestParam("content") String content, @RequestParam("code") String code,
                      @RequestParam("id_topic") String id_topic, @RequestParam("id_user") String id_user,
                      HttpServletRequest request) {
    Answer answer = new Answer();
    answer.setContent(content);

    // I know that it can be blank field, but I did it on purpose to find out about Optionals:
    if (Objects.equals(code, ""))
        answer.setCode(null);
    else
        answer.setCode(code);
    answer.setCreatedDate(LocalDateTime.now());
    answer.setUseful(false);
    answer.setTopic(topicRepository.findTopicById(Long.valueOf(id_topic)));
    answer.setUser(userRepository.getUserById(Long.parseLong(id_user)));

    answerRepository.save(answer);
    String contextPath = request.getContextPath();
    return new RedirectView(contextPath + "/topic/" + id_topic);
}
 
Example #17
Source File: ViewControllerBeanDefinitionParser.java    From java-technology-stack with MIT License 6 votes vote down vote up
private RootBeanDefinition getRedirectView(Element element, @Nullable HttpStatus status, @Nullable Object source) {
	RootBeanDefinition redirectView = new RootBeanDefinition(RedirectView.class);
	redirectView.setSource(source);
	redirectView.getConstructorArgumentValues().addIndexedArgumentValue(0, element.getAttribute("redirect-url"));

	if (status != null) {
		redirectView.getPropertyValues().add("statusCode", status);
	}

	if (element.hasAttribute("context-relative")) {
		redirectView.getPropertyValues().add("contextRelative", element.getAttribute("context-relative"));
	}
	else {
		redirectView.getPropertyValues().add("contextRelative", true);
	}

	if (element.hasAttribute("keep-query-params")) {
		redirectView.getPropertyValues().add("propagateQueryParams", element.getAttribute("keep-query-params"));
	}

	return redirectView;
}
 
Example #18
Source File: ServletInvocableHandlerMethodTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void invokeAndHandle_DynamicReturnValue() throws Exception {
	this.argumentResolvers.addResolver(new RequestParamMethodArgumentResolver(null, false));
	this.returnValueHandlers.addHandler(new ViewMethodReturnValueHandler());
	this.returnValueHandlers.addHandler(new ViewNameMethodReturnValueHandler());

	// Invoke without a request parameter (String return value)
	ServletInvocableHandlerMethod handlerMethod = getHandlerMethod(new Handler(), "dynamicReturnValue", String.class);
	handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);

	assertNotNull(this.mavContainer.getView());
	assertEquals(RedirectView.class, this.mavContainer.getView().getClass());

	// Invoke with a request parameter (RedirectView return value)
	this.request.setParameter("param", "value");
	handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);

	assertEquals("view", this.mavContainer.getViewName());
}
 
Example #19
Source File: AdminLoginController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm adminLoginForm, BindingResult bindingResult){
	model.addAttribute("adminLoginForm", adminLoginForm);
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	
	if(bindingResult.hasErrors()) {
		adminLoginForm = new LoginForm();
		redirectView.setUrl("/smp/admin_login.html");
		model.addAttribute("adminLoginForm", adminLoginForm);
	} else{
		Login login = new Login();
		login.setUserName(adminLoginForm.getUsername());
		login.setPassWord(adminLoginForm.getPassword());
		if(loginService.isAdminUser(login)){
			redirectView.setUrl("/smp/admin_pending.html");
		}else{
			adminLoginForm = new LoginForm();
			redirectView.setUrl("/smp/admin_login.html");
		}
	}
	return redirectView;
}
 
Example #20
Source File: NowPlayingController.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
@GetMapping
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

    Player player = playerService.getPlayer(request, response);
    TransferStatus status = statusService.getStreamStatusesForPlayer(player).stream().findFirst()
            .orElseGet(() -> statusService.getInactiveStreamStatusForPlayer(player));

    String url = Optional.ofNullable(status)
            .map(s -> mediaFileService.getMediaFile(s.getFile()))
            .map(current -> mediaFileService.getParentOf(current))
            .filter(dir -> !mediaFileService.isRoot(dir))
            .map(dir -> "main.view?id=" + dir.getId())
            .orElse("home.view");

    return new ModelAndView(new RedirectView(url));
}
 
Example #21
Source File: AdminLoginController.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm adminLoginForm, BindingResult bindingResult){
	model.addAttribute("adminLoginForm", adminLoginForm);
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	
	if(bindingResult.hasErrors()) {
		adminLoginForm = new LoginForm();
		redirectView.setUrl("/smp/admin_login.html");
		model.addAttribute("adminLoginForm", adminLoginForm);
	} else{
		Login login = new Login();
		login.setUserName(adminLoginForm.getUsername());
		login.setPassWord(adminLoginForm.getPassword());
		if(loginService.isAdminUser(login.getUserName(), login.getPassWord())){
			redirectView.setUrl("/smp/admin_pending.html");
		}else{
			adminLoginForm = new LoginForm();
			redirectView.setUrl("/smp/admin_login.html");
		}
	}
	return redirectView;
}
 
Example #22
Source File: ManageAudienceController.java    From line-bot-sdk-java with Apache License 2.0 6 votes vote down vote up
@PostMapping("/manage_audience/add_audience/{audienceGroupId}")
public CompletableFuture<RedirectView> postAddAudience(
        @PathVariable Long audienceGroupId,
        @RequestParam(required = false) String uploadDescription,
        @RequestParam String audiences) {
    List<Audience> audienceList = Arrays.stream(audiences.split("\r?\n"))
                                        .map(it -> it.replaceAll("\\s+", ""))
                                        .filter(it -> it.length() > 0)
                                        .map(Audience::new)
                                        .collect(Collectors.toList());
    AddAudienceToAudienceGroupRequest request = AddAudienceToAudienceGroupRequest
            .builder()
            .audienceGroupId(audienceGroupId)
            .audiences(audienceList)
            .uploadDescription(uploadDescription)
            .build();
    return client.addAudienceToAudienceGroup(request)
                 .thenApply(it -> new RedirectView("/manage_audience/" + audienceGroupId));
}
 
Example #23
Source File: AdminPosts.java    From fenixedu-cms with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "{slugSite}/{slugPost}/delete", method = RequestMethod.POST)
public RedirectView delete(@PathVariable String slugSite, @PathVariable String slugPost) {

    FenixFramework.atomic(() -> {
        Site s = Site.fromSlug(slugSite);
        Post post = s.postForSlug(slugPost);
        ensureCanEditPost(post);
        ensureCanDoThis(s, Permission.DELETE_POSTS);
        if(post.isVisible()) {
            ensureCanDoThis(s, Permission.DELETE_POSTS_PUBLISHED);
        }
        if(!Authenticate.getUser().equals(post.getCreatedBy())) {
            ensureCanDoThis(s, Permission.DELETE_OTHERS_POSTS);
        }
        SiteActivity.deletedPost(post, Site.fromSlug(slugSite), Authenticate.getUser());
        post.archive();
    });
    return new RedirectView("/cms/posts/" + slugSite + "", true);
}
 
Example #24
Source File: AdminThemes.java    From fenixedu-cms with GNU Lesser General Public License v3.0 5 votes vote down vote up
@RequestMapping(value = "{type}/deleteTemplate", method = RequestMethod.POST)
public RedirectView deleteTemplate(@PathVariable(value = "type") String type,
        @RequestParam(value = "type") String templateType) {
    CmsSettings.getInstance().ensureCanManageThemes();
    CMSTheme theme = CMSTheme.forType(type);
    deleteTemplate(templateType, theme);
    return new RedirectView("/cms/themes/" + type + "/see#templates", true);
}
 
Example #25
Source File: GitResource.java    From jhipster-online with Apache License 2.0 5 votes vote down vote up
/**
 * Handles the callback code returned by the OAuth2 authentication.
 */
@GetMapping("/{gitProvider}/callback")
public RedirectView callback(@PathVariable String gitProvider, String code) {
    switch (gitProvider.toLowerCase()) {
        case GITHUB:
            log.debug("GitHub callback received: {}", code);
            return new RedirectView("/github/callback/" + code);
        case GITLAB:
            log.debug("GitHub callback received: {}", code);
            return new RedirectView("/gitlab/callback/" + code);
        default:
            log.error("Unknown git provider : {}", gitProvider);
            return null;
    }
}
 
Example #26
Source File: AdminPagesAdvanced.java    From fenixedu-cms with GNU Lesser General Public License v3.0 5 votes vote down vote up
@RequestMapping(value = "{slugSite}/{slugPage}/delete", method = RequestMethod.POST)
public RedirectView delete(@PathVariable String slugSite, @PathVariable String slugPage) {
    FenixFramework.atomic(() -> {
        Site site = Site.fromSlug(slugSite);
        ensureCanDoThis(site, Permission.SEE_PAGES, Permission.EDIT_PAGE, Permission.DELETE_PAGE, Permission.EDIT_ADVANCED_PAGES);
        site.pageForSlug(slugPage).archive();
    });
    return new RedirectView("/cms/pages/advanced/" + slugSite, true);
}
 
Example #27
Source File: ModelAndViewMethodReturnValueHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void handleRedirectAttributesWithViewReference() throws Exception {
	RedirectAttributesModelMap redirectAttributes  = new RedirectAttributesModelMap();
	mavContainer.setRedirectModel(redirectAttributes);

	ModelAndView mav = new ModelAndView(new RedirectView(), "attrName", "attrValue");
	handler.handleReturnValue(mav, returnParamModelAndView, mavContainer, webRequest);

	assertEquals(RedirectView.class, mavContainer.getView().getClass());
	assertEquals("attrValue", mavContainer.getModel().get("attrName"));
	assertSame("RedirectAttributes should be used if controller redirects", redirectAttributes,
			mavContainer.getModel());
}
 
Example #28
Source File: ModelAndViewMethodReturnValueHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void handleViewInstance() throws Exception {
	ModelAndView mav = new ModelAndView(new RedirectView(), "attrName", "attrValue");
	handler.handleReturnValue(mav, returnParamModelAndView, mavContainer, webRequest);

	assertEquals(RedirectView.class, mavContainer.getView().getClass());
	assertEquals("attrValue", mavContainer.getModel().get("attrName"));
}
 
Example #29
Source File: LoginDecoratorController.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
@RequestMapping(method=RequestMethod.POST)
public RedirectView submitForm(Model model, @ModelAttribute LoginForm loginForm){
	model.addAttribute("loginForm", loginForm);
	RedirectView redirectView = new RedirectView();
	redirectView.setContextRelative(true);
	
				
		if(userService.checkUser(loginForm)){
			redirectView.setUrl("/hms/index.html");
		}else{
			loginForm = new LoginForm();
			redirectView.setUrl("/hms/membership/login.html");			}

	return redirectView;
}
 
Example #30
Source File: ManageAudienceController.java    From line-bot-sdk-java with Apache License 2.0 5 votes vote down vote up
@PostMapping("/manage_audience/update_description/{audienceGroupId}")
public CompletableFuture<RedirectView> postUpdateDescription(@PathVariable Long audienceGroupId,
                                                             @RequestParam String description) {
    UpdateAudienceGroupDescriptionRequest request = UpdateAudienceGroupDescriptionRequest
            .builder()
            .description(description)
            .build();
    return client.updateAudienceGroupDescription(audienceGroupId, request)
                 .thenApply(response -> new RedirectView("/manage_audience/" + audienceGroupId));
}