org.springframework.hateoas.PagedResources Java Examples

The following examples show how to use org.springframework.hateoas.PagedResources. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringDataRestConfiguration.java    From spring-in-action-5-samples with Apache License 2.0 6 votes vote down vote up
@Bean
public ResourceProcessor<PagedResources<Resource<Taco>>>
  tacoProcessor(EntityLinks links) {

  return new ResourceProcessor<PagedResources<Resource<Taco>>>() {
    @Override
    public PagedResources<Resource<Taco>> process(
                        PagedResources<Resource<Taco>> resource) {
      resource.add(
          links.linkFor(Taco.class)
               .slash("recent")
               .withRel("recents"));
      return resource;
    }
  };
}
 
Example #2
Source File: RuntimeAppsController.java    From spring-cloud-dashboard with Apache License 2.0 6 votes vote down vote up
@RequestMapping
public PagedResources<AppStatusResource> list(PagedResourcesAssembler<AppStatus> assembler) {
	List<AppStatus> values = new ArrayList<>();

	for (ApplicationDefinition applicationDefinition : this.applicationDefinitionRepository.findAll()) {
		String key = forApplicationDefinition(applicationDefinition);
		String id = this.deploymentIdRepository.findOne(key);
		if (id != null) {
			values.add(appDeployer.status(id));
		}
	}

	Collections.sort(values, new Comparator<AppStatus>() {
		@Override
		public int compare(AppStatus o1, AppStatus o2) {
			return o1.getDeploymentId().compareTo(o2.getDeploymentId());
		}
	});
	return assembler.toResource(new PageImpl<>(values), statusAssembler);
}
 
Example #3
Source File: RuntimeCommandsTests.java    From spring-cloud-dashboard with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatusWithoutSummary() {
	Collection<AppStatusResource> data = new ArrayList<>();
	data.add(appStatusResource1);
	data.add(appStatusResource2);
	PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
	PagedResources<AppStatusResource> result = new PagedResources<>(data, metadata);
	when(runtimeOperations.status()).thenReturn(result);
	Object[][] expected = new String[][] {
			{"1", "deployed", "2"},
			{"10", "deployed"},
			{"20", "deployed"},
			{"2", "undeployed", "0"}
	};
	TableModel model = runtimeCommands.list(false, null).getModel();
	for (int row = 0; row < expected.length; row++) {
		for (int col = 0; col < expected[row].length; col++) {
			assertThat(String.valueOf(model.getValue(row + 1, col)), Matchers.is(expected[row][col]));
		}
	}
}
 
Example #4
Source File: RuntimeCommandsTests.java    From spring-cloud-dashboard with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatusWithSummary() {
	Collection<AppStatusResource> data = new ArrayList<>();
	data.add(appStatusResource1);
	data.add(appStatusResource2);
	data.add(appStatusResource3);
	PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
	PagedResources<AppStatusResource> result = new PagedResources<>(data, metadata);
	when(runtimeOperations.status()).thenReturn(result);
	Object[][] expected = new String[][] {
			{"1", "deployed", "2"},
			{"2", "undeployed", "0"},
			{"3", "failed", "0"}
	};
	TableModel model = runtimeCommands.list(true, null).getModel();
	for (int row = 0; row < expected.length; row++) {
		for (int col = 0; col < expected[row].length; col++) {
			assertThat(String.valueOf(model.getValue(row + 1, col)), Matchers.is(expected[row][col]));
		}
	}
}
 
Example #5
Source File: AppRegistryCommandsTests.java    From spring-cloud-dashboard with Apache License 2.0 6 votes vote down vote up
@Test
public void importFromLocalResource() {
	String name1 = "foo";
	String type1 = "source";
	String uri1 = "file:///foo";
	String name2 = "bar";
	String type2 = "sink";
	String uri2 = "file:///bar";
	Properties apps = new Properties();
	apps.setProperty(type1 + "." + name1, uri1);
	apps.setProperty(type2 + "." + name2, uri2);
	List<AppRegistrationResource> resources = new ArrayList<>();
	resources.add(new AppRegistrationResource(name1, type1, uri1));
	resources.add(new AppRegistrationResource(name2, type2, uri2));
	PagedResources<AppRegistrationResource> pagedResources = new PagedResources<>(resources,
			new PagedResources.PageMetadata(resources.size(), 1, resources.size(), 1));
	when(appRegistryOperations.registerAll(apps, true)).thenReturn(pagedResources);
	String appsFileUri = "classpath:appRegistryCommandsTests-apps.properties";
	String result = appRegistryCommands.importFromResource(appsFileUri, true, true);
	assertEquals("Successfully registered applications: [source.foo, sink.bar]", result);
}
 
