Example usage for org.springframework.web.util UriComponentsBuilder path

List of usage examples for org.springframework.web.util UriComponentsBuilder path

Introduction

In this page you can find the example usage for org.springframework.web.util UriComponentsBuilder path.

Prototype

@Override
public UriComponentsBuilder path(String path) 

Source Link

Document

Append the given path to the existing path of this builder.

Usage

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:cz.muni.pa165.carparkapp.web.AdminController.java

@RequestMapping(value = "branch/delete/{id}", method = RequestMethod.POST)
public String delete(@PathVariable int id, RedirectAttributes redirectAttributes, Locale locale,
        UriComponentsBuilder uriBuilder) {
    log.debug("delete({})", id);
    BranchDTO branch = branchService.findBranch(id);
    branchService.deleteBranch(branch);/*www.ja  v a  2 s  .co  m*/
    redirectAttributes.addFlashAttribute("message", messageSource.getMessage("addBranch.delete.mess",
            new Object[] { branch.getCompanyNumber() }, locale));
    return "redirect:" + uriBuilder.path("/admin/branch/addBranch").build();
}

From source file:it.scoppelletti.wui.ActivityPanelAction.java

/**
 * Elenco delle attività./*from  w w w . ja  v  a2  s .com*/
 * 
 * @param  applList Applicazioni.
 * @return          Collezione.
 */
private List<Activity> listActivities(List<String> applList) {
    String uri;
    UriComponentsBuilder uriBuilder;
    ActivityListResource activityRes;
    List<Activity> activityList, list;

    activityList = new ArrayList<Activity>();
    for (String ctxPath : applList) {
        uriBuilder = UriComponentsBuilder.fromHttpUrl(myApplMgr.getBaseUrl());
        uriBuilder.path(ctxPath).path(ActivityListResource.PATH);
        uriBuilder.queryParam(AbstractServerResource.QUERY_LOCALE, getLocale().toString());
        if (!Strings.isNullOrEmpty(myCatgFilter)) {
            uriBuilder.queryParam(ActivityListResource.QUERY_CATEGORY, myCatgFilter);
        }

        uri = uriBuilder.build().toUriString();
        activityRes = ClientResource.create(uri, ActivityListResource.class);
        try {
            list = activityRes.listActivities();
        } 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;
        }

        activityList.addAll(list);
    }

    Collections.sort(activityList, new ActivityComparator());

    return activityList;
}

From source file:cz.muni.fi.pa165.mvc.controllers.PlayerController.java

@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
public String delete(@PathVariable long id, Model model, UriComponentsBuilder uriBuilder,
        RedirectAttributes redirectAttributes) {
    PlayerDTO player = playerFacade.findById(id);
    playerFacade.deletePlayer(id);/*from  w  w  w . j a v a  2 s  .c  om*/
    log.debug("delete({})", id);
    redirectAttributes.addFlashAttribute("alert_success", "Player \"" + player.toString() + "\" was deleted.");
    return "redirect:" + uriBuilder.path("/player/list").toUriString();
}

From source file:org.cloudfoundry.identity.client.UaaContextFactory.java

/**
 * Returns the URI/*from w  w w. j  av a2 s .  c  o m*/
 * @return
 */
public URI getTokenUri() {
    UriComponentsBuilder tokenURI = UriComponentsBuilder.newInstance();
    tokenURI.uri(uaaURI);
    tokenURI.path(tokenPath);
    return tokenURI.build().toUri();
}

From source file:rest.DependenciaRestController.java

@RequestMapping(value = "/dependencia/", method = RequestMethod.POST)
public ResponseEntity<Void> createDependencia(@RequestBody DependenciaBean dependencia,
        UriComponentsBuilder ucBuilder) {
    System.out.println("Registrar una Dependencia");
    if (dependenciaService.isDependenciaExist(dependencia)) {
        System.out.println("La dependencia con Nombre " + dependencia.getDesDep() + " ya existe.");
        return new ResponseEntity<Void>(HttpStatus.CONFLICT);
    }//from   w w  w  . ja va2  s  .  c om
    dependenciaService.save(dependencia);

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(
            ucBuilder.path("/dependencia/{codDep}").buildAndExpand(dependencia.getCodDep()).toUri());
    return new ResponseEntity<Void>(headers, HttpStatus.CREATED);
}

From source file:cz.muni.pa165.carparkapp.web.LoansController.java

@RequestMapping(value = "/return/{id}", method = RequestMethod.POST)
public String update(@PathVariable int id, UriComponentsBuilder uriBuilder,
        RedirectAttributes redirectAttributes, Locale locale) {
    LoanDTO loan = loanService.getLoanById(id);
    log.debug("update(locale={}, loan={})", locale, loan);
    Date date = new Date();
    loan.setEndDate(date);//from w  w w .  j  a v  a  2 s  .co  m
    loanService.updateLoan(loan);
    redirectAttributes.addFlashAttribute("message",
            messageSource.getMessage("loan.returned", new Object[] { loan.getCar().getId() }, locale));
    return "redirect:" + uriBuilder.path("/loans").build();
}

From source file:cz.muni.fi.dndtroopsweb.controllers.TroopController.java

/**
 * Deletes troop from database if the troop is empty
 *
 * @param id of troop/*from w  ww.j a v  a  2  s  .  co  m*/
 * @return list of troops after successful removal
 */
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
public String delete(@PathVariable long id, Model model, UriComponentsBuilder uriBuilder,
        RedirectAttributes redirectAttributes) {
    TroopDTO troop = troopFacade.getTroopWithId(id);
    if (troopFacade.getTroopWithId(id).getMembers().isEmpty() == false) {
        redirectAttributes.addFlashAttribute("alert_warning", "Troop \"" + troop.getName() + "\" is not empty");
        return "redirect:" + uriBuilder.path("/troop/list").toUriString();
    }
    troopFacade.deleteTroop(id);
    log.debug("delete({})", id);
    redirectAttributes.addFlashAttribute("alert_success", "Troop \"" + troop.getName() + "\" was deleted.");
    return "redirect:" + uriBuilder.path("/troop/list").toUriString();
}

From source file:org.cloudfoundry.identity.client.UaaContextFactory.java

/**
 * Returns the authorize URI/*from   w  w w .j  a  va  2s.  c o m*/
 * @return the UAA authorization URI
 */
public URI getAuthorizeUri() {
    UriComponentsBuilder authorizationURI = UriComponentsBuilder.newInstance();
    authorizationURI.uri(uaaURI);
    authorizationURI.path(authorizePath);
    return authorizationURI.build().toUri();
}

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

@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=reset", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public View resetProfiles(@PathVariable("connectionId") final String connectionId,
        @PathVariable("databaseName") final String databaseName,
        final UriComponentsBuilder uriComponentsBuilder) throws Exception {

    requireProfiler(connectionId, databaseName).reset();

    return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}")
            .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString());
}