Merge "Nonrtric Control Panel Gateway"
diff --git a/docs/api.json b/docs/api.json
index 53e1a2f..3a47572 100644
--- a/docs/api.json
+++ b/docs/api.json
@@ -141,7 +141,7 @@
"tags": [
"policy-controller"
],
- "summary": "Returns a policy instance of a type",
+ "summary": "Returns a policy instance",
"operationId": "getPolicyInstanceUsingGET",
"produces": [
"application/json"
@@ -153,13 +153,6 @@
"description": "policy_instance_id",
"required": true,
"type": "string"
- },
- {
- "name": "type",
- "in": "query",
- "description": "type",
- "required": true,
- "type": "string"
}
],
"responses": {
diff --git a/pom.xml b/pom.xml
index f3bae57..dccfe22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,6 @@
<sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
</properties>
<modules>
- <module>webapp-frontend</module>
<module>webapp-backend</module>
</modules>
<build>
diff --git a/webapp-backend/pom.xml b/webapp-backend/pom.xml
index fc4ec39..d49b53b 100644
--- a/webapp-backend/pom.xml
+++ b/webapp-backend/pom.xml
@@ -219,26 +219,6 @@
</archive>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-resources</id>
- <phase>validate</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/classes/resources/</outputDirectory>
- <resources>
- <resource>
- <directory>${project.parent.basedir}/webapp-frontend/dist/controlpanelApp/</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
<!-- do not deploy a jar or pom file -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -281,7 +261,7 @@
<image>
<!-- Specify a tag to avoid default tag "latest" -->
<!-- Avoid maven artifact name here -->
- <name>o-ran-sc/nonrtric-controlpanel:${project.version}</name>
+ <name>o-ran-sc/nonrtric-controlpanel-backend:${project.version}</name>
<build>
<from>openjdk:11-jre-slim</from>
<tags>
diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/PolicyController.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/PolicyController.java
index 6cf79f1..ccc2ac7 100644
--- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/PolicyController.java
+++ b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/PolicyController.java
@@ -93,12 +93,10 @@
return this.policyAgentApi.getPolicyInstancesForType(policyTypeIdString);
}
- @ApiOperation(value = "Returns a policy instance of a type")
+ @ApiOperation(value = "Returns a policy instance")
@GetMapping(POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME + "}")
- public ResponseEntity<Object> getPolicyInstance(
- @RequestParam(name = "type", required = true) String policyTypeIdString,
- @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
- logger.debug("getPolicyInstance {}:{}", policyTypeIdString, policyInstanceId);
+ public ResponseEntity<Object> getPolicyInstance(@PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
+ logger.debug("getPolicyInstance {}", policyInstanceId);
return this.policyAgentApi.getPolicyInstance(policyInstanceId);
}
diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInfo.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInfo.java
index 782919d..9ea4d93 100644
--- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInfo.java
+++ b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInfo.java
@@ -18,25 +18,44 @@
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.portal.nonrtric.controlpanel.model;
+import com.google.gson.annotations.SerializedName;
+
+import lombok.Builder;
+
import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-@Value.Immutable
@Gson.TypeAdapters
-public interface PolicyInfo {
+@Builder
+public class PolicyInfo {
+ @SerializedName(value = "id", alternate = "policy_id")
+ public String policyId;
- public String id();
+ @SerializedName(value = "type", alternate = "policytype_id")
+ public String policyTypeId;
- public String type();
+ @SerializedName(value = "ric", alternate = "ric_id")
+ public String ricId;
- public String ric();
+ @SerializedName(value = "json", alternate = "policy_data")
+ public Object policyData;
- public Object json();
+ @SerializedName(value = "service", alternate = "service_id")
+ public String serviceId;
- public String service();
+ @SerializedName("transient")
+ public boolean isTransient = false;
- public String lastModified();
+ @SerializedName(value = "statusNotificationUri", alternate = "status_notification_uri")
+ public String statusNotificationUri = "";
+
+ @SerializedName("lastModified")
+ public String lastModified = "";
+
+ public boolean validate() {
+ return policyId != null && policyTypeId != null && ricId != null && policyData != null && serviceId != null;
+ }
}
diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstance.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstance.java
new file mode 100644
index 0000000..993538c
--- /dev/null
+++ b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstance.java
@@ -0,0 +1,62 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 Nordix Foundation
+ * Modifications Copyright (C) 2020 Nordix Foundation
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================LICENSE_END===================================
+ */
+
+package org.oransc.portal.nonrtric.controlpanel.model;
+
+import com.google.gson.annotations.SerializedName;
+
+import lombok.Builder;
+
+import org.immutables.gson.Gson;
+
+@Gson.TypeAdapters
+@Builder
+public class PolicyInstance {
+
+ @SerializedName(value = "policy_id")
+ public String policyId;
+
+ @SerializedName(value = "policytype_id")
+ public String policyTypeId;
+
+ @SerializedName(value = "ric_id")
+ public String ricId;
+
+ @SerializedName(value = "policy_data")
+ public Object policyData;
+
+ @SerializedName(value = "service_id")
+ public String serviceId;
+
+ @SerializedName(value = "transient")
+ public boolean isTransient = false;
+
+ @SerializedName(value = "status_notification_uri")
+ public String statusNotificationUri = "";
+
+ @SerializedName(value = "lastModified")
+ public String lastModified = "";
+
+ public boolean validate() {
+ return policyId != null && policyTypeId != null && ricId != null && policyData != null && serviceId != null;
+ }
+
+}
diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImpl.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImpl.java
index f8b7c3e..9e30c51 100644
--- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImpl.java
+++ b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImpl.java
@@ -35,8 +35,8 @@
import org.immutables.gson.Gson;
import org.immutables.value.Value;
-import org.oransc.portal.nonrtric.controlpanel.model.ImmutablePolicyInfo;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyInfo;
+import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstance;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyType;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyTypes;
import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient;
@@ -127,31 +127,55 @@
.get("policy_ids") //
.getAsJsonArray(); //
- Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {}.getType();
- List<PolicyInfo> rspParsed = gson.fromJson(policyInstances, listType);
+ List<Object> res = new ArrayList<>();
+ for (JsonElement p : policyInstances) {
+ ResponseEntity<Object> policyInstance = getIndividualPolicyInstance(p.getAsString());
+ res.add(policyInstance.getBody());
+ }
- return new ResponseEntity<>(gson.toJson(rspParsed), rsp.getStatusCode());
+ return new ResponseEntity<>(gson.toJson(res), rsp.getStatusCode());
} catch (Exception e) {
return ErrorResponseHandler.handleException(e);
}
}
- @Override
- public ResponseEntity<Object> getPolicyInstance(String id) {
+ public ResponseEntity<Object> getIndividualPolicyInstance(String id) {
try {
String url = "/v2/policies/" + id;
ResponseEntity<String> rsp = webClient.getForEntity(url).block();
JsonObject obj = JsonParser.parseString(rsp.getBody()).getAsJsonObject();
- String str = obj.toString();
- return new ResponseEntity<>(str, rsp.getStatusCode());
+
+ // lastModified timestamp is fetched from PolicyStatus instead
+ ResponseEntity<String> status = getPolicyStatus(id);
+ String lastModified = JsonParser.parseString(status.getBody()).getAsJsonObject() //
+ .get("last_modified") //
+ .getAsString(); //
+ obj.addProperty("lastModified", lastModified);
+
+ PolicyInfo i = gson.fromJson(obj, PolicyInfo.class);
+ return new ResponseEntity<>(i, rsp.getStatusCode());
} catch (Exception e) {
ResponseEntity<String> rsp = ErrorResponseHandler.handleException(e);
return new ResponseEntity<>(rsp.getBody(), rsp.getStatusCode());
}
}
- private String getTimeStampUTC() {
- return java.time.Instant.now().toString();
+ public ResponseEntity<String> getPolicyStatus(String id) {
+ try {
+ String url = "/v2/policies/" + id + "/status";
+ ResponseEntity<String> rsp = webClient.getForEntity(url).block();
+ return new ResponseEntity<>(rsp.getBody(), rsp.getStatusCode());
+ } catch (Exception e) {
+ ResponseEntity<String> rsp = ErrorResponseHandler.handleException(e);
+ return new ResponseEntity<>(rsp.getBody(), rsp.getStatusCode());
+ }
+ }
+
+ @Override
+ public ResponseEntity<Object> getPolicyInstance(String id) {
+ ResponseEntity<Object> rsp = getIndividualPolicyInstance(id);
+ PolicyInfo i = (PolicyInfo) rsp.getBody();
+ return new ResponseEntity<>(i.policyData, rsp.getStatusCode());
}
@Override
@@ -159,17 +183,19 @@
String ric) {
String url = "/v2/policies/";
- PolicyInfo i = ImmutablePolicyInfo.builder() //
- .id(policyInstanceId) //
- .type(policyTypeIdString) //
- .ric(ric) //
- .json(json) //
- .service("controlpanel") //
- .lastModified(getTimeStampUTC()) //
+ JsonElement data = JsonParser.parseString(json.toString()).getAsJsonObject();
+
+ PolicyInstance i = PolicyInstance.builder() //
+ .policyId(policyInstanceId) //
+ .policyTypeId(policyTypeIdString) //
+ .ricId(ric) //
+ .policyData(data) //
+ .serviceId("controlpanel") //
.build(); //
try {
- String jsonStr = gson.toJson(i, PolicyInfo.class);
+ String jsonStr = gson.toJson(i, PolicyInstance.class);
+ logger.debug("PolicyInstance: " + jsonStr);
webClient.putForEntity(url, jsonStr).block();
return new ResponseEntity<>(HttpStatus.OK);
} catch (Exception e) {
@@ -191,11 +217,11 @@
@Value.Immutable
@Gson.TypeAdapters
interface RicInfo {
- public String ricName();
+ public String ric_id();
- public Collection<String> nodeNames();
+ public Collection<String> managed_element_ids();
- public Collection<String> policyTypes();
+ public Collection<String> policytype_ids();
}
@Override
@@ -215,7 +241,7 @@
List<RicInfo> rspParsed = gson.fromJson(rics, listType);
Collection<String> result = new ArrayList<>(rspParsed.size());
for (RicInfo ric : rspParsed) {
- result.add(ric.ricName());
+ result.add(ric.ric_id());
}
String json = gson.toJson(result);
return new ResponseEntity<>(json, HttpStatus.OK);
diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/PolicyControllerMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/PolicyControllerMockConfiguration.java
index e593736..d6476db 100644
--- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/PolicyControllerMockConfiguration.java
+++ b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/PolicyControllerMockConfiguration.java
@@ -35,7 +35,6 @@
import java.util.Vector;
import java.util.stream.Collectors;
-import org.oransc.portal.nonrtric.controlpanel.model.ImmutablePolicyInfo;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyInfo;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstances;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyType;
@@ -154,8 +153,14 @@
}
void putInstance(String typeId, String instanceId, Object instanceData, String ric) {
- PolicyInfo i = ImmutablePolicyInfo.builder().json(instanceData).lastModified(getTimeStampUTC())
- .id(instanceId).ric(ric).service("service").type(typeId).build();
+ PolicyInfo i = PolicyInfo.builder() //
+ .policyData(instanceData) //
+ .lastModified(getTimeStampUTC()) //
+ .policyId(instanceId) //
+ .ricId(ric) //
+ .serviceId("service") //
+ .policyTypeId(typeId) //
+ .build(); //
instances.put(instanceId, i);
}
@@ -168,7 +173,7 @@
if (i == null) {
throw new RestClientException("Type not found: " + id);
}
- return i.json();
+ return i.policyData;
}
public Collection<PolicyType> getTypes() {
@@ -179,7 +184,7 @@
ArrayList<PolicyInfo> result = new ArrayList<>();
for (PolicyInfo i : instances.values()) {
if (typeId.isPresent()) {
- if (i.type().equals(typeId.get())) {
+ if (i.policyTypeId.equals(typeId.get())) {
result.add(i);
}
diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImplTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImplTest.java
index 42d2669..deedd8e 100644
--- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImplTest.java
+++ b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImplTest.java
@@ -28,17 +28,17 @@
import static org.mockito.Mockito.when;
import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
-import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.oransc.portal.nonrtric.controlpanel.model.ImmutablePolicyInfo;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyInfo;
+import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstance;
import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstances;
import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient;
import org.springframework.http.HttpStatus;
@@ -53,13 +53,20 @@
private static final String POLICY_TYPE_1_INVALID = "\"title\":\"type1\"}";
private static final String POLICY_TYPE_2_VALID = "{\"title\":\"type2\"}";
private static final String POLICY_1_ID = "policy1";
- private static final String POLICY_1_VALID = "{\"policyId\":\"policy1\"}";
- private static final String POLICY_1_INVALID = "\"policyId\":\"policy1\"}";
+ private static final String POLICY_DATA =
+ "{\"qosObjectives\":{\"priorityLevel\":22.0},\"scope\":{\"qosId\":\"22\",\"ueId\":\"22\"}}";
+ private static final String POLICY_1_VALID =
+ "{\"policy_id\":\"policy1\",\"policytype_id\":\"type1\",\"ric_id\":\"ric1\",\"policy_data\":" + POLICY_DATA
+ + ",\"service_id\":\"controlpanel\"}";
+ private static final String POLICY_1_INVALID = "\"policy_id\":\"policy1\"}";
private static final String RIC_1_ID = "ric1";
- private static final String RIC_1_INFO_VALID = "{\"ricName\":\"ric1\",\"policyTypes\":[\"type1\"]}";
- private static final String RIC_1_INFO_INVALID = "{\"ricName\":\"ric1\",\"policyTypes\":\"type1\"]}";
+ private static final String RIC_1_INFO_VALID = "{\"ric_id\":\"ric1\",\"policytype_ids\":[\"type1\"]}";
+ private static final String RIC_1_INFO_INVALID = "{\"ric_id\":\"ric1\",\"policytype_ids\":\"type1\"]}";
private static final String CLIENT_ERROR_MESSAGE = "XXXXXXX";
-
+ private static final String SERVICE_ID = "controlpanel";
+ private static final String TIMESTAMP = "2021-01-12T09:59:33.392470Z";
+ private static final String STATUS =
+ "{\"last_modified\": \"" + TIMESTAMP + "\",\"status\":{\"enforceStatus\": \"\",\"enforceReason\": \"\"}}";
private static com.google.gson.Gson gson = new GsonBuilder() //
.serializeNulls() //
.create(); //
@@ -129,10 +136,13 @@
@Test
void testGetPolicyInstancesForTypeSuccessValidJson() {
- String policyInstances = "{\"policy_ids\":[{\"id\":\"policy1\"}]}";
- String policyInstancesJson = parsePolicyInstancesJson("[{\"id\":\"policy1\"}]");
+ String policyInstances = "{\"policy_ids\":[\"policy1\"]}";
+ String policyInstancesJson = parsePolicyInstancesJson("[\"policy1\"]");
whenGetReturnOK(urlPolicyInstances(POLICY_TYPE_1_ID), HttpStatus.OK, policyInstances);
+ whenGetReturnOK(urlPolicyInstance(POLICY_1_ID), HttpStatus.OK, POLICY_1_VALID);
+ whenGetReturnOK(urlPolicyStatus(POLICY_1_ID), HttpStatus.OK, STATUS);
+
ResponseEntity<String> returnedResp = apiUnderTest.getPolicyInstancesForType(POLICY_TYPE_1_ID);
assertEquals(returnedResp.getBody(), policyInstancesJson);
assertEquals(HttpStatus.OK, returnedResp.getStatusCode());
@@ -154,15 +164,19 @@
return "/v2/policies/" + id;
}
+ private String urlPolicyStatus(String id) {
+ return "/v2/policies/" + id + "/status";
+ }
+
@Test
void testGetPolicyInstance() {
whenGetReturnOK(urlPolicyInstance(POLICY_1_ID), HttpStatus.OK, POLICY_1_VALID);
+ whenGetReturnOK(urlPolicyStatus(POLICY_1_ID), HttpStatus.OK, STATUS);
ResponseEntity<Object> returnedResp = apiUnderTest.getPolicyInstance(POLICY_1_ID);
assertEquals(HttpStatus.OK, returnedResp.getStatusCode());
- assertEquals(POLICY_1_VALID, returnedResp.getBody());
-
+ assertEquals(POLICY_DATA, gson.toJson(returnedResp.getBody()));
}
private String urlPutPolicy() {
@@ -183,21 +197,20 @@
@Test
void testPutPolicyFailure() {
String url = urlPutPolicy();
-
- PolicyInfo i = ImmutablePolicyInfo.builder() //
- .id(POLICY_1_ID) //
- .type(POLICY_TYPE_1_ID) //
- .ric(RIC_1_ID) //
- .json(POLICY_1_VALID) //
- .service("") //
- .lastModified("") //
+ JsonElement data = JsonParser.parseString(POLICY_DATA).getAsJsonObject();
+ PolicyInstance i = PolicyInstance.builder() //
+ .policyId(POLICY_1_ID) //
+ .policyTypeId(POLICY_TYPE_1_ID) //
+ .ricId(RIC_1_ID) //
+ .policyData(data) //
+ .serviceId(SERVICE_ID) //
.build(); //
- String jsonStr = gson.toJson(i, PolicyInfo.class);
+ String jsonStr = gson.toJson(i);
whenPutReturnFailure(url, jsonStr, HttpStatus.NOT_FOUND, CLIENT_ERROR_MESSAGE);
ResponseEntity<String> returnedResp =
- apiUnderTest.putPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, POLICY_1_VALID, RIC_1_ID);
+ apiUnderTest.putPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, POLICY_DATA, RIC_1_ID);
assertTrue(returnedResp.getBody().contains(CLIENT_ERROR_MESSAGE));
assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode());
@@ -206,22 +219,19 @@
@Test
void testPutPolicySuccess() {
String url = urlPutPolicy();
- PolicyInfo i = ImmutablePolicyInfo.builder() //
- .id(POLICY_1_ID) //
- .type(POLICY_TYPE_1_ID) //
- .ric(RIC_1_ID) //
- .json(POLICY_1_VALID) //
- .service("") //
- .lastModified("") //
+ JsonElement data = JsonParser.parseString(POLICY_DATA).getAsJsonObject();
+ PolicyInstance i = PolicyInstance.builder() //
+ .policyId(POLICY_1_ID) //
+ .policyTypeId(POLICY_TYPE_1_ID) //
+ .ricId(RIC_1_ID) //
+ .policyData(data) //
+ .serviceId(SERVICE_ID) //
.build(); //
-
- String jsonStr = gson.toJson(i, PolicyInfo.class);
-
+ String jsonStr = gson.toJson(i);
whenPutReturnOK(url, jsonStr, HttpStatus.OK, POLICY_1_VALID);
ResponseEntity<String> returnedResp =
- apiUnderTest.putPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, POLICY_1_VALID, RIC_1_ID);
-
+ apiUnderTest.putPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, POLICY_DATA, RIC_1_ID);
assertNull(returnedResp.getBody());
assertEquals(HttpStatus.OK, returnedResp.getStatusCode());
}
@@ -288,12 +298,20 @@
}
private String parsePolicyInstancesJson(String inputString) {
- Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {}.getType();
- List<PolicyInfo> rspParsed = gson.fromJson(inputString, listType);
- PolicyInstances policyInstances = new PolicyInstances();
- for (PolicyInfo policy : rspParsed) {
- policyInstances.add(policy);
+ JsonArray arr = JsonParser.parseString(inputString).getAsJsonArray();
+ PolicyInstances res = new PolicyInstances();
+ JsonElement data = JsonParser.parseString(POLICY_DATA).getAsJsonObject();
+ for (JsonElement id : arr) {
+ PolicyInfo i = PolicyInfo.builder() //
+ .policyId(id.getAsString()) //
+ .policyTypeId(POLICY_TYPE_1_ID) //
+ .ricId(RIC_1_ID) //
+ .policyData(data) //
+ .serviceId(SERVICE_ID) //
+ .lastModified(TIMESTAMP) //
+ .build(); //
+ res.add(i);
}
- return gson.toJson(policyInstances);
+ return gson.toJson(res);
}
}
diff --git a/webapp-frontend/.dockerignore b/webapp-frontend/.dockerignore
new file mode 100644
index 0000000..1521c8b
--- /dev/null
+++ b/webapp-frontend/.dockerignore
@@ -0,0 +1 @@
+dist
diff --git a/webapp-frontend/Dockerfile b/webapp-frontend/Dockerfile
new file mode 100644
index 0000000..c711e47
--- /dev/null
+++ b/webapp-frontend/Dockerfile
@@ -0,0 +1,28 @@
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+### STAGE 1: Build App ###
+FROM node:14-alpine AS stage1
+WORKDIR /usr/src/app
+COPY package*.json ./
+RUN npm install
+COPY . .
+RUN npm run-script build
+
+### STAGE 2: Run App ###
+FROM nginx:alpine
+COPY nginx.conf /etc/nginx/nginx.conf
+COPY --from=stage1 /usr/src/app/dist/controlpanelApp /usr/share/nginx/html
\ No newline at end of file
diff --git a/webapp-frontend/container-tag.yaml b/webapp-frontend/container-tag.yaml
new file mode 100644
index 0000000..82f559b
--- /dev/null
+++ b/webapp-frontend/container-tag.yaml
@@ -0,0 +1,2 @@
+---
+tag: 2.2.0
diff --git a/webapp-frontend/nginx.conf b/webapp-frontend/nginx.conf
new file mode 100644
index 0000000..47d7b26
--- /dev/null
+++ b/webapp-frontend/nginx.conf
@@ -0,0 +1,20 @@
+events{}
+
+http {
+ include /etc/nginx/mime.types;
+
+ upstream backend {
+ # to be replaced with hostname:port of nonrtric-gateway once it gets ready
+ server controlpanel-backend-container:8080;
+ }
+
+ server {
+ listen 7070;
+ server_name localhost;
+ root /usr/share/nginx/html;
+ index index.html;
+ location /api/ {
+ proxy_pass http://backend;
+ }
+ }
+}
\ No newline at end of file
diff --git a/webapp-frontend/pom.xml b/webapp-frontend/pom.xml
deleted file mode 100644
index f3a1077..0000000
--- a/webapp-frontend/pom.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--<![CDATA[
-========================LICENSE_START=================================
-O-RAN-SC
-%%
-Copyright (C) 2019 AT&T Intellectual Property
-Modifications Copyright (C) 2020 Nordix Foundation
-%%
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-========================LICENSE_END===================================
-]]>-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.o-ran-sc.portal.nonrtric.controlpanel</groupId>
- <artifactId>nonrtric-controlpanel-parent</artifactId>
- <version>2.2.0-SNAPSHOT</version>
- </parent>
- <artifactId>nonrtric-controlpanel-fe</artifactId>
- <name>Non-RT RIC Control Panel Webapp frontend</name>
- <build>
- <plugins>
- <plugin>
- <groupId>com.github.eirslett</groupId>
- <artifactId>frontend-maven-plugin</artifactId>
- <version>1.3</version>
- <configuration>
- <nodeVersion>v10.15.3</nodeVersion>
- <npmVersion>6.7.0</npmVersion>
- <workingDirectory>.</workingDirectory>
- </configuration>
- <executions>
- <execution>
- <id>install node and npm</id>
- <goals>
- <goal>install-node-and-npm</goal>
- </goals>
- </execution>
- <execution>
- <id>npm install</id>
- <goals>
- <goal>npm</goal>
- </goals>
- </execution>
- <execution>
- <id>npm run build</id>
- <goals>
- <goal>npm</goal>
- </goals>
- <configuration>
- <arguments>run build</arguments>
- </configuration>
- </execution>
- <execution>
- <id>prod</id>
- <goals>
- <goal>npm</goal>
- </goals>
- <configuration>
- <arguments>run-script build</arguments>
- </configuration>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${project.basedir}</directory>
- <includes>
- <include>**/node_modules/**</include>
- <include>dist/**</include>
- <include>node/**</include>
- </includes>
- <followSymlinks>false</followSymlinks>
- </fileset>
- <fileset>
- <directory>node</directory>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>