-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional links configuration (#1217)
- Loading branch information
1 parent
771c735
commit f75fd54
Showing
13 changed files
with
155 additions
and
10 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...i/src/main/java/org/opendatadiscovery/oddplatform/config/AdditionalLinkConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.opendatadiscovery.oddplatform.config; | ||
|
||
import org.opendatadiscovery.oddplatform.config.properties.AdditionalLinkProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(AdditionalLinkProperties.class) | ||
public class AdditionalLinkConfiguration { | ||
} |
10 changes: 10 additions & 0 deletions
10
...in/java/org/opendatadiscovery/oddplatform/config/properties/AdditionalLinkProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.opendatadiscovery.oddplatform.config.properties; | ||
|
||
import java.util.List; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties("odd") | ||
public record AdditionalLinkProperties(List<Link> links) { | ||
public record Link(String title, String url) { | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...tform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/LinksController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.opendatadiscovery.oddplatform.controller; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.opendatadiscovery.oddplatform.api.contract.api.LinksApi; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.Link; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.LinkList; | ||
import org.opendatadiscovery.oddplatform.config.properties.AdditionalLinkProperties; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import reactor.core.publisher.Mono; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class LinksController implements LinksApi { | ||
private final AdditionalLinkProperties linkProperties; | ||
|
||
@Override | ||
public Mono<ResponseEntity<LinkList>> getLinks(final ServerWebExchange exchange) { | ||
if (CollectionUtils.isEmpty(linkProperties.links())) { | ||
return Mono.just(ResponseEntity.ok(new LinkList().items(emptyList()))); | ||
} | ||
|
||
final List<Link> links = linkProperties.links().stream() | ||
.map(link -> new Link().title(link.title()).url(link.url())) | ||
.toList(); | ||
|
||
return Mono.just(ResponseEntity.ok(new LinkList().items(links))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters