本文整理汇总了Java中org.springframework.hateoas.MediaTypes类的典型用法代码示例。如果您正苦于以下问题:Java MediaTypes类的具体用法?Java MediaTypes怎么用?Java MediaTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaTypes类属于org.springframework.hateoas包,在下文中一共展示了MediaTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRestTemplate
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
protected RestTemplate getRestTemplate() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
converter.setObjectMapper(mapper);
return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
}
示例2: getMessagesSent
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get sent messages")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No user found") })
@GetMapping(value = "/sent", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
List<MessageSentResource> getMessagesSent(
@ApiParam(value = "Search for a phrase")
@RequestParam(value = "q", required = false) final String q
) {
log.info("Called with q {}", q);
return this.messageSearchService.getMessagesSent(this.authorizationService.getUserId(), q)
.stream()
.map(this.messageSentResourceAssembler::toResource)
.collect(Collectors.toList());
}
示例3: getMessagesReceived
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get received messages")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No user found") })
@GetMapping(value = "/received", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
List<MessageReceivedResource> getMessagesReceived(
@ApiParam(value = "Search for a phrase")
@RequestParam(value = "q", required = false) final String q
) {
log.info("Called with q {}", q);
return this.messageSearchService.getMessagesReceived(this.authorizationService.getUserId(), q)
.stream()
.map(this.messageReceivedResourceAssembler::toResource)
.collect(Collectors.toList());
}
示例4: getOtherTitleContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of titles")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/othertitles", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<OtherTitle> getOtherTitleContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<OtherTitle> otherTitleContribution = this.movieContributionSearchService.getOtherTitleContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getOtherTitleContribution(id)
).withSelfRel();
return new ContributionResource<>(otherTitleContribution, self);
}
示例5: getReleaseDateContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of release dates")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/releasedates", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<ReleaseDate> getReleaseDateContribution(
@ApiParam(value = "The contribution ID", required = true) @PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<ReleaseDate> releaseDateContribution = this.movieContributionSearchService.getReleaseDateContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getReleaseDateContribution(id)
).withSelfRel();
return new ContributionResource<>(releaseDateContribution, self);
}
示例6: getStorylineContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of storylines")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/storylines", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<Storyline> getStorylineContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<Storyline> storylineContribution = this.movieContributionSearchService.getStorylineContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getStorylineContribution(id)
).withSelfRel();
return new ContributionResource<>(storylineContribution, self);
}
示例7: getBoxOfficeContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of box offices")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/boxoffices", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<BoxOffice> getBoxOfficeContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<BoxOffice> boxOfficeContribution = this.movieContributionSearchService.getBoxOfficeContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getBoxOfficeContribution(id)
).withSelfRel();
return new ContributionResource<>(boxOfficeContribution, self);
}
示例8: getSiteContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of sites")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/sites", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<Site> getSiteContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<Site> siteContribution = this.movieContributionSearchService.getSiteContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getSiteContribution(id)
).withSelfRel();
return new ContributionResource<>(siteContribution, self);
}
示例9: getCountryContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of countries")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/countries", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<Country> getCountryContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<Country> countryContribution = this.movieContributionSearchService.getCountryContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getCountryContribution(id)
).withSelfRel();
return new ContributionResource<>(countryContribution, self);
}
示例10: getLanguageContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of languages")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/languages", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<Language> getLanguageContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<Language> languageContribution = this.movieContributionSearchService.getLanguageContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getLanguageContribution(id)
).withSelfRel();
return new ContributionResource<>(languageContribution, self);
}
示例11: getGenreContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of genres")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/genres", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<Genre> getGenreContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<Genre> genreContribution = this.movieContributionSearchService.getGenreContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getGenreContribution(id)
).withSelfRel();
return new ContributionResource<>(genreContribution, self);
}
示例12: getReviewContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of reviews")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/reviews", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<Review> getReviewContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<Review> reviewContribution = this.movieContributionSearchService.getReviewContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getReviewContribution(id)
).withSelfRel();
return new ContributionResource<>(reviewContribution, self);
}
示例13: getPhotoContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of photos")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/photos", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<ImageResponse> getPhotoContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<ImageResponse> photoContribution = this.movieContributionSearchService.getPhotoContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getPhotoContribution(id)
).withSelfRel();
return new ContributionResource<>(photoContribution, self);
}
示例14: getPosterContribution
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get the contribution of posters")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No contribution found") })
@GetMapping(value = "/contributions/{id}/posters", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
ContributionResource<ImageResponse> getPosterContribution(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id
) {
log.info("Called with id {}", id);
final Contribution<ImageResponse> posterContribution = this.movieContributionSearchService.getPosterContribution(id);
final Link self = linkTo(
methodOn(MovieContributionRestController.class).getPosterContribution(id)
).withSelfRel();
return new ContributionResource<>(posterContribution, self);
}
示例15: getFriends
import org.springframework.hateoas.MediaTypes; //导入依赖的package包/类
@ApiOperation(value = "Get user friends")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No user found") })
@GetMapping(value = "/{username}/friends", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
List<UserResource> getFriends(
@ApiParam(value = "The user's name", required = true)
@PathVariable("username") final String username
) {
log.info("Called with username {}", username);
final String id = this.userSearchService.getUserByUsername(username).getId();
return this.userSearchService.getFriends(id)
.stream()
.map(this.userResourceAssembler::toResource)
.collect(Collectors.toList());
}