aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management/src/main/java/org')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java15
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java19
5 files changed, 32 insertions, 15 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 4e4ec2d5..4c3a0c79 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
@@ -83,7 +83,10 @@ public class SwaggerConfig {
+ H3 + StatusController.API_NAME + H3_END + //
"<p>API used for supervision of the PMS component.</p>" + //
H3 + ServiceController.API_NAME + H3_END + //
- "<p>API used for registering services that uses PMS. Each A1 policy is owned by a service. PMS can supervise each registered service and will automatically remove policies for unavailable services.</p>";
+ "<p>" + "API used for registering services that uses PMS."
+ + " Each A1 policy is optionally owned by a service. PMS can supervise each registered service by a heart-beat supervision and will automatically remove policies for unavailable services."
+ + " Note that a service does not need to be registered in order to create A1 Policies. This is a feature that is optional to use."
+ + "</p>";
public static final String VERSION = "1.1.0";
}
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 55a9343d..a3870b2c 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
@@ -48,19 +48,24 @@ public class PolicyInfo {
@SerializedName("policy_data")
public Object policyData;
- @Schema(name = "service_id", description = "the identity of the service owning the policy", required = true)
- @JsonProperty(value = "service_id", required = true)
+ private static final String SERVICE_ID_DESCRIPTION = "the identity of the service owning the policy."
+ + " This can be used to group the policies (it is possible to get all policies associated to a service)."
+ + " Note that the service does not need to be registerred.";
+
+ @Schema(name = "service_id", description = SERVICE_ID_DESCRIPTION, required = false, defaultValue = "")
+ @JsonProperty(value = "service_id", required = false)
@SerializedName("service_id")
- public String serviceId;
+ public String serviceId = "";
@Schema(name = "transient",
description = "if true, the policy is deleted at RIC restart. If false, its value is maintained by this service until explicitly deleted. Default false.",
- required = false)
+ required = false, defaultValue = "false", example = "false")
@JsonProperty(value = "transient", required = false, defaultValue = "false")
@SerializedName("transient")
public boolean isTransient = false;
- @Schema(name = "status_notification_uri", description = "Callback URI for policy status updates", required = false)
+ @Schema(name = "status_notification_uri", description = "Callback URI for policy status updates", required = false,
+ defaultValue = "")
@JsonProperty(value = "status_notification_uri", required = false)
@SerializedName("status_notification_uri")
public String statusNotificationUri = "";
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 faa152ca..c3f41768 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
@@ -128,10 +128,10 @@ 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>"//
+ + "<li>Get callbacks about available NearRT RICs.</li>" //
+ + "<li>Activate supervision of the service. If a service is inactive, its policies will automatically be deleted.</li>"//
+ "</ul>" //
- ;
+ + "Policies can be created even if the service is not registerred. This is a feature which it is optional to use.";
@PutMapping(Consts.V2_API_ROOT + "/services")
@Operation(summary = "Register a service", description = REGISTER_SERVICE_DETAILS)
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 0f975c24..c016b6fb 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
@@ -42,7 +42,7 @@ public class ServiceRegistrationInfo {
@JsonProperty("keep_alive_interval_seconds")
public long keepAliveIntervalSeconds = 0;
- @Schema(description = "callback for notifying of Near-RT RIC state changes", required = false)
+ @Schema(description = "callback for notifying of Near-RT RIC state changes", required = false, defaultValue = "")
@SerializedName("callback_url")
@JsonProperty("callback_url")
public String callbackUrl = "";
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java
index 09f59ca4..6161fbd9 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java
@@ -97,6 +97,11 @@ public class Policies {
}
public synchronized void put(Policy policy) {
+ Policy previousDef = this.get(policy.getId());
+ if (previousDef != null) {
+ removeFromMaps(previousDef);
+ }
+
policiesId.put(policy.getId(), policy);
policiesRic.put(policy.getRic().id(), policy.getId(), policy);
policiesService.put(policy.getOwnerServiceId(), policy.getId(), policy);
@@ -150,10 +155,7 @@ public class Policies {
if (!policy.isTransient()) {
dataStore.deleteObject(getPath(policy)).subscribe();
}
- policiesId.remove(policy.getId());
- policiesRic.remove(policy.getRic().id(), policy.getId());
- policiesService.remove(policy.getOwnerServiceId(), policy.getId());
- policiesType.remove(policy.getType().getId(), policy.getId());
+ removeFromMaps(policy);
}
public synchronized void removePoliciesForRic(String ricId) {
@@ -189,7 +191,7 @@ public class Policies {
dataStore.deleteAllObjects().onErrorResume(t -> Mono.empty()).subscribe();
}
- public void store(Policy policy) {
+ private void store(Policy policy) {
byte[] bytes = gson.toJson(toStorageObject(policy)).getBytes();
this.dataStore.writeObject(this.getPath(policy), bytes) //
@@ -197,6 +199,13 @@ public class Policies {
.subscribe();
}
+ private void removeFromMaps(Policy policy) {
+ policiesId.remove(policy.getId());
+ policiesRic.remove(policy.getRic().id(), policy.getId());
+ policiesService.remove(policy.getOwnerServiceId(), policy.getId());
+ policiesType.remove(policy.getType().getId(), policy.getId());
+ }
+
private boolean isMatch(String filterValue, String actualValue) {
return filterValue == null || actualValue.equals(filterValue);
}