List of usage examples for org.springframework.web.util UriComponentsBuilder path
@Override
public UriComponentsBuilder path(String path)
From source file:it.scoppelletti.wui.ActivityPanelAction.java
/** * Elenco delle categorie./*from ww w . ja v a 2s .c o m*/ * * @param applList Applicazioni. * @return Collezione. */ private List<String> listCategories(List<String> applList) { String uri; UriComponentsBuilder uriBuilder; ActivityCategoryListResource catgRes; List<String> categoryList, list; Map<String, String> map; map = new HashMap<String, String>(); for (String ctxPath : applList) { uriBuilder = UriComponentsBuilder.fromHttpUrl(myApplMgr.getBaseUrl()); uriBuilder.path(ctxPath).path(ActivityCategoryListResource.PATH); uriBuilder.queryParam(AbstractServerResource.QUERY_LOCALE, getLocale().toString()); uri = uriBuilder.build().toUriString(); catgRes = ClientResource.create(uri, ActivityCategoryListResource.class); try { list = catgRes.listCategories(); } catch (Exception ex) { myLogger.error(String.format("Failed to get %1$s.", uri), ex); continue; } if (list == null) { myLogger.error("Failed to get {}.", uri); continue; } for (String catg : list) { addCategory(map, Strings.trim(catg)); } } categoryList = new ArrayList<String>(map.values()); Collections.sort(categoryList); return categoryList; }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=newSample", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View takeSample(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws Exception { requireProfiler(connectionId, databaseName).newSample(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=stopProfiling", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View stopProfiling(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws Exception { requireProfiler(connectionId, databaseName).stopProfiling(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=startProfiling", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View startProfiling(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws Exception { requireProfiler(connectionId, databaseName).continueProfiling(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:com.sentinel.web.controllers.RegistrationController.java
@RequestMapping(value = "/user", method = RequestMethod.POST) @ResponseBody/*from www . j a v a2 s. com*/ public ResponseEntity<Void> createUser(@RequestBody UserForm accountDto, UriComponentsBuilder ucBuilder) { LOG.debug("Registring new user"); final User registered = createUserAccount(accountDto); if (registered == null) { return new ResponseEntity<Void>(HttpStatus.CONFLICT); } /* if (userService.isUserExist(user)) { System.out.println("A User with name " + user.getUsername() + " already exist"); } */ userService.saveRegisteredUser(registered); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/user/{id}").buildAndExpand(registered.getId()).toUri());//TODO return new ResponseEntity<Void>(headers, HttpStatus.CREATED); }
From source file:cz.muni.fi.dndtroopsweb.controllers.HeroController.java
/** * Removes selected hero from troop/*from w ww. ja v a 2s.co m*/ * * @param id of hero to be removed from troop * @return redirects to list of heroes after deleting hero */ @RequestMapping(value = "/remove/{id}", method = RequestMethod.POST) public String remove(@PathVariable long id, Model model, UriComponentsBuilder uriBuilder, RedirectAttributes redirectAttributes) { HeroDTO hero = heroFacade.getHeroWithId(id); if (hero.getTroop() == null) { redirectAttributes.addFlashAttribute("alert_warning", "Hero \"" + hero.getName() + "\" is not in troop"); return "redirect:" + uriBuilder.path("/hero/details/" + id).toUriString(); } heroFacade.removeTroop(id); log.debug("removeTroop({})", id); redirectAttributes.addFlashAttribute("alert_success", "Hero \"" + hero.getName() + "\" was removed from Troop."); return "redirect:" + uriBuilder.path("/hero/details/" + id).toUriString(); }
From source file:za.ac.cput.project.universalhardwarestorev2.api.ItemApi.java
@RequestMapping(value = "/item/create", method = RequestMethod.POST) public ResponseEntity<Void> createItem(@RequestBody Item item, UriComponentsBuilder ucBuilder) { System.out.println("Creating Item " + item.getName()); // USE THIS IF YOU WANT TO CHECK UNIQUE OBJECT // if (ItemService.isItemExist(Item)) { // System.out.println("A Item with name " + Item.getName() + " already exist"); // return new ResponseEntity<Void>(HttpStatus.CONFLICT); // }/*from ww w . ja va 2 s . com*/ service.save(item); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/item/{id}").buildAndExpand(item.getId()).toUri()); return new ResponseEntity<Void>(headers, HttpStatus.CREATED); }
From source file:cz.muni.fi.mvc.controllers.StewardController.java
/** * Prepares edit form.//w w w .ja v a2 s . co m * * @param id, model * @return JSP page name */ @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public String editSteward(@PathVariable("id") long id, RedirectAttributes redirectAttributes, UriComponentsBuilder uriBuilder, Model model) { UpdateStewardDTO steward = stewardFacade.getUpdateStewardWithId(id); if (steward == null) { redirectAttributes.addFlashAttribute("alert_danger", "Steward " + id + " cannot be updated"); return "redirect:" + uriBuilder.path("/steward/list").toUriString(); } model.addAttribute("steward", steward); return "steward/edit"; }
From source file:cz.fi.muni.pa165.presentation.layer.mvc.controllers.GenreController.java
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) public String delete(@PathVariable long id, Model model, UriComponentsBuilder uriBuilder, RedirectAttributes redirectAttributes) { GenreDTO found = genreFacade.findGenreByID(id); if (found != null) { genreFacade.deleteGenre(id);/*from ww w . j a v a 2s .co m*/ redirectAttributes.addFlashAttribute("alert_success", "Genre with title: " + found.getTitle() + " was deleted."); return "redirect:" + uriBuilder.path("/genre/listAsAdmin").toUriString(); } return "redirect:" + uriBuilder.path("/genre/listAsAdmin").toUriString(); }
From source file:cz.muni.fi.mvc.controllers.DestinationController.java
/** * Deletes a Destination//from w w w .j a v a2s .c om * @param id Destination's id * @param model display data * @return jsp page */ @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) public String delete(@PathVariable long id, Model model, UriComponentsBuilder uriBuilder, RedirectAttributes redirectAttributes) { DestinationDTO destination; try { destination = destinationFacade.getDestinationWithId(id); if (destination == null) { redirectAttributes.addFlashAttribute("alert_danger", "Destination with id: " + id + " does not exist."); return "redirect:" + uriBuilder.path("/destination").toUriString(); } destinationFacade.removeDestination(id); } catch (Exception ex) { redirectAttributes.addFlashAttribute("alert_danger", "Destination with id: " + id + " cannot be deleted."); return "redirect:" + uriBuilder.path("/destination").toUriString(); } redirectAttributes.addFlashAttribute("alert_info", "Destination with id: " + destination.getId() + " was deleted."); return "redirect:" + uriBuilder.path("/destination").toUriString(); }