Example #6
Source File: StockProductController.java    From cloudstreetmarket.com with GNU General Public License v3.0 6 votes vote down vote up
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Get overviews of stocks", notes = "Return a page of stock-overviews")
public PagedResources<StockProductResource> getSeveral(
		@Or({
               @Spec(params="cn", path="id", spec=LikeIgnoreCase.class),
               @Spec(params="cn", path="name", spec=LikeIgnoreCase.class)}	
		) @ApiIgnore Specification<StockProduct> spec,
		@ApiParam(value="Exchange ID") @RequestParam(value="exchange", required=false) String exchangeId,
		@ApiParam(value="Index ID") @RequestParam(value="index", required=false) String indexId, 
		@ApiParam(value="Market ID") @RequestParam(value="market", required=false) MarketId marketId, 
           @ApiParam(value="Starts with filter") @RequestParam(value="sw", defaultValue="", required=false) String startWith, 
           @ApiParam(value="Contains filter") @RequestParam(value="cn", defaultValue="", required=false) String contain, 
           @ApiIgnore @PageableDefault(size=10, page=0, sort={"name"}, direction=Direction.ASC) Pageable pageable){
	return pagedAssembler.toResource(stockProductService.gather(indexId, exchangeId, marketId, startWith, spec, pageable), assembler);
}
 
Example #7
Source File: EventController.java    From sos with Apache License 2.0 6 votes vote down vote up
@GetMapping("events")
HttpEntity<Resources<?>> events(PagedResourcesAssembler<AbstractEvent<?>> assembler,
		@SortDefault("publicationDate") Pageable pageable,
		@RequestParam(required = false) @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime since,
		@RequestParam(required = false) String type) {

	QAbstractEvent $ = QAbstractEvent.abstractEvent;

	BooleanBuilder builder = new BooleanBuilder();

	// Apply date
	Optional.ofNullable(since).ifPresent(it -> builder.and($.publicationDate.after(it)));

	// Apply type
	Optional.ofNullable(type) //
			.flatMap(events::findEventTypeByName) //
			.ifPresent(it -> builder.and($.instanceOf(it)));

	Page<AbstractEvent<?>> result = events.findAll(builder, pageable);

	PagedResources<Resource<AbstractEvent<?>>> resource = assembler.toResource(result, event -> toResource(event));
	resource
			.add(links.linkTo(methodOn(EventController.class).events(assembler, pageable, since, type)).withRel("events"));

	return ResponseEntity.ok(resource);
}
 
Example #8
Source File: IndustryController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Get industries", notes = "Return a page of industries")
public PagedResources<IndustryResource> getSeveral(
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"dailyLatestValue"}, direction=Direction.DESC) Pageable pageable){
	return pagedAssembler.toResource(industryService.getAll(pageable), assembler);
}
 
Example #9
Source File: AuthorBlogRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_AUTHOR_BLOGS) 
public HttpEntity<PagedResources<AuthorBlogResource>> getBlogPosts(
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0)Pageable pageable,
        PagedResourcesAssembler<BlogPost> assembler) {
    UserAccount currentUser = getCurrentAuthenticatedAuthor();        
    Page<BlogPost> blogPosts = this.blogPostRepository.findByAuthorIdOrderByCreatedTimeDesc(currentUser.getUserId(), pageable);
    return new ResponseEntity<>(assembler.toResource(blogPosts, authorBlogResourceAssembler), HttpStatus.OK);
}
 
Example #10
Source File: TacoResourcesProcessor.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@Override
public PagedResources<Resource<Taco>> process(PagedResources<Resource<Taco>> resources) {
  resources
    .add(entityLinks
        .linkFor(Taco.class)
        .slash("recent")
        .withRel("recents"));
  
  return resources;
}
 
Example #11
Source File: RuntimeAppsController.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
@RequestMapping
public PagedResources<AppInstanceStatusResource> list(@PathVariable String appId,
		PagedResourcesAssembler<AppInstanceStatus> assembler) {
	AppStatus status = appDeployer.status(appId);
	if (status != null) {
		List<AppInstanceStatus> appInstanceStatuses = new ArrayList<>(status.getInstances().values());
		Collections.sort(appInstanceStatuses, INSTANCE_SORTER);
		return assembler.toResource(new PageImpl<>(appInstanceStatuses), new InstanceAssembler(status));
	}
	throw new ResourceNotFoundException();
}
 
Example #12
Source File: AppRegistryController.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
/**
 * Register all applications listed in a properties file or provided as key/value pairs.
 * @param uri         URI for the properties file
 * @param apps        key/value pairs representing applications, separated by newlines
 * @param force       if {@code true}, overwrites any pre-existing registrations
 */
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public PagedResources<? extends AppRegistrationResource> registerAll(
		PagedResourcesAssembler<AppRegistration> pagedResourcesAssembler,
		@RequestParam(value = "uri", required = false) String uri,
		@RequestParam(value = "apps", required = false) Properties apps,
		@RequestParam(value = "force", defaultValue = "false") boolean force) {
	List<AppRegistration> registrations = new ArrayList<>();
	if (StringUtils.hasText(uri)) {
		registrations.addAll(appRegistry.importAll(force, uri));
	}
	else if (!CollectionUtils.isEmpty(apps)) {
		for (String key : apps.stringPropertyNames()) {
			String[] tokens = key.split("\\.", 2);
			if (tokens.length != 2) {
				throw new IllegalArgumentException("Invalid application key: " + key +
						"; the expected format is <name>.<type>");
			}
			String name = tokens[1];
			String type = tokens[0];
			if (force || null == appRegistry.find(name, type)) {
				try {
					registrations.add(appRegistry.save(name, type, new URI(apps.getProperty(key))));
				}
				catch (URISyntaxException e) {
					throw new IllegalArgumentException(e);
				}
			}
		}
	}
	Collections.sort(registrations);
	return pagedResourcesAssembler.toResource(new PageImpl<>(registrations), assembler);
}
 
Example #13
Source File: AuthorBlogCommentRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_AUTHOR_BLOGS_BLOG_COMMENTS) 
public HttpEntity<PagedResources<AuthorBlogCommentResource>> getCommentPostsByBlogPostId(
        @PathVariable("blogId") String blogId,
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable,
        PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException {
    getBlogByIdAndCheckAuthor(blogId);

    Page<CommentPost> commentPosts = commentPostRepository.findByBlogPostIdOrderByCreatedTimeDesc(blogId, pageable);
    return new ResponseEntity<>(assembler.toResource(commentPosts, authorBlogCommentResourceAssembler), HttpStatus.OK);
}
 
Example #14
Source File: ApplicationDefinitionController.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public PagedResources<ApplicationDefinitionResource> list(Pageable pageable, @RequestParam(required=false) String search,
		PagedResourcesAssembler<ApplicationDefinition> assembler) {
	if (search != null) {
		final SearchPageable searchPageable = new SearchPageable(pageable, search);
		searchPageable.addColumns("DEFINITION_NAME", "DEFINITION");
		return assembler.toResource(definitionRepository.search(searchPageable), applicationAssembler);
	}
	else {
		return assembler.toResource(definitionRepository.findAll(pageable), applicationAssembler);
	}
}
 
Example #15
Source File: LikeActionController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Search for likes", notes = "")
public PagedResources<LikeActionResource> search(
		@ApiParam(value="Action Id: 123") @RequestParam(value="action", required=true) Long actionId,
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"id"}, direction=Direction.DESC) Pageable pageable){
	return pagedAssembler.toResource(likeActionService.findBy(pageable, actionId), assembler);
}
 
