List of usage examples for org.springframework.web.servlet.mvc.method.annotation MvcUriComponentsBuilder fromMethodName
public static UriComponentsBuilder fromMethodName(Class<?> controllerType, String methodName, Object... args)
From source file:ch.heigvd.gamification.api.ApplicationsEndpoint.java
@Override @RequestMapping(value = "/{applicationName}", method = RequestMethod.GET) public ResponseEntity<ApplicationDTO> applicationsApplicationNameGet( @ApiParam(value = "applicationName", required = true) @PathVariable("applicationName") String applicationUsername) { Application app = apprepository.findByName(applicationUsername); UriComponents uriComponents = MvcUriComponentsBuilder.fromMethodName(BadgesEndpoint.class, "badgesGet", 1) .build();//w w w. j av a2 s .co m if (app == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } ApplicationDTO dto = toDTO(app, uriComponents); if (dto == null) { return new ResponseEntity<>(dto, HttpStatus.NOT_FOUND); } else { return new ResponseEntity<>(dto, HttpStatus.OK); } }
From source file:ch.heigvd.gamification.api.ApplicationsEndpoint.java
@Override @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<ApplicationDTO>> applicationsGet() { UriComponents uriComponents = MvcUriComponentsBuilder.fromMethodName(BadgesEndpoint.class, "badgesGet", 1) .build();// w w w . j av a 2 s . c o m return new ResponseEntity<>(StreamSupport.stream(apprepository.findAll().spliterator(), true) .map(p -> toDTO(p, uriComponents)).collect(toList()), HttpStatus.OK); }