List of usage examples for org.springframework.web.util UriComponentsBuilder path
@Override
public UriComponentsBuilder path(String path)
From source file:org.wallride.web.support.DefaultModelAttributeInterceptor.java
private String buildAdminLink() { UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentContextPath(); builder.path("/_admin"); return builder.buildAndExpand().toUriString(); }
From source file:puma.application.webapp.users.AuthenticationController.java
@RequestMapping(value = "/user/logout", method = RequestMethod.GET) public RedirectView logout(ModelMap model, HttpSession session, HttpServletRequest request, UriComponentsBuilder builder) { session.invalidate();//from w w w.j av a 2 s . c om String relayState = builder.path("/").build().toString(); try { relayState = URLEncoder.encode(relayState, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return new RedirectView(LOGOUT_URL + "?RelayState=" + relayState); }
From source file:org.wallride.support.PostUtils.java
private String path(UriComponentsBuilder builder, Article article, boolean encode) { Map<String, Object> params = new HashMap<>(); builder.path("/{year}/{month}/{day}/{code}"); params.put("year", String.format("%04d", article.getDate().getYear())); params.put("month", String.format("%02d", article.getDate().getMonth().getValue())); params.put("day", String.format("%02d", article.getDate().getDayOfMonth())); params.put("code", article.getCode()); UriComponents components = builder.buildAndExpand(params); if (encode) { components = components.encode(); }/* w w w . j av a 2s.c om*/ return components.toUriString(); }
From source file:com.cocktail.controller.CocktailController.java
@RequestMapping(value = "/cocktails/cocktail", method = RequestMethod.POST) public ResponseEntity<?> addCocktail(@RequestBody CocktailResource cocktailDTO, UriComponentsBuilder ucBuilder) { Cocktail cocktail = cocktailService.addCocktail(cocktailDTO); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/Cocktails/Cocktail/{id}").buildAndExpand(cocktail.getId()).toUri()); return new ResponseEntity<>(null, headers, HttpStatus.CREATED); }
From source file:org.wallride.web.support.DefaultModelAttributeInterceptor.java
private String buildGuestPath(String currentLanguage, List<String> languages) { UriComponentsBuilder builder = UriComponentsBuilder.fromPath(""); if (languages.size() > 1) { builder.path("/{language}"); }//ww w . j a va 2s . c om return builder.buildAndExpand(currentLanguage).toUriString(); }
From source file:de.otto.mongodb.profiler.web.DatabaseController.java
@RequestMapping(method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE) public View showDatabases(@PathVariable("connectionId") final String connectionId, final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException { final String uri = uriComponentsBuilder.path("/connections/{connectionId}").buildAndExpand(connectionId) .toUriString();//ww w . j a v a 2 s . c o m return new RedirectView(uri); }
From source file:de.tobiasbruns.content.storage.ContentController.java
private Link currentContentSelfLink(UriComponentsBuilder uriBuilder, String path) { return new Link(uriBuilder.path(path).toUriString()).withSelfRel(); }
From source file:com.wavemaker.tools.deployment.tomcat.TomcatManager.java
private String getUrl(String application, Command command) { if (!application.startsWith("/")) { application = "/" + application; }/*from ww w. j av a2 s. c o m*/ UriComponentsBuilder uri = newUriBuilder(); uri.path(this.managerPath); uri.pathSegment(command.toString().toLowerCase()); uri.queryParam("path", application); return uri.build().toUriString(); }
From source file:de.tobiasbruns.content.storage.ContentController.java
@RequestMapping(method = RequestMethod.GET, params = "projection=metadata", produces = "application/json") public @ResponseBody Resource<MetaDatum[]> loadMetadata(HttpServletRequest req, UriComponentsBuilder uriBuilder) { Link selfLink = new Link(uriBuilder.path(getPath(req)).queryParam("projection", "metadata").toUriString()); Collection<MetaDatum> metaData = service.loadMetaData(getPath(req)).getData(); return new Resource<>(metaData.toArray(new MetaDatum[metaData.size()]), selfLink); }
From source file:org.wallride.web.support.DefaultModelAttributeInterceptor.java
private String buildAdminPath(String currentLanguage) { // String contextPath = request.getContextPath(); UriComponentsBuilder builder = UriComponentsBuilder .fromPath(WallRideServletConfiguration.ADMIN_SERVLET_PATH); builder.path("/{language}"); return builder.buildAndExpand(currentLanguage).toUriString(); }