Example usage for org.springframework.http HttpStatus MOVED_PERMANENTLY

List of usage examples for org.springframework.http HttpStatus MOVED_PERMANENTLY

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus MOVED_PERMANENTLY.

Prototype

HttpStatus MOVED_PERMANENTLY

To view the source code for org.springframework.http HttpStatus MOVED_PERMANENTLY.

Click Source Link

Document

301 Moved Permanently .

Usage

From source file:io.restassured.module.mockmvc.http.RedirectController.java

@RequestMapping(value = "/redirect", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<String> redirect() {
    return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY)
            .header("Location", "http://localhost:8080/redirect/1").body("{ \"id\" : 1 }");
}

From source file:org.ow2.proactive.inmemory_keyvalue_store.controller.SwaggerController.java

@RequestMapping("/")
public ModelAndView swagger() {
    RedirectView redirectView = new RedirectView("swagger-ui.html");
    redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    return new ModelAndView(redirectView);
}

From source file:org.zalando.riptide.RedirectTest.java

@Test
public void shouldFollowRedirect() {
    final URI originalUrl = URI.create("https://api.example.com/accounts/123");
    final URI redirectUrl = URI.create("https://api.example.org/accounts/123");

    server.expect(requestTo(originalUrl))
            .andRespond(withStatus(HttpStatus.MOVED_PERMANENTLY).location(redirectUrl));

    server.expect(requestTo(redirectUrl))
            .andRespond(withSuccess().contentType(MediaType.TEXT_PLAIN).body("123"));

    assertThat(send(originalUrl), is("123"));
}

From source file:ru.mystamps.web.controller.AccountController.java

@GetMapping(Url.ACTIVATE_ACCOUNT_PAGE_WITH_KEY)
public View showActivationFormWithKey(@PathVariable("key") String activationKey,
        RedirectAttributes redirectAttributes) {

    redirectAttributes.addAttribute("key", activationKey);

    RedirectView view = new RedirectView();
    view.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    view.setUrl(Url.ACTIVATE_ACCOUNT_PAGE);

    return view;//from  w  ww.ja  va2s.  co  m
}

From source file:ru.mystamps.web.controller.CollectionController.java

@GetMapping(Url.INFO_COLLECTION_BY_ID_PAGE)
public View showInfoById(@PathVariable("slug") String slug, HttpServletResponse response) throws IOException {

    if (slug == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }/*from   w  w  w.j  a va 2s  .  com*/

    CollectionInfoDto collection = collectionService.findBySlug(slug);
    if (collection == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }

    RedirectView view = new RedirectView();
    view.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    view.setUrl(Url.INFO_COLLECTION_PAGE);

    return view;
}

From source file:ru.mystamps.web.controller.CategoryController.java

@GetMapping(Url.INFO_CATEGORY_BY_ID_PAGE)
public View showInfoById(@Category @PathVariable("slug") LinkEntityDto country, HttpServletResponse response)
        throws IOException {

    if (country == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }/*from  w  w  w  .j  av  a  2 s.  c o  m*/

    RedirectView view = new RedirectView();
    view.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    view.setUrl(Url.INFO_CATEGORY_PAGE);

    return view;
}

From source file:ru.mystamps.web.controller.CountryController.java

/**
 * @author Aleksander Parkhomenko//w w  w .  j av  a 2  s .com
 */
@GetMapping(Url.INFO_COUNTRY_BY_ID_PAGE)
public View showInfoById(@Country @PathVariable("slug") LinkEntityDto country, HttpServletResponse response)
        throws IOException {

    if (country == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }

    RedirectView view = new RedirectView();
    view.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    view.setUrl(Url.INFO_COUNTRY_PAGE);

    return view;
}

From source file:org.smigo.config.WebConfiguration.java

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/garden-planner-comparison").setViewName("garden-planner-comparison.jsp");
    registry.addViewController("/").setViewName("home.jsp");
    registry.addViewController("/help").setViewName("help.jsp");
    registry.addViewController("/robots.txt").setViewName("robots-txt.jsp");
    registry.addViewController("/sitemap.xml").setViewName("sitemap-xml.jsp");
    registry.addRedirectViewController("/garden-planner.html", "/views/garden-planner.html")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/garden/**", "/garden-planner")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/hasta-luego/**", "/welcome-back")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/beta/**", "/").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/accept-termsofservice/**", "/accept-terms-of-service")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/signup/**", "/register").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/_=_", "/garden-planner").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/wall/{username}/**", "/gardener/{username}")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/tos.html", "/static/terms-of-service.html")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addStatusController("/static/terms-of-service.html", HttpStatus.GONE);
    registry.addStatusController("/listspecies", HttpStatus.GONE);
    registry.addStatusController("/update-species", HttpStatus.GONE);
    registry.addStatusController("/rest/species/search", HttpStatus.GONE);
    registry.addStatusController("/addyear/**", HttpStatus.GONE);
    registry.addStatusController("/deletespecies/**", HttpStatus.GONE);
    registry.addStatusController("/species/**", HttpStatus.GONE);
    registry.addStatusController("/rule/**", HttpStatus.GONE);
    registry.addStatusController("**/*.php", HttpStatus.NOT_FOUND);
    registry.addStatusController("cgi-bin/**", HttpStatus.NOT_FOUND);
    registry.addStatusController("**/*.cgi", HttpStatus.NOT_FOUND);
    registry.addStatusController("/wp/", HttpStatus.NOT_FOUND);
    registry.addStatusController("/wordpress/", HttpStatus.NOT_FOUND);
    registry.addStatusController("/HNAP1/", HttpStatus.NOT_FOUND);
    registry.addStatusController("/blog/robots.txt", HttpStatus.NOT_FOUND);
    registry.addStatusController("/apple-touch-icon-precomposed.png", HttpStatus.NOT_FOUND);
    registry.addStatusController("/apple-touch-icon.png", HttpStatus.NOT_FOUND);
}

From source file:ru.mystamps.web.controller.SeriesController.java

@GetMapping(Url.ADD_SERIES_WITH_CATEGORY_PAGE)
public View showFormWithCategory(@PathVariable("slug") String category, RedirectAttributes redirectAttributes) {

    redirectAttributes.addAttribute("category", category);

    RedirectView view = new RedirectView();
    view.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    view.setUrl(Url.ADD_SERIES_PAGE);/*from ww  w  .  j av  a  2s . c  om*/

    return view;
}

From source file:com.gooddata.gdc.DataStoreService.java

/**
 * Delete given path from datastore.//  w  ww .  ja  v  a 2  s  .  co  m
 * @param path path to delete
 * @throws com.gooddata.gdc.DataStoreException in case delete failed
 */
public void delete(String path) {
    notEmpty(path, "path");
    final URI uri = getUri(path);
    try {
        final ResponseEntity result = restTemplate.exchange(uri, HttpMethod.DELETE,
                org.springframework.http.HttpEntity.EMPTY, Void.class);

        // in case we get redirect (i.e. when we want to delete collection) we will follow redirect to the new location
        if (HttpStatus.MOVED_PERMANENTLY.equals(result.getStatusCode())) {
            restTemplate.exchange(result.getHeaders().getLocation(), HttpMethod.DELETE,
                    org.springframework.http.HttpEntity.EMPTY, Void.class);
        }
    } catch (RestClientException e) {
        throw new DataStoreException("Unable to delete " + uri, e);
    }
}