X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=mod2%2Fhelm-generator%2Fhelmchartgenerator-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdcaegen2%2Fplatform%2Fhelmchartgenerator%2Fdistribution%2FChartMuseumDistributor.java;h=ab0b9642560ae3c5dc7c2ab61ec56ca25a65ffc1;hb=a494a322554924f6f9c3d6cc79240f54d3a8da0b;hp=ed861b0b2bbff52d3b30e71a268b19b677afabb7;hpb=0d1b8727a44b0add010b79e495b799e538057d20;p=dcaegen2%2Fplatform.git diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java index ed861b0..ab0b964 100644 --- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java +++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java @@ -40,14 +40,19 @@ import java.util.Objects; @Slf4j public class ChartMuseumDistributor implements ChartDistributor { - @Value("${chartmuseum.baseurl}") - private String chartMuseumUrl; + private final String chartMuseumUrl; - @Value("${chartmuseum.auth.basic.username}") - private String username; + private final String username; - @Value("${chartmuseum.auth.basic.password}") - private String password; + private final String password; + + public ChartMuseumDistributor( @Value("${chartmuseum.baseurl}") String chartMuseumUrl, + @Value("${chartmuseum.auth.basic.username}") String username, + @Value("${chartmuseum.auth.basic.password}")String password) { + this.chartMuseumUrl = chartMuseumUrl; + this.username = username; + this.password = password; + } /** * distributes chart to Chart Museum @@ -60,6 +65,9 @@ public class ChartMuseumDistributor implements ChartDistributor { try { Response response = client.newCall(request).execute(); log.info(Objects.requireNonNull(response.body()).string()); + if(!response.isSuccessful()){ + throw new RuntimeException("Distribution Failed."); + } } catch (IOException e) { throw new RuntimeException(e.getMessage()); } @@ -70,7 +78,7 @@ public class ChartMuseumDistributor implements ChartDistributor { MediaType mediaType = MediaType.parse("application/octet-stream"); RequestBody body = RequestBody.create(chartFile, mediaType); return new Request.Builder() - .url(chartMuseumUrl) + .url(chartMuseumUrl + "/api/charts") .method("POST", body) .addHeader("Content-Type", "application/octet-stream") .addHeader("Authorization", credential)