Example #16
Source File: ExchangeController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(method=GET)
@ApiOperation(value = "Get list of exchanges", notes = "Returns a page of exchanges")
public PagedResources<ExchangeResource> getSeveral(
		@ApiParam(value="Market code: EUROPE") @RequestParam(value="market") MarketId marketId,
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"name"}, direction=Direction.ASC) Pageable pageable){
	return pagedAssembler.toResource(exchangeService.getSeveral(marketId, pageable), assembler);
}
 
Example #17
Source File: UserCommentRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
/**
 * Returns current user comments with pagination.
 * 
 * @param pageable
 * @param assembler
 * @return
 */
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_USER_COMMENTS)
public HttpEntity<PagedResources<UserCommentResource>> getCurrentUserComments(
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable,
        PagedResourcesAssembler<CommentPost> assembler) {
    UserAccount currentUser = getCurrentAuthenticatedUser();
    Page<CommentPost> comments = 
            commentPostRepository.findByAuthorIdOrderByCreatedTimeDesc(currentUser.getUserId(), pageable);
    
    return new ResponseEntity<>(assembler.toResource(comments, userCommentResourceAssembler), HttpStatus.OK);
}
 
Example #18
Source File: UserRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_USERS)
public HttpEntity<PagedResources<UserResource>> getUserAccounts(
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0, sort="createdTime") Pageable pageable,
        PagedResourcesAssembler<UserAccount> assembler) {
    Page<UserAccount> userAccounts = this.userAccountRepository.findAll(pageable);
    return new ResponseEntity<>(assembler.toResource(userAccounts, userResourceAssembler), HttpStatus.OK);
}
 
Example #19
Source File: IndexController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Get overviews of indices", notes = "Return a page of index-overviews")
public PagedResources<IndexResource> getSeveral(
		@RequestParam(value="exchange", required=false) String exchangeId,
		@RequestParam(value="market", required=false) MarketId marketId,
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"previousClose"}, direction=Direction.DESC) Pageable pageable){
	return pagedAssembler.toResource(indexService.gather(exchangeId, marketId, pageable), assembler);
}
 
Example #20
Source File: MarketController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Get list of markets", notes = "Return a page of markets")
public PagedResources<MarketResource> getSeveral(
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"name"}, direction=Direction.ASC) Pageable pageable){
	return pagedAssembler.toResource(marketService.getAll(pageable), assembler);
}
 
Example #21
Source File: TransactionController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Get the user transactions", notes = "Return the transactions of a user")
public PagedResources<TransactionResource> search(
		@ApiParam(value="User id: WHATEVERKEY") @RequestParam(value="user", required=false) String userName,
		@ApiParam(value="Quote id: 123L") @RequestParam(value="quote:[\\d]+", required=false) Long quoteId,
		@ApiParam(value="Product ticker: FB") @RequestParam(value="ticker", required=false) String ticker, 
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"lastUpdate"}, direction=Direction.DESC) Pageable pageable,
		HttpServletResponse response
		){
	return pagedAssembler.toResource(transactionService.findBy(pageable, userName, quoteId, ticker), assembler);
}
 
Example #22
Source File: WebsiteRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_SITE_PROFILES_USER_COMMENTS)
public HttpEntity<PagedResources<PublicCommentResource>> getUserApprovedCommentPosts(
        @PathVariable("userId") String userId,
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable,
        PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException {
    Page<CommentPost> commentPosts = this.commentPostRepository.findByAuthorIdAndStatusOrderByCreatedTimeDesc(
            userId, CommentStatusType.APPROVED, pageable);
    return new ResponseEntity<>(assembler.toResource(commentPosts, publicCommentResourceAssembler), HttpStatus.OK);
}
 
Example #23
Source File: PublicBlogRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
/**
 * Returns public blog posts with pagination.
 * 
 * @param pageable
 * @param assembler
 * @return
 */
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_SITE_BLOGS)
public HttpEntity<PagedResources<PublicBlogResource>> getPublicBlogPosts(
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0)Pageable pageable,
        PagedResourcesAssembler<BlogPost> assembler) {
    
    Page<BlogPost> blogPosts = this.blogPostRepository.findByPublishedIsTrueOrderByPublishedTimeDesc(pageable);
    return new ResponseEntity<>(assembler.toResource(blogPosts, publicBlogResourceAssembler), HttpStatus.OK);
}
 
Example #24
Source File: PublicBlogRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
/**
 * Returns blog post approved comments with pagination.
 * @param id
 * @param pageable
 * @param assembler
 * @return
 * @throws ResourceNotFoundException
 */
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_SITE_BLOGS_BLOG_COMMENTS)
public HttpEntity<PagedResources<PublicCommentResource>> getBlogApprovedCommentPosts(
        @PathVariable("blogId") String id,
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable,
        PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException {
    getPublishedBlogById(id); //security check
    
    Page<CommentPost> commentPosts = 
            this.commentPostRepository.findByBlogPostIdAndStatusOrderByCreatedTimeAsc(id, CommentStatusType.APPROVED, pageable);
    return new ResponseEntity<>(assembler.toResource(commentPosts, publicCommentResourceAssembler), HttpStatus.OK);
}
 
Example #25
Source File: BlogRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_BLOGS) 
public HttpEntity<PagedResources<BlogResource>> getBlogPosts(
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable,
        PagedResourcesAssembler<BlogPost> assembler) {
    Page<BlogPost> blogPosts = this.blogPostRepository.findAll(pageable);
    return new ResponseEntity<>(assembler.toResource(blogPosts, blogResourceAssembler), HttpStatus.OK);
}
 
Example #26
Source File: BlogRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_BLOGS_BLOG_COMMENTS) 
public HttpEntity<PagedResources<CommentResource>> getCommentPostsByBlogPostId(
        @PathVariable("blogId") String blogId,
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable,
        PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException {
    Page<CommentPost> commentPosts = commentPostRepository.findByBlogPostIdOrderByCreatedTimeDesc(blogId, pageable);
    return new ResponseEntity<>(assembler.toResource(commentPosts, commentResourceAssembler), HttpStatus.OK);
}
 
Example #27
Source File: CommentRestController.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_COMMENTS) 
public HttpEntity<PagedResources<CommentResource>> getCommentPosts(
        @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, 
                         page = 0, sort="createdTime", direction=Direction.DESC) Pageable pageable,
        PagedResourcesAssembler<CommentPost> assembler) {
    Page<CommentPost> commentPosts = this.commentPostRepository.findAll(pageable);
    return new ResponseEntity<>(assembler.toResource(commentPosts, commentResourceAssembler), HttpStatus.OK);
}
 
Example #28
Source File: AppRegistryCommandsTests.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
@Test
public void importFromResource() {
	List<AppRegistrationResource> resources = new ArrayList<>();
	resources.add(new AppRegistrationResource("foo", "source", null));
	resources.add(new AppRegistrationResource("bar", "sink", null));
	PagedResources<AppRegistrationResource> pagedResources = new PagedResources<>(resources,
			new PagedResources.PageMetadata(resources.size(), 1, resources.size(), 1));
	String uri = "test://example";
	when(appRegistryOperations.importFromResource(uri, true)).thenReturn(pagedResources);
	String result = appRegistryCommands.importFromResource(uri, false, true);
	assertEquals("Successfully registered 2 applications from 'test://example'", result);
}
 
Example #29
Source File: CustomSearchController.java    From galeb with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@GetMapping(value = "/environment/findAllByVirtualhostgroupId", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<PagedResources<Resource<Environment>>> findAllByVirtualhostgroupId(@RequestParam("vhgid") Long vhgid) {
    List<Environment> environments = environmentRepository.findAllByVirtualhostgroupId(vhgid);
    List<Resource<Environment>> resources = environments.stream().map(Resource::new).collect(Collectors.toList());
    PagedResources.PageMetadata meta = new PagedResources.PageMetadata(environments.size(), 0, environments.size());
    return ResponseEntity.ok(new PagedResources<>(resources, meta, Collections.emptyList()));
}
 
Example #30
Source File: AppRegistryTemplate.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
@Override
public PagedResources<AppRegistrationResource> importFromResource(String uri, boolean force) {
	MultiValueMap<String, Object> values = new LinkedMultiValueMap<String, Object>();
	values.add("uri", uri);
	values.add("force", Boolean.toString(force));
	return restTemplate.postForObject(uriTemplate.toString(), values,
			AppRegistrationResource.Page.class);
}