diff options
author | grabinsk <maciej.grabinski@nokia.com> | 2019-06-27 12:25:59 +0200 |
---|---|---|
committer | grabinsk <maciej.grabinski@nokia.com> | 2019-06-28 15:15:33 +0200 |
commit | 768ab8275b35750ebf46411be54e7bd452a95578 (patch) | |
tree | fbd7c81e0dd293daa7a228c9517c6a31baf325d5 /prh-app-server/src/main | |
parent | 3e9dc9c5421fe2997e2e5032c6c587c389d9f483 (diff) |
fix PRH dmaap content type configuration after breaking changes introduced to SDK
and mix of minor code cleanups
Change-Id: I568f49b8b6635f23b2089a4355eb78451102c2b1
Issue-ID: DCAEGEN2-1647
Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main')
8 files changed, 16 insertions, 71 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java index 0297a67a..df318550 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration -@EnableConfigurationProperties +@EnableConfigurationProperties(CbsProperties.class) public class CbsBootstrapConfiguration { @Bean 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 84d9fcd2..1d2a65d3 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 @@ -23,14 +23,12 @@ package org.onap.dcaegen2.services.prh; import java.util.Map; import java.util.UUID; -import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationClient; import org.slf4j.MDC; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; @@ -41,7 +39,6 @@ import static org.onap.dcaegen2.services.sdk.rest.services.model.logging.MdcVari * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18 */ @SpringBootApplication(exclude = {JacksonAutoConfiguration.class}) -@Configuration @EnableScheduling @EnableConfigurationProperties public class MainApp { @@ -61,10 +58,4 @@ public class MainApp { return new ConcurrentTaskScheduler(); } - - @Bean - CloudConfigurationClient getCloudConfigurationClient(){ - return new CloudConfigurationClient(); - } - } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java index a57a5393..85b4c035 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java @@ -69,21 +69,18 @@ class CbsContentParser { } MessageRouterPublishRequest getMessageRouterPublishRequest() { - RawDataStream<JsonObject> sink = DataStreams.namedSinks(jsonObject).find(streamWithName(PNF_READY)).get(); - MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink); - - return ImmutableMessageRouterPublishRequest.builder() - .contentType(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapContentType").getAsString()) - .sinkDefinition(parsedSink) - .build(); + return getMessageRouterPublishRequest(PNF_READY); } MessageRouterPublishRequest getMessageRouterUpdatePublishRequest() { - RawDataStream<JsonObject> sink = DataStreams.namedSinks(jsonObject).find(streamWithName(PNF_UPDATE)).get(); + return getMessageRouterPublishRequest(PNF_UPDATE); + } + + private MessageRouterPublishRequest getMessageRouterPublishRequest(String streamName) { + RawDataStream<JsonObject> sink = DataStreams.namedSinks(jsonObject).find(streamWithName(streamName)).get(); MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink); return ImmutableMessageRouterPublishRequest.builder() - .contentType(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapContentType").getAsString()) .sinkDefinition(parsedSink) .build(); } 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 31794f6b..c21fd400 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 @@ -43,8 +43,8 @@ public class PrhAppConfig { private Resource gitInfo; - @EventListener - public void onApplicationStartedEvent(ApplicationStartedEvent applicationStartedEvent) throws IOException { + @EventListener(ApplicationStartedEvent.class) + public void onApplicationStarted() throws IOException { if(LOGGER.isDebugEnabled()) { LOGGER.debug("Git info={}", StreamUtils.copyToString(gitInfo.getInputStream(), Charset.defaultCharset())); } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java deleted file mode 100644 index 5fef80d8..00000000 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * 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 8/10/18 - */ -public class EnvironmentLoaderException extends Exception { - - public EnvironmentLoaderException(String message) { - super(message); - } -} 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 f49723e2..123eb5a3 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 @@ -20,21 +20,11 @@ package org.onap.dcaegen2.services.prh.tasks; -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 reactor.core.publisher.Mono; -import javax.net.ssl.SSLException; - - -/** - * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 - */ -public abstract class AaiProducerTask { - - abstract Mono<ConsumerDmaapModel> publish(ConsumerDmaapModel message) throws AaiNotFoundException; - - protected abstract Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) - throws PrhTaskException, SSLException; +@FunctionalInterface +interface AaiProducerTask { + Mono<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 e0dcf0b3..7aaff47d 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 @@ -39,7 +39,7 @@ import reactor.core.publisher.Mono; * @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 implements AaiProducerTask { private static final Logger LOGGER = LoggerFactory.getLogger(AaiProducerTaskImpl.class); @@ -50,8 +50,7 @@ public class AaiProducerTaskImpl extends AaiProducerTask { this.aaiHttpPatchClient = aaiHttpPatchClient; } - @Override - Mono<ConsumerDmaapModel> publish(ConsumerDmaapModel consumerDmaapModel) { + private Mono<ConsumerDmaapModel> publish(ConsumerDmaapModel consumerDmaapModel) { Mono<HttpResponse> response = aaiHttpPatchClient.getAaiResponse(consumerDmaapModel); return response.flatMap(r -> { if (HttpUtils.isSuccessfulResponseCode(r.statusCode())) { @@ -63,7 +62,7 @@ public class AaiProducerTaskImpl extends AaiProducerTask { } @Override - protected Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException { + public Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException { if (consumerDmaapModel == null) { throw new DmaapNotFoundException("Invoked null object to DMaaP task"); } 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 670d2140..74c6c426 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 @@ -37,7 +37,6 @@ import org.springframework.stereotype.Component; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import javax.net.ssl.SSLException; import java.util.Map; import java.util.UUID; import java.util.concurrent.CountDownLatch; @@ -167,7 +166,7 @@ public class ScheduledTasks { : aaiProducerTask .execute(state.dmaapModel) .map(x -> state); - } catch (PrhTaskException | SSLException e) { + } catch (PrhTaskException e) { LOGGER.warn("AAIProducerTask exception has been registered: ", e); return Mono.error(e); } |