Skip to content

Commit

Permalink
Add icon and metadata source controllers improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewelinagr committed Apr 23, 2024
1 parent 383d5f6 commit f0bab73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static class Storage {

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class Service {
public static class ExternalService {
@NotBlank
private String name;

Expand All @@ -63,7 +63,7 @@ public static class Service {
private List<String> domains = Collections.emptyList();
private Map<String, Storage> storages = new LinkedHashMap<>();
private Map<String, MetadataSource> metadataSources = new LinkedHashMap<>();
private Map<String, Service> services = new LinkedHashMap<>();
private Map<String, ExternalService> services = new LinkedHashMap<>();
private String downstreamServiceHealthUrl;
private String staticHtmlLocation;
private Map<String, String> icons;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.IOException;
import java.io.InputStream;

import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.http.ResponseEntity;
Expand All @@ -17,17 +17,18 @@

@RestController
@Slf4j
@AllArgsConstructor
@RequiredArgsConstructor
public class IconsResource {

private final PlutoConfig plutoConfig;
/**
* GET /api/iconsvg/{icon_name} : returns an icon of specified name if exists.
* GET /api/iconsvg/{icon_name} : returns a svg icon of specified name if exists.
*
* @return svg icon.
*/
@GetMapping(value = ICONS_PATH + "{icon_name}", produces = "image/svg+xml")
public ResponseEntity<byte[]> iconsvg(@PathVariable String icon_name) {
try {
InputStream in = getSvgIconInputStream(icon_name);
try (InputStream in = getSvgIconInputStream(icon_name)) {
if (in == null || in.available() == 0) {
return ResponseEntity.notFound().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public ResponseEntity<List<MetadataSourceInfo>> metadataSources() {
.map(source -> new MetadataSourceInfo(
source.getName(),
source.getLabel(),
source.getName() != null ? String.format("/api/metadata-sources/%s", source.getName()) : null,
source.getName() != null
? String.format("%s%s", METADATA_SOURCES_PATH, source.getName())
: null,
iconsResource.getIconUrl(source.getIconName())))
.collect(Collectors.toList());
return ResponseEntity.ok(metadataSources);
Expand Down

0 comments on commit f0bab73

Please sign in to comment.