diff options
Diffstat (limited to 'a1-policy-management/src/main/java')
30 files changed, 23 insertions, 561 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java index 259a5ba9..6f458647 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.oran.a1policymanagementservice; import java.lang.invoke.MethodHandles; -import org.onap.ccsdk.oran.a1policymanagementservice.dmaap.DmaapMessageConsumer; import org.onap.ccsdk.oran.a1policymanagementservice.tasks.RefreshConfigTask; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,9 +39,6 @@ public class Application { @Autowired private RefreshConfigTask configRefresh; - @Autowired - private DmaapMessageConsumer dmaapMessageConsumer; - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); public static void main(String[] args) { @@ -68,16 +64,4 @@ public class Application { public CommandLineRunner configRefreshRunner(ApplicationContext ctx) { return args -> configRefresh.start(); } - - /** - * Starts the DMaaP message consumer service. - * - * @param ctx the application context. - * - * @return the command line runner for the DMaaP message consumer service. - */ - @Bean - public CommandLineRunner dmaapMessageConsumerRunner(ApplicationContext ctx) { - return args -> dmaapMessageConsumer.start(); - } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspect.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspect.java index 1c40f04f..e41ebe16 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspect.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspect.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1AdapterJsonHelper.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1AdapterJsonHelper.java index 60dca3b4..ab93ea3e 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1AdapterJsonHelper.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1AdapterJsonHelper.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java index 0956aa13..14738a91 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1UriBuilder.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1UriBuilder.java index 801cb4d5..d6d890d4 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1UriBuilder.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1UriBuilder.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java index 9c32d79c..225d2f71 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java index 1d567a89..62115b5a 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java index 24990a1a..c61ecb86 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java index 796d6ad9..358680a0 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java @@ -100,12 +100,6 @@ public class ApplicationConfig { private Map<String, RicConfig> ricConfigs = new HashMap<>(); - @Getter - private String dmaapConsumerTopicUrl; - - @Getter - private String dmaapProducerTopicUrl; - private Map<String, ControllerConfig> controllerConfigs = new HashMap<>(); private WebClientConfig webClientConfig = null; @@ -174,9 +168,6 @@ public class ApplicationConfig { Collection<RicConfigUpdate> modifications = new ArrayList<>(); this.controllerConfigs = parserResult.getControllerConfigs(); - this.dmaapConsumerTopicUrl = parserResult.getDmaapConsumerTopicUrl(); - this.dmaapProducerTopicUrl = parserResult.getDmaapProducerTopicUrl(); - Map<String, RicConfig> newRicConfigs = new HashMap<>(); for (RicConfig newConfig : parserResult.getRicConfigs()) { RicConfig oldConfig = this.ricConfigs.get(newConfig.getRicId()); @@ -202,5 +193,4 @@ public class ApplicationConfig { public boolean isS3Enabled() { return !(Strings.isNullOrEmpty(s3EndpointOverride) || Strings.isNullOrEmpty(s3Bucket)); } - } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java index 6c178d36..9df901fa 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java @@ -36,7 +36,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import lombok.Builder; @@ -70,44 +69,23 @@ public class ApplicationConfigParser { @Builder.Default private Map<String, ControllerConfig> controllerConfigs = new HashMap<>(); - @Builder.Default - private String dmaapConsumerTopicUrl = ""; - - @Builder.Default - private String dmaapProducerTopicUrl = ""; - } public ConfigParserResult parse(JsonObject root) throws ServiceException { validateJsonObjectAgainstSchema(root); - String dmaapProducerTopicUrl = ""; - String dmaapConsumerTopicUrl = ""; - JsonObject pmsConfigJson = root.getAsJsonObject(CONFIG); if (pmsConfigJson == null) { throw new ServiceException("Missing root configuration \"" + CONFIG + "\" in JSON: " + root); } - JsonObject json = pmsConfigJson.getAsJsonObject("streams_publishes"); - if (json != null) { - dmaapProducerTopicUrl = parseDmaapConfig(json); - } - - json = pmsConfigJson.getAsJsonObject("streams_subscribes"); - if (json != null) { - dmaapConsumerTopicUrl = parseDmaapConfig(json); - } - List<RicConfig> ricConfigs = parseRics(pmsConfigJson); Map<String, ControllerConfig> controllerConfigs = parseControllerConfigs(pmsConfigJson); checkConfigurationConsistency(ricConfigs, controllerConfigs); return ConfigParserResult.builder() // - .dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) // - .dmaapProducerTopicUrl(dmaapProducerTopicUrl) // .ricConfigs(ricConfigs) // .controllerConfigs(controllerConfigs) // .build(); @@ -236,17 +214,6 @@ public class ApplicationConfigParser { return get(obj, memberName).getAsJsonArray(); } - private String parseDmaapConfig(JsonObject streamCfg) throws ServiceException { - Set<Entry<String, JsonElement>> streamConfigEntries = streamCfg.entrySet(); - if (streamConfigEntries.size() != 1) { - throw new ServiceException( - "Invalid configuration. Number of streams must be one, config: " + streamConfigEntries); - } - JsonObject streamConfigEntry = streamConfigEntries.iterator().next().getValue().getAsJsonObject(); - JsonObject dmaapInfo = get(streamConfigEntry, "dmaap_info").getAsJsonObject(); - return getAsString(dmaapInfo, "topic_url"); - } - private static String getAsString(JsonObject obj, String memberName) throws ServiceException { return get(obj, memberName).getAsString(); } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ConfigurationFile.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ConfigurationFile.java index efe2fa2e..7f5af451 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ConfigurationFile.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ConfigurationFile.java @@ -1,6 +1,6 @@ /*- * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java index e71f8557..04367e0e 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java index c5436cd3..ec23f838 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbacks.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbacks.java index b028cd63..67b56f8e 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbacks.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbacks.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java index 6470abfe..001226d2 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java index c8d9e4c7..0d0919d8 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java @@ -1,6 +1,6 @@ /*- * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java index 56421003..7f954e90 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java index 82a21ae2..6bc5a6dd 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java index 4e55c506..35c1c947 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java index 04f7e1ec..ae1aed95 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java index c2610b07..0da2e654 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java index 591c1caf..1f0e4476 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java index 44927707..6843cd1e 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java index f5612f9c..715c15b4 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java index e6aa8d41..55593894 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java deleted file mode 100644 index 94888c38..00000000 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java +++ /dev/null @@ -1,235 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * ONAP : ccsdk oran - * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. 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.ccsdk.oran.a1policymanagementservice.dmaap; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.lang.invoke.MethodHandles; -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; - -import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient; -import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory; -import org.onap.ccsdk.oran.a1policymanagementservice.clients.SecurityContext; -import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.FluxSink; -import reactor.core.publisher.Mono; - -/** - * The class fetches incoming requests from DMAAP. It uses the timeout parameter - * that lets the MessageRouter keep the connection with the Kafka open until - * requests are sent in. - * - * <p> - * this service will regularly check the configuration and start polling DMaaP - * if the configuration is added. If the DMaaP configuration is removed, then - * the service will stop polling and resume checking for configuration. - * - * <p> - * Each received request is processed by {@link DmaapMessageHandler}. - */ -@Component -public class DmaapMessageConsumer { - - protected static final Duration TIME_BETWEEN_DMAAP_RETRIES = Duration.ofSeconds(10); - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final ApplicationConfig applicationConfig; - - private DmaapMessageHandler dmaapMessageHandler = null; - - private final Gson gson; - - private final AsyncRestClientFactory restClientFactory; - - private final InfiniteFlux infiniteSubmitter = new InfiniteFlux(); - - @Value("${server.http-port}") - private int localServerHttpPort; - - private static class InfiniteFlux { - private FluxSink<Integer> sink; - private int counter = 0; - - public synchronized Flux<Integer> start() { - stop(); - return Flux.create(this::next).doOnRequest(this::onRequest); - } - - public synchronized void stop() { - if (this.sink != null) { - this.sink.complete(); - this.sink = null; - } - } - - void onRequest(long no) { - for (long i = 0; i < no; ++i) { - sink.next(counter++); - } - } - - void next(FluxSink<Integer> sink) { - this.sink = sink; - sink.next(counter++); - } - - } - - @Autowired - public DmaapMessageConsumer(ApplicationConfig applicationConfig, SecurityContext securityContext) { - this.applicationConfig = applicationConfig; - GsonBuilder gsonBuilder = new GsonBuilder(); - this.gson = gsonBuilder.create(); - this.restClientFactory = new AsyncRestClientFactory(applicationConfig.getWebClientConfig(), securityContext); - } - - /** - * Starts the DMAAP consumer. If there is a DMaaP configuration, it will start - * polling for messages. Otherwise it will check regularly for the - * configuration. - * - */ - public void start() { - infiniteSubmitter.stop(); - - createTask().subscribe(// - value -> logger.debug("DmaapMessageConsumer next: {}", value), // - throwable -> logger.error("DmaapMessageConsumer error: {}", throwable.getMessage()), // - () -> logger.warn("DmaapMessageConsumer stopped") // - ); - } - - protected Flux<String> createTask() { - return infiniteFlux() // - .flatMap(notUsed -> fetchFromDmaap(), 1) // - .doOnNext(message -> logger.debug("Message Reveived from DMAAP : {}", message)) // - .flatMap(this::parseReceivedMessage, 1)// - .flatMap(this::handleDmaapMsg, 1) // - .onErrorResume(throwable -> Mono.empty()); - } - - protected Flux<Integer> infiniteFlux() { - return infiniteSubmitter.start(); - } - - protected Mono<Object> delay() { - return Mono.delay(TIME_BETWEEN_DMAAP_RETRIES).flatMap(o -> Mono.empty()); - } - - private <T> List<T> parseList(String jsonString, Class<T> clazz) { - List<T> result = new ArrayList<>(); - JsonArray jsonArr = JsonParser.parseString(jsonString).getAsJsonArray(); - for (JsonElement jsonElement : jsonArr) { - // The element can either be a JsonObject or a JsonString - if (jsonElement.isJsonPrimitive()) { - T json = gson.fromJson(jsonElement.getAsString(), clazz); - result.add(json); - } else { - T json = gson.fromJson(jsonElement.toString(), clazz); - result.add(json); - } - } - return result; - } - - protected boolean isDmaapConfigured() { - String producerTopicUrl = applicationConfig.getDmaapProducerTopicUrl(); - String consumerTopicUrl = applicationConfig.getDmaapConsumerTopicUrl(); - return (producerTopicUrl != null && consumerTopicUrl != null && !producerTopicUrl.isEmpty() - && !consumerTopicUrl.isEmpty()); - } - - protected Mono<String> handleDmaapMsg(DmaapRequestMessage dmaapRequestMessage) { - return getDmaapMessageHandler().handleDmaapMsg(dmaapRequestMessage); - } - - protected Mono<String> getFromMessageRouter(String topicUrl) { - logger.trace("getFromMessageRouter {}", topicUrl); - AsyncRestClient c = restClientFactory.createRestClientNoHttpProxy(""); - return c.get(topicUrl); - } - - protected Flux<DmaapRequestMessage> parseReceivedMessage(String jsonString) { - try { - logger.trace("parseMessages {}", jsonString); - return Flux.fromIterable(parseList(jsonString, DmaapRequestMessage.class)); - } catch (Exception e) { - logger.error("parseMessages error {}", jsonString); - return sendErrorResponse("Could not parse: " + jsonString) // - .flatMapMany(s -> Flux.empty()); - } - } - - protected Mono<String> sendErrorResponse(String response) { - logger.debug("sendErrorResponse {}", response); - DmaapRequestMessage fakeRequest = DmaapRequestMessage.builder() // - .apiVersion("") // - .correlationId("") // - .operation(DmaapRequestMessage.Operation.PUT) // - .originatorId("") // - .payload(null) // - .requestId("") // - .target("") // - .timestamp("") // - .url("URL") // - .build(); - return getDmaapMessageHandler().sendDmaapResponse(response, fakeRequest, HttpStatus.BAD_REQUEST) // - .onErrorResume(e -> Mono.empty()); - } - - private Mono<String> fetchFromDmaap() { - if (!this.isDmaapConfigured()) { - return delay().flatMap(o -> Mono.empty()); - } - logger.debug("fetchFromDmaap"); - String topicUrl = this.applicationConfig.getDmaapConsumerTopicUrl(); - - return getFromMessageRouter(topicUrl) // - .onErrorResume(throwable -> delay().flatMap(o -> Mono.empty())); - } - - private DmaapMessageHandler getDmaapMessageHandler() { - if (this.dmaapMessageHandler == null) { - String pmsBaseUrl = "http://localhost:" + this.localServerHttpPort; - AsyncRestClient pmsClient = restClientFactory.createRestClientNoHttpProxy(pmsBaseUrl); - AsyncRestClient producer = - restClientFactory.createRestClientNoHttpProxy(this.applicationConfig.getDmaapProducerTopicUrl()); - this.dmaapMessageHandler = new DmaapMessageHandler(producer, pmsClient); - } - return this.dmaapMessageHandler; - } - -} diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java deleted file mode 100644 index 022dec05..00000000 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * ONAP : ccsdk oran - * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. 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.ccsdk.oran.a1policymanagementservice.dmaap; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; - -import java.lang.invoke.MethodHandles; - -import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient; -import org.onap.ccsdk.oran.a1policymanagementservice.dmaap.DmaapRequestMessage.Operation; -import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.reactive.function.client.WebClientException; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -/** - * The class handles incoming requests from DMAAP. - * <p> - * That means: invoke a REST call towards this services and to send back a - * response though DMAAP - */ -public class DmaapMessageHandler { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private static Gson gson = new GsonBuilder().create(); - private final AsyncRestClient dmaapClient; - private final AsyncRestClient pmsClient; - - public DmaapMessageHandler(AsyncRestClient dmaapClient, AsyncRestClient pmsClient) { - this.pmsClient = pmsClient; - this.dmaapClient = dmaapClient; - } - - public Mono<String> handleDmaapMsg(DmaapRequestMessage dmaapRequestMessage) { - return this.invokePolicyManagementService(dmaapRequestMessage) // - .onErrorResume(t -> handlePolicyManagementServiceCallError(t, dmaapRequestMessage)) // - .flatMap(response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage, - response.getStatusCode())) - .doOnError(t -> logger.warn("Failed to handle DMAAP message : {}", t.getMessage()))// - .onErrorResume(t -> Mono.empty()); - } - - private Mono<ResponseEntity<String>> handlePolicyManagementServiceCallError(Throwable error, - DmaapRequestMessage dmaapRequestMessage) { - logger.debug("Policy Management Service call failed: {}", error.getMessage()); - HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; - String errorMessage = error.getMessage(); - if (error instanceof WebClientResponseException) { - WebClientResponseException exception = (WebClientResponseException) error; - status = exception.getStatusCode(); - errorMessage = exception.getResponseBodyAsString(); - } else if (error instanceof ServiceException) { - status = HttpStatus.BAD_REQUEST; - errorMessage = error.getMessage(); - } else if (!(error instanceof WebClientException)) { - logger.warn("Unexpected exception ", error); - } - return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) // - .flatMap(notUsed -> Mono.empty()); - } - - public Mono<String> sendDmaapResponse(String response, DmaapRequestMessage dmaapRequestMessage, HttpStatus status) { - return createDmaapResponseMessage(dmaapRequestMessage, response, status) // - .flatMap(this::sendToDmaap) // - .onErrorResume(this::handleResponseCallError); - } - - private Mono<ResponseEntity<String>> invokePolicyManagementService(DmaapRequestMessage dmaapRequestMessage) { - DmaapRequestMessage.Operation operation = dmaapRequestMessage.getOperation(); - String uri = dmaapRequestMessage.getUrl(); - - if (operation == Operation.DELETE) { - return pmsClient.deleteForEntity(uri); - } else if (operation == Operation.GET) { - return pmsClient.getForEntity(uri); - } else if (operation == Operation.PUT) { - return pmsClient.putForEntity(uri, payload(dmaapRequestMessage)); - } else if (operation == Operation.POST) { - return pmsClient.postForEntity(uri, payload(dmaapRequestMessage)); - } else { - return Mono.error(new ServiceException("Not implemented operation: " + operation)); - } - } - - private String payload(DmaapRequestMessage message) { - JsonObject payload = message.getPayload(); - if (payload != null) { - return gson.toJson(payload); - } else { - logger.warn("Expected payload in message from DMAAP: {}", message); - return ""; - } - } - - private Mono<String> sendToDmaap(String body) { - logger.debug("sendToDmaap: {} ", body); - return dmaapClient.post("", "[" + body + "]"); - } - - private Mono<String> handleResponseCallError(Throwable t) { - logger.warn("Failed to send response to DMaaP: {}", t.getMessage()); - return Mono.empty(); - } - - private Mono<String> createDmaapResponseMessage(DmaapRequestMessage dmaapRequestMessage, String response, - HttpStatus status) { - DmaapResponseMessage dmaapResponseMessage = DmaapResponseMessage.builder() // - .status(status.toString()) // - .message(response == null ? "" : response) // - .type("response") // - .correlationId( - dmaapRequestMessage.getCorrelationId() == null ? "" : dmaapRequestMessage.getCorrelationId()) // - .originatorId( - dmaapRequestMessage.getOriginatorId() == null ? "" : dmaapRequestMessage.getOriginatorId()) // - .requestId(dmaapRequestMessage.getRequestId() == null ? "" : dmaapRequestMessage.getRequestId()) // - .timestamp(dmaapRequestMessage.getTimestamp() == null ? "" : dmaapRequestMessage.getTimestamp()) // - .build(); - String str = gson.toJson(dmaapResponseMessage); - return Mono.just(str); - } -} diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java deleted file mode 100644 index 10dc981e..00000000 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * ONAP : ccsdk oran - * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. 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.ccsdk.oran.a1policymanagementservice.dmaap; - -import com.google.gson.JsonObject; - -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -@Getter -@Builder -@EqualsAndHashCode -public class DmaapRequestMessage { - - public enum Operation { - PUT, GET, DELETE, POST - } - - String correlationId; - - String target; - - String timestamp; - - String apiVersion; - - String originatorId; - - String requestId; - - Operation operation; - - String url; - - JsonObject payload; -} diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java deleted file mode 100644 index 64778551..00000000 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * ONAP : ccsdk oran - * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. 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.ccsdk.oran.a1policymanagementservice.dmaap; - -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -@Getter -@Builder -@EqualsAndHashCode -public class DmaapResponseMessage { - - String type; - - String correlationId; - - String timestamp; - - String originatorId; - - String requestId; - - String status; - - String message; -} diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java index 3f0d3a0c..f11e30f3 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * ONAP : ccsdk oran * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * Copyright (C) 2020-2023 Nordix Foundation. 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. |