* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.lang.invoke.MethodHandles;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.tasks.RefreshConfigTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
+@RequiredArgsConstructor
public class Application {
- @Autowired
- private RefreshConfigTask configRefresh;
+ private final RefreshConfigTask configRefresh;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
* ONAP : ccsdk oran
* ======================================================================
* Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import reactor.core.publisher.Mono;
+
/**
* Factory for A1 clients that supports four different protocol versions of the
* A1 api.
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final ApplicationConfig appConfig;
-
private final AsyncRestClientFactory restClientFactory;
public A1ClientFactory(ApplicationConfig appConfig, SecurityContext securityContext) {
- this.appConfig = appConfig;
this.restClientFactory = new AsyncRestClientFactory(appConfig.getWebClientConfig(), securityContext);
}
* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Map<String, ControllerConfig> controllerConfigs = parseControllerConfigs(pmsConfigJson);
List<RicConfig> ricConfigs = parseRics(pmsConfigJson, controllerConfigs);
- checkConfigurationConsistency(ricConfigs, controllerConfigs);
+ checkConfigurationConsistency(ricConfigs);
return ConfigParserResult.builder() //
.ricConfigs(ricConfigs) //
return CharStreams.toString(new InputStreamReader(in, StandardCharsets.UTF_8));
}
- private void checkConfigurationConsistency(List<RicConfig> ricConfigs,
- Map<String, ControllerConfig> controllerConfigs) throws ServiceException {
+ private void checkConfigurationConsistency(List<RicConfig> ricConfigs) throws ServiceException {
Set<String> ricUrls = new HashSet<>();
Set<String> ricNames = new HashSet<>();
for (RicConfig ric : ricConfigs) {
private JsonArray getAsJsonArray(JsonObject obj, String memberName) throws ServiceException {
return get(obj, memberName).getAsJsonArray();
}
-
- private static String getAsString(JsonObject obj, String memberName) throws ServiceException {
- return get(obj, memberName).getAsString();
- }
}
/*-
* ========================LICENSE_START=================================
* Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.IOException;
import java.util.Optional;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfigParser;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ConfigurationFile;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
-@RestController("ConfigurationControllerV2")
+@RestController("configurationControllerV2")
+@RequiredArgsConstructor
@Tag( //
name = ConfigurationController.API_NAME, //
description = ConfigurationController.API_DESCRIPTION //
private final ConfigurationFile configurationFile;
private final ApplicationConfig applicationConfig;
- ConfigurationController(@Autowired ConfigurationFile configurationFile,
- @Autowired ApplicationConfig applicationConfig) {
- this.configurationFile = configurationFile;
- this.applicationConfig = applicationConfig;
- }
-
private static Gson gson = new GsonBuilder() //
.create(); //
* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.authorization.AuthorizationCheck;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
-@RestController("PolicyControllerV2")
+@RestController("policyControllerV2")
+@RequiredArgsConstructor
@Tag(//
name = PolicyController.API_NAME, //
description = PolicyController.API_DESCRIPTION //
}
}
- @Autowired
- private Rics rics;
- @Autowired
- private PolicyTypes policyTypes;
- @Autowired
- private Policies policies;
- @Autowired
- private A1ClientFactory a1ClientFactory;
- @Autowired
- private Services services;
-
- @Autowired
- private AuthorizationCheck authorization;
+ private final Rics rics;
+ private final PolicyTypes policyTypes;
+ private final Policies policies;
+ private final A1ClientFactory a1ClientFactory;
+ private final Services services;
+ private final AuthorizationCheck authorization;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static Gson gson = new GsonBuilder() //
- .create(); //
+ private static final Gson gson = new GsonBuilder().create();
@GetMapping(path = Consts.V2_API_ROOT + "/policy-types/{policytype_id:.+}") //
@Operation(summary = "Returns a policy type definition") //
.lastModified(Instant.now()) //
.isTransient(policyInfo.isTransient) //
.statusNotificationUri(policyInfo.statusNotificationUri == null ? "" : policyInfo.statusNotificationUri) //
- .build();
+ .build();
return authorization.doAccessControl(headers, policy, AccessType.WRITE) //
.flatMap(x -> ric.getLock().lock(LockType.SHARED, "putPolicy")) //
}
private Mono<ResponseEntity<Object>> handleException(Throwable throwable) {
- if (throwable instanceof WebClientResponseException) {
- WebClientResponseException e = (WebClientResponseException) throwable;
+ if (throwable instanceof WebClientResponseException e) {
return ErrorResponse.createMono(e.getResponseBodyAsString(), e.getStatusCode());
- } else if (throwable instanceof WebClientException) {
- WebClientException e = (WebClientException) throwable;
+ } else if (throwable instanceof WebClientException e) {
return ErrorResponse.createMono(e.getMessage(), HttpStatus.BAD_GATEWAY);
- } else if (throwable instanceof RejectionException) {
- RejectionException e = (RejectionException) throwable;
+ } else if (throwable instanceof RejectionException e) {
return ErrorResponse.createMono(e.getMessage(), e.getStatus());
- } else if (throwable instanceof ServiceException) {
- ServiceException e = (ServiceException) throwable;
+ } else if (throwable instanceof ServiceException e) {
return ErrorResponse.createMono(e.getMessage(), e.getHttpStatus());
} else {
return ErrorResponse.createMono(throwable.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
policyInfo.isTransient = p.isTransient();
if (!p.getStatusNotificationUri().isEmpty()) {
policyInfo.statusNotificationUri = p.getStatusNotificationUri();
- }
+ }
if (!policyInfo.validate()) {
logger.error("BUG, all mandatory fields must be set");
}
- return policyInfo;
+ return policyInfo;
}
private String policiesToJson(Collection<Policy> policies) {
}
return gson.toJson(new PolicyIdList(v));
}
-
}
* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.ArrayList;
import java.util.List;
+import lombok.RequiredArgsConstructor;
+
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.InvalidRequestException;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-@RestController("RicRepositoryControllerV2")
+
+@RestController("ricRepositoryControllerV2")
+@RequiredArgsConstructor
@Tag( //
name = RicRepositoryController.API_NAME, //
description = RicRepositoryController.API_DESCRIPTION //
public static final String API_NAME = "NearRT-RIC Repository";
public static final String API_DESCRIPTION = "";
- @Autowired
- private Rics rics;
-
- @Autowired
- PolicyTypes types;
+ private final Rics rics;
+ private final PolicyTypes types;
- private static Gson gson = new GsonBuilder() //
- .create(); //
+ private static final Gson gson = new GsonBuilder().create();
private static final String GET_RIC_BRIEF = "Returns info for one Near-RT RIC";
private static final String GET_RIC_DETAILS =
* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Collection;
import java.util.Map;
+import lombok.RequiredArgsConstructor;
+
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-@RestController("ServiceControllerV2")
+@RestController("serviceControllerV2")
+@RequiredArgsConstructor
@Tag( //
name = ServiceController.API_NAME, //
description = ServiceController.API_DESCRIPTION //
)
public class ServiceController {
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
public static final String API_NAME = "Service Registry and Supervision";
public static final String API_DESCRIPTION = "";
private final Services services;
private final Policies policies;
+ private final PolicyController policyController;
- private static Gson gson = new GsonBuilder().create();
-
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- @Autowired
- private PolicyController policyController;
-
- ServiceController(Services services, Policies policies) {
- this.services = services;
- this.policies = policies;
- }
+ private static final Gson gson = new GsonBuilder().create();
private static final String GET_SERVICE_DETAILS =
"Either information about a registered service with given identity or all registered services are returned.";
public ResponseEntity<Object> putService(//
@RequestBody ServiceRegistrationInfo registrationInfo) {
- try {
+ try {
validateRegistrationInfo(registrationInfo);
final boolean isCreate = this.services.get(registrationInfo.serviceId) == null;
this.services.put(toService(registrationInfo));
return new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK);
- } catch (Exception e) {
+ } catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.BAD_REQUEST);
- }
+ }
}
@DeleteMapping(Consts.V2_API_ROOT + "/services/{service_id:.+}")
removePolicies(service, headers);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (ServiceException e) {
- logger.warn("Exception caught during service deletion while deleting service {}: {}", serviceId, e.getMessage());
+ logger.warn("Exception caught during service deletion while deleting service {}: {}", serviceId,
+ e.getMessage());
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
}
}
public ResponseEntity<Object> keepAliveService(//
@PathVariable(Consts.SERVICE_ID_PARAM) String serviceId) {
try {
- services.getService(serviceId).keepAlive();
+ services.getService(serviceId).keepAlive();
return new ResponseEntity<>(HttpStatus.OK);
} catch (ServiceException e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import reactor.core.publisher.Mono;
-@RestController("StatusControllerV2")
+@RestController("statusControllerV2")
@Tag( //
name = StatusController.API_NAME, //
description = StatusController.API_DESCRIPTION //
return Mono.just(new ResponseEntity<>("success", HttpStatus.OK));
}
-}
+}
\ No newline at end of file