From be3127220aed103d1c1bb495080d62593d61b835 Mon Sep 17 00:00:00 2001 From: pwielebs Date: Tue, 4 Sep 2018 09:50:05 +0200 Subject: Maven resources refactoring Added resurces to java spring classpath directly Change-Id: I194748706f63cff1966111bbdb52538bd5a83855 Issue-ID: DCAEGEN2-606 Signed-off-by: pwielebs --- .../prh/configuration/CloudConfiguration.java | 8 ++-- .../services/prh/configuration/PrhAppConfig.java | 25 +++++------ .../src/main/resources/application.properties | 17 -------- prh-app-server/src/main/resources/application.yaml | 19 +++++++++ prh-app-server/src/main/resources/keystore-local | Bin 0 -> 2643 bytes prh-app-server/src/main/resources/keystore-onap | Bin 0 -> 2196 bytes prh-app-server/src/main/resources/keystore.jks | Bin 2643 -> 0 bytes prh-app-server/src/main/resources/keystore.jks.old | Bin 2272 -> 0 bytes .../src/main/resources/prh_endpoints.json | 47 +++++++++++++++++++++ .../src/main/resources/scheduled-context.xml | 16 ------- 10 files changed, 81 insertions(+), 51 deletions(-) delete mode 100644 prh-app-server/src/main/resources/application.properties create mode 100644 prh-app-server/src/main/resources/application.yaml create mode 100644 prh-app-server/src/main/resources/keystore-local create mode 100644 prh-app-server/src/main/resources/keystore-onap delete mode 100644 prh-app-server/src/main/resources/keystore.jks delete mode 100644 prh-app-server/src/main/resources/keystore.jks.old create mode 100644 prh-app-server/src/main/resources/prh_endpoints.json delete mode 100644 prh-app-server/src/main/resources/scheduled-context.xml (limited to 'prh-app-server/src/main') 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 Przemysław Wąsala 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) { diff --git a/prh-app-server/src/main/resources/application.properties b/prh-app-server/src/main/resources/application.properties deleted file mode 100644 index e343a360..00000000 --- a/prh-app-server/src/main/resources/application.properties +++ /dev/null @@ -1,17 +0,0 @@ -spring.profiles.active=prod -server.port=8433 -server.ssl.key-store-type=PKCS12 -server.ssl.key-store-password=nokiapnf -server.ssl.key-store=classpath:keystore.jks -server.ssl.key-password=nokiapnf -server.ssl.key-alias=tomcat-localhost -logging.level.root=ERROR -logging.level.org.springframework=ERROR -logging.level.org.springframework.data=ERROR -logging.level.org.onap.dcaegen2.services.prh=INFO -logging.level.org.springframework.web.reactive=WARN -logging.level.reactor.ipc.netty.http.client=WARN -app.filepath=config/prh_endpoints.json -app.xonaprequestid=requestID -app.xinvocationid=invocationID - diff --git a/prh-app-server/src/main/resources/application.yaml b/prh-app-server/src/main/resources/application.yaml new file mode 100644 index 00000000..88d1e401 --- /dev/null +++ b/prh-app-server/src/main/resources/application.yaml @@ -0,0 +1,19 @@ +spring: + profiles: + active: prod +server: + port: 8433 + ssl: + key-store-type: PKCS12 + key-store-password: nokiapnf + key-store: classpath:keystore-local + key-password: nokiapnf + keyAlias: tomcat-localhost +logging: + level: + ROOT: ERROR + org.onap.dcaegen2.services.prh: INFO + reactor.ipc.netty.http.client: WARN + org.springframework: ERROR + org.springframework.data: ERROR + org.springframework.web.reactive: WARN diff --git a/prh-app-server/src/main/resources/keystore-local b/prh-app-server/src/main/resources/keystore-local new file mode 100644 index 00000000..cd27cc01 Binary files /dev/null and b/prh-app-server/src/main/resources/keystore-local differ diff --git a/prh-app-server/src/main/resources/keystore-onap b/prh-app-server/src/main/resources/keystore-onap new file mode 100644 index 00000000..26a16f75 Binary files /dev/null and b/prh-app-server/src/main/resources/keystore-onap differ diff --git a/prh-app-server/src/main/resources/keystore.jks b/prh-app-server/src/main/resources/keystore.jks deleted file mode 100644 index cd27cc01..00000000 Binary files a/prh-app-server/src/main/resources/keystore.jks and /dev/null differ diff --git a/prh-app-server/src/main/resources/keystore.jks.old b/prh-app-server/src/main/resources/keystore.jks.old deleted file mode 100644 index 8a2b4f99..00000000 Binary files a/prh-app-server/src/main/resources/keystore.jks.old and /dev/null differ diff --git a/prh-app-server/src/main/resources/prh_endpoints.json b/prh-app-server/src/main/resources/prh_endpoints.json new file mode 100644 index 00000000..b3bff7d9 --- /dev/null +++ b/prh-app-server/src/main/resources/prh_endpoints.json @@ -0,0 +1,47 @@ +{ + "configs": { + "dmaap": { + "dmaapConsumerConfiguration": { + "dmaapHostName": "localhost", + "dmaapPortNumber": 2222, + "dmaapTopicName": "/events/unauthenticated.VES_PNFREG_OUTPUT", + "dmaapProtocol": "http", + "dmaapUserName": "admin", + "dmaapUserPassword": "admin", + "dmaapContentType": "application/json", + "consumerId": "c12", + "consumerGroup": "OpenDcae-c12", + "timeoutMs": -1, + "messageLimit": 1 + }, + "dmaapProducerConfiguration": { + "dmaapHostName": "localhost", + "dmaapPortNumber": 2223, + "dmaapTopicName": "/events/unauthenticated.PNF_READY", + "dmaapProtocol": "http", + "dmaapUserName": "admin", + "dmaapUserPassword": "admin", + "dmaapContentType": "application/json" + } + }, + "aai": { + "aaiClientConfiguration": { + "aaiHost": "localhost", + "aaiPort": 8080, + "aaiProtocol": "https", + "aaiUserName": "AAI", + "aaiUserPassword": "AAI", + "aaiIgnoreSslCertificateErrors": true, + "aaiBasePath": "/aai/v12", + "aaiPnfPath": "/network/pnfs/pnf", + "aaiHeaders": { + "X-FromAppId": "prh", + "X-TransactionId": "9999", + "Accept": "application/json", + "Real-Time": "true", + "Content-Type": "application/merge-patch+json" + } + } + } + } +} \ No newline at end of file diff --git a/prh-app-server/src/main/resources/scheduled-context.xml b/prh-app-server/src/main/resources/scheduled-context.xml deleted file mode 100644 index 82067c17..00000000 --- a/prh-app-server/src/main/resources/scheduled-context.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - -- cgit 1.2.3-korg