aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main/java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-09-04 09:50:05 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-09-04 09:50:05 +0200
commitbe3127220aed103d1c1bb495080d62593d61b835 (patch)
treed18321c21dd28859e5f6e7eed3553ea0fff38a3c /prh-app-server/src/main/java
parenta4c979b6de8c1c76f0f12ae2b8dd0e60c3084830 (diff)
Maven resources refactoring
Added resurces to java spring classpath directly Change-Id: I194748706f63cff1966111bbdb52538bd5a83855 Issue-ID: DCAEGEN2-606 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main/java')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java8
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java25
2 files changed, 15 insertions, 18 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
index 10626a32..e598b4b3 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
@@ -89,7 +89,8 @@ public class CloudConfiguration extends AppConfig {
LOGGER.info("Received application configuration: {}", jsonObject);
CloudConfigParser cloudConfigParser = new CloudConfigParser(jsonObject);
dmaapPublisherCloudConfiguration = cloudConfigParser.getDmaapPublisherConfig();
- aaiClientCloudConfiguration = cloudConfigParser.getAaiClientConfig();
+ aaiClientCloudConfiguration = ImmutableAaiClientConfiguration.copyOf(cloudConfigParser.getAaiClientConfig())
+ .withAaiHeaders(aaiClientConfiguration.aaiHeaders());
dmaapConsumerCloudConfiguration = cloudConfigParser.getDmaapConsumerConfig();
}
@@ -100,11 +101,10 @@ public class CloudConfiguration extends AppConfig {
@Override
public AaiClientConfiguration getAaiClientConfiguration() {
- return Optional.ofNullable(ImmutableAaiClientConfiguration.copyOf(aaiClientCloudConfiguration)
- .withAaiHeaders(aaiClientConfiguration.aaiHeaders()))
- .orElse(ImmutableAaiClientConfiguration.copyOf(super.getAaiClientConfiguration()));
+ return Optional.ofNullable(aaiClientCloudConfiguration).orElse(super.getAaiClientConfiguration());
}
+
@Override
public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
return Optional.ofNullable(dmaapConsumerCloudConfiguration).orElse(super.getDmaapConsumerConfiguration());
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
index 03d24382..882e4d7e 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
@@ -36,7 +36,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ServiceLoader;
-import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration;
@@ -44,9 +43,11 @@ import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.Resource;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
@@ -71,9 +72,8 @@ public abstract class PrhAppConfig implements Config {
DmaapPublisherConfiguration dmaapPublisherConfiguration;
- @NotEmpty
- private String filepath;
-
+ @Value("classpath:prh_endpoints.json")
+ private Resource resourceFile;
@Override
public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
@@ -97,7 +97,8 @@ public abstract class PrhAppConfig implements Config {
ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
JsonParser parser = new JsonParser();
JsonObject jsonObject;
- try (InputStream inputStream = getInputStream(filepath)) {
+
+ try (InputStream inputStream = resourceFile.getInputStream()) {
JsonElement rootElement = getJsonElement(parser, inputStream);
if (rootElement.isJsonObject()) {
jsonObject = rootElement.getAsJsonObject();
@@ -114,7 +115,7 @@ public abstract class PrhAppConfig implements Config {
DmaapPublisherConfiguration.class);
}
} catch (IOException e) {
- LOGGER.warn("Problem with file loading, file: {}", filepath, e);
+ LOGGER.warn("Problem with file loading, file ", e);
} catch (JsonSyntaxException e) {
LOGGER.warn("Problem with Json deserialization", e);
}
@@ -129,16 +130,12 @@ public abstract class PrhAppConfig implements Config {
return gsonBuilder.create().fromJson(jsonObject, type);
}
- InputStream getInputStream(@NotNull String filepath) throws IOException {
- return new BufferedInputStream(new FileInputStream(filepath));
- }
-
- String getFilepath() {
- return this.filepath;
+ void setResourceFile(Resource resourceFile) {
+ this.resourceFile = resourceFile;
}
- public void setFilepath(String filepath) {
- this.filepath = filepath;
+ InputStream getInputStream(@NotNull String filepath) throws IOException {
+ return new BufferedInputStream(new FileInputStream(filepath));
}
public void setXOnapRequestId(String xonaprequestid) {