diff options
Diffstat (limited to 'prh-app-server/src/main/java/org/onap')
22 files changed, 161 insertions, 124 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java index 0cc12d41..21dcf81e 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh; import org.springframework.boot.SpringApplication; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java index f24dd177..e10c51d0 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java @@ -17,15 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.configuration; +import java.util.Optional; + import java.util.function.Predicate; -import org.onap.dcaegen2.services.prh.config.*; +import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; +import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration; +import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration; +import org.onap.dcaegen2.services.prh.config.ImmutableAaiClientConfiguration; +import org.onap.dcaegen2.services.prh.config.ImmutableDmaapConsumerConfiguration; +import org.onap.dcaegen2.services.prh.config.ImmutableDmaapPublisherConfiguration; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; -import java.util.Optional; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18 @@ -63,8 +70,8 @@ public class AppConfig extends PrhAppConfig { @Value("${dmaap.dmaapConsumerConfiguration.consumerGroup:}") public String consumerGroup; - @Value("${dmaap.dmaapConsumerConfiguration.timeoutMS:}") - public Integer consumerTimeoutMS; + @Value("${dmaap.dmaapConsumerConfiguration.timeoutMs:}") + public Integer consumerTimeoutMs; @Value("${dmaap.dmaapConsumerConfiguration.message-limit:}") public Integer consumerMessageLimit; @@ -105,8 +112,8 @@ public class AppConfig extends PrhAppConfig { @Value("${aai.aaiClientConfiguration.aaiUserPassword:}") public String aaiUserPassword; - @Value("${aai.aaiClientConfiguration.aaiIgnoreSSLCertificateErrors:}") - public Boolean aaiIgnoreSSLCertificateErrors; + @Value("${aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors:}") + public Boolean aaiIgnoreSslCertificateErrors; @Value("${aai.aaiClientConfiguration.aaiBasePath:}") public String aaiBasePath; @@ -141,8 +148,8 @@ public class AppConfig extends PrhAppConfig { .messageLimit( Optional.ofNullable(consumerMessageLimit).filter(p -> !p.toString().isEmpty()) .orElse(dmaapConsumerConfiguration.messageLimit())) - .timeoutMS(Optional.ofNullable(consumerTimeoutMS).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapConsumerConfiguration.timeoutMS())) + .timeoutMs(Optional.ofNullable(consumerTimeoutMs).filter(p -> !p.toString().isEmpty()) + .orElse(dmaapConsumerConfiguration.timeoutMs())) .consumerGroup(Optional.ofNullable(consumerGroup).filter(isEmpty.negate()) .orElse(dmaapConsumerConfiguration.consumerGroup())) .consumerId(Optional.ofNullable(consumerId).filter(isEmpty.negate()) @@ -151,15 +158,15 @@ public class AppConfig extends PrhAppConfig { } @Override - public AAIClientConfiguration getAAIClientConfiguration() { - return new ImmutableAAIClientConfiguration.Builder() + public AaiClientConfiguration getAaiClientConfiguration() { + return new ImmutableAaiClientConfiguration.Builder() .aaiHost(Optional.ofNullable(aaiHost).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiHost())) .aaiHostPortNumber( Optional.ofNullable(aaiHostPortNumber).filter(p -> !p.toString().isEmpty()) .orElse(aaiClientConfiguration.aaiHostPortNumber())) - .aaiIgnoreSSLCertificateErrors( - Optional.ofNullable(aaiIgnoreSSLCertificateErrors).filter(p -> !p.toString().isEmpty()) - .orElse(aaiClientConfiguration.aaiIgnoreSSLCertificateErrors())) + .aaiIgnoreSslCertificateErrors( + Optional.ofNullable(aaiIgnoreSslCertificateErrors).filter(p -> !p.toString().isEmpty()) + .orElse(aaiClientConfiguration.aaiIgnoreSslCertificateErrors())) .aaiProtocol( Optional.ofNullable(aaiProtocol).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiProtocol())) .aaiUserName( diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java index f3b1b557..776ece6c 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java @@ -17,9 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.configuration; -import org.onap.dcaegen2.services.prh.config.AAIClientConfiguration; +import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration; import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration; @@ -30,7 +31,7 @@ public interface Config { DmaapConsumerConfiguration getDmaapConsumerConfiguration(); - AAIClientConfiguration getAAIClientConfiguration(); + AaiClientConfiguration getAaiClientConfiguration(); DmaapPublisherConfiguration getDmaapPublisherConfiguration(); 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 ab850044..a6ed3146 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 @@ -17,10 +17,27 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.configuration; -import com.google.gson.*; -import org.onap.dcaegen2.services.prh.config.AAIClientConfiguration; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import com.google.gson.TypeAdapterFactory; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +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; import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration; import org.slf4j.Logger; @@ -29,11 +46,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.*; -import java.util.ServiceLoader; - /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18 */ @@ -51,7 +63,7 @@ public abstract class PrhAppConfig implements Config { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - AAIClientConfiguration aaiClientConfiguration; + AaiClientConfiguration aaiClientConfiguration; DmaapConsumerConfiguration dmaapConsumerConfiguration; @@ -67,7 +79,7 @@ public abstract class PrhAppConfig implements Config { } @Override - public AAIClientConfiguration getAAIClientConfiguration() { + public AaiClientConfiguration getAaiClientConfiguration() { return aaiClientConfiguration; } @@ -89,7 +101,7 @@ public abstract class PrhAppConfig implements Config { jsonObject = rootElement.getAsJsonObject(); aaiClientConfiguration = deserializeType(gsonBuilder, jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(AAI).getAsJsonObject(AAI_CONFIG), - AAIClientConfiguration.class); + AaiClientConfiguration.class); dmaapConsumerConfiguration = deserializeType(gsonBuilder, jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(DMAAP).getAsJsonObject(DMAAP_CONSUMER), diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java index a650fe85..2eb2903d 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.configuration; import io.swagger.annotations.ApiOperation; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SwaggerConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SwaggerConfig.java index cb598226..b28fb407 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SwaggerConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SwaggerConfig.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.configuration; import org.springframework.context.annotation.Bean; @@ -38,40 +39,40 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @Profile("prod") public class SwaggerConfig extends WebMvcConfigurationSupport { - private static final String PACKAGE_PATH = "org.onap.dcaegen2.services.prh"; - private static final String API_TITLE = "PRH app server"; - private static final String DESCRIPTION = "This page lists all the rest apis for PRH app server."; - private static final String VERSION = "1.0"; - private static final String RESOURCES_PATH = "classpath:/META-INF/resources/"; - private static final String WEBJARS_PATH = RESOURCES_PATH + "webjars/"; - private static final String SWAGGER_UI = "swagger-ui.html"; - private static final String WEBJARS = "/webjars/**"; + private static final String PACKAGE_PATH = "org.onap.dcaegen2.services.prh"; + private static final String API_TITLE = "PRH app server"; + private static final String DESCRIPTION = "This page lists all the rest apis for PRH app server."; + private static final String VERSION = "1.0"; + private static final String RESOURCES_PATH = "classpath:/META-INF/resources/"; + private static final String WEBJARS_PATH = RESOURCES_PATH + "webjars/"; + private static final String SWAGGER_UI = "swagger-ui.html"; + private static final String WEBJARS = "/webjars/**"; - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.basePackage(PACKAGE_PATH)) - .paths(PathSelectors.any()) - .build(); - } + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage(PACKAGE_PATH)) + .paths(PathSelectors.any()) + .build(); + } - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title(API_TITLE) - .description(DESCRIPTION) - .version(VERSION) - .build(); - } + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title(API_TITLE) + .description(DESCRIPTION) + .version(VERSION) + .build(); + } - @Override - protected void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler(SWAGGER_UI) - .addResourceLocations(RESOURCES_PATH); + @Override + protected void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler(SWAGGER_UI) + .addResourceLocations(RESOURCES_PATH); - registry.addResourceHandler(WEBJARS) - .addResourceLocations(WEBJARS_PATH); - } + registry.addResourceHandler(WEBJARS) + .addResourceLocations(WEBJARS_PATH); + } }
\ No newline at end of file diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/TomcatHttpConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/TomcatHttpConfig.java index 0e9d7fe6..27227251 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/TomcatHttpConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/TomcatHttpConfig.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.configuration; import org.apache.catalina.connector.Connector; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java index 989c6fb2..ae5f2277 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.controllers; import io.swagger.annotations.Api; @@ -48,7 +49,7 @@ public class HeartbeatController { @ApiResponse(code = 401, message = "You are not authorized to view the resource"), @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"), @ApiResponse(code = 404, message = "The resource you were trying to reach is not found") - } + } ) public Mono<ResponseEntity<String>> heartbeat() { logger.trace("Receiving heartbeat request"); diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java index 418d7667..270fa584 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.controllers; import io.swagger.annotations.Api; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiNotFoundException.java index a01abc56..9cefd891 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiNotFoundException.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * PNF-REGISTRATION-HANDLER * ================================================================================ @@ -17,14 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.exceptions; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18 */ -public class AAINotFoundException extends PrhTaskException { +public class AaiNotFoundException extends PrhTaskException { - public AAINotFoundException(String message) { + public AaiNotFoundException(String message) { super(message); } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapEmptyResponseException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapEmptyResponseException.java index e83a96e2..9e3b3c1a 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapEmptyResponseException.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapEmptyResponseException.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.exceptions; /** diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapNotFoundException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapNotFoundException.java index af22284f..8394916d 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapNotFoundException.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/DmaapNotFoundException.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.exceptions; /** diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java index 45597d05..4d543f4c 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.exceptions; /** diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiConsumerTask.java index 1bb28504..959dc9cd 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiConsumerTask.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * PNF-REGISTRATION-HANDLER * ================================================================================ @@ -21,15 +21,15 @@ package org.onap.dcaegen2.services.prh.tasks; import java.util.Optional; -import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; +import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; -import org.onap.dcaegen2.services.prh.service.AAIConsumerClient; +import org.onap.dcaegen2.services.prh.service.AaiConsumerClient; -public abstract class AAIConsumerTask { +public abstract class AaiConsumerTask { - abstract Optional<String> consume(ConsumerDmaapModel message) throws AAINotFoundException; + abstract Optional<String> consume(ConsumerDmaapModel message) throws AaiNotFoundException; - abstract AAIConsumerClient resolveClient(); + abstract AaiConsumerClient resolveClient(); - protected abstract String execute(ConsumerDmaapModel consumerDmaapModel) throws AAINotFoundException; + protected abstract String execute(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException; } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiConsumerTaskImpl.java index c545a1be..63d1e0da 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiConsumerTaskImpl.java @@ -17,60 +17,61 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; import java.io.IOException; import java.util.Optional; -import org.onap.dcaegen2.services.prh.config.AAIClientConfiguration; +import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.onap.dcaegen2.services.prh.configuration.Config; -import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; +import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; -import org.onap.dcaegen2.services.prh.service.AAIConsumerClient; +import org.onap.dcaegen2.services.prh.service.AaiConsumerClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class AAIConsumerTaskImpl extends AAIConsumerTask { +public class AaiConsumerTaskImpl extends AaiConsumerTask { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Config prhAppConfig; - private AAIConsumerClient aaiConsumerClient; + private AaiConsumerClient aaiConsumerClient; @Autowired - public AAIConsumerTaskImpl(AppConfig prhAppConfig) { + public AaiConsumerTaskImpl(AppConfig prhAppConfig) { this.prhAppConfig = prhAppConfig; } @Override - Optional<String> consume(ConsumerDmaapModel consumerDmaapModel) throws AAINotFoundException { + Optional<String> consume(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException { logger.trace("Method called with arg {}", consumerDmaapModel); try { return aaiConsumerClient.getHttpResponse(consumerDmaapModel); } catch (IOException e) { logger.warn("Get request not successful", e); - throw new AAINotFoundException("Get request not successful"); + throw new AaiNotFoundException("Get request not successful"); } } @Override - public String execute(ConsumerDmaapModel consumerDmaapModel) throws AAINotFoundException { + public String execute(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException { consumerDmaapModel = Optional.ofNullable(consumerDmaapModel) - .orElseThrow(() -> new AAINotFoundException("Invoked null object to AAI task")); + .orElseThrow(() -> new AaiNotFoundException("Invoked null object to AAI task")); logger.trace("Method called with arg {}", consumerDmaapModel); aaiConsumerClient = resolveClient(); - return consume(consumerDmaapModel).orElseThrow(() -> new AAINotFoundException("Null response code")); + return consume(consumerDmaapModel).orElseThrow(() -> new AaiNotFoundException("Null response code")); } - protected AAIClientConfiguration resolveConfiguration() { - return prhAppConfig.getAAIClientConfiguration(); + protected AaiClientConfiguration resolveConfiguration() { + return prhAppConfig.getAaiClientConfiguration(); } @Override - AAIConsumerClient resolveClient() { - return Optional.ofNullable(aaiConsumerClient).orElseGet(() -> new AAIConsumerClient(resolveConfiguration())); + AaiConsumerClient resolveClient() { + return Optional.ofNullable(aaiConsumerClient).orElseGet(() -> new AaiConsumerClient(resolveConfiguration())); } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java index 4a763ef3..abd4fc45 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java @@ -17,21 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; -import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; +import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException; import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; -import org.onap.dcaegen2.services.prh.service.AAIProducerClient; +import org.onap.dcaegen2.services.prh.service.AaiProducerClient; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ -public abstract class AAIProducerTask { +public abstract class AaiProducerTask { - abstract ConsumerDmaapModel publish(ConsumerDmaapModel message) throws AAINotFoundException; + abstract ConsumerDmaapModel publish(ConsumerDmaapModel message) throws AaiNotFoundException; - abstract AAIProducerClient resolveClient(); + abstract AaiProducerClient resolveClient(); protected abstract ConsumerDmaapModel execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException; } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java index b12fb5bb..124a5c63 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java @@ -17,17 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; import java.net.URISyntaxException; import java.util.Optional; -import org.onap.dcaegen2.services.prh.config.AAIClientConfiguration; +import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.onap.dcaegen2.services.prh.configuration.Config; -import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; +import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; import org.onap.dcaegen2.services.prh.model.utils.HttpUtils; -import org.onap.dcaegen2.services.prh.service.AAIProducerClient; +import org.onap.dcaegen2.services.prh.service.AaiProducerClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -37,47 +38,47 @@ import org.springframework.stereotype.Component; * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ @Component -public class AAIProducerTaskImpl extends - AAIProducerTask { +public class AaiProducerTaskImpl extends + AaiProducerTask { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Config prhAppConfig; - private AAIProducerClient aaiProducerClient; + private AaiProducerClient aaiProducerClient; @Autowired - public AAIProducerTaskImpl(AppConfig prhAppConfig) { + public AaiProducerTaskImpl(AppConfig prhAppConfig) { this.prhAppConfig = prhAppConfig; } @Override - ConsumerDmaapModel publish(ConsumerDmaapModel consumerDmaapModel) throws AAINotFoundException { + ConsumerDmaapModel publish(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException { logger.info("Sending PNF model to AAI {}", consumerDmaapModel); try { return aaiProducerClient.getHttpResponse(consumerDmaapModel) .filter(HttpUtils::isSuccessfulResponseCode).map(response -> consumerDmaapModel).orElseThrow(() -> - new AAINotFoundException("Incorrect response code for continuation of tasks workflow")); + new AaiNotFoundException("Incorrect response code for continuation of tasks workflow")); } catch (URISyntaxException e) { logger.warn("Patch request not successful", e); - throw new AAINotFoundException("Patch request not successful"); + throw new AaiNotFoundException("Patch request not successful"); } } @Override - public ConsumerDmaapModel execute(ConsumerDmaapModel consumerDmaapModel) throws AAINotFoundException { + public ConsumerDmaapModel execute(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException { consumerDmaapModel = Optional.ofNullable(consumerDmaapModel) - .orElseThrow(() -> new AAINotFoundException("Invoked null object to AAI task")); + .orElseThrow(() -> new AaiNotFoundException("Invoked null object to AAI task")); logger.trace("Method called with arg {}", consumerDmaapModel); aaiProducerClient = resolveClient(); return publish(consumerDmaapModel); } - protected AAIClientConfiguration resolveConfiguration() { - return prhAppConfig.getAAIClientConfiguration(); + protected AaiClientConfiguration resolveConfiguration() { + return prhAppConfig.getAaiClientConfiguration(); } @Override - AAIProducerClient resolveClient() { - return Optional.ofNullable(aaiProducerClient).orElseGet(() -> new AAIProducerClient(resolveConfiguration())); + AaiProducerClient resolveClient() { + return Optional.ofNullable(aaiProducerClient).orElseGet(() -> new AaiProducerClient(resolveConfiguration())); } }
\ No newline at end of file diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java index 93c287b4..a912ca9e 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java index 45709aa2..812c04e1 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration; @@ -40,7 +41,7 @@ public class DmaapConsumerTaskImpl extends DmaapConsumerTask { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Config prhAppConfig; private DmaapConsumerJsonParser dmaapConsumerJsonParser; - private DMaaPConsumerReactiveHttpClient dMaaPConsumerReactiveHttpClient; + private DMaaPConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient; @Autowired public DmaapConsumerTaskImpl(AppConfig prhAppConfig) { @@ -61,9 +62,9 @@ public class DmaapConsumerTaskImpl extends DmaapConsumerTask { @Override public Mono<ConsumerDmaapModel> execute(String object) { - dMaaPConsumerReactiveHttpClient = resolveClient(); + dmaaPConsumerReactiveHttpClient = resolveClient(); logger.trace("Method called with arg {}", object); - return consume((dMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse())); + return consume((dmaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse())); } @Override @@ -78,8 +79,8 @@ public class DmaapConsumerTaskImpl extends DmaapConsumerTask { @Override DMaaPConsumerReactiveHttpClient resolveClient() { - return dMaaPConsumerReactiveHttpClient == null + return dmaaPConsumerReactiveHttpClient == null ? new DMaaPConsumerReactiveHttpClient(resolveConfiguration()).createDMaaPWebClient(buildWebClient()) - : dMaaPConsumerReactiveHttpClient; + : dmaaPConsumerReactiveHttpClient; } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java index f559683d..9a5813d1 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * PNF-REGISTRATION-HANDLER * ================================================================================ @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java index 673e00f3..4949faa7 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; import java.util.Optional; @@ -40,7 +41,7 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Config prhAppConfig; - private DMaaPProducerReactiveHttpClient dMaaPProducerReactiveHttpClient; + private DMaaPProducerReactiveHttpClient dmaapProducerReactiveHttpClient; @Autowired public DmaapPublisherTaskImpl(AppConfig prhAppConfig) { @@ -51,14 +52,14 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask { Mono<String> publish(Mono<ConsumerDmaapModel> consumerDmaapModel) { logger.info("Publishing on DMaaP topic {} object {}", resolveConfiguration().dmaapTopicName(), consumerDmaapModel); - return dMaaPProducerReactiveHttpClient.getDMaaPProducerResponse(consumerDmaapModel); + return dmaapProducerReactiveHttpClient.getDMaaPProducerResponse(consumerDmaapModel); } @Override public Mono<String> execute(Mono<ConsumerDmaapModel> consumerDmaapModel) throws DmaapNotFoundException { consumerDmaapModel = Optional.ofNullable(consumerDmaapModel) .orElseThrow(() -> new DmaapNotFoundException("Invoked null object to DMaaP task")); - dMaaPProducerReactiveHttpClient = resolveClient(); + dmaapProducerReactiveHttpClient = resolveClient(); logger.trace("Method called with arg {}", consumerDmaapModel); return publish(consumerDmaapModel); } @@ -70,8 +71,8 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask { @Override DMaaPProducerReactiveHttpClient resolveClient() { - return dMaaPProducerReactiveHttpClient == null + return dmaapProducerReactiveHttpClient == null ? new DMaaPProducerReactiveHttpClient(resolveConfiguration()).createDMaaPWebClient(buildWebClient()) - : dMaaPProducerReactiveHttpClient; + : dmaapProducerReactiveHttpClient; } }
\ No newline at end of file diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java index 365552b7..26b9e6e7 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * PNF-REGISTRATION-HANDLER * ================================================================================ @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.prh.tasks; import java.util.Optional; @@ -41,11 +42,11 @@ public class ScheduledTasks { private final DmaapConsumerTask dmaapConsumerTask; private final DmaapPublisherTask dmaapProducerTask; - private final AAIProducerTask aaiProducerTask; + private final AaiProducerTask aaiProducerTask; @Autowired public ScheduledTasks(DmaapConsumerTask dmaapConsumerTask, DmaapPublisherTask dmaapPublisherTask, - AAIProducerTask aaiPublisherTask) { + AaiProducerTask aaiPublisherTask) { this.dmaapConsumerTask = dmaapConsumerTask; this.dmaapProducerTask = dmaapPublisherTask; this.aaiProducerTask = aaiPublisherTask; @@ -56,8 +57,8 @@ public class ScheduledTasks { Mono<String> dmaapProducerResponse = Mono.fromCallable(consumeFromDMaaPMessage()) .doOnError(DmaapEmptyResponseException.class, error -> logger.warn("Nothing to consume from DMaaP")) - .map(this::publishToAAIConfiguration) - .flatMap(this::publishToDMaaPConfiguration) + .map(this::publishToAaiConfiguration) + .flatMap(this::publishToDmaapConfiguration) .subscribeOn(Schedulers.elastic()); dmaapProducerResponse.subscribe(this::onSuccess, this::onError, this::onComplete); @@ -78,14 +79,13 @@ public class ScheduledTasks { } private Callable<Mono<ConsumerDmaapModel>> consumeFromDMaaPMessage() { - return () -> - { + return () -> { dmaapConsumerTask.initConfigs(); return dmaapConsumerTask.execute(""); }; } - private Mono<ConsumerDmaapModel> publishToAAIConfiguration(Mono<ConsumerDmaapModel> monoDMaaPModel) { + private Mono<ConsumerDmaapModel> publishToAaiConfiguration(Mono<ConsumerDmaapModel> monoDMaaPModel) { return monoDMaaPModel.flatMap(dmaapModel -> { try { return Mono.just(aaiProducerTask.execute(dmaapModel)); @@ -95,9 +95,9 @@ public class ScheduledTasks { }); } - private Mono<String> publishToDMaaPConfiguration(Mono<ConsumerDmaapModel> monoAAIModel) { + private Mono<String> publishToDmaapConfiguration(Mono<ConsumerDmaapModel> monoAaiModel) { try { - return dmaapProducerTask.execute(monoAAIModel); + return dmaapProducerTask.execute(monoAaiModel); } catch (PrhTaskException e) { return Mono.error(e); } |