diff options
Diffstat (limited to 'a1-policy-management/src/main/java/org')
12 files changed, 20 insertions, 56 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/DatabaseIndependentBeanFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/DatabaseIndependentBeanFactory.java index 305499d0..9c489a30 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/DatabaseIndependentBeanFactory.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/DatabaseIndependentBeanFactory.java @@ -46,7 +46,7 @@ public class DatabaseIndependentBeanFactory { @Bean public PolicyTypes getPolicyTypes(@Autowired ApplicationConfig applicationConfig) { PolicyTypes types = new PolicyTypes(applicationConfig); - types.restoreFromDatabase().blockLast(); + types.restoreFromDatabase().subscribe(); return types; } 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 ab93ea3e..66d32110 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 @@ -92,26 +92,4 @@ class A1AdapterJsonHelper { return Mono.error(ex); } } - - public static Mono<String> getValueFromResponse(String response, String key) { - return getOutput(response) // - .map(responseParams -> { - if (!responseParams.has(key)) { - return ""; - } - return responseParams.get(key).toString(); - }); - } - - public static Mono<String> extractPolicySchema(String inputString) { - try { - JSONObject jsonObject = new JSONObject(inputString); - JSONObject schemaObject = jsonObject.getJSONObject("policySchema"); - String schemaString = schemaObject.toString(); - return Mono.just(schemaString); - } catch (Exception ex) { // invalid json - logger.debug("Invalid json {}", ex.getMessage()); - return Mono.error(ex); - } - } } 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 01891e99..947c50db 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 @@ -21,20 +21,18 @@ package org.onap.ccsdk.oran.a1policymanagementservice.clients; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Constructor; - import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client.A1ProtocolType; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig; -import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ControllerConfig; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import reactor.core.publisher.Mono; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Constructor; + /** * Factory for A1 clients that supports four different protocol versions of the * A1 api. @@ -92,28 +90,19 @@ public class A1ClientFactory { } } - private ControllerConfig getControllerConfig(Ric ric) throws ServiceException { - ControllerConfig controllerConfig = ric.getConfig().getControllerConfig(); - if (controllerConfig == null) { - ric.setProtocolVersion(A1ProtocolType.UNKNOWN); - throw new ServiceException("No controller configured for Near-RT RIC: " + ric.id()); - } - return controllerConfig; - } - private A1Client createCustomAdapter(Ric ric) throws ServiceException { try { if (ric.getConfig().getCustomAdapterClass() != null && !ric.getConfig().getCustomAdapterClass().isEmpty()) { Class<?> clazz = Class.forName(ric.getConfig().getCustomAdapterClass()); if (A1Client.class.isAssignableFrom(clazz)) { Constructor<?> constructor = clazz.getConstructor(RicConfig.class, AsyncRestClientFactory.class); - logger.debug("A1Client (" + clazz.getTypeName() + ") being created for ric: {}", - ric.getConfig().getRicId()); + logger.debug("A1Client \"{}\" being created for ric: {}", + clazz.getTypeName(), ric.getConfig().getRicId()); return (A1Client) constructor.newInstance(ric.getConfig(), this.restClientFactory); } else if (A1Client.Factory.class.isAssignableFrom(clazz)) { A1Client.Factory factory = (A1Client.Factory) clazz.getDeclaredConstructor().newInstance(); - logger.debug("A1Client (" + clazz.getTypeName() + ") factory creating client for ric: {}", - ric.getConfig().getRicId()); + logger.debug("A1Client \"{}\" factory creating client for ric: {}", + clazz.getTypeName(), ric.getConfig().getRicId()); return factory.create(ric.getConfig(), this.restClientFactory); } else { throw new ServiceException("The custom class must either implement A1Client.Factory or A1Client"); 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 04ecf045..f62d0807 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 @@ -100,7 +100,6 @@ public class CcsdkA1AdapterClient implements A1Client { * CCSDK_A1_ADAPTER_STD_V2_0_0 with * @param ricConfig the configuration of the Near-RT RIC to communicate * with - * @param controllerConfig the configuration of the CCSDK A1 Adapter to use * * @throws IllegalArgumentException when the protocolType is wrong. */ @@ -119,7 +118,6 @@ public class CcsdkA1AdapterClient implements A1Client { * CCSDK_A1_ADAPTER_STD_V2_0_0 with * @param ricConfig the configuration of the Near-RT RIC to communicate * with - * @param controllerConfig the configuration of the CCSDK A1 Adapter to use * @param restClient the REST client to use * * @throws IllegalArgumentException when the protocolType is illegal. @@ -131,8 +129,8 @@ public class CcsdkA1AdapterClient implements A1Client { this.restClient = restClient; this.ricConfig = ricConfig; this.protocolType = protocolType; - logger.debug("A1Client (" + getClass().getTypeName() + ") created for ric: {}, a1Controller: {}", - ricConfig.getRicId(), ricConfig.getControllerConfig()); + logger.debug("A1Client \"{}\" created for ric: {}, a1Controller: {}", + getClass().getTypeName(), ricConfig.getRicId(), ricConfig.getControllerConfig()); } else { logger.error("Not supported protocoltype: {}", protocolType); 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 17681cb6..f536076b 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 @@ -143,7 +143,7 @@ public class OscA1Client implements A1Client { public OscA1Client(RicConfig ricConfig, AsyncRestClient restClient) { this.restClient = restClient; uri = new UriBuilder(ricConfig); - logger.debug("A1Client (" + getClass().getTypeName() + ") created for ric: {}", ricConfig.getRicId()); + logger.debug("A1Client \"{}\" created for ric: {}", getClass().getTypeName(), ricConfig.getRicId()); } public static Mono<String> extractCreateSchema(String policyTypeResponse, String policyTypeId) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java index 2f06b6a6..b033aeaa 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java @@ -109,7 +109,7 @@ public class StdA1ClientVersion1 implements A1Client { public StdA1ClientVersion1(AsyncRestClient restClient, RicConfig ricConfig) { this.restClient = restClient; this.uri = new UriBuilder(ricConfig); - logger.debug("A1Client (" + getClass().getTypeName() + ") created for ric: {}", ricConfig.getRicId()); + logger.debug("A1Client \"{}\" created for ric: {}", getClass().getTypeName(), ricConfig.getRicId()); } @Override 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 6f907539..3362b790 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 @@ -138,7 +138,7 @@ public class StdA1ClientVersion2 implements A1Client { public StdA1ClientVersion2(RicConfig ricConfig, AsyncRestClient restClient) { this.restClient = restClient; uriBuiler = new OranV2UriBuilder(ricConfig); - logger.debug("A1Client (" + getClass().getTypeName() + ") created for ric: {}", ricConfig.getRicId()); + logger.debug("A1Client \"{}\" created for ric: {}", getClass().getTypeName(), ricConfig.getRicId()); } public static Mono<String> extractPolicySchema(String policyTypeResponse, String policyTypeId) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/AuthorizationResult.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/AuthorizationResult.java index 796c44e9..dc717d38 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/AuthorizationResult.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/AuthorizationResult.java @@ -32,7 +32,7 @@ import lombok.Getter; @Builder public class AuthorizationResult { - @Schema(name = "result", description = "If true, the access is granted", required = true) + @Schema(name = "result", description = "If true, the access is granted", requiredMode = Schema.RequiredMode.REQUIRED) @JsonProperty(value = "result", required = true) @SerializedName("result") @Getter diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/PolicyAuthorizationRequest.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/PolicyAuthorizationRequest.java index 8dd4e7bb..cb93006a 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/PolicyAuthorizationRequest.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/authorization/PolicyAuthorizationRequest.java @@ -51,25 +51,25 @@ public class PolicyAuthorizationRequest { READ, WRITE, DELETE } - @Schema(name = "access_type", description = "Access type", required = true) + @Schema(name = "access_type", description = "Access type", requiredMode = Schema.RequiredMode.REQUIRED) @JsonProperty(value = "access_type", required = true) @SerializedName("access_type") @Getter private AccessType accessType; - @Schema(name = "policy_type_id", description = "Policy type identifier", required = true) + @Schema(name = "policy_type_id", description = "Policy type identifier", requiredMode = Schema.RequiredMode.REQUIRED) @SerializedName("policy_type_id") @JsonProperty(value = "policy_type_id", required = true) private String policyTypeId; - @Schema(name = "auth_token", description = "Authorization token", required = true) + @Schema(name = "auth_token", description = "Authorization token", requiredMode = Schema.RequiredMode.REQUIRED) @SerializedName("auth_token") @JsonProperty(value = "auth_token", required = true) private String authToken; } - @Schema(name = "input", description = "Input", required = true) + @Schema(name = "input", description = "Input", requiredMode = Schema.RequiredMode.REQUIRED) @JsonProperty(value = "input", required = true) @SerializedName("input") private Input input; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java index f463ecd0..426e1c47 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java @@ -45,7 +45,7 @@ public class DatabaseDependentBeanFactory { @DependsOn({ "springContextProvider", "flywayInitializer" }) public PolicyTypes getPolicyTypes(@Autowired ApplicationConfig applicationConfig) { PolicyTypes types = new PolicyTypes(applicationConfig); - types.restoreFromDatabase().blockLast(); + types.restoreFromDatabase().subscribe(); return types; } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/datastore/S3ObjectStore.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/datastore/S3ObjectStore.java index 1c67ff7d..d014ad53 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/datastore/S3ObjectStore.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/datastore/S3ObjectStore.java @@ -141,7 +141,7 @@ class S3ObjectStore implements DataStore { return Mono.fromFuture(future) // .map(f -> s3Bucket) // .doOnError(t -> logger.debug("Could not create S3 bucket: {}", t.getMessage())) - .onErrorResume(t -> Mono.just(s3Bucket)); + .onErrorResume(t -> Mono.just("Not Created")); } @Override diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/ErrorHandlingService.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/ErrorHandlingService.java index 693ae513..b445150a 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/ErrorHandlingService.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/ErrorHandlingService.java @@ -20,7 +20,6 @@ package org.onap.ccsdk.oran.a1policymanagementservice.service.v3; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.PolicyController; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.ProblemDetails; import org.slf4j.Logger; |