aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2020-09-03 16:24:57 -0400
committerSingal, Kapil (ks220y) <ks220y@att.com>2020-09-03 17:12:29 -0400
commit7788a0b2ef5ca1dbdad19cc2f39245c4a91ec066 (patch)
tree6f02d3eca27d2237c9355e6ff86f9613caa0ab8e /a1-policy-management/src/main
parent25473e2b1596a01687940edfbad7533d99e1717a (diff)
Fixing and Refactoring POM's
Adding missing xml tag and parent pom referencing Issue-ID: CCSDK-2730 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: I2fa6eb3aea80480452122a62b417a2e944732645
Diffstat (limited to 'a1-policy-management/src/main')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java50
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java26
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java152
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java18
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java21
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java80
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java86
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java8
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java18
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java38
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java191
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java22
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java32
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java12
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java257
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java8
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java44
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java54
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java26
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java31
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java31
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java51
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java30
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java81
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java42
38 files changed, 684 insertions, 775 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
index a5636592..89058a1c 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
@@ -54,14 +54,14 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
static final String API_TITLE = "A1 Policy management service";
static final String DESCRIPTION = //
- "The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices. \n" //
- + "It provides support for:" //
- + "<ul>" //
- + "<li>A1 Policy creation and modification.</li>" //
- + "<li>Maintaining a view of supported Near-RT RIC policy types </li>" //
- + "<li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> " //
- + "<li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li>" //
- + "</ul>"//
+ "The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices. \n" //
+ + "It provides support for:" //
+ + "<ul>" //
+ + "<li>A1 Policy creation and modification.</li>" //
+ + "<li>Maintaining a view of supported Near-RT RIC policy types </li>" //
+ + "<li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> " //
+ + "<li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li>" //
+ + "</ul>"//
;
static final String VERSION = "1.1.0";
@SuppressWarnings("squid:S1075") // Refactor your code to get this URI from a customizable parameter.
@@ -78,25 +78,25 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2) //
- .apiInfo(apiInfo()) //
- .select() //
- .apis(RequestHandlerSelectors.any()) //
- .paths(PathSelectors.any()) //
- .paths(Predicates.not(PathSelectors.regex("/error"))) //
- // this endpoint is not implemented, but was visible for Swagger
- .paths(Predicates.not(PathSelectors.regex("/actuator.*"))) //
- // this endpoint is implemented by spring framework, exclude for now
- .build();
+ .apiInfo(apiInfo()) //
+ .select() //
+ .apis(RequestHandlerSelectors.any()) //
+ .paths(PathSelectors.any()) //
+ .paths(Predicates.not(PathSelectors.regex("/error"))) //
+ // this endpoint is not implemented, but was visible for Swagger
+ .paths(Predicates.not(PathSelectors.regex("/actuator.*"))) //
+ // this endpoint is implemented by spring framework, exclude for now
+ .build();
}
private static ApiInfo apiInfo() {
return new ApiInfoBuilder() //
- .title(API_TITLE) //
- .description(DESCRIPTION) //
- .version(VERSION) //
- .contact(contact()) //
- .extensions(vendorExtentions()) //
- .build();
+ .title(API_TITLE) //
+ .description(DESCRIPTION) //
+ .version(VERSION) //
+ .contact(contact()) //
+ .extensions(vendorExtentions()) //
+ .build();
}
@SuppressWarnings("rawtypes") // VendorExtension is a raw type. References to generic type VendorExtension<T>
@@ -116,10 +116,10 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(SWAGGER_UI) //
- .addResourceLocations(RESOURCES_PATH);
+ .addResourceLocations(RESOURCES_PATH);
registry.addResourceHandler(WEBJARS) //
- .addResourceLocations(WEBJARS_PATH);
+ .addResourceLocations(WEBJARS_PATH);
}
}
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 31a706b4..cfb01d0b 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
@@ -66,7 +66,7 @@ public class A1ClientFactory {
*/
public Mono<A1Client> createA1Client(Ric ric) {
return getProtocolVersion(ric) //
- .flatMap(version -> createA1ClientMono(ric, version));
+ .flatMap(version -> createA1ClientMono(ric, version));
}
A1Client createClient(Ric ric, A1ProtocolType version) throws ServiceException {
@@ -78,7 +78,7 @@ public class A1ClientFactory {
return new OscA1Client(ric.getConfig(), this.appConfig.getWebClientConfig());
} else if (version == A1ProtocolType.SDNC_OSC_STD_V1_1 || version == A1ProtocolType.SDNC_OSC_OSC_V1) {
return new SdncOscA1Client(version, ric.getConfig(), getControllerConfig(ric),
- this.appConfig.getWebClientConfig());
+ this.appConfig.getWebClientConfig());
} else if (version == A1ProtocolType.SDNC_ONAP) {
return new SdncOnapA1Client(ric.getConfig(), getControllerConfig(ric), this.appConfig.getWebClientConfig());
} else {
@@ -105,7 +105,7 @@ public class A1ClientFactory {
if (!ric.getConfig().controllerName().isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
throw new ServiceException(
- "Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version);
+ "Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version);
}
}
@@ -120,15 +120,15 @@ public class A1ClientFactory {
private Mono<A1Client.A1ProtocolType> getProtocolVersion(Ric ric) {
if (ric.getProtocolVersion() == A1ProtocolType.UNKNOWN) {
return fetchVersion(ric, A1ProtocolType.STD_V1_1) //
- .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.OSC_V1)) //
- .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_OSC_STD_V1_1)) //
- .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
- .doOnNext(ric::setProtocolVersion)
- .doOnNext(
- version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version, ric.id())) //
- .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) //
- .onErrorResume(
- notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id())));
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.OSC_V1)) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_OSC_STD_V1_1)) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
+ .doOnNext(ric::setProtocolVersion)
+ .doOnNext(version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version,
+ ric.id())) //
+ .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) //
+ .onErrorResume(
+ notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id())));
} else {
return Mono.just(ric.getProtocolVersion());
}
@@ -136,6 +136,6 @@ public class A1ClientFactory {
private Mono<A1ProtocolType> fetchVersion(Ric ric, A1ProtocolType protocolType) {
return createA1ClientMono(ric, protocolType) //
- .flatMap(A1Client::getProtocolVersion);
+ .flatMap(A1Client::getProtocolVersion);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
index c3de6b2c..c1cea8b5 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
@@ -90,18 +90,18 @@ public class AsyncRestClient {
logger.trace("{} POST body: {}", traceTag, body);
Mono<String> bodyProducer = body != null ? Mono.just(body) : Mono.empty();
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.post() //
- .uri(uri) //
- .contentType(MediaType.APPLICATION_JSON) //
- .body(bodyProducer, String.class);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.post() //
+ .uri(uri) //
+ .contentType(MediaType.APPLICATION_JSON) //
+ .body(bodyProducer, String.class);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> post(String uri, @Nullable String body) {
return postForEntity(uri, body) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
public Mono<String> postWithAuthHeader(String uri, String body, String username, String password) {
@@ -109,15 +109,15 @@ public class AsyncRestClient {
logger.debug("{} POST (auth) uri = '{}{}''", traceTag, baseUrl, uri);
logger.trace("{} POST body: {}", traceTag, body);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.post() //
- .uri(uri) //
- .headers(headers -> headers.setBasicAuth(username, password)) //
- .contentType(MediaType.APPLICATION_JSON) //
- .bodyValue(body);
- return retrieve(traceTag, request) //
- .flatMap(this::toBody);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.post() //
+ .uri(uri) //
+ .headers(headers -> headers.setBasicAuth(username, password)) //
+ .contentType(MediaType.APPLICATION_JSON) //
+ .bodyValue(body);
+ return retrieve(traceTag, request) //
+ .flatMap(this::toBody);
+ });
}
public Mono<ResponseEntity<String>> putForEntity(String uri, String body) {
@@ -125,13 +125,13 @@ public class AsyncRestClient {
logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri);
logger.trace("{} PUT body: {}", traceTag, body);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.put() //
- .uri(uri) //
- .contentType(MediaType.APPLICATION_JSON) //
- .bodyValue(body);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.put() //
+ .uri(uri) //
+ .contentType(MediaType.APPLICATION_JSON) //
+ .bodyValue(body);
+ return retrieve(traceTag, request);
+ });
}
public Mono<ResponseEntity<String>> putForEntity(String uri) {
@@ -139,54 +139,54 @@ public class AsyncRestClient {
logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri);
logger.trace("{} PUT body: <empty>", traceTag);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.put() //
- .uri(uri);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.put() //
+ .uri(uri);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> put(String uri, String body) {
return putForEntity(uri, body) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
public Mono<ResponseEntity<String>> getForEntity(String uri) {
Object traceTag = createTraceTag();
logger.debug("{} GET uri = '{}{}''", traceTag, baseUrl, uri);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.get().uri(uri);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.get().uri(uri);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> get(String uri) {
return getForEntity(uri) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
public Mono<ResponseEntity<String>> deleteForEntity(String uri) {
Object traceTag = createTraceTag();
logger.debug("{} DELETE uri = '{}{}''", traceTag, baseUrl, uri);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.delete().uri(uri);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.delete().uri(uri);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> delete(String uri) {
return deleteForEntity(uri) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
private Mono<ResponseEntity<String>> retrieve(Object traceTag, RequestHeadersSpec<?> request) {
final Class<String> clazz = String.class;
return request.retrieve() //
- .toEntity(clazz) //
- .doOnNext(entity -> logReceivedData(traceTag, entity)) //
- .doOnError(throwable -> onHttpError(traceTag, throwable));
+ .toEntity(clazz) //
+ .doOnNext(entity -> logReceivedData(traceTag, entity)) //
+ .doOnError(throwable -> onHttpError(traceTag, throwable));
}
private void logReceivedData(Object traceTag, ResponseEntity<String> entity) {
@@ -201,7 +201,7 @@ public class AsyncRestClient {
if (t instanceof WebClientResponseException) {
WebClientResponseException exception = (WebClientResponseException) t;
logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(),
- exception.getResponseBodyAsString());
+ exception.getResponseBodyAsString());
} else {
logger.debug("{} HTTP error", traceTag, t);
}
@@ -234,7 +234,7 @@ public class AsyncRestClient {
}
private static synchronized KeyStore getTrustStore(String trustStorePath, String trustStorePass)
- throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
+ throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
if (clientTrustStore == null) {
KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());
store.load(new FileInputStream(ResourceUtils.getFile(trustStorePath)), trustStorePass.toCharArray());
@@ -244,66 +244,66 @@ public class AsyncRestClient {
}
private SslContext createSslContextRejectingUntrustedPeers(String trustStorePath, String trustStorePass,
- KeyManagerFactory keyManager)
- throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
+ KeyManagerFactory keyManager)
+ throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
final KeyStore trustStore = getTrustStore(trustStorePath, trustStorePass);
List<Certificate> certificateList = Collections.list(trustStore.aliases()).stream() //
- .filter(alias -> isCertificateEntry(trustStore, alias)) //
- .map(alias -> getCertificate(trustStore, alias)) //
- .collect(Collectors.toList());
+ .filter(alias -> isCertificateEntry(trustStore, alias)) //
+ .map(alias -> getCertificate(trustStore, alias)) //
+ .collect(Collectors.toList());
final X509Certificate[] certificates = certificateList.toArray(new X509Certificate[certificateList.size()]);
return SslContextBuilder.forClient() //
- .keyManager(keyManager) //
- .trustManager(certificates) //
- .build();
+ .keyManager(keyManager) //
+ .trustManager(certificates) //
+ .build();
}
private SslContext createSslContext(KeyManagerFactory keyManager)
- throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
+ throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
if (this.clientConfig.isTrustStoreUsed()) {
return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(),
- this.clientConfig.trustStorePassword(), keyManager);
+ this.clientConfig.trustStorePassword(), keyManager);
} else {
// Trust anyone
return SslContextBuilder.forClient() //
- .keyManager(keyManager) //
- .trustManager(InsecureTrustManagerFactory.INSTANCE) //
- .build();
+ .keyManager(keyManager) //
+ .trustManager(InsecureTrustManagerFactory.INSTANCE) //
+ .build();
}
}
private TcpClient createTcpClientSecure(SslContext sslContext) {
return TcpClient.create(ConnectionProvider.newConnection()) //
- .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
- .secure(c -> c.sslContext(sslContext)) //
- .doOnConnected(connection -> {
- connection.addHandlerLast(new ReadTimeoutHandler(30));
- connection.addHandlerLast(new WriteTimeoutHandler(30));
- });
+ .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
+ .secure(c -> c.sslContext(sslContext)) //
+ .doOnConnected(connection -> {
+ connection.addHandlerLast(new ReadTimeoutHandler(30));
+ connection.addHandlerLast(new WriteTimeoutHandler(30));
+ });
}
private TcpClient createTcpClientInsecure() {
return TcpClient.create(ConnectionProvider.newConnection()) //
- .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
- .doOnConnected(connection -> {
- connection.addHandlerLast(new ReadTimeoutHandler(30));
- connection.addHandlerLast(new WriteTimeoutHandler(30));
- });
+ .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
+ .doOnConnected(connection -> {
+ connection.addHandlerLast(new ReadTimeoutHandler(30));
+ connection.addHandlerLast(new WriteTimeoutHandler(30));
+ });
}
private WebClient createWebClient(String baseUrl, TcpClient tcpClient) {
HttpClient httpClient = HttpClient.from(tcpClient);
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() //
- .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) //
- .build();
+ .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) //
+ .build();
return WebClient.builder() //
- .clientConnector(connector) //
- .baseUrl(baseUrl) //
- .exchangeStrategies(exchangeStrategies) //
- .build();
+ .clientConnector(connector) //
+ .baseUrl(baseUrl) //
+ .exchangeStrategies(exchangeStrategies) //
+ .build();
}
private Mono<WebClient> getWebClient() {
@@ -311,7 +311,7 @@ public class AsyncRestClient {
try {
if (this.sslEnabled) {
final KeyManagerFactory keyManager =
- KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.keyStoreType());
final String keyStoreFile = this.clientConfig.keyStore();
final String keyStorePassword = this.clientConfig.keyStorePassword();
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 bdbb916b..fed218e8 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
@@ -144,21 +144,21 @@ public class OscA1Client implements A1Client {
@Override
public Mono<List<String>> getPolicyTypeIdentities() {
return getPolicyTypeIds() //
- .collectList();
+ .collectList();
}
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyTypeIds() //
- .flatMap(this::getPolicyIdentitiesByType) //
- .collectList();
+ .flatMap(this::getPolicyIdentitiesByType) //
+ .collectList();
}
@Override
public Mono<String> getPolicyTypeSchema(String policyTypeId) {
String schemaUri = uri.createGetSchemaUri(policyTypeId);
return restClient.get(schemaUri) //
- .flatMap(response -> extractCreateSchema(response, policyTypeId));
+ .flatMap(response -> extractCreateSchema(response, policyTypeId));
}
@Override
@@ -175,13 +175,13 @@ public class OscA1Client implements A1Client {
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return restClient.get(uri.createHealtcheckUri()) //
- .flatMap(notUsed -> Mono.just(A1ProtocolType.OSC_V1));
+ .flatMap(notUsed -> Mono.just(A1ProtocolType.OSC_V1));
}
@Override
public Flux<String> deleteAllPolicies() {
return getPolicyTypeIds() //
- .flatMap(this::deletePoliciesForType, CONCURRENCY_RIC);
+ .flatMap(this::deletePoliciesForType, CONCURRENCY_RIC);
}
@Override
@@ -193,12 +193,12 @@ public class OscA1Client implements A1Client {
private Flux<String> getPolicyTypeIds() {
return restClient.get(uri.createPolicyTypesUri()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Flux<String> getPolicyIdentitiesByType(String typeId) {
return restClient.get(uri.createGetPolicyIdsUri(typeId)) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Mono<String> deletePolicyById(String typeId, String policyId) {
@@ -208,6 +208,6 @@ public class OscA1Client implements A1Client {
private Flux<String> deletePoliciesForType(String typeId) {
return getPolicyIdentitiesByType(typeId) //
- .flatMap(policyId -> deletePolicyById(typeId, policyId), CONCURRENCY_RIC);
+ .flatMap(policyId -> deletePolicyById(typeId, policyId), CONCURRENCY_RIC);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java
index fdbbd533..ada35fd6 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java
@@ -45,13 +45,12 @@ import reactor.core.publisher.Mono;
@SuppressWarnings("java:S1192") // Same text in several traces
class SdncJsonHelper {
private static Gson gson = new GsonBuilder() //
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
- .create();
+ .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
+ .create();
private static final String OUTPUT = "output";
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private SdncJsonHelper() {
- }
+ private SdncJsonHelper() {}
public static Flux<String> parseJsonArrayOfString(String inputString) {
try {
@@ -97,13 +96,13 @@ class SdncJsonHelper {
public static Mono<String> getValueFromResponse(String response, String key) {
return getOutput(response) //
- .flatMap(responseParams -> {
- if (!responseParams.has(key)) {
- return Mono.just("");
- }
- String value = responseParams.get(key).toString();
- return Mono.just(value);
- });
+ .flatMap(responseParams -> {
+ if (!responseParams.has(key)) {
+ return Mono.just("");
+ }
+ String value = responseParams.get(key).toString();
+ return Mono.just(value);
+ });
}
public static Mono<String> extractPolicySchema(String inputString) {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java
index 0591e668..2c564c3f 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java
@@ -66,9 +66,9 @@ public class SdncOnapA1Client implements A1Client {
public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, WebClientConfig clientConfig) {
this(ricConfig, controllerConfig,
- new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
+ new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
logger.debug("SdncOnapA1Client for ric: {}, a1ControllerBaseUrl: {}", ricConfig.ricId(),
- controllerConfig.baseUrl());
+ controllerConfig.baseUrl());
}
public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, AsyncRestClient restClient) {
@@ -80,47 +80,47 @@ public class SdncOnapA1Client implements A1Client {
@Override
public Mono<List<String>> getPolicyTypeIdentities() {
return getPolicyTypeIds() //
- .collectList();
+ .collectList();
}
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyTypeIds() //
- .flatMap(this::getPolicyIdentitiesByType) //
- .collectList();
+ .flatMap(this::getPolicyIdentitiesByType) //
+ .collectList();
}
@Override
public Mono<String> getPolicyTypeSchema(String policyTypeId) {
SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policyTypeId) //
- .build();
+ .nearRtRicId(ricConfig.baseUrl()) //
+ .policyTypeId(policyTypeId) //
+ .build();
String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
logger.debug("POST getPolicyType inputJsonString = {}", inputJsonString);
return restClient
- .postWithAuthHeader(URL_PREFIX + "getPolicyType", inputJsonString, controllerConfig.userName(),
- controllerConfig.password()) //
- .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type")) //
- .flatMap(SdncJsonHelper::extractPolicySchema);
+ .postWithAuthHeader(URL_PREFIX + "getPolicyType", inputJsonString, controllerConfig.userName(),
+ controllerConfig.password()) //
+ .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type")) //
+ .flatMap(SdncJsonHelper::extractPolicySchema);
}
@Override
public Mono<String> putPolicy(Policy policy) {
SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policy.type().id()) //
- .policyInstanceId(policy.id()) //
- .policyInstance(policy.json()) //
- .properties(new ArrayList<>()) //
- .build();
+ .nearRtRicId(ricConfig.baseUrl()) //
+ .policyTypeId(policy.type().id()) //
+ .policyInstanceId(policy.id()) //
+ .policyInstance(policy.json()) //
+ .properties(new ArrayList<>()) //
+ .build();
String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
logger.debug("POST putPolicy inputJsonString = {}", inputJsonString);
return restClient.postWithAuthHeader(URL_PREFIX + "createPolicyInstance", inputJsonString,
- controllerConfig.userName(), controllerConfig.password());
+ controllerConfig.userName(), controllerConfig.password());
}
@Override
@@ -131,13 +131,13 @@ public class SdncOnapA1Client implements A1Client {
@Override
public Flux<String> deleteAllPolicies() {
return getPolicyTypeIds() //
- .flatMap(this::deletePoliciesForType); //
+ .flatMap(this::deletePoliciesForType); //
}
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return getPolicyTypeIdentities() //
- .flatMap(notUsed -> Mono.just(A1ProtocolType.SDNC_ONAP));
+ .flatMap(notUsed -> Mono.just(A1ProtocolType.SDNC_ONAP));
}
@Override
@@ -147,48 +147,48 @@ public class SdncOnapA1Client implements A1Client {
private Flux<String> getPolicyTypeIds() {
SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .build();
+ .nearRtRicId(ricConfig.baseUrl()) //
+ .build();
String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
logger.debug("POST getPolicyTypeIdentities inputJsonString = {}", inputJsonString);
return restClient
- .postWithAuthHeader(URL_PREFIX + "getPolicyTypes", inputJsonString, controllerConfig.userName(),
- controllerConfig.password()) //
- .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type-id-list")) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .postWithAuthHeader(URL_PREFIX + "getPolicyTypes", inputJsonString, controllerConfig.userName(),
+ controllerConfig.password()) //
+ .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type-id-list")) //
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Flux<String> getPolicyIdentitiesByType(String policyTypeId) {
SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policyTypeId) //
- .build();
+ .nearRtRicId(ricConfig.baseUrl()) //
+ .policyTypeId(policyTypeId) //
+ .build();
String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
logger.debug("POST getPolicyIdentities inputJsonString = {}", inputJsonString);
return restClient
- .postWithAuthHeader(URL_PREFIX + "getPolicyInstances", inputJsonString, controllerConfig.userName(),
- controllerConfig.password()) //
- .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-instance-id-list")) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .postWithAuthHeader(URL_PREFIX + "getPolicyInstances", inputJsonString, controllerConfig.userName(),
+ controllerConfig.password()) //
+ .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-instance-id-list")) //
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Flux<String> deletePoliciesForType(String typeId) {
return getPolicyIdentitiesByType(typeId) //
- .flatMap(policyId -> deletePolicyByTypeId(typeId, policyId)); //
+ .flatMap(policyId -> deletePolicyByTypeId(typeId, policyId)); //
}
private Mono<String> deletePolicyByTypeId(String policyTypeId, String policyId) {
SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policyTypeId) //
- .policyInstanceId(policyId) //
- .build();
+ .nearRtRicId(ricConfig.baseUrl()) //
+ .policyTypeId(policyTypeId) //
+ .policyInstanceId(policyId) //
+ .build();
String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
logger.debug("POST deletePolicy inputJsonString = {}", inputJsonString);
return restClient.postWithAuthHeader(URL_PREFIX + "deletePolicyInstance", inputJsonString,
- controllerConfig.userName(), controllerConfig.password());
+ controllerConfig.userName(), controllerConfig.password());
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java
index 4ad08ce2..3647f225 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java
@@ -68,8 +68,8 @@ public class SdncOscA1Client implements A1Client {
}
static com.google.gson.Gson gson = new GsonBuilder() //
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
- .create(); //
+ .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
+ .create(); //
private static final String GET_POLICY_RPC = "getA1Policy";
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -90,9 +90,9 @@ public class SdncOscA1Client implements A1Client {
* @throws IllegalArgumentException when the protocolType is wrong.
*/
public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
- WebClientConfig clientConfig) {
+ WebClientConfig clientConfig) {
this(protocolType, ricConfig, controllerConfig,
- new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
+ new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
logger.debug("SdncOscA1Client for ric: {}, a1Controller: {}", ricConfig.ricId(), controllerConfig);
}
@@ -109,11 +109,11 @@ public class SdncOscA1Client implements A1Client {
* @throws IllegalArgumentException when the protocolType is wrong.
*/
public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
- AsyncRestClient restClient) {
+ AsyncRestClient restClient) {
if (!(A1ProtocolType.SDNC_OSC_STD_V1_1.equals(protocolType)
- || A1ProtocolType.SDNC_OSC_OSC_V1.equals(protocolType))) {
+ || A1ProtocolType.SDNC_OSC_OSC_V1.equals(protocolType))) {
throw new IllegalArgumentException("Protocol type must be " + A1ProtocolType.SDNC_OSC_STD_V1_1 + " or "
- + A1ProtocolType.SDNC_OSC_OSC_V1 + ", was: " + protocolType);
+ + A1ProtocolType.SDNC_OSC_OSC_V1 + ", was: " + protocolType);
}
this.restClient = restClient;
this.ricConfig = ricConfig;
@@ -129,8 +129,8 @@ public class SdncOscA1Client implements A1Client {
OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
final String ricUrl = uri.createPolicyTypesUri();
return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) //
- .collectList();
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) //
+ .collectList();
}
}
@@ -138,7 +138,7 @@ public class SdncOscA1Client implements A1Client {
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyIds() //
- .collectList();
+ .collectList();
}
@Override
@@ -149,17 +149,17 @@ public class SdncOscA1Client implements A1Client {
OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
final String ricUrl = uri.createGetSchemaUri(policyTypeId);
return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
- .flatMap(response -> OscA1Client.extractCreateSchema(response, policyTypeId));
+ .flatMap(response -> OscA1Client.extractCreateSchema(response, policyTypeId));
}
}
@Override
public Mono<String> putPolicy(Policy policy) {
return getUriBuilder() //
- .flatMap(builder -> {
- String ricUrl = builder.createPutPolicyUri(policy.type().id(), policy.id());
- return post("putA1Policy", ricUrl, Optional.of(policy.json()));
- });
+ .flatMap(builder -> {
+ String ricUrl = builder.createPutPolicyUri(policy.type().id(), policy.id());
+ return post("putA1Policy", ricUrl, Optional.of(policy.json()));
+ });
}
@Override
@@ -171,38 +171,38 @@ public class SdncOscA1Client implements A1Client {
public Flux<String> deleteAllPolicies() {
if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
return getPolicyIds() //
- .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); //
+ .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); //
} else {
OscA1Client.UriBuilder uriBuilder = new OscA1Client.UriBuilder(ricConfig);
return getPolicyTypeIdentities() //
- .flatMapMany(Flux::fromIterable) //
- .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC);
+ .flatMapMany(Flux::fromIterable) //
+ .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC);
}
}
private Flux<String> oscGetInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) {
return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(type), Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Flux<String> oscDeleteInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) {
return oscGetInstancesForType(uriBuilder, type) //
- .flatMap(instance -> deletePolicyById(type, instance), CONCURRENCY_RIC);
+ .flatMap(instance -> deletePolicyById(type, instance), CONCURRENCY_RIC);
}
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return tryStdProtocolVersion() //
- .onErrorResume(t -> tryOscProtocolVersion());
+ .onErrorResume(t -> tryOscProtocolVersion());
}
@Override
public Mono<String> getPolicyStatus(Policy policy) {
return getUriBuilder() //
- .flatMap(builder -> {
- String ricUrl = builder.createGetPolicyStatusUri(policy.type().id(), policy.id());
- return post("getA1PolicyStatus", ricUrl, Optional.empty());
- });
+ .flatMap(builder -> {
+ String ricUrl = builder.createGetPolicyStatusUri(policy.type().id(), policy.id());
+ return post("getA1PolicyStatus", ricUrl, Optional.empty());
+ });
}
private Mono<A1UriBuilder> getUriBuilder() {
@@ -216,13 +216,13 @@ public class SdncOscA1Client implements A1Client {
private Mono<A1ProtocolType> tryOscProtocolVersion() {
OscA1Client.UriBuilder oscApiuriBuilder = new OscA1Client.UriBuilder(ricConfig);
return post(GET_POLICY_RPC, oscApiuriBuilder.createHealtcheckUri(), Optional.empty()) //
- .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_OSC_V1));
+ .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_OSC_V1));
}
private Mono<A1ProtocolType> tryStdProtocolVersion() {
StdA1ClientVersion1.UriBuilder uriBuilder = new StdA1ClientVersion1.UriBuilder(ricConfig);
return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(), Optional.empty()) //
- .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_STD_V1_1));
+ .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_STD_V1_1));
}
private Flux<String> getPolicyIds() {
@@ -230,36 +230,36 @@ public class SdncOscA1Client implements A1Client {
StdA1ClientVersion1.UriBuilder uri = new StdA1ClientVersion1.UriBuilder(ricConfig);
final String ricUrl = uri.createGetPolicyIdsUri();
return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
} else {
OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
return getPolicyTypeIdentities() //
- .flatMapMany(Flux::fromIterable)
- .flatMap(type -> post(GET_POLICY_RPC, uri.createGetPolicyIdsUri(type), Optional.empty())) //
- .flatMap(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(Flux::fromIterable)
+ .flatMap(type -> post(GET_POLICY_RPC, uri.createGetPolicyIdsUri(type), Optional.empty())) //
+ .flatMap(SdncJsonHelper::parseJsonArrayOfString);
}
}
private Mono<String> deletePolicyById(String type, String policyId) {
return getUriBuilder() //
- .flatMap(builder -> {
- String ricUrl = builder.createDeleteUri(type, policyId);
- return post("deleteA1Policy", ricUrl, Optional.empty());
- });
+ .flatMap(builder -> {
+ String ricUrl = builder.createDeleteUri(type, policyId);
+ return post("deleteA1Policy", ricUrl, Optional.empty());
+ });
}
private Mono<String> post(String rpcName, String ricUrl, Optional<String> body) {
AdapterRequest inputParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(ricUrl) //
- .body(body) //
- .build();
+ .nearRtRicUrl(ricUrl) //
+ .body(body) //
+ .build();
final String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
logger.debug("POST inputJsonString = {}", inputJsonString);
return restClient
- .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.userName(),
- this.controllerConfig.password()) //
- .flatMap(this::extractResponseBody);
+ .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.userName(),
+ this.controllerConfig.password()) //
+ .flatMap(this::extractResponseBody);
}
private Mono<String> extractResponse(JSONObject responseOutput) {
@@ -272,7 +272,7 @@ public class SdncOscA1Client implements A1Client {
logger.debug("Error response: {} {}", output.httpStatus(), body);
byte[] responseBodyBytes = body.getBytes(StandardCharsets.UTF_8);
WebClientResponseException responseException = new WebClientResponseException(output.httpStatus(),
- "statusText", null, responseBodyBytes, StandardCharsets.UTF_8, null);
+ "statusText", null, responseBodyBytes, StandardCharsets.UTF_8, null);
return Mono.error(responseException);
}
@@ -280,7 +280,7 @@ public class SdncOscA1Client implements A1Client {
private Mono<String> extractResponseBody(String responseStr) {
return SdncJsonHelper.getOutput(responseStr) //
- .flatMap(this::extractResponse);
+ .flatMap(this::extractResponse);
}
private String controllerUrl(String rpcName) {
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 51beea71..0da9a267 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
@@ -97,7 +97,7 @@ public class StdA1ClientVersion1 implements A1Client {
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyIds() //
- .collectList();
+ .collectList();
}
@Override
@@ -123,13 +123,13 @@ public class StdA1ClientVersion1 implements A1Client {
@Override
public Flux<String> deleteAllPolicies() {
return getPolicyIds() //
- .flatMap(this::deletePolicyById); //
+ .flatMap(this::deletePolicyById); //
}
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return getPolicyIdentities() //
- .flatMap(x -> Mono.just(A1ProtocolType.STD_V1_1));
+ .flatMap(x -> Mono.just(A1ProtocolType.STD_V1_1));
}
@Override
@@ -139,7 +139,7 @@ public class StdA1ClientVersion1 implements A1Client {
private Flux<String> getPolicyIds() {
return restClient.get(uri.createGetPolicyIdsUri()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Mono<String> deletePolicyById(String policyId) {
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 4f8e87fd..65c6daa3 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
@@ -80,14 +80,14 @@ public class ApplicationConfig {
public WebClientConfig getWebClientConfig() {
return ImmutableWebClientConfig.builder() //
- .keyStoreType(this.sslKeyStoreType) //
- .keyStorePassword(this.sslKeyStorePassword) //
- .keyStore(this.sslKeyStore) //
- .keyPassword(this.sslKeyPassword) //
- .isTrustStoreUsed(this.sslTrustStoreUsed) //
- .trustStore(this.sslTrustStore) //
- .trustStorePassword(this.sslTrustStorePassword) //
- .build();
+ .keyStoreType(this.sslKeyStoreType) //
+ .keyStorePassword(this.sslKeyStorePassword) //
+ .keyStore(this.sslKeyStore) //
+ .keyPassword(this.sslKeyPassword) //
+ .isTrustStoreUsed(this.sslTrustStoreUsed) //
+ .trustStore(this.sslTrustStore) //
+ .trustStorePassword(this.sslTrustStorePassword) //
+ .build();
}
public synchronized ControllerConfig getControllerConfig(String name) throws ServiceException {
@@ -123,7 +123,7 @@ public class ApplicationConfig {
}
public synchronized Flux<RicConfigUpdate> setConfiguration(
- ApplicationConfigParser.ConfigParserResult parserResult) {
+ ApplicationConfigParser.ConfigParserResult parserResult) {
Collection<RicConfigUpdate> modifications = new ArrayList<>();
this.controllerConfigs = parserResult.controllerConfigs();
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 07c04e1a..bc1f62a4 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
@@ -87,15 +87,15 @@ public class ApplicationConfigParser {
checkConfigurationConsistency(ricConfigs, controllerConfigs);
return ImmutableConfigParserResult.builder() //
- .dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) //
- .dmaapProducerTopicUrl(dmaapProducerTopicUrl) //
- .ricConfigs(ricConfigs) //
- .controllerConfigs(controllerConfigs) //
- .build();
+ .dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) //
+ .dmaapProducerTopicUrl(dmaapProducerTopicUrl) //
+ .ricConfigs(ricConfigs) //
+ .controllerConfigs(controllerConfigs) //
+ .build();
}
private void checkConfigurationConsistency(List<RicConfig> ricConfigs,
- Map<String, ControllerConfig> controllerConfigs) throws ServiceException {
+ Map<String, ControllerConfig> controllerConfigs) throws ServiceException {
Set<String> ricUrls = new HashSet<>();
Set<String> ricNames = new HashSet<>();
for (RicConfig ric : ricConfigs) {
@@ -107,7 +107,7 @@ public class ApplicationConfigParser {
}
if (!ric.controllerName().isEmpty() && controllerConfigs.get(ric.controllerName()) == null) {
throw new ServiceException(
- "Configuration error, controller configuration not found: " + ric.controllerName());
+ "Configuration error, controller configuration not found: " + ric.controllerName());
}
}
@@ -119,11 +119,11 @@ public class ApplicationConfigParser {
JsonObject ricAsJson = ricElem.getAsJsonObject();
JsonElement controllerNameElement = ricAsJson.get(CONTROLLER);
RicConfig ricConfig = ImmutableRicConfig.builder() //
- .ricId(get(ricAsJson, "name", "id", "ricId").getAsString()) //
- .baseUrl(get(ricAsJson, "baseUrl").getAsString()) //
- .managedElementIds(parseManagedElementIds(get(ricAsJson, "managedElementIds").getAsJsonArray())) //
- .controllerName(controllerNameElement != null ? controllerNameElement.getAsString() : "") //
- .build();
+ .ricId(get(ricAsJson, "name", "id", "ricId").getAsString()) //
+ .baseUrl(get(ricAsJson, "baseUrl").getAsString()) //
+ .managedElementIds(parseManagedElementIds(get(ricAsJson, "managedElementIds").getAsJsonArray())) //
+ .controllerName(controllerNameElement != null ? controllerNameElement.getAsString() : "") //
+ .build();
result.add(ricConfig);
}
return result;
@@ -137,15 +137,15 @@ public class ApplicationConfigParser {
for (JsonElement element : getAsJsonArray(config, CONTROLLER)) {
JsonObject controllerAsJson = element.getAsJsonObject();
ImmutableControllerConfig controllerConfig = ImmutableControllerConfig.builder() //
- .name(get(controllerAsJson, "name").getAsString()) //
- .baseUrl(get(controllerAsJson, "baseUrl").getAsString()) //
- .password(get(controllerAsJson, "password").getAsString()) //
- .userName(get(controllerAsJson, "userName").getAsString()) // )
- .build();
+ .name(get(controllerAsJson, "name").getAsString()) //
+ .baseUrl(get(controllerAsJson, "baseUrl").getAsString()) //
+ .password(get(controllerAsJson, "password").getAsString()) //
+ .userName(get(controllerAsJson, "userName").getAsString()) // )
+ .build();
if (result.put(controllerConfig.name(), controllerConfig) != null) {
throw new ServiceException(
- "Configuration error, more than one controller with name: " + controllerConfig.name());
+ "Configuration error, more than one controller with name: " + controllerConfig.name());
}
}
return result;
@@ -179,7 +179,7 @@ public class ApplicationConfigParser {
Set<Entry<String, JsonElement>> streamConfigEntries = streamCfg.entrySet();
if (streamConfigEntries.size() != 1) {
throw new ServiceException(
- "Invalid configuration. Number of streams must be one, config: " + streamConfigEntries);
+ "Invalid configuration. Number of streams must be one, config: " + streamConfigEntries);
}
JsonObject streamConfigEntry = streamConfigEntries.iterator().next().getValue().getAsJsonObject();
JsonObject dmaapInfo = get(streamConfigEntry, "dmaap_info").getAsJsonObject();
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 6ee656cc..a2b9af4b 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
@@ -27,6 +27,5 @@ import org.immutables.gson.Gson;
@Gson.TypeAdapters
@ApiModel(value = "void", description = "Void/empty")
public class VoidResponse {
- private VoidResponse() {
- }
+ private VoidResponse() {}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java
index cef31c30..c54394e0 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java
@@ -24,6 +24,5 @@ public class Consts {
public static final String V1_API_NAME = "A1 Policy Management Version 1.0";
- private Consts() {
- }
+ private Consts() {}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
index 90666e7a..d5024581 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
@@ -92,18 +92,17 @@ public class PolicyController {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
@GetMapping("/policy_schemas")
@ApiOperation(value = "Returns policy type schema definitions")
- @ApiResponses(
- value = {
+ @ApiResponses(value = {
@ApiResponse(code = 200, message = "Policy schemas", response = Object.class, responseContainer = "List"), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)})
public ResponseEntity<String> getPolicySchemas( //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get the definitions for.") //
- @RequestParam(name = "ric", required = false) String ricName) {
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get the definitions for.") //
+ @RequestParam(name = "ric", required = false) String ricName) {
if (ricName == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
@@ -119,13 +118,13 @@ public class PolicyController {
@GetMapping("/policy_schema")
@ApiOperation(value = "Returns one policy type schema definition")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy schema", response = Object.class),
@ApiResponse(code = 404, message = "The policy type is not found", response = String.class)})
public ResponseEntity<String> getPolicySchema( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy type to get the definition for.") //
- @RequestParam(name = "id", required = true) String id) {
+ @ApiParam(name = "id", required = true,
+ value = "The identity of the policy type to get the definition for.") //
+ @RequestParam(name = "id", required = true) String id) {
try {
PolicyType type = policyTypes.getType(id);
return new ResponseEntity<>(type.schema(), HttpStatus.OK);
@@ -136,17 +135,13 @@ public class PolicyController {
@GetMapping("/policy_types")
@ApiOperation(value = "Query policy type names")
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "Policy type names",
- response = String.class,
- responseContainer = "List"),
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Policy type names", response = String.class,
+ responseContainer = "List"),
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)})
public ResponseEntity<String> getPolicyTypes( //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get types for.") //
- @RequestParam(name = "ric", required = false) String ricName) {
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get types for.") //
+ @RequestParam(name = "ric", required = false) String ricName) {
if (ricName == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK);
@@ -162,14 +157,13 @@ public class PolicyController {
@GetMapping("/policy")
@ApiOperation(value = "Returns a policy configuration") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy found", response = Object.class), //
@ApiResponse(code = 404, message = "Policy is not found")} //
)
public ResponseEntity<String> getPolicy( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = "id", required = true) String id) {
+ @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = "id", required = true) String id) {
try {
Policy p = policies.getPolicy(id);
return new ResponseEntity<>(p.json(), HttpStatus.OK);
@@ -180,28 +174,27 @@ public class PolicyController {
@DeleteMapping("/policy")
@ApiOperation(value = "Delete a policy", response = Object.class)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 204, message = "Policy deleted", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Policy is not found", response = String.class),
@ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class)})
public Mono<ResponseEntity<Object>> deletePolicy( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = "id", required = true) String id) {
+ @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = "id", required = true) String id) {
try {
Policy policy = policies.getPolicy(id);
keepServiceAlive(policy.ownerServiceId());
Ric ric = policy.ric();
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
- .doOnNext(notUsed -> policies.remove(policy)) //
- .flatMap(client -> client.deletePolicy(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
+ .doOnNext(notUsed -> policies.remove(policy)) //
+ .flatMap(client -> client.deletePolicy(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
@@ -209,28 +202,27 @@ public class PolicyController {
@PutMapping(path = "/policy")
@ApiOperation(value = "Put a policy", response = VoidResponse.class)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), //
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
@ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class), //
@ApiResponse(code = 404, message = "Near-RT RIC or policy type is not found", response = String.class) //
- })
+ })
public Mono<ResponseEntity<Object>> putPolicy( //
- @ApiParam(name = "type", required = false, value = "The name of the policy type.") //
- @RequestParam(name = "type", required = false, defaultValue = "") String typeName, //
- @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = "id", required = true) String instanceId, //
- @ApiParam(name = "ric", required = true, value = "The name of the Near-RT RIC where the policy will be " + //
- "created.") //
- @RequestParam(name = "ric", required = true) String ricName, //
- @ApiParam(name = "service", required = true, value = "The name of the service creating the policy.") //
- @RequestParam(name = "service", required = true) String service, //
- @ApiParam(name = "transient", required = false, value = "If the policy is transient or not (boolean " + //
- "defaulted to false). A policy is transient if it will be forgotten when the service needs to " + //
- "reconnect to the Near-RT RIC.") //
- @RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, //
- @RequestBody Object jsonBody) {
+ @ApiParam(name = "type", required = false, value = "The name of the policy type.") //
+ @RequestParam(name = "type", required = false, defaultValue = "") String typeName, //
+ @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = "id", required = true) String instanceId, //
+ @ApiParam(name = "ric", required = true, value = "The name of the Near-RT RIC where the policy will be " + //
+ "created.") //
+ @RequestParam(name = "ric", required = true) String ricName, //
+ @ApiParam(name = "service", required = true, value = "The name of the service creating the policy.") //
+ @RequestParam(name = "service", required = true) String service, //
+ @ApiParam(name = "transient", required = false, value = "If the policy is transient or not (boolean " + //
+ "defaulted to false). A policy is transient if it will be forgotten when the service needs to " + //
+ "reconnect to the Near-RT RIC.") //
+ @RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, //
+ @RequestBody Object jsonBody) {
String jsonString = gson.toJson(jsonBody);
Ric ric = rics.get(ricName);
@@ -240,28 +232,28 @@ public class PolicyController {
return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
Policy policy = ImmutablePolicy.builder() //
- .id(instanceId) //
- .json(jsonString) //
- .type(type) //
- .ric(ric) //
- .ownerServiceId(service) //
- .lastModified(Instant.now()) //
- .isTransient(isTransient) //
- .build();
+ .id(instanceId) //
+ .json(jsonString) //
+ .type(type) //
+ .ric(ric) //
+ .ownerServiceId(service) //
+ .lastModified(Instant.now()) //
+ .isTransient(isTransient) //
+ .build();
final boolean isCreate = this.policies.get(policy.id()) == null;
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> checkSupportedType(ric, type)) //
- .flatMap(notUsed -> validateModifiedPolicy(policy)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
- .flatMap(client -> client.putPolicy(policy)) //
- .doOnNext(notUsed -> policies.put(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(trowable -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> checkSupportedType(ric, type)) //
+ .flatMap(notUsed -> validateModifiedPolicy(policy)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
+ .flatMap(client -> client.putPolicy(policy)) //
+ .doOnNext(notUsed -> policies.put(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(trowable -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
+ .onErrorResume(this::handleException);
}
@SuppressWarnings({"unchecked"})
@@ -287,8 +279,8 @@ public class PolicyController {
Policy current = this.policies.get(policy.id());
if (current != null && !current.ric().id().equals(policy.ric().id())) {
RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
- ", RIC name: " + current.ric().id() + //
- ", new name: " + policy.ric().id(), HttpStatus.CONFLICT);
+ ", RIC name: " + current.ric().id() + //
+ ", new name: " + policy.ric().id(), HttpStatus.CONFLICT);
logger.debug("Request rejected, {}", e.getMessage());
return Mono.error(e);
}
@@ -299,7 +291,7 @@ public class PolicyController {
if (!ric.isSupportingType(type.id())) {
logger.debug("Request rejected, type not supported, RIC: {}", ric);
RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(),
- HttpStatus.NOT_FOUND);
+ HttpStatus.NOT_FOUND);
return Mono.error(e);
}
return Mono.just("OK");
@@ -311,24 +303,23 @@ public class PolicyController {
} else {
logger.debug("Request rejected RIC not IDLE, ric: {}", ric);
RejectionException e = new RejectionException(
- "Ric is not operational, RIC name: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED);
+ "Ric is not operational, RIC name: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED);
return Mono.error(e);
}
}
@GetMapping("/policies")
@ApiOperation(value = "Query policies")
- @ApiResponses(
- value = {
+ @ApiResponses(value = {
@ApiResponse(code = 200, message = "Policies", response = PolicyInfo.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)})
public ResponseEntity<String> getPolicies( //
- @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
- @RequestParam(name = "type", required = false) String type, //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
- @RequestParam(name = "ric", required = false) String ric, //
- @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
- @RequestParam(name = "service", required = false) String service) //
+ @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
+ @RequestParam(name = "type", required = false) String type, //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = "ric", required = false) String ric, //
+ @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
+ @RequestParam(name = "service", required = false) String service) //
{
if ((type != null && this.policyTypes.get(type) == null)) {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
@@ -343,21 +334,17 @@ public class PolicyController {
@GetMapping("/policy_ids")
@ApiOperation(value = "Query policies, only policy identities returned")
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "Policy identitiess",
- response = String.class,
- responseContainer = "List"),
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Policy identitiess", response = String.class,
+ responseContainer = "List"),
@ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)})
public ResponseEntity<String> getPolicyIds( //
- @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
- @RequestParam(name = "type", required = false) String type, //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
- @RequestParam(name = "ric", required = false) String ric, //
- @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
- @RequestParam(name = "service", required = false) String service) //
+ @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
+ @RequestParam(name = "type", required = false) String type, //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = "ric", required = false) String ric, //
+ @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
+ @RequestParam(name = "service", required = false) String service) //
{
if ((type != null && this.policyTypes.get(type) == null)) {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
@@ -372,22 +359,20 @@ public class PolicyController {
@GetMapping("/policy_status")
@ApiOperation(value = "Returns a policy status") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy status", response = Object.class), //
@ApiResponse(code = 404, message = "Policy is not found", response = String.class)} //
)
public Mono<ResponseEntity<String>> getPolicyStatus( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy.") @RequestParam(
- name = "id", //
- required = true) String id) {
+ @ApiParam(name = "id", required = true, value = "The identity of the policy.") @RequestParam(name = "id", //
+ required = true) String id) {
try {
Policy policy = policies.getPolicy(id);
return a1ClientFactory.createA1Client(policy.ric()) //
- .flatMap(client -> client.getPolicyStatus(policy)) //
- .flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK)))
- .onErrorResume(this::handleException);
+ .flatMap(client -> client.getPolicyStatus(policy)) //
+ .flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return Mono.just(new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND));
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java
index c4862016..21e5b96c 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java
@@ -47,8 +47,7 @@ public class PolicyInfo {
@ApiModelProperty(value = "timestamp, last modification time")
public String lastModified;
- PolicyInfo() {
- }
+ PolicyInfo() {}
public boolean validate() {
return id != null && type != null && ric != null && json != null && service != null && lastModified != null;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java
index cd56abda..31c4f3bf 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java
@@ -54,22 +54,21 @@ public class RicRepositoryController {
PolicyTypes types;
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
/**
* Example: http://localhost:8081/rics?managedElementId=kista_1
*/
@GetMapping("/ric")
@ApiOperation(value = "Returns the name of a RIC managing one Mananged Element")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Near-RT RIC is found", response = String.class), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class) //
- })
+ })
public ResponseEntity<String> getRic( //
- @ApiParam(name = "managedElementId", required = true, value = "The identity of the Managed Element") //
- @RequestParam(name = "managedElementId", required = true) String managedElementId) {
+ @ApiParam(name = "managedElementId", required = true, value = "The identity of the Managed Element") //
+ @RequestParam(name = "managedElementId", required = true) String managedElementId) {
Optional<Ric> ric = this.rics.lookupRicForManagedElement(managedElementId);
if (ric.isPresent()) {
@@ -84,13 +83,12 @@ public class RicRepositoryController {
*/
@GetMapping("/rics")
@ApiOperation(value = "Query Near-RT RIC information")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfo.class, responseContainer = "List"), //
@ApiResponse(code = 404, message = "Policy type is not found", response = String.class)})
public ResponseEntity<String> getRics( //
- @ApiParam(name = "policyType", required = false, value = "The name of the policy type") //
- @RequestParam(name = "policyType", required = false) String supportingPolicyType) {
+ @ApiParam(name = "policyType", required = false, value = "The name of the policy type") //
+ @RequestParam(name = "policyType", required = false) String supportingPolicyType) {
if ((supportingPolicyType != null) && (this.types.get(supportingPolicyType) == null)) {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
}
@@ -99,7 +97,7 @@ public class RicRepositoryController {
for (Ric ric : rics.getRics()) {
if (supportingPolicyType == null || ric.isSupportingType(supportingPolicyType)) {
result.add(new RicInfo(ric.id(), ric.getManagedElementIds(), ric.getSupportedPolicyTypeNames(),
- ric.getState().toString()));
+ ric.getState().toString()));
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
index bb85ad14..8f51c686 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
@@ -59,7 +59,7 @@ public class ServiceController {
private final Policies policies;
private static Gson gson = new GsonBuilder() //
- .create(); //
+ .create(); //
@Autowired
ServiceController(Services services, Policies policies) {
@@ -69,13 +69,12 @@ public class ServiceController {
@GetMapping("/services")
@ApiOperation(value = "Returns service information")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = ServiceStatus.class, responseContainer = "List"), //
@ApiResponse(code = 404, message = "Service is not found", response = String.class)})
public ResponseEntity<String> getServices(//
- @ApiParam(name = "name", required = false, value = "The name of the service") //
- @RequestParam(name = "name", required = false) String name) {
+ @ApiParam(name = "name", required = false, value = "The name of the service") //
+ @RequestParam(name = "name", required = false) String name) {
if (name != null && this.services.get(name) == null) {
return new ResponseEntity<>("Service not found", HttpStatus.NOT_FOUND);
}
@@ -93,11 +92,11 @@ public class ServiceController {
private ServiceStatus toServiceStatus(Service s) {
return new ServiceStatus(s.getName(), s.getKeepAliveInterval().toSeconds(), s.timeSinceLastPing().toSeconds(),
- s.getCallbackUrl());
+ s.getCallbackUrl());
}
private void validateRegistrationInfo(ServiceRegistrationInfo registrationInfo)
- throws ServiceException, MalformedURLException {
+ throws ServiceException, MalformedURLException {
if (registrationInfo.serviceName.isEmpty()) {
throw new ServiceException("Missing mandatory parameter 'serviceName'");
}
@@ -110,14 +109,13 @@ public class ServiceController {
}
@ApiOperation(value = "Register a service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service updated", response = String.class),
@ApiResponse(code = 201, message = "Service created", response = String.class), //
@ApiResponse(code = 400, message = "The ServiceRegistrationInfo is not accepted", response = String.class)})
@PutMapping("/service")
public ResponseEntity<String> putService(//
- @RequestBody ServiceRegistrationInfo registrationInfo) {
+ @RequestBody ServiceRegistrationInfo registrationInfo) {
try {
validateRegistrationInfo(registrationInfo);
final boolean isCreate = this.services.get(registrationInfo.serviceName) == null;
@@ -129,15 +127,14 @@ public class ServiceController {
}
@ApiOperation(value = "Delete a service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 204, message = "Service deleted"),
@ApiResponse(code = 204, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Service not found", response = String.class)})
@DeleteMapping("/services")
public ResponseEntity<String> deleteService(//
- @ApiParam(name = "name", required = true, value = "The name of the service") //
- @RequestParam(name = "name", required = true) String serviceName) {
+ @ApiParam(name = "name", required = true, value = "The name of the service") //
+ @RequestParam(name = "name", required = true) String serviceName) {
try {
Service service = removeService(serviceName);
// Remove the policies from the repo and let the consistency monitoring
@@ -150,14 +147,13 @@ public class ServiceController {
}
@ApiOperation(value = "Heartbeat from a serice")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service supervision timer refreshed, OK"),
@ApiResponse(code = 404, message = "The service is not found, needs re-registration")})
@PutMapping("/services/keepalive")
public ResponseEntity<String> keepAliveService(//
- @ApiParam(name = "name", required = true, value = "The name of the service") //
- @RequestParam(name = "name", required = true) String serviceName) {
+ @ApiParam(name = "name", required = true, value = "The name of the service") //
+ @RequestParam(name = "name", required = true) String serviceName) {
try {
services.getService(serviceName).keepAlive();
return new ResponseEntity<>("OK", HttpStatus.OK);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java
index 89016919..38e9b3b4 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java
@@ -34,8 +34,7 @@ public class ServiceRegistrationInfo {
@SerializedName("serviceName")
public String serviceName = "";
- @ApiModelProperty(
- value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ @ApiModelProperty(value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ "which in regular intevals must invoke a 'keepAlive' REST call. "
+ "When a service does not invoke this call within the given time, it is considered unavailble. "
+ "An unavailable service will be automatically deregistered and its policies will be deleted. "
@@ -47,8 +46,7 @@ public class ServiceRegistrationInfo {
@SerializedName("callbackUrl")
public String callbackUrl = "";
- public ServiceRegistrationInfo() {
- }
+ public ServiceRegistrationInfo() {}
public ServiceRegistrationInfo(String name, long keepAliveIntervalSeconds, String callbackUrl) {
this.serviceName = name;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java
index e520a282..492b1ea8 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java
@@ -37,10 +37,9 @@ public class StatusController {
@GetMapping("/status")
@ApiOperation(value = "Returns status and statistics of this service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service is living", response = String.class) //
- })
+ })
public Mono<ResponseEntity<String>> getStatus() {
return Mono.just(new ResponseEntity<>("hunky dory", HttpStatus.OK));
}
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 68c1d717..478b8c27 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
@@ -31,6 +31,5 @@ public class Consts {
public static final String V2_API_ROOT = "/v2";
public static final String V2_API_NAME = "A1 Policy Management Version 2.0 (in progress)";
- private Consts() {
- }
+ private Consts() {}
}
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 2ba63abc..988fbc2a 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
@@ -35,7 +35,7 @@ import reactor.core.publisher.Mono;
class ErrorResponse {
private static Gson gson = new GsonBuilder() //
- .create(); //
+ .create(); //
// Returned as body for all failed REST calls
@ApiModel(value = "error_information", description = "Problem as defined in https://tools.ietf.org/html/rfc7807")
@@ -60,16 +60,14 @@ class ErrorResponse {
this.status = status;
}
- @ApiModelProperty(
- example = "503",
- value = "The HTTP status code generated by the origin server for this occurrence of the problem. ")
+ @ApiModelProperty(example = "503",
+ value = "The HTTP status code generated by the origin server for this occurrence of the problem. ")
public Integer getStatus() {
return status;
}
- @ApiModelProperty(
- example = "Policy type not found",
- value = " A human-readable explanation specific to this occurrence of the problem.")
+ @ApiModelProperty(example = "Policy type not found",
+ value = " A human-readable explanation specific to this occurrence of the problem.")
public String getDetail() {
return this.detail;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java
index 22227656..fea1d097 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java
@@ -25,8 +25,7 @@ import io.swagger.annotations.ApiModel;
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(
- value = "json_object",
- description = "A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.")
+@ApiModel(value = "json_object",
+ description = "A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.")
class JsonObject {
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
index d42d51e9..8d3ecf6c 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
@@ -94,26 +94,21 @@ public class PolicyController {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
@GetMapping(path = Consts.V2_API_ROOT + "/policy-schemas", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns policy type schema definitions")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy schemas", response = PolicySchemaList.class), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicySchemas( //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get the definitions for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId,
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = true,
- value = "The identity of the policy type to get the definition for. When this parameter is given, max one schema will be returned") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId) {
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get the definitions for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId,
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = true,
+ value = "The identity of the policy type to get the definition for. When this parameter is given, max one schema will be returned") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId) {
try {
Ric ric = ricId == null ? null : rics.getRic(ricId);
if (ric == null && policyTypeId == null) {
@@ -146,15 +141,12 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy-types", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query policy type identities", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiResponses(
- value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class),
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class),
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyTypes( //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get types for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get types for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
if (ricId == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK);
@@ -170,14 +162,13 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns a policy configuration") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy found", response = JsonObject.class), //
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class)} //
)
public ResponseEntity<Object> getPolicy( //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
try {
Policy p = policies.getPolicy(id);
return new ResponseEntity<>(p.json(), HttpStatus.OK);
@@ -188,31 +179,28 @@ public class PolicyController {
@DeleteMapping(Consts.V2_API_ROOT + "/policy")
@ApiOperation(value = "Delete a policy")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 204, message = "Policy deleted", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class),
- @ApiResponse(
- code = 423,
- message = "Near-RT RIC is not operational",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 423, message = "Near-RT RIC is not operational",
+ response = ErrorResponse.ErrorInfo.class)})
public Mono<ResponseEntity<Object>> deletePolicy( //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
try {
Policy policy = policies.getPolicy(id);
keepServiceAlive(policy.ownerServiceId());
Ric ric = policy.ric();
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
- .doOnNext(notUsed -> policies.remove(policy)) //
- .flatMap(client -> client.deletePolicy(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
+ .doOnNext(notUsed -> policies.remove(policy)) //
+ .flatMap(client -> client.deletePolicy(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return ErrorResponse.createMono(e, HttpStatus.NOT_FOUND);
}
@@ -220,43 +208,33 @@ public class PolicyController {
@PutMapping(path = Consts.V2_API_ROOT + "/policy", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Create or update a policy")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), //
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
- @ApiResponse(
- code = 423,
- message = "Near-RT RIC is not operational",
- response = ErrorResponse.ErrorInfo.class), //
- @ApiResponse(
- code = 404,
- message = "Near-RT RIC or policy type is not found",
- response = ErrorResponse.ErrorInfo.class) //
- })
+ @ApiResponse(code = 423, message = "Near-RT RIC is not operational",
+ response = ErrorResponse.ErrorInfo.class), //
+ @ApiResponse(code = 404, message = "Near-RT RIC or policy type is not found",
+ response = ErrorResponse.ErrorInfo.class) //
+ })
public Mono<ResponseEntity<Object>> putPolicy( //
- @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, value = "The identity of the policy type.") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, defaultValue = "") String policyTypeId, //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String instanceId, //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = true,
- value = "The identity of the Near-RT RIC where the policy will be " + //
- "created.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = true) String ricId, //
- @ApiParam(
- name = Consts.SERVICE_ID_PARAM,
- required = true,
- value = "The identity of the service creating the policy.") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceId, //
- @ApiParam(
- name = Consts.TRANSIENT_PARAM,
- required = false,
- value = "If the policy is transient or not (boolean " + //
- "defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC " + //
- "when it has been lost (for instance due to a restart)") //
- @RequestParam(name = Consts.TRANSIENT_PARAM, required = false, defaultValue = "false") boolean isTransient, //
- @RequestBody Object jsonBody) {
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, value = "The identity of the policy type.") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, defaultValue = "") String policyTypeId, //
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String instanceId, //
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = true,
+ value = "The identity of the Near-RT RIC where the policy will be " + //
+ "created.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = true) String ricId, //
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true,
+ value = "The identity of the service creating the policy.") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceId, //
+ @ApiParam(name = Consts.TRANSIENT_PARAM, required = false,
+ value = "If the policy is transient or not (boolean " + //
+ "defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC "
+ + //
+ "when it has been lost (for instance due to a restart)") //
+ @RequestParam(name = Consts.TRANSIENT_PARAM, required = false, defaultValue = "false") boolean isTransient, //
+ @RequestBody Object jsonBody) {
String jsonString = gson.toJson(jsonBody);
Ric ric = rics.get(ricId);
@@ -266,28 +244,28 @@ public class PolicyController {
return ErrorResponse.createMono("Near-RT RIC or policy type not found", HttpStatus.NOT_FOUND);
}
Policy policy = ImmutablePolicy.builder() //
- .id(instanceId) //
- .json(jsonString) //
- .type(type) //
- .ric(ric) //
- .ownerServiceId(serviceId) //
- .lastModified(Instant.now()) //
- .isTransient(isTransient) //
- .build();
+ .id(instanceId) //
+ .json(jsonString) //
+ .type(type) //
+ .ric(ric) //
+ .ownerServiceId(serviceId) //
+ .lastModified(Instant.now()) //
+ .isTransient(isTransient) //
+ .build();
final boolean isCreate = this.policies.get(policy.id()) == null;
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> checkSupportedType(ric, type)) //
- .flatMap(notUsed -> validateModifiedPolicy(policy)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
- .flatMap(client -> client.putPolicy(policy)) //
- .doOnNext(notUsed -> policies.put(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(trowable -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> checkSupportedType(ric, type)) //
+ .flatMap(notUsed -> validateModifiedPolicy(policy)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
+ .flatMap(client -> client.putPolicy(policy)) //
+ .doOnNext(notUsed -> policies.put(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(trowable -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
+ .onErrorResume(this::handleException);
}
private Mono<ResponseEntity<Object>> handleException(Throwable throwable) {
@@ -307,8 +285,8 @@ public class PolicyController {
Policy current = this.policies.get(policy.id());
if (current != null && !current.ric().id().equals(policy.ric().id())) {
RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
- ", RIC ID: " + current.ric().id() + //
- ", new ID: " + policy.ric().id(), HttpStatus.CONFLICT);
+ ", RIC ID: " + current.ric().id() + //
+ ", new ID: " + policy.ric().id(), HttpStatus.CONFLICT);
logger.debug("Request rejected, {}", e.getMessage());
return Mono.error(e);
}
@@ -319,7 +297,7 @@ public class PolicyController {
if (!ric.isSupportingType(type.id())) {
logger.debug("Request rejected, type not supported, RIC: {}", ric);
RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(),
- HttpStatus.NOT_FOUND);
+ HttpStatus.NOT_FOUND);
return Mono.error(e);
}
return Mono.just("{}");
@@ -337,40 +315,32 @@ public class PolicyController {
} else {
logger.debug("Request rejected Near-RT RIC not IDLE, ric: {}", ric);
RejectionException e = new RejectionException(
- "Near-RT RIC: is not operational, id: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED);
+ "Near-RT RIC: is not operational, id: " + ric.id() + ", state: " + ric.getState(),
+ HttpStatus.LOCKED);
return Mono.error(e);
}
}
static final String GET_POLICIES_QUERY_DETAILS =
- "Returns a list of A1 policies matching given search criteria. <br>" //
- + "If several query parameters are defined, the policies matching all conditions are returned.";
+ "Returns a list of A1 policies matching given search criteria. <br>" //
+ + "If several query parameters are defined, the policies matching all conditions are returned.";
@GetMapping(path = Consts.V2_API_ROOT + "/policies", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query for existing A1 policies", notes = GET_POLICIES_QUERY_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policies", response = PolicyInfoList.class),
- @ApiResponse(
- code = 404,
- message = "Near-RT RIC, policy type or service not found",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 404, message = "Near-RT RIC, policy type or service not found",
+ response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicies( //
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = false,
- value = "The identity of the policy type to get policies for.") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String type, //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get policies for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ric, //
- @ApiParam(
- name = Consts.SERVICE_ID_PARAM,
- required = false,
- value = "The identity of the service to get policies for.") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String service) //
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false,
+ value = "The identity of the policy type to get policies for.") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String type, //
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ric, //
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false,
+ value = "The identity of the service to get policies for.") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String service) //
{
if ((type != null && this.policyTypes.get(type) == null)) {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
@@ -385,29 +355,19 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy-ids", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query policies, only policy identities are returned", notes = GET_POLICIES_QUERY_DETAILS)
- @ApiResponses(
- value = { //
- @ApiResponse(code = 200, message = "Policy identities", response = PolicyIdList.class),
- @ApiResponse(
- code = 404,
- message = "Near-RT RIC or type not found",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponses(value = { //
+ @ApiResponse(code = 200, message = "Policy identities", response = PolicyIdList.class), @ApiResponse(
+ code = 404, message = "Near-RT RIC or type not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyIds( //
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = false,
- value = "The identity of the policy type to get policies for.") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId, //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get policies for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, //
- @ApiParam(
- name = Consts.SERVICE_ID_PARAM,
- required = false,
- value = "The identity of the service to get policies for.") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String serviceId) //
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false,
+ value = "The identity of the policy type to get policies for.") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId, //
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, //
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false,
+ value = "The identity of the service to get policies for.") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String serviceId) //
{
if ((policyTypeId != null && this.policyTypes.get(policyTypeId) == null)) {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
@@ -422,21 +382,20 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy-status", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns a policy status") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy status", response = JsonObject.class), //
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class)} //
)
public Mono<ResponseEntity<Object>> getPolicyStatus( //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String policyId) {
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String policyId) {
try {
Policy policy = policies.getPolicy(policyId);
return a1ClientFactory.createA1Client(policy.ric()) //
- .flatMap(client -> client.getPolicyStatus(policy)) //
- .flatMap(status -> Mono.just(new ResponseEntity<>((Object) status, HttpStatus.OK)))
- .onErrorResume(this::handleException);
+ .flatMap(client -> client.getPolicyStatus(policy)) //
+ .flatMap(status -> Mono.just(new ResponseEntity<>((Object) status, HttpStatus.OK)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return ErrorResponse.createMono(e, HttpStatus.NOT_FOUND);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
index 673c9455..ab812790 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
@@ -62,12 +62,11 @@ public class PolicyInfo {
@JsonProperty("last_modified")
public String lastModified;
- PolicyInfo() {
- }
+ PolicyInfo() {}
public boolean validate() {
return policyId != null && policyTypeId != null && ricId != null && policyData != null && serviceId != null
- && lastModified != null;
+ && lastModified != null;
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java
index 6768b76a..d550db4e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java
@@ -38,7 +38,7 @@ import org.immutables.gson.Gson;
public class PolicySchemaList {
@ApiModelProperty(
- value = "Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema")
+ value = "Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema")
@SerializedName("policy_schemas")
@JsonProperty("policy_schemas")
public final Collection<Object> schemas;
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 750f0dfb..938d5106 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
@@ -41,10 +41,10 @@ public class RicInfo {
}
private static final String STATE_DESCRIPTION = "State for the Near-RT RIC, values: \n"
- + "UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent \n"
- + "AVAILABLE: The normal state. Policies can be configured. +\n"
- + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured. \n"
- + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured.";
+ + "UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent \n"
+ + "AVAILABLE: The normal state. Policies can be configured. +\n"
+ + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured. \n"
+ + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured.";
@ApiModelProperty(value = "identity of the Near-RT RIC")
@SerializedName("ric_id")
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
index cc8a8e92..a7505016 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
@@ -56,35 +56,30 @@ public class RicRepositoryController {
PolicyTypes types;
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
private static final String GET_RIC_BRIEF = "Returns info for a Near-RT RIC";
private static final String GET_RIC_DETAILS =
- "Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>" //
- + "The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).";
+ "Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>" //
+ + "The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).";
/**
* Example: http://localhost:8081/v2/ric?managed_element_id=kista_1
*/
@GetMapping(path = Consts.V2_API_ROOT + "/ric", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = GET_RIC_BRIEF, notes = GET_RIC_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Near-RT RIC is found", response = RicInfo.class), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class) //
- })
+ })
public ResponseEntity<Object> getRic( //
- @ApiParam(
- name = Consts.MANAGED_ELEMENT_ID_PARAM,
- required = false,
- value = "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.") //
- @RequestParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false) String managedElementId,
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of a Near-RT RIC to get information for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
+ @ApiParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false,
+ value = "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.") //
+ @RequestParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false) String managedElementId,
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of a Near-RT RIC to get information for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
try {
if (managedElementId != null && ricId != null) {
return ErrorResponse.create("Give one query parameter", HttpStatus.BAD_REQUEST);
@@ -107,23 +102,20 @@ public class RicRepositoryController {
}
static final String QUERY_RIC_INFO_DETAILS =
- "The call returns all Near-RT RICs that supports a given policy type identity";
+ "The call returns all Near-RT RICs that supports a given policy type identity";
/**
* @return a Json array of all RIC data Example: http://localhost:8081/v2/ric
*/
@GetMapping(path = Consts.V2_API_ROOT + "/rics", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query Near-RT RIC information", notes = QUERY_RIC_INFO_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfoList.class), //
@ApiResponse(code = 404, message = "Policy type is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getRics( //
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = false,
- value = "The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String supportingPolicyType) {
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false,
+ value = "The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String supportingPolicyType) {
if ((supportingPolicyType != null) && (this.types.get(supportingPolicyType) == null)) {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
}
@@ -155,6 +147,6 @@ public class RicRepositoryController {
private RicInfo toRicInfo(Ric ric) {
return new RicInfo(ric.id(), ric.getManagedElementIds(), ric.getSupportedPolicyTypeNames(),
- toRicState(ric.getState()));
+ toRicState(ric.getState()));
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
index 383e4f7f..73e421be 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
@@ -60,7 +60,7 @@ public class ServiceController {
private final Policies policies;
private static Gson gson = new GsonBuilder() //
- .create(); //
+ .create(); //
@Autowired
ServiceController(Services services, Policies policies) {
@@ -69,17 +69,16 @@ public class ServiceController {
}
private static final String GET_SERVICE_DETAILS =
- "Either information about a registered service with given identity or all registered services are returned.";
+ "Either information about a registered service with given identity or all registered services are returned.";
@GetMapping(path = Consts.V2_API_ROOT + "/services", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns service information", notes = GET_SERVICE_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = ServiceStatusList.class), //
@ApiResponse(code = 404, message = "Service is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getServices(//
- @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, value = "The identity of the service") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String name) {
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, value = "The identity of the service") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String name) {
if (name != null && this.services.get(name) == null) {
return ErrorResponse.create("Service not found", HttpStatus.NOT_FOUND);
}
@@ -97,11 +96,11 @@ public class ServiceController {
private ServiceStatus toServiceStatus(Service s) {
return new ServiceStatus(s.getName(), s.getKeepAliveInterval().toSeconds(), s.timeSinceLastPing().toSeconds(),
- s.getCallbackUrl());
+ s.getCallbackUrl());
}
private void validateRegistrationInfo(ServiceRegistrationInfo registrationInfo)
- throws ServiceException, MalformedURLException {
+ throws ServiceException, MalformedURLException {
if (registrationInfo.serviceId.isEmpty()) {
throw new ServiceException("Missing mandatory parameter 'serviceName'");
}
@@ -114,24 +113,21 @@ public class ServiceController {
}
private static final String REGISTER_SERVICE_DETAILS = "Registering a service is needed to:" //
- + "<ul>" //
- + "<li>Get callbacks.</li>" //
- + "<li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li>"//
- + "</ul>" //
+ + "<ul>" //
+ + "<li>Get callbacks.</li>" //
+ + "<li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li>"//
+ + "</ul>" //
;
@ApiOperation(value = "Register a service", notes = REGISTER_SERVICE_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service updated"),
@ApiResponse(code = 201, message = "Service created"), //
- @ApiResponse(
- code = 400,
- message = "The ServiceRegistrationInfo is not accepted",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 400, message = "The ServiceRegistrationInfo is not accepted",
+ response = ErrorResponse.ErrorInfo.class)})
@PutMapping(Consts.V2_API_ROOT + "/services")
public ResponseEntity<Object> putService(//
- @RequestBody ServiceRegistrationInfo registrationInfo) {
+ @RequestBody ServiceRegistrationInfo registrationInfo) {
try {
validateRegistrationInfo(registrationInfo);
final boolean isCreate = this.services.get(registrationInfo.serviceId) == null;
@@ -143,15 +139,14 @@ public class ServiceController {
}
@ApiOperation(value = "Unregister a service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 204, message = "Service unregistered"),
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Service not found", response = ErrorResponse.ErrorInfo.class)})
@DeleteMapping(Consts.V2_API_ROOT + "/services")
public ResponseEntity<Object> deleteService(//
- @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The idenitity of the service") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The idenitity of the service") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
try {
Service service = removeService(serviceName);
// Remove the policies from the repo and let the consistency monitoring
@@ -164,18 +159,15 @@ public class ServiceController {
}
@ApiOperation(value = "Heartbeat indicates that the service is running")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service supervision timer refreshed, OK"), //
- @ApiResponse(
- code = 404,
- message = "The service is not found, needs re-registration",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 404, message = "The service is not found, needs re-registration",
+ response = ErrorResponse.ErrorInfo.class)})
@PutMapping(Consts.V2_API_ROOT + "/services/keepalive")
public ResponseEntity<Object> keepAliveService(//
- @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The identity of the service") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The identity of the service") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
try {
services.getService(serviceName).keepAlive();
return new ResponseEntity<>(HttpStatus.OK);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
index 30fcb7d6..68afc384 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
@@ -37,8 +37,7 @@ public class ServiceRegistrationInfo {
@JsonProperty("service_id")
public String serviceId = "";
- @ApiModelProperty(
- value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ @ApiModelProperty(value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ "which in regular intevals must invoke a 'keepAlive' REST call. "
+ "When a service does not invoke this call within the given time, it is considered unavailble. "
+ "An unavailable service will be automatically deregistered and its policies will be deleted. "
@@ -52,8 +51,7 @@ public class ServiceRegistrationInfo {
@JsonProperty("callback_url")
public String callbackUrl = "";
- public ServiceRegistrationInfo() {
- }
+ public ServiceRegistrationInfo() {}
public ServiceRegistrationInfo(String id, long keepAliveIntervalSeconds, String callbackUrl) {
this.serviceId = id;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
index f47cdd5c..1c5a473b 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
@@ -52,10 +52,9 @@ public class StatusController {
@GetMapping(path = Consts.V2_API_ROOT + "/status", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns status and statistics of this service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service is living", response = StatusInfo.class) //
- })
+ })
public Mono<ResponseEntity<Object>> getStatus() {
StatusInfo info = new StatusInfo("hunky dory");
return Mono.just(new ResponseEntity<>(info, HttpStatus.OK));
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
index a4da4bdd..bafa8453 100644
--- 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
@@ -123,7 +123,7 @@ public class DmaapMessageConsumer {
String producerTopicUrl = applicationConfig.getDmaapProducerTopicUrl();
String consumerTopicUrl = applicationConfig.getDmaapConsumerTopicUrl();
return (producerTopicUrl != null && consumerTopicUrl != null && !producerTopicUrl.isEmpty()
- && !consumerTopicUrl.isEmpty());
+ && !consumerTopicUrl.isEmpty());
}
private <T> List<T> parseList(String jsonString, Class<T> clazz) {
@@ -144,16 +144,16 @@ public class DmaapMessageConsumer {
private void sendErrorResponse(String response) {
DmaapRequestMessage fakeRequest = ImmutableDmaapRequestMessage.builder() //
- .apiVersion("") //
- .correlationId("") //
- .operation(DmaapRequestMessage.Operation.PUT) //
- .originatorId("") //
- .payload(Optional.empty()) //
- .requestId("") //
- .target("") //
- .timestamp("") //
- .url("URL") //
- .build();
+ .apiVersion("") //
+ .correlationId("") //
+ .operation(DmaapRequestMessage.Operation.PUT) //
+ .originatorId("") //
+ .payload(Optional.empty()) //
+ .requestId("") //
+ .target("") //
+ .timestamp("") //
+ .url("URL") //
+ .build();
getDmaapMessageHandler().sendDmaapResponse(response, fakeRequest, HttpStatus.BAD_REQUEST).block();
}
@@ -175,7 +175,7 @@ public class DmaapMessageConsumer {
return parseMessages(response.getBody());
} else {
throw new ServiceException("Cannot fetch because of Error respons: " + response.getStatusCode().toString()
- + " " + response.getBody());
+ + " " + response.getBody());
}
}
@@ -189,7 +189,7 @@ public class DmaapMessageConsumer {
String pmsBaseUrl = "http://localhost:" + this.localServerHttpPort;
AsyncRestClient pmsClient = new AsyncRestClient(pmsBaseUrl, this.applicationConfig.getWebClientConfig());
AsyncRestClient producer = new AsyncRestClient(this.applicationConfig.getDmaapProducerTopicUrl(),
- this.applicationConfig.getWebClientConfig());
+ this.applicationConfig.getWebClientConfig());
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
index 2d7b5063..967cab1d 100644
--- 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
@@ -65,12 +65,13 @@ public class DmaapMessageHandler {
Mono<String> createTask(DmaapRequestMessage dmaapRequestMessage) {
return this.invokePolicyManagementService(dmaapRequestMessage) //
- .onErrorResume(t -> handlePolicyManagementServiceCallError(t, dmaapRequestMessage)) //
- .flatMap(response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage, response.getStatusCode()));
+ .onErrorResume(t -> handlePolicyManagementServiceCallError(t, dmaapRequestMessage)) //
+ .flatMap(response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage,
+ response.getStatusCode()));
}
private Mono<ResponseEntity<String>> handlePolicyManagementServiceCallError(Throwable error,
- DmaapRequestMessage dmaapRequestMessage) {
+ DmaapRequestMessage dmaapRequestMessage) {
logger.debug("Policy Management Service call failed: {}", error.getMessage());
HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
String errorMessage = error.getMessage();
@@ -85,13 +86,13 @@ public class DmaapMessageHandler {
logger.warn("Unexpected exception ", error);
}
return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) //
- .flatMap(notUsed -> Mono.empty());
+ .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);
+ .flatMap(this::sendToDmaap) //
+ .onErrorResume(this::handleResponseCallError);
}
private Mono<ResponseEntity<String>> invokePolicyManagementService(DmaapRequestMessage dmaapRequestMessage) {
@@ -132,16 +133,16 @@ public class DmaapMessageHandler {
}
private Mono<String> createDmaapResponseMessage(DmaapRequestMessage dmaapRequestMessage, String response,
- HttpStatus status) {
+ HttpStatus status) {
DmaapResponseMessage dmaapResponseMessage = ImmutableDmaapResponseMessage.builder() //
- .status(status.toString()) //
- .message(response == null ? "" : response) //
- .type("response") //
- .correlationId(dmaapRequestMessage.correlationId() == null ? "" : dmaapRequestMessage.correlationId()) //
- .originatorId(dmaapRequestMessage.originatorId() == null ? "" : dmaapRequestMessage.originatorId()) //
- .requestId(dmaapRequestMessage.requestId() == null ? "" : dmaapRequestMessage.requestId()) //
- .timestamp(dmaapRequestMessage.timestamp() == null ? "" : dmaapRequestMessage.timestamp()) //
- .build();
+ .status(status.toString()) //
+ .message(response == null ? "" : response) //
+ .type("response") //
+ .correlationId(dmaapRequestMessage.correlationId() == null ? "" : dmaapRequestMessage.correlationId()) //
+ .originatorId(dmaapRequestMessage.originatorId() == null ? "" : dmaapRequestMessage.originatorId()) //
+ .requestId(dmaapRequestMessage.requestId() == null ? "" : dmaapRequestMessage.requestId()) //
+ .timestamp(dmaapRequestMessage.timestamp() == null ? "" : dmaapRequestMessage.timestamp()) //
+ .build();
String str = gson.toJson(dmaapResponseMessage);
return Mono.just(str);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java
index 0cde2e12..6892a503 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java
@@ -87,7 +87,7 @@ public class Lock {
@Override
public synchronized String toString() {
return "Lock cnt: " + this.lockCounter + " exclusive: " + this.isExclusive + " queued: "
- + this.lockRequestQueue.size();
+ + this.lockRequestQueue.size();
}
/** returns the current number of granted locks */
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
index 05ba41da..c7f471eb 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
@@ -134,7 +134,7 @@ public class Ric {
@Override
public synchronized String toString() {
return Ric.class.getSimpleName() + ": " + "name: " + id() + ", state: " + state + ", baseUrl: "
- + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds();
+ + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds();
}
/**
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java
index 840de817..ba81d222 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java
@@ -39,19 +39,18 @@ class EnvironmentProcessor {
private static final int DEFAULT_CONSUL_PORT = 8500;
private static final Logger logger = LoggerFactory.getLogger(EnvironmentProcessor.class);
- private EnvironmentProcessor() {
- }
+ private EnvironmentProcessor() {}
static Mono<EnvProperties> readEnvironmentVariables(Properties systemEnvironment) {
EnvProperties envProperties;
try {
envProperties = ImmutableEnvProperties.builder() //
- .consulHost(getConsulHost(systemEnvironment)) //
- .consulPort(getConsultPort(systemEnvironment)) //
- .cbsName(getConfigBindingService(systemEnvironment)) //
- .appName(getService(systemEnvironment)) //
- .build();
+ .consulHost(getConsulHost(systemEnvironment)) //
+ .consulPort(getConsultPort(systemEnvironment)) //
+ .cbsName(getConfigBindingService(systemEnvironment)) //
+ .appName(getService(systemEnvironment)) //
+ .build();
} catch (EnvironmentLoaderException e) {
return Mono.error(e);
}
@@ -61,27 +60,27 @@ class EnvironmentProcessor {
private static String getConsulHost(Properties systemEnvironments) throws EnvironmentLoaderException {
return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_HOST"))
- .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined"));
+ .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined"));
}
private static Integer getConsultPort(Properties systemEnvironments) {
return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_PORT")) //
- .map(Integer::valueOf) //
- .orElseGet(EnvironmentProcessor::getDefaultPortOfConsul);
+ .map(Integer::valueOf) //
+ .orElseGet(EnvironmentProcessor::getDefaultPortOfConsul);
}
private static String getConfigBindingService(Properties systemEnvironments) throws EnvironmentLoaderException {
return Optional.ofNullable(systemEnvironments.getProperty("CONFIG_BINDING_SERVICE")) //
- .orElseThrow(
- () -> new EnvironmentLoaderException("$CONFIG_BINDING_SERVICE environment has not been defined"));
+ .orElseThrow(() -> new EnvironmentLoaderException(
+ "$CONFIG_BINDING_SERVICE environment has not been defined"));
}
private static String getService(Properties systemEnvironments) throws EnvironmentLoaderException {
return Optional
- .ofNullable(Optional.ofNullable(systemEnvironments.getProperty("HOSTNAME"))
- .orElse(systemEnvironments.getProperty("SERVICE_NAME")))
- .orElseThrow(() -> new EnvironmentLoaderException(
- "Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment"));
+ .ofNullable(Optional.ofNullable(systemEnvironments.getProperty("HOSTNAME"))
+ .orElse(systemEnvironments.getProperty("SERVICE_NAME")))
+ .orElseThrow(() -> new EnvironmentLoaderException(
+ "Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment"));
}
private static Integer getDefaultPortOfConsul() {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
index 248ba32d..5da066f3 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
@@ -94,7 +94,7 @@ public class RefreshConfigTask {
@Autowired
public RefreshConfigTask(ApplicationConfig appConfig, Rics rics, Policies policies, Services services,
- PolicyTypes policyTypes, A1ClientFactory a1ClientFactory) {
+ PolicyTypes policyTypes, A1ClientFactory a1ClientFactory) {
this.appConfig = appConfig;
this.rics = rics;
this.policies = policies;
@@ -107,9 +107,10 @@ public class RefreshConfigTask {
logger.debug("Starting refreshConfigTask");
stop();
refreshTask = createRefreshTask() //
- .subscribe(notUsed -> logger.debug("Refreshed configuration data"),
- throwable -> logger.error("Configuration refresh terminated due to exception {}", throwable.toString()),
- () -> logger.error("Configuration refresh terminated"));
+ .subscribe(
+ notUsed -> logger.debug("Refreshed configuration data"), throwable -> logger
+ .error("Configuration refresh terminated due to exception {}", throwable.toString()),
+ () -> logger.error("Configuration refresh terminated"));
}
public void stop() {
@@ -120,44 +121,44 @@ public class RefreshConfigTask {
Flux<RicConfigUpdate.Type> createRefreshTask() {
Flux<JsonObject> loadFromFile = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) //
- .filter(notUsed -> !this.isConsulUsed) //
- .flatMap(notUsed -> loadConfigurationFromFile()) //
- .onErrorResume(this::ignoreErrorFlux) //
- .doOnNext(json -> logger.debug("loadFromFile succeeded")) //
- .doOnTerminate(() -> logger.error("loadFromFile Terminate"));
+ .filter(notUsed -> !this.isConsulUsed) //
+ .flatMap(notUsed -> loadConfigurationFromFile()) //
+ .onErrorResume(this::ignoreErrorFlux) //
+ .doOnNext(json -> logger.debug("loadFromFile succeeded")) //
+ .doOnTerminate(() -> logger.error("loadFromFile Terminate"));
Flux<JsonObject> loadFromConsul = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) //
- .flatMap(i -> getEnvironment(systemEnvironment)) //
- .flatMap(this::createCbsClient) //
- .flatMap(this::getFromCbs) //
- .onErrorResume(this::ignoreErrorMono) //
- .doOnNext(json -> logger.debug("loadFromConsul succeeded")) //
- .doOnNext(json -> this.isConsulUsed = true) //
- .doOnTerminate(() -> logger.error("loadFromConsul Terminated"));
+ .flatMap(i -> getEnvironment(systemEnvironment)) //
+ .flatMap(this::createCbsClient) //
+ .flatMap(this::getFromCbs) //
+ .onErrorResume(this::ignoreErrorMono) //
+ .doOnNext(json -> logger.debug("loadFromConsul succeeded")) //
+ .doOnNext(json -> this.isConsulUsed = true) //
+ .doOnTerminate(() -> logger.error("loadFromConsul Terminated"));
return Flux.merge(loadFromFile, loadFromConsul) //
- .flatMap(this::parseConfiguration) //
- .flatMap(this::updateConfig) //
- .doOnNext(this::handleUpdatedRicConfig) //
- .flatMap(configUpdate -> Flux.just(configUpdate.getType())) //
- .doOnTerminate(() -> logger.error("Configuration refresh task is terminated"));
+ .flatMap(this::parseConfiguration) //
+ .flatMap(this::updateConfig) //
+ .doOnNext(this::handleUpdatedRicConfig) //
+ .flatMap(configUpdate -> Flux.just(configUpdate.getType())) //
+ .doOnTerminate(() -> logger.error("Configuration refresh task is terminated"));
}
Mono<EnvProperties> getEnvironment(Properties systemEnvironment) {
return EnvironmentProcessor.readEnvironmentVariables(systemEnvironment) //
- .onErrorResume(t -> Mono.empty());
+ .onErrorResume(t -> Mono.empty());
}
Mono<CbsClient> createCbsClient(EnvProperties env) {
return CbsClientFactory.createCbsClient(env) //
- .onErrorResume(this::ignoreErrorMono);
+ .onErrorResume(this::ignoreErrorMono);
}
private Mono<JsonObject> getFromCbs(CbsClient cbsClient) {
try {
final CbsRequest getConfigRequest = CbsRequests.getAll(RequestDiagnosticContext.create());
return cbsClient.get(getConfigRequest) //
- .onErrorResume(this::ignoreErrorMono);
+ .onErrorResume(this::ignoreErrorMono);
} catch (Exception e) {
return ignoreErrorMono(e);
}
@@ -223,7 +224,7 @@ public class RefreshConfigTask {
void runRicSynchronization(Ric ric) {
RicSynchronizationTask synchronizationTask =
- new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services);
+ new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services);
synchronizationTask.run(ric);
}
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 332af8bc..46059fd9 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
@@ -83,7 +83,7 @@ public class RicSupervision {
@Autowired
public RicSupervision(Rics rics, Policies policies, A1ClientFactory a1ClientFactory, PolicyTypes policyTypes,
- Services services) {
+ Services services) {
this.rics = rics;
this.policies = policies;
this.a1ClientFactory = a1ClientFactory;
@@ -102,19 +102,19 @@ public class RicSupervision {
private Flux<RicData> createTask() {
return Flux.fromIterable(rics.getRics()) //
- .flatMap(this::createRicData) //
- .flatMap(this::checkOneRic);
+ .flatMap(this::createRicData) //
+ .flatMap(this::checkOneRic);
}
private Mono<RicData> checkOneRic(RicData ricData) {
return checkRicState(ricData) //
- .flatMap(x -> ricData.ric.getLock().lock(LockType.EXCLUSIVE)) //
- .flatMap(notUsed -> setRicState(ricData)) //
- .flatMap(x -> checkRicPolicies(ricData)) //
- .flatMap(x -> checkRicPolicyTypes(ricData)) //
- .doOnNext(x -> onRicCheckedOk(ricData)) //
- .doOnError(t -> onRicCheckedError(t, ricData)) //
- .onErrorResume(throwable -> Mono.empty());
+ .flatMap(x -> ricData.ric.getLock().lock(LockType.EXCLUSIVE)) //
+ .flatMap(notUsed -> setRicState(ricData)) //
+ .flatMap(x -> checkRicPolicies(ricData)) //
+ .flatMap(x -> checkRicPolicyTypes(ricData)) //
+ .doOnNext(x -> onRicCheckedOk(ricData)) //
+ .doOnError(t -> onRicCheckedError(t, ricData)) //
+ .onErrorResume(throwable -> Mono.empty());
}
private void onRicCheckedError(Throwable t, RicData ricData) {
@@ -148,14 +148,14 @@ public class RicSupervision {
private Mono<RicData> createRicData(Ric ric) {
return Mono.just(ric) //
- .flatMap(aRic -> this.a1ClientFactory.createA1Client(ric)) //
- .flatMap(a1Client -> Mono.just(new RicData(ric, a1Client)));
+ .flatMap(aRic -> this.a1ClientFactory.createA1Client(ric)) //
+ .flatMap(a1Client -> Mono.just(new RicData(ric, a1Client)));
}
private Mono<RicData> checkRicState(RicData ric) {
if (ric.ric.getState() == RicState.UNAVAILABLE) {
return startSynchronization(ric) //
- .onErrorResume(t -> Mono.empty());
+ .onErrorResume(t -> Mono.empty());
} else if (ric.ric.getState() == RicState.SYNCHRONIZING || ric.ric.getState() == RicState.CONSISTENCY_CHECK) {
return Mono.empty();
} else {
@@ -165,7 +165,7 @@ public class RicSupervision {
private Mono<RicData> checkRicPolicies(RicData ric) {
return ric.getClient().getPolicyIdentities() //
- .flatMap(ricP -> validateInstances(ricP, ric));
+ .flatMap(ricP -> validateInstances(ricP, ric));
}
private Mono<RicData> validateInstances(Collection<String> ricPolicies, RicData ric) {
@@ -185,7 +185,7 @@ public class RicSupervision {
private Mono<RicData> checkRicPolicyTypes(RicData ric) {
return ric.getClient().getPolicyTypeIdentities() //
- .flatMap(ricTypes -> validateTypes(ricTypes, ric));
+ .flatMap(ricTypes -> validateTypes(ricTypes, ric));
}
private Mono<RicData> validateTypes(Collection<String> ricTypes, RicData ric) {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
index f810c659..ccc57852 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
@@ -66,7 +66,7 @@ public class RicSynchronizationTask {
private final Services services;
public RicSynchronizationTask(A1ClientFactory a1ClientFactory, PolicyTypes policyTypes, Policies policies,
- Services services) {
+ Services services) {
this.a1ClientFactory = a1ClientFactory;
this.policyTypes = policyTypes;
this.policies = policies;
@@ -82,27 +82,28 @@ public class RicSynchronizationTask {
}
ric.getLock().lock(LockType.EXCLUSIVE) //
- .flatMap(notUsed -> setRicState(ric)) //
- .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) //
- .flatMapMany(client -> runSynchronization(ric, client)) //
- .onErrorResume(throwable -> deleteAllPolicyInstances(ric, throwable))
- .subscribe(new BaseSubscriber<Object>() {
- @Override
- protected void hookOnError(Throwable throwable) {
- logger.warn("Synchronization failure for ric: {}, reason: {}", ric.id(), throwable.getMessage());
- ric.setState(RicState.UNAVAILABLE);
- }
-
- @Override
- protected void hookOnComplete() {
- onSynchronizationComplete(ric);
- }
-
- @Override
- protected void hookFinally(SignalType type) {
- ric.getLock().unlockBlocking();
- }
- });
+ .flatMap(notUsed -> setRicState(ric)) //
+ .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) //
+ .flatMapMany(client -> runSynchronization(ric, client)) //
+ .onErrorResume(throwable -> deleteAllPolicyInstances(ric, throwable))
+ .subscribe(new BaseSubscriber<Object>() {
+ @Override
+ protected void hookOnError(Throwable throwable) {
+ logger.warn("Synchronization failure for ric: {}, reason: {}", ric.id(),
+ throwable.getMessage());
+ ric.setState(RicState.UNAVAILABLE);
+ }
+
+ @Override
+ protected void hookOnComplete() {
+ onSynchronizationComplete(ric);
+ }
+
+ @Override
+ protected void hookFinally(SignalType type) {
+ ric.getLock().unlockBlocking();
+ }
+ });
}
@SuppressWarnings("squid:S2445") // Blocks should be synchronized on "private final" fields
@@ -136,12 +137,12 @@ public class RicSynchronizationTask {
String url = service.getCallbackUrl();
if (url.length() > 0) {
createNotificationClient(url) //
- .put("", body) //
- .subscribe( //
- notUsed -> logger.debug("Service {} notified", service.getName()),
- throwable -> logger.warn("Service notification failed for service: {}. Cause: {}",
- service.getName(), throwable.getMessage()),
- () -> logger.debug("All services notified"));
+ .put("", body) //
+ .subscribe( //
+ notUsed -> logger.debug("Service {} notified", service.getName()),
+ throwable -> logger.warn("Service notification failed for service: {}. Cause: {}",
+ service.getName(), throwable.getMessage()),
+ () -> logger.debug("All services notified"));
}
}
}
@@ -151,10 +152,10 @@ public class RicSynchronizationTask {
deleteAllPoliciesInRepository(ric);
Flux<PolicyType> synchronizedTypes = this.a1ClientFactory.createA1Client(ric) //
- .flatMapMany(a1Client -> synchronizePolicyTypes(ric, a1Client));
+ .flatMapMany(a1Client -> synchronizePolicyTypes(ric, a1Client));
Flux<?> deletePoliciesInRic = this.a1ClientFactory.createA1Client(ric) //
- .flatMapMany(A1Client::deleteAllPolicies) //
- .doOnComplete(() -> deleteAllPoliciesInRepository(ric));
+ .flatMapMany(A1Client::deleteAllPolicies) //
+ .doOnComplete(() -> deleteAllPoliciesInRepository(ric));
return Flux.concat(synchronizedTypes, deletePoliciesInRic);
}
@@ -165,11 +166,11 @@ public class RicSynchronizationTask {
private Flux<PolicyType> synchronizePolicyTypes(Ric ric, A1Client a1Client) {
return a1Client.getPolicyTypeIdentities() //
- .doOnNext(x -> ric.clearSupportedPolicyTypes()) //
- .flatMapMany(Flux::fromIterable) //
- .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().ricId(), typeId)) //
- .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) //
- .doOnNext(ric::addSupportedPolicyType); //
+ .doOnNext(x -> ric.clearSupportedPolicyTypes()) //
+ .flatMapMany(Flux::fromIterable) //
+ .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().ricId(), typeId)) //
+ .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) //
+ .doOnNext(ric::addSupportedPolicyType); //
}
private Mono<PolicyType> getPolicyType(String policyTypeId, A1Client a1Client) {
@@ -177,7 +178,7 @@ public class RicSynchronizationTask {
return Mono.just(policyTypes.get(policyTypeId));
}
return a1Client.getPolicyTypeSchema(policyTypeId) //
- .flatMap(schema -> createPolicyType(policyTypeId, schema));
+ .flatMap(schema -> createPolicyType(policyTypeId, schema));
}
private Mono<PolicyType> createPolicyType(String policyTypeId, String schema) {
@@ -195,7 +196,7 @@ public class RicSynchronizationTask {
private Flux<Policy> putPolicy(Policy policy, Ric ric, A1Client a1Client) {
logger.debug("Recreating policy: {}, for ric: {}", policy.id(), ric.getConfig().ricId());
return a1Client.putPolicy(policy) //
- .flatMapMany(notUsed -> Flux.just(policy));
+ .flatMapMany(notUsed -> Flux.just(policy));
}
private boolean checkTransient(Policy policy) {
@@ -207,8 +208,8 @@ public class RicSynchronizationTask {
private Flux<Policy> recreateAllPoliciesInRic(Ric ric, A1Client a1Client) {
return Flux.fromIterable(policies.getForRic(ric.id())) //
- .filter(policy -> !checkTransient(policy)) //
- .flatMap(policy -> putPolicy(policy, ric, a1Client), CONCURRENCY_RIC);
+ .filter(policy -> !checkTransient(policy)) //
+ .flatMap(policy -> putPolicy(policy, ric, a1Client), CONCURRENCY_RIC);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
index a46ff1f9..4c063e2d 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
@@ -62,7 +62,7 @@ public class ServiceSupervision {
}
public ServiceSupervision(Services services, Policies policies, A1ClientFactory a1ClientFactory,
- Duration checkInterval) {
+ Duration checkInterval) {
this.services = services;
this.policies = policies;
this.a1ClientFactory = a1ClientFactory;
@@ -77,32 +77,32 @@ public class ServiceSupervision {
private Flux<?> createTask() {
return Flux.interval(this.checkInterval) //
- .flatMap(notUsed -> checkAllServices());
+ .flatMap(notUsed -> checkAllServices());
}
Flux<Policy> checkAllServices() {
return Flux.fromIterable(services.getAll()) //
- .filter(Service::isExpired) //
- .doOnNext(service -> logger.info("Service is expired: {}", service.getName())) //
- .doOnNext(service -> services.remove(service.getName())) //
- .flatMap(this::getAllPoliciesForService) //
- .flatMap(this::deletePolicy, CONCURRENCY_RIC);
+ .filter(Service::isExpired) //
+ .doOnNext(service -> logger.info("Service is expired: {}", service.getName())) //
+ .doOnNext(service -> services.remove(service.getName())) //
+ .flatMap(this::getAllPoliciesForService) //
+ .flatMap(this::deletePolicy, CONCURRENCY_RIC);
}
@SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
private Flux<Policy> deletePolicy(Policy policy) {
Lock lock = policy.ric().getLock();
return lock.lock(LockType.SHARED) //
- .doOnNext(notUsed -> policies.remove(policy)) //
- .flatMap(notUsed -> deletePolicyInRic(policy))
- .doOnNext(notUsed -> logger.debug("Policy deleted due to service inactivity: {}, service: {}", policy.id(),
- policy.ownerServiceId())) //
- .doOnNext(notUsed -> lock.unlockBlocking()) //
- .doOnError(throwable -> lock.unlockBlocking()) //
- .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.id(),
- throwable.getMessage())) //
- .flatMapMany(notUsed -> Flux.just(policy)) //
- .onErrorResume(throwable -> Flux.empty());
+ .doOnNext(notUsed -> policies.remove(policy)) //
+ .flatMap(notUsed -> deletePolicyInRic(policy))
+ .doOnNext(notUsed -> logger.debug("Policy deleted due to service inactivity: {}, service: {}",
+ policy.id(), policy.ownerServiceId())) //
+ .doOnNext(notUsed -> lock.unlockBlocking()) //
+ .doOnError(throwable -> lock.unlockBlocking()) //
+ .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.id(),
+ throwable.getMessage())) //
+ .flatMapMany(notUsed -> Flux.just(policy)) //
+ .onErrorResume(throwable -> Flux.empty());
}
private Flux<Policy> getAllPoliciesForService(Service service) {
@@ -111,14 +111,14 @@ public class ServiceSupervision {
private Mono<Policy> deletePolicyInRic(Policy policy) {
return a1ClientFactory.createA1Client(policy.ric()) //
- .flatMap(client -> client.deletePolicy(policy) //
- .onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) //
- .map(nothing -> policy));
+ .flatMap(client -> client.deletePolicy(policy) //
+ .onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) //
+ .map(nothing -> policy));
}
private Mono<String> handleDeleteFromRicFailure(Policy policy, Throwable e) {
logger.warn("Could not delete policy: {} from ric: {}. Cause: {}", policy.id(), policy.ric().id(),
- e.getMessage());
+ e.getMessage());
return Mono.empty();
}
}