Dashboard using policy agent NBI
Change-Id: I21081d49a1ce3704a4e88e009ae92003efa96d18
Issue-ID: NONRTRIC-84
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
diff --git a/dashboard/a1-controller-client/.gitignore b/dashboard/a1-controller-client/.gitignore
deleted file mode 100644
index 212de16..0000000
--- a/dashboard/a1-controller-client/.gitignore
+++ /dev/null
@@ -1,24 +0,0 @@
-*.class
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.ear
-
-# exclude jar for gradle wrapper
-!gradle/wrapper/*.jar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-# build files
-**/target
-target
-.gradle
-build
-
-logs/
-bin/
diff --git a/dashboard/a1-controller-client/README.md b/dashboard/a1-controller-client/README.md
deleted file mode 100644
index b93a390..0000000
--- a/dashboard/a1-controller-client/README.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# A1 Controller Client Generator
-
-This projects generates a REST client library from the OpenAPI specification
-file stored here and packages it in a jar.
-
-## Eclipse and STS Users
-
-The Swagger Codegen maven plugin is not supported in Eclipse/STS. You can
-limp along by taking these steps:
-
-1. Generate the code using maven:
- mvn install
-2. Add this folder to the project build path:
- target/generated-sources/swagger/src/main/java
-
-## License
-
-Copyright (C) 2019 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.
diff --git a/dashboard/a1-controller-client/pom.xml b/dashboard/a1-controller-client/pom.xml
deleted file mode 100644
index 4011bfb..0000000
--- a/dashboard/a1-controller-client/pom.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--<![CDATA[
-========================LICENSE_START=================================
-O-RAN-SC
-%%
-Copyright (C) 2019 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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.o-ran-sc.nonrt.ric-dashboard</groupId>
- <artifactId>ric-dash-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
- <!-- This groupId will NOT allow deployment in LF -->
- <groupId>org.o-ran-sc.ric.plt.a1controller.client</groupId>
- <artifactId>a1-controller-client</artifactId>
- <name>RIC A1 Controller client</name>
- <version>0.1.0-SNAPSHOT</version>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <!-- Jenkins invokes maven with -Dbuild.number=.. -->
- <build.number>0</build.number>
- <!-- same as groupId BUT without hyphens -->
- <client.base.package.name>org.oransc.ric.a1controller.client</client.base.package.name>
- </properties>
- <!-- Successful compilation requires generated code dependencies -->
- <dependencies>
- <!-- Required for Java 9 and later -->
- <dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>javax.annotation-api</artifactId>
- </dependency>
- <dependency>
- <groupId>io.swagger.core.v3</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>2.0.8</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
- <!-- HTTP client: Spring RestTemplate -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- </dependency>
- <!-- JSON processing: jackson -->
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.datatype</groupId>
- <artifactId>jackson-datatype-jsr310</artifactId>
- </dependency>
- <!-- test dependencies -->
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <!-- This 2019 version is required for OpenAPI 3 -->
- <groupId>io.swagger.codegen.v3</groupId>
- <artifactId>swagger-codegen-maven-plugin</artifactId>
- <version>3.0.8</version>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <inputSpec>${project.basedir}/src/main/resources/a1_controller_0.1.0.yaml</inputSpec>
- <language>java</language>
- <packageName>${client.base.package.name}</packageName>
- <modelPackage>${client.base.package.name}.model</modelPackage>
- <apiPackage>${client.base.package.name}.api</apiPackage>
- <invokerPackage>${client.base.package.name}.invoker</invokerPackage>
- <configOptions>
- <groupId>${project.groupId}</groupId>
- <artifactId>${project.artifactId}</artifactId>
- <artifactVersion>${project.version}</artifactVersion>
- <library>resttemplate</library>
- <java8>true</java8>
- <dateLibrary>java8</dateLibrary>
- <licenseName>Apache 2.0</licenseName>
- <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
- </configOptions>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- add build information to manifest. Java provides access to the implementation
- version for a package, so cram the build number into there. -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Implementation-Version>${project.version}-b${build.number}</Implementation-Version>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
- only. It has no influence on the Maven build itself. -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>io.swagger.codegen.v3</groupId>
- <artifactId>swagger-codegen-maven-plugin</artifactId>
- <versionRange>[1.0,)</versionRange>
- <goals>
- <goal>generate</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
diff --git a/dashboard/a1-controller-client/src/main/resources/a1_controller_0.1.0.yaml b/dashboard/a1-controller-client/src/main/resources/a1_controller_0.1.0.yaml
deleted file mode 100644
index 86bb823..0000000
--- a/dashboard/a1-controller-client/src/main/resources/a1_controller_0.1.0.yaml
+++ /dev/null
@@ -1,555 +0,0 @@
-# ==================================================================================
-# Copyright (c) 2019 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.
-# ==================================================================================
-openapi: 3.0.0
-info:
- version: 1.0.0
- title: RIC A1
-paths:
- '/A1-ADAPTER-API:getNearRT-RICs':
- post:
- description: >
- Get a list of all nearRT-RICs
- tags:
- - A1 Controller
- operationId: a1.controller.get_all_nearrt_rics
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_NRRids_list_code_schema"
-
- '/A1-ADAPTER-API:getHealthCheck':
- post:
- description: >
- Get health status for a Near-RT-RIC. true - health ok, false - health is not ok.
- tags:
- - A1 Controller
- operationId: a1.controller.get_healthcheck
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_healthstatus_code_schema"
-
- '/A1-ADAPTER-API:getPolicyTypes':
- post:
- description: >
- Get a list of all registered policy-type-ids.
- tags:
- - A1 Controller
- operationId: a1.controller.get_all_policy_types
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_PTids_list_code_schema"
-
- '/A1-ADAPTER-API:createPolicyType':
- post:
- description: >
- Create a policy type.
- tags:
- - A1 Controller
- operationId: a1.controller.create_policy_type
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_desc_name_PT_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_code_schema"
-
- '/A1-ADAPTER-API:getPolicyType':
- post:
- description: >
- Get a policy type.
- tags:
- - A1 Controller
- operationId: a1.controller.get_policy_type
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_desc_name_PT_code_schema"
-
- '/A1-ADAPTER-API:deletePolicyType':
- post:
- description: >
- Delete a policy type.
- tags:
- - A1 Controller
- operationId: a1.controller.delete_policy_type
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_code_schema"
-
- '/A1-ADAPTER-API:getPolicyInstances':
- post:
- description: >
- Get a list of all policy-instance-ids for this policy-type-id.
- tags:
- - A1 Controller
- operationId: a1.controller.get_all_instances_for_type
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_PIids_list_code_schema"
-
- '/A1-ADAPTER-API:createPolicyInstance':
- post:
- description: >
- Create a policy instance.
- tags:
- - A1 Controller
- operationId: a1.controller.create_policy_instance
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_PIid_PI_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_code_schema"
-
- '/A1-ADAPTER-API:getPolicyInstance':
- post:
- description: >
- Get a policy instance.
- tags:
- - A1 Controller
- operationId: a1.controller.get_policy_instance
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_PIid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_PI_code_schema"
-
- '/A1-ADAPTER-API:deletePolicyInstance':
- post:
- description: >
- Delete a policy instance.
- tags:
- - A1 Controller
- operationId: a1.controller.delete_policy_instance
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_PIid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_code_schema"
-
- '/A1-ADAPTER-API:getStatus':
- post:
- description: >
- Get the status for a policy instance.
- tags:
- - A1 Controller
- operationId: a1.controller.get_policy_instance_status
- requestBody:
- required: true
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/input_NRRid_PTid_PIid_schema"
- responses:
- '200':
- description: >
- Successfully got the response.
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/output_status_code_schema"
-
-components:
- schemas:
- input_NRRid_schema:
- type: object
- required:
- - input
- additionalProperties: false
- properties:
- input:
- type: object
- required:
- - near-rt-ric-id
- additionalProperties: false
- properties:
- near-rt-ric-id:
- "$ref": "#/components/schemas/near_rt_ric_id"
-
- input_NRRid_PTid_schema:
- type: object
- required:
- - input
- additionalProperties: false
- properties:
- input:
- type: object
- required:
- - near-rt-ric-id
- - policy-type-id
- additionalProperties: false
- properties:
- near-rt-ric-id:
- "$ref": "#/components/schemas/near_rt_ric_id"
- policy-type-id:
- "$ref": "#/components/schemas/policy_type_id"
-
- input_NRRid_PTid_PIid_schema:
- type: object
- required:
- - input
- additionalProperties: false
- properties:
- input:
- type: object
- required:
- - near-rt-ric-id
- - policy-type-id
- - policy-instance-id
- additionalProperties: false
- properties:
- near-rt-ric-id:
- "$ref": "#/components/schemas/near_rt_ric_id"
- policy-type-id:
- "$ref": "#/components/schemas/policy_type_id"
- policy-instance-id:
- "$ref": "#/components/schemas/policy_instance_id"
-
- input_NRRid_PTid_PIid_PI_schema:
- type: object
- required:
- - input
- additionalProperties: false
- properties:
- input:
- type: object
- required:
- - near-rt-ric-id
- - policy-type-id
- - policy-instance-id
- - policy-instance
- additionalProperties: false
- properties:
- near-rt-ric-id:
- "$ref": "#/components/schemas/near_rt_ric_id"
- policy-type-id:
- "$ref": "#/components/schemas/policy_type_id"
- policy-instance-id:
- "$ref": "#/components/schemas/policy_instance_id"
- policy-instance:
- "$ref": "#/components/schemas/policy_instance"
-
- input_NRRid_PTid_desc_name_PT_schema:
- type: object
- required:
- - input
- additionalProperties: false
- properties:
- input:
- type: object
- required:
- - near-rt-ric-id
- - policy-type-id
- - description
- - name
- - policy-type
- additionalProperties: false
- properties:
- near-rt-ric-id:
- "$ref": "#/components/schemas/near_rt_ric_id"
- policy-type-id:
- "$ref": "#/components/schemas/policy_type_id"
- description:
- type: string
- name:
- type: string
- policy-type:
- "$ref": "#/components/schemas/policy_type"
-
- output_NRRids_list_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - near-rt-ric-id-list
- - code
- additionalProperties: false
- properties:
- near-rt-ric-id-list:
- type: array
- items:
- "$ref": "#/components/schemas/near_rt_ric_id"
- code:
- type: string
-
- output_healthstatus_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - health-status
- - code
- additionalProperties: false
- properties:
- health-status:
- type: boolean
- code:
- type: string
-
- output_desc_name_PT_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - description
- - name
- - policy_type
- - code
- additionalProperties: false
- properties:
- description:
- type: string
- name:
- type: string
- policy-type:
- "$ref": "#/components/schemas/policy_type"
- code:
- type: string
-
- output_PTids_list_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - policy-type-id-list
- - code
- additionalProperties: false
- properties:
- policy-type-id-list:
- type: array
- items:
- "$ref": "#/components/schemas/policy_type_id"
- code:
- type: string
-
- output_PIids_list_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - policy-instance-id-list
- - code
- additionalProperties: false
- properties:
- policy-instance-id-list:
- type: array
- items:
- "$ref": "#/components/schemas/policy_instance_id"
- code:
- type: string
-
- output_PI_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - policy-instance
- - code
- additionalProperties: false
- properties:
- policy-instance:
- "$ref": "#/components/schemas/policy_instance"
- code:
- type: string
-
- output_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - code
- additionalProperties: false
- properties:
- code:
- type: string
-
- output_status_code_schema:
- type: object
- required:
- - output
- additionalProperties: false
- properties:
- output:
- type: object
- required:
- - status
- - code
- additionalProperties: false
- properties:
- status:
- type: string
- code:
- type: string
-
- near_rt_ric_id:
- description: >
- represents a near RT RIC identifier. Currently this can be any string.
- type: string
- example: near-rt-ric-1
-
- policy_type_id:
- description: >
- represents a policy type identifier. Currently this is an integer.
- type: integer
- example: 20000
-
- policy_instance_id:
- description: >
- represents a policy instance identifier. UUIDs are advisable but can be any string
- type: string
- example: 3d2157af-6a8f-4a7c-810f-38c2f824bf12
-
- policy_type:
- description: >
- represents a policy type. String is used for now to represent this
- type: string
- example:
- "{type: A}"
-
- policy_instance:
- description: >
- represents a policy instance. String is used for now to represent this
- type: string
- example:
- "{slice_id: slice-1, priority_level: high}"
-
- securitySchemes:
- basicAuth:
- type: http
- scheme: basic
-
-security:
- - basicAuth: []
\ No newline at end of file
diff --git a/dashboard/a1-controller-client/src/test/java/org/oransc/ric/portal/dashboard/a1controller/client/test/A1ControllerClientTest.java b/dashboard/a1-controller-client/src/test/java/org/oransc/ric/portal/dashboard/a1controller/client/test/A1ControllerClientTest.java
deleted file mode 100644
index cbafba4..0000000
--- a/dashboard/a1-controller-client/src/test/java/org/oransc/ric/portal/dashboard/a1controller/client/test/A1ControllerClientTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 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.ric.portal.dashboard.a1controller.client.test;
-
-import java.lang.invoke.MethodHandles;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.oransc.ric.a1controller.client.api.A1ControllerApi;
-import org.oransc.ric.a1controller.client.invoker.ApiClient;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidPISchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidPISchemaInput;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidSchema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.client.RestClientException;
-
-/**
- * Demonstrates use of the generated A1 controller client.
- *
- * The tests fail because no server is available.
- */
-public class A1ControllerClientTest {
-
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- @Test
- public void demo() {
- ApiClient apiClient = new ApiClient();
- apiClient.setBasePath("http://localhost:30099/");
- A1ControllerApi a1Api = new A1ControllerApi(apiClient);
- try {
- Object o = a1Api.a1ControllerGetPolicyInstance(new InputNRRidPTidPIidSchema());
- logger.info(
- "getPolicy answered code {}, content {} ", apiClient.getStatusCode().toString(), o.toString());
- Assertions.assertTrue(apiClient.getStatusCode().is2xxSuccessful());
- } catch (RestClientException e) {
- logger.error("getPolicy failed: {}", e.toString());
- }
- try {
- String policy = "{}";
- InputNRRidPTidPIidPISchema body = new InputNRRidPTidPIidPISchema();
- InputNRRidPTidPIidPISchemaInput input = new InputNRRidPTidPIidPISchemaInput();
- input.setNearRtRicId("1");
- input.setPolicyTypeId(1);
- input.setPolicyInstanceId("1");
- input.setPolicyInstance("{}");
- body.setInput(input);
- a1Api.a1ControllerCreatePolicyInstance(body);
- logger.info("putPolicy answered: {}", apiClient.getStatusCode().toString());
- Assertions.assertTrue(apiClient.getStatusCode().is2xxSuccessful());
- } catch (RestClientException e) {
- logger.error("getPolicy failed: {}", e.toString());
- }
- }
-}
diff --git a/dashboard/pom.xml b/dashboard/pom.xml
index 1473449..8c2b0dc 100644
--- a/dashboard/pom.xml
+++ b/dashboard/pom.xml
@@ -44,8 +44,7 @@
<lmp.process.start.tag>========================LICENSE_START=================================</lmp.process.start.tag>
<lmp.process.end.tag>========================LICENSE_END===================================</lmp.process.end.tag>
</properties>
- <modules>
- <module>a1-controller-client</module>
+ <modules>
<module>webapp-frontend</module>
<module>webapp-backend</module>
</modules>
diff --git a/dashboard/webapp-backend/pom.xml b/dashboard/webapp-backend/pom.xml
index 215ec75..80bb585 100644
--- a/dashboard/webapp-backend/pom.xml
+++ b/dashboard/webapp-backend/pom.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--<![CDATA[
+<!--
+
+
+<![CDATA[
========================LICENSE_START=================================
O-RAN-SC
%%
@@ -18,287 +21,295 @@
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"
+<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.nonrt.ric-dashboard</groupId>
- <artifactId>ric-dash-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
- <artifactId>ric-dash-be</artifactId>
- <name>NonRT RIC Dashboard Webapp backend</name>
- <properties>
- <springfox.version>2.9.2</springfox.version>
- <!-- Set by Jenkins -->
- <build.number>0</build.number>
- </properties>
- <repositories>
- <repository>
- <id>onap-releases</id>
- <name>ONAP - Release Repository</name>
- <url>https://nexus.onap.org/content/repositories/releases</url>
- </repository>
- </repositories>
- <dependencies>
- <!-- Platform components -->
- <dependency>
- <groupId>org.o-ran-sc.ric.plt.a1controller.client</groupId>
- <artifactId>a1-controller-client</artifactId>
- <version>0.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.onap.portal.sdk</groupId>
- <artifactId>epsdk-fw</artifactId>
- <version>2.6.0</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>apache-log4j-extras</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </exclusion>
- <!-- EELF omits "test" scope on this dependency -->
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- </exclusion>
- <!-- EELF omits "test" scope on this dependency -->
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-security</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <!-- Bridge uses of Apache commons logging, like EPSDK-FW -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <!-- Test dependencies -->
- <!-- Mockito supports development, not just testing -->
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-launcher</artifactId>
- <!-- Override Spring-Boot choice for Eclipse -->
- <version>1.4.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <!-- Most configuration and all execution is inherited -->
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <configuration>
- <roots>
- <root>src</root>
- </roots>
- <excludes>
- <exclude>**/*.json</exclude>
- </excludes>
- </configuration>
- </plugin>
- <!-- Add the build number to the jar manifest. Spring-Boot uses a complex
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.o-ran-sc.nonrt.ric-dashboard</groupId>
+ <artifactId>ric-dash-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>ric-dash-be</artifactId>
+ <name>NonRT RIC Dashboard Webapp backend</name>
+ <properties>
+ <springfox.version>2.9.2</springfox.version>
+ <immutable.version>2.7.1</immutable.version>
+ <!-- Set by Jenkins -->
+ <build.number>0</build.number>
+ </properties>
+ <repositories>
+ <repository>
+ <id>onap-releases</id>
+ <name>ONAP - Release Repository</name>
+ <url>https://nexus.onap.org/content/repositories/releases</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <!-- Platform components -->
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-fw</artifactId>
+ <version>2.6.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>apache-log4j-extras</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </exclusion>
+ <!-- EELF omits "test" scope on this dependency -->
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ </exclusion>
+ <!-- EELF omits "test" scope on this dependency -->
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <!-- Bridge uses of Apache commons logging, like EPSDK-FW -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>value</artifactId>
+ <version>${immutable.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>gson</artifactId>
+ <version>${immutable.version}</version>
+ </dependency>
+ <!-- Test dependencies -->
+ <!-- Mockito supports development, not just testing -->
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-launcher</artifactId>
+ <!-- Override Spring-Boot choice for Eclipse -->
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <!-- Most configuration and all execution is inherited -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <configuration>
+ <roots>
+ <root>src</root>
+ </roots>
+ <excludes>
+ <exclude>**/*.json</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <!-- Add the build number to the jar manifest. Spring-Boot uses a complex
packaging process that makes access to the original Manifest.MF very difficult.
However, Java provides access to the implementation version for a package,
so cram the build number into there. -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Implementation-Version>${project.version}-b${build.number}</Implementation-Version>
- </manifestEntries>
- </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/dashApp/</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- do not deploy a jar or pom file -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>0.8.4</version>
- <executions>
- <execution>
- <id>default-prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>default-report</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <!-- https://stackoverflow.com/questions/39126226/fabric8-springboot-full-example -->
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>0.30.0</version>
- <configuration>
- <verbose>true</verbose>
- <!-- environment variables supplied by Jenkins -->
- <pullRegistry>${env.CONTAINER_PULL_REGISTRY}</pullRegistry>
- <pushRegistry>${env.CONTAINER_PUSH_REGISTRY}</pushRegistry>
- <images>
- <image>
- <!-- Specify a tag to avoid default tag "latest" -->
- <!-- Avoid maven artifact name here -->
- <name>o-ran-sc/nonrtric-dashboard:${project.version}</name>
- <build>
- <from>openjdk:11-jre-slim</from>
- <tags>
- <!-- Add tag with build number -->
- <tag>${project.version}</tag>
- </tags>
- <assembly>
- <descriptorRef>artifact</descriptorRef>
- </assembly>
- <runCmds>
- <!-- Ensure logs dir exists and is world writable -->
- <runCmd>mkdir /logs</runCmd>
- <runCmd>chmod -R 777 /logs</runCmd>
- </runCmds>
- <cmd>
- <!-- Include maven dir on classpath for prop files -->
- <exec>
- <arg>java</arg>
- <arg>-Xms128m</arg>
- <arg>-Xmx256m</arg>
- <arg>-cp</arg>
- <arg>maven:maven/${project.artifactId}-${project.version}.${project.packaging}</arg>
- <arg>-Dloader.main=org.oransc.ric.portal.dashboard.DashboardApplication</arg>
- <arg>-Djava.security.egd=file:/dev/./urandom</arg>
- <arg>org.springframework.boot.loader.PropertiesLauncher</arg>
- </exec>
- </cmd>
- </build>
- </image>
- </images>
- </configuration>
- <!-- build Docker images in install phase, push in deploy phase -->
- <executions>
- <execution>
- <goals>
- <goal>build</goal>
- <goal>push</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <Implementation-Version>${project.version}-b${build.number}</Implementation-Version>
+ </manifestEntries>
+ </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/dashApp/</directory>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- do not deploy a jar or pom file -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.8.4</version>
+ <executions>
+ <execution>
+ <id>default-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-report</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- https://stackoverflow.com/questions/39126226/fabric8-springboot-full-example -->
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.30.0</version>
+ <configuration>
+ <verbose>true</verbose>
+ <!-- environment variables supplied by Jenkins -->
+ <pullRegistry>${env.CONTAINER_PULL_REGISTRY}</pullRegistry>
+ <pushRegistry>${env.CONTAINER_PUSH_REGISTRY}</pushRegistry>
+ <images>
+ <image>
+ <!-- Specify a tag to avoid default tag "latest" -->
+ <!-- Avoid maven artifact name here -->
+ <name>o-ran-sc/nonrtric-dashboard:${project.version}</name>
+ <build>
+ <from>openjdk:11-jre-slim</from>
+ <tags>
+ <!-- Add tag with build number -->
+ <tag>${project.version}</tag>
+ </tags>
+ <assembly>
+ <descriptorRef>artifact</descriptorRef>
+ </assembly>
+ <runCmds>
+ <!-- Ensure logs dir exists and is world writable -->
+ <runCmd>mkdir /logs</runCmd>
+ <runCmd>chmod -R 777 /logs</runCmd>
+ </runCmds>
+ <cmd>
+ <!-- Include maven dir on classpath for prop files -->
+ <exec>
+ <arg>java</arg>
+ <arg>-Xms128m</arg>
+ <arg>-Xmx256m</arg>
+ <arg>-cp</arg>
+ <arg>maven:maven/${project.artifactId}-${project.version}.${project.packaging}</arg>
+ <arg>-Dloader.main=org.oransc.ric.portal.dashboard.DashboardApplication</arg>
+ <arg>-Djava.security.egd=file:/dev/./urandom</arg>
+ <arg>org.springframework.boot.loader.PropertiesLauncher</arg>
+ </exec>
+ </cmd>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ <!-- build Docker images in install phase, push in deploy phase -->
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java
index d61ce1d..b82aa64 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java
@@ -38,7 +38,7 @@
private static final String ROLE_PREFIX = "ROLE_";
public static final String ROLE_ADMIN = ROLE_PREFIX + ROLE_NAME_ADMIN;
public static final String ROLE_STANDARD = ROLE_PREFIX + ROLE_NAME_STANDARD;
- public static final String A1_CONTROLLER_USERNAME = "admin";
- public static final String A1_CONTROLLER_PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
+ public static final String POLICY_CONTROLLER_USERNAME = "admin";
+ public static final String POLICY_CONTROLLER_PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1ControllerConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1ControllerConfiguration.java
deleted file mode 100644
index ffdcacd..0000000
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1ControllerConfiguration.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 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.ric.portal.dashboard.config;
-
-import java.lang.invoke.MethodHandles;
-import org.oransc.ric.a1controller.client.api.A1ControllerApi;
-import org.oransc.ric.a1controller.client.invoker.ApiClient;
-import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.util.DefaultUriBuilderFactory;
-
-/**
- * Creates an A1 controller client as a bean to be managed by the Spring
- * container.
- */
-@Configuration
-@Profile("!test")
-public class A1ControllerConfiguration {
-
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public static final String A1_CONTROLLER_USERNAME = DashboardConstants.A1_CONTROLLER_USERNAME;
- public static final String A1_CONTROLLER_PASSWORD = DashboardConstants.A1_CONTROLLER_PASSWORD;
-
- // Populated by the autowired constructor
- private final String a1ControllerUrl;
-
- @Autowired
- public A1ControllerConfiguration(@Value("${a1controller.url.prefix}") final String urlPrefix, //
- @Value("${a1controller.url.suffix}") final String urlSuffix) {
- logger.debug("ctor prefix '{}' suffix '{}'", urlPrefix, urlSuffix);
- a1ControllerUrl = new DefaultUriBuilderFactory(urlPrefix.trim()).builder().path(urlSuffix.trim()).build().normalize()
- .toString();
- logger.info("Configuring A1 Controller at URL {}", a1ControllerUrl);
- }
-
- private ApiClient apiClient() {
- ApiClient apiClient = new ApiClient(new RestTemplate());
- apiClient.setBasePath(a1ControllerUrl);
- apiClient.setUsername(A1_CONTROLLER_USERNAME);
- apiClient.setPassword(A1_CONTROLLER_PASSWORD);
- return apiClient;
- }
-
- @Bean
- // The bean (method) name must be globally unique
- public A1ControllerApi a1ControllerApi() {
- return new A1ControllerApi(apiClient());
- }
-
-}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
index 0a7f02c..85a96d0 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
@@ -23,9 +23,9 @@
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.InvocationTargetException;
+
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.oransc.ric.portal.dashboard.DashboardUserManager;
-import org.oransc.ric.portal.dashboard.controller.A1Controller;
import org.oransc.ric.portal.dashboard.controller.SimpleErrorController;
import org.oransc.ric.portal.dashboard.portalapi.PortalAuthManager;
import org.oransc.ric.portal.dashboard.portalapi.PortalAuthenticationFilter;
@@ -43,6 +43,7 @@
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
+import org.oransc.ric.portal.dashboard.controller.PolicyController;
@Configuration
@EnableWebSecurity
@@ -71,7 +72,7 @@
DashboardUserManager userManager;
@Override
- protected void configure(HttpSecurity http) throws Exception {
+ protected void configure(HttpSecurity http) throws Exception {
logger.debug("configure: portalapi.username {}", userName);
// A chain of ".and()" always baffles me
http.authorizeRequests().anyRequest().authenticated();
@@ -90,7 +91,7 @@
"/swagger-ui.html", //
"/webjars/**", //
PortalApiConstants.API_PREFIX + "/**", //
- A1Controller.CONTROLLER_PATH + "/" + A1Controller.VERSION_METHOD, //
+ PolicyController.CONTROLLER_PATH + "/" + PolicyController.VERSION_METHOD, //
SimpleErrorController.ERROR_PATH };
@Override
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/A1Controller.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/A1Controller.java
deleted file mode 100644
index 08b485e..0000000
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/A1Controller.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 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.ric.portal.dashboard.controller;
-
-import java.lang.invoke.MethodHandles;
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.oransc.ric.a1controller.client.api.A1ControllerApi;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidPISchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidPISchemaInput;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidSchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidSchemaInput;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidSchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidSchemaInput;
-import org.oransc.ric.a1controller.client.model.InputNRRidSchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidSchemaInput;
-import org.oransc.ric.a1controller.client.model.OutputCodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputDescNamePTCodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputDescNamePTCodeSchemaOutput;
-import org.oransc.ric.a1controller.client.model.OutputPICodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputPIidsListCodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputPTidsListCodeSchema;
-import org.oransc.ric.portal.dashboard.DashboardApplication;
-import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.oransc.ric.portal.dashboard.exceptions.HttpBadRequestException;
-import org.oransc.ric.portal.dashboard.exceptions.HttpInternalServerErrorException;
-import org.oransc.ric.portal.dashboard.exceptions.HttpNotFoundException;
-import org.oransc.ric.portal.dashboard.exceptions.HttpNotImplementedException;
-import org.oransc.ric.portal.dashboard.model.PolicyInstance;
-import org.oransc.ric.portal.dashboard.model.PolicyInstances;
-import org.oransc.ric.portal.dashboard.model.PolicyType;
-import org.oransc.ric.portal.dashboard.model.PolicyTypes;
-import org.oransc.ric.portal.dashboard.model.SuccessTransport;
-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.security.access.annotation.Secured;
-import org.springframework.util.Assert;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * Proxies calls from the front end to the A1 Controller via the A1 Mediator
- * API.
- *
- * If a method throws RestClientResponseException, it is handled by
- * {@link CustomResponseEntityExceptionHandler#handleProxyMethodException(Exception,
- * org.springframework.web.context.request.WebRequest)}
- * which returns status 502. All other exceptions are handled by Spring which
- * returns status 500.
- */
-@RestController
-@RequestMapping(value = A1Controller.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
-public class A1Controller {
-
- private static final String NEAR_RT_RIC_ID = "NearRtRic1";
-
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- // Publish paths in constants so tests are easy to write
- public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/policy";
- // Endpoints
- public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD;
- public static final String POLICY_TYPES_METHOD = "policytypes";
- public static final String POLICY_TYPE_ID_NAME = "policy_type_id";
- public static final String POLICIES_NAME = "policies";
- public static final String POLICY_INSTANCE_ID_NAME = "policy_instance_id";
-
- // Populated by the autowired constructor
- private final A1ControllerApi a1ControllerApi;
-
- @Autowired
- public A1Controller(final A1ControllerApi A1ControllerApi) {
- Assert.notNull(A1ControllerApi, "API must not be null");
- this.a1ControllerApi = A1ControllerApi;
- if (logger.isDebugEnabled())
- logger.debug("ctor: configured with client type {}", A1ControllerApi.getClass().getName());
- }
-
- @ApiOperation(value = "Gets the A1 client library MANIFEST.MF property Implementation-Version.",
- response = SuccessTransport.class)
- @GetMapping(VERSION_METHOD)
- // No role required
- public SuccessTransport getA1ControllerClientVersion() {
- return new SuccessTransport(200, DashboardApplication.getImplementationVersion(A1ControllerApi.class));
- }
-
- /*
- * The fields are defined in the A1Control Typescript interface.
- */
- @ApiOperation(value = "Gets the policy types from Near Realtime-RIC via the A1 Controller API")
- @GetMapping(POLICY_TYPES_METHOD)
- @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
- public Object getAllPolicyTypes(HttpServletResponse response) {
- logger.debug("getAllPolicyTypes");
- InputNRRidSchemaInput nrrid = new InputNRRidSchemaInput();
- nrrid.setNearRtRicId(NEAR_RT_RIC_ID);
- InputNRRidSchema inputSchema = new InputNRRidSchema();
- inputSchema.setInput(nrrid);
- OutputPTidsListCodeSchema outputPTidsListCodeSchema =
- a1ControllerApi.a1ControllerGetAllPolicyTypes(inputSchema);
- checkHttpError(outputPTidsListCodeSchema.getOutput().getCode());
- List<Integer> policyTypeIds = outputPTidsListCodeSchema.getOutput().getPolicyTypeIdList();
- PolicyTypes policyTypes = new PolicyTypes();
- InputNRRidPTidSchema typeSchema = new InputNRRidPTidSchema();
- InputNRRidPTidSchemaInput typeId = new InputNRRidPTidSchemaInput();
- typeId.setNearRtRicId(NEAR_RT_RIC_ID);
- for (Integer policyTypeId : policyTypeIds) {
- typeId.setPolicyTypeId(policyTypeId);
- typeSchema.setInput(typeId);
- OutputDescNamePTCodeSchema controllerGetPolicyType =
- a1ControllerApi.a1ControllerGetPolicyType(typeSchema);
- checkHttpError(controllerGetPolicyType.getOutput().getCode());
- OutputDescNamePTCodeSchemaOutput policyTypeSchema = controllerGetPolicyType.getOutput();
- PolicyType type = new PolicyType(policyTypeId, policyTypeSchema.getName(),
- policyTypeSchema.getPolicyType().toString());
- policyTypes.add(type);
- }
- return policyTypes;
- }
-
- @ApiOperation(value = "Returns the policy instances for the given policy type.")
- @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME)
- @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
- public Object getPolicyInstances(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString) {
- logger.debug("getPolicyInstances {}", policyTypeIdString);
- InputNRRidPTidSchemaInput typeIdInput = new InputNRRidPTidSchemaInput();
- typeIdInput.setNearRtRicId(NEAR_RT_RIC_ID);
- Integer policyTypeId = Integer.decode(policyTypeIdString);
- typeIdInput.setPolicyTypeId(policyTypeId);
- InputNRRidPTidSchema inputSchema = new InputNRRidPTidSchema();
- inputSchema.setInput(typeIdInput);
- OutputPIidsListCodeSchema controllerGetAllInstancesForType =
- a1ControllerApi.a1ControllerGetAllInstancesForType(inputSchema);
- checkHttpError(controllerGetAllInstancesForType.getOutput().getCode());
- List<String> instancesForType = controllerGetAllInstancesForType.getOutput().getPolicyInstanceIdList();
- PolicyInstances instances = new PolicyInstances();
- InputNRRidPTidPIidSchemaInput instanceIdInput = new InputNRRidPTidPIidSchemaInput();
- instanceIdInput.setNearRtRicId(NEAR_RT_RIC_ID);
- instanceIdInput.setPolicyTypeId(policyTypeId);
- InputNRRidPTidPIidSchema instanceInputSchema = new InputNRRidPTidPIidSchema();
- for (String instanceId : instancesForType) {
- instanceIdInput.setPolicyInstanceId(instanceId);
- instanceInputSchema.setInput(instanceIdInput);
- OutputPICodeSchema policyInstance =
- a1ControllerApi.a1ControllerGetPolicyInstance(instanceInputSchema);
- checkHttpError(policyInstance.getOutput().getCode());
- PolicyInstance instance =
- new PolicyInstance(instanceId, policyInstance.getOutput().getPolicyInstance());
- instances.add(instance);
- }
- return instances;
- }
-
- @ApiOperation(value = "Returns a policy instance of a type")
- @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{"
- + POLICY_INSTANCE_ID_NAME + "}")
- @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
- public Object getPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
- @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
- logger.debug("getPolicyInstance {}:{}", policyTypeIdString, policyInstanceId);
- InputNRRidPTidPIidSchemaInput instanceIdInput = new InputNRRidPTidPIidSchemaInput();
- instanceIdInput.setNearRtRicId(NEAR_RT_RIC_ID);
- instanceIdInput.setPolicyTypeId(Integer.decode(policyTypeIdString));
- instanceIdInput.setPolicyInstanceId(policyInstanceId);
- InputNRRidPTidPIidSchema inputSchema = new InputNRRidPTidPIidSchema();
- inputSchema.setInput(instanceIdInput);
- OutputPICodeSchema policyInstance = a1ControllerApi.a1ControllerGetPolicyInstance(inputSchema);
- checkHttpError(policyInstance.getOutput().getCode());
- return policyInstance.getOutput().getPolicyInstance();
- }
-
- @ApiOperation(value = "Creates the policy instances for the given policy type.")
- @PutMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{"
- + POLICY_INSTANCE_ID_NAME + "}")
- @Secured({ DashboardConstants.ROLE_ADMIN })
- public void putPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
- @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId, @RequestBody String instance) {
- logger.debug("putPolicyInstance typeId: {}, instanceId: {}, instance: {}", policyTypeIdString,
- policyInstanceId, instance);
- InputNRRidPTidPIidPISchemaInput createInstanceInput = new InputNRRidPTidPIidPISchemaInput();
- createInstanceInput.setNearRtRicId(NEAR_RT_RIC_ID);
- createInstanceInput.setPolicyTypeId(Integer.decode(policyTypeIdString));
- createInstanceInput.setPolicyInstanceId(policyInstanceId);
- createInstanceInput.setPolicyInstance(instance);
- InputNRRidPTidPIidPISchema inputSchema = new InputNRRidPTidPIidPISchema();
- inputSchema.setInput(createInstanceInput);
- OutputCodeSchema outputCodeSchema = a1ControllerApi.a1ControllerCreatePolicyInstance(inputSchema);
- checkHttpError(outputCodeSchema.getOutput().getCode());
- }
-
- @ApiOperation(value = "Deletes the policy instances for the given policy type.")
- @DeleteMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{"
- + POLICY_INSTANCE_ID_NAME + "}")
- @Secured({ DashboardConstants.ROLE_ADMIN })
- public void deletePolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
- @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
- logger.debug("deletePolicyInstance typeId: {}, instanceId: {}", policyTypeIdString, policyInstanceId);
- InputNRRidPTidPIidSchemaInput instanceIdInput = new InputNRRidPTidPIidSchemaInput();
- instanceIdInput.setNearRtRicId(NEAR_RT_RIC_ID);
- instanceIdInput.setPolicyTypeId(Integer.decode(policyTypeIdString));
- instanceIdInput.setPolicyInstanceId(policyInstanceId);
- InputNRRidPTidPIidSchema inputSchema = new InputNRRidPTidPIidSchema();
- inputSchema.setInput(instanceIdInput);
- OutputCodeSchema outputCodeSchema = a1ControllerApi.a1ControllerDeletePolicyInstance(inputSchema);
- checkHttpError(outputCodeSchema.getOutput().getCode());
- }
-
- private void checkHttpError(String httpCode) {
- logger.debug("Http Response Code: {}", httpCode);
- if (httpCode.equals(String.valueOf(HttpStatus.NOT_FOUND.value()))) {
- logger.error("Caught HttpNotFoundException");
- throw new HttpNotFoundException("Not Found Exception");
- } else if (httpCode.equals(String.valueOf(HttpStatus.BAD_REQUEST.value()))) {
- logger.error("Caught HttpBadRequestException");
- throw new HttpBadRequestException("Bad Request Exception");
- } else if (httpCode.equals(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()))) {
- logger.error("Caught HttpInternalServerErrorException");
- throw new HttpInternalServerErrorException("Internal Server Error Exception");
- } else if (httpCode.equals(String.valueOf(HttpStatus.NOT_IMPLEMENTED.value()))) {
- logger.error("Caught HttpNotImplementedException");
- throw new HttpNotImplementedException("Not Implemented Exception");
- }
- }
-}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java
new file mode 100644
index 0000000..8af4e97
--- /dev/null
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java
@@ -0,0 +1,161 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 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.ric.portal.dashboard.controller;
+
+import java.lang.invoke.MethodHandles;
+
+import javax.servlet.http.HttpServletResponse;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import org.oransc.ric.portal.dashboard.DashboardApplication;
+import org.oransc.ric.portal.dashboard.DashboardConstants;
+import org.oransc.ric.portal.dashboard.exceptions.HttpBadRequestException;
+import org.oransc.ric.portal.dashboard.exceptions.HttpInternalServerErrorException;
+import org.oransc.ric.portal.dashboard.exceptions.HttpNotFoundException;
+import org.oransc.ric.portal.dashboard.exceptions.HttpNotImplementedException;
+import org.oransc.ric.portal.dashboard.model.PolicyInstances;
+import org.oransc.ric.portal.dashboard.model.PolicyTypes;
+import org.oransc.ric.portal.dashboard.model.SuccessTransport;
+import org.oransc.ric.portal.dashboard.policyagentapi.PolicyAgentApi;
+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.security.access.annotation.Secured;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * Proxies calls from the front end to the Policy agent API.
+ *
+ * If a method throws RestClientResponseException, it is handled by
+ * {@link CustomResponseEntityExceptionHandler#handleProxyMethodException(Exception, org.springframework.web.context.request.WebRequest)}
+ * which returns status 502. All other exceptions are handled by Spring which
+ * returns status 500.
+ */
+@RestController
+@RequestMapping(value = PolicyController.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
+public class PolicyController {
+
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static Gson gson = new GsonBuilder() //
+ .serializeNulls() //
+ .create(); //
+
+ // Publish paths in constants so tests are easy to write
+ public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/policy";
+ // Endpoints
+ public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD;
+ public static final String POLICY_TYPES_METHOD = "policytypes";
+ public static final String POLICY_TYPE_ID_NAME = "policy_type_id";
+ public static final String POLICIES_NAME = "policies";
+ public static final String POLICY_INSTANCE_ID_NAME = "policy_instance_id";
+
+ // Populated by the autowired constructor
+ private final PolicyAgentApi policyAgentApi;
+
+ @Autowired
+ public PolicyController(final PolicyAgentApi policyAgentApi) {
+ Assert.notNull(policyAgentApi, "API must not be null");
+ this.policyAgentApi = policyAgentApi;
+ logger.debug("ctor: configured with client type {}", policyAgentApi.getClass().getName());
+ }
+
+ /*
+ * The fields are defined in the Policy Control Typescript interface.
+ */
+ @ApiOperation(value = "Gets the policy types from Near Realtime-RIC")
+ @GetMapping(POLICY_TYPES_METHOD)
+ @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
+ public PolicyTypes getAllPolicyTypes(HttpServletResponse response) {
+ logger.debug("getAllPolicyTypes");
+ return this.policyAgentApi.getAllPolicyTypes();
+ }
+
+ @ApiOperation(value = "Returns the policy instances for the given policy type.")
+ @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME)
+ @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
+ public String getPolicyInstances(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString) {
+ logger.debug("getPolicyInstances {}", policyTypeIdString);
+
+ PolicyInstances i = this.policyAgentApi.getPolicyInstancesForType(policyTypeIdString);
+ String json = gson.toJson(i);
+ return json;
+ }
+
+ @ApiOperation(value = "Returns a policy instance of a type")
+ @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
+ + "}")
+ @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
+ public String getPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
+ @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
+ logger.debug("getPolicyInstance {}:{}", policyTypeIdString, policyInstanceId);
+ return this.policyAgentApi.getPolicyInstance(policyInstanceId);
+ }
+
+ @ApiOperation(value = "Creates the policy instances for the given policy type.")
+ @PutMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
+ + "}")
+ @Secured({ DashboardConstants.ROLE_ADMIN })
+ public void putPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
+ @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId, @RequestBody String instance) {
+ logger.debug("putPolicyInstance typeId: {}, instanceId: {}, instance: {}", policyTypeIdString, policyInstanceId,
+ instance);
+ this.policyAgentApi.putPolicy(policyTypeIdString, policyInstanceId, instance);
+ }
+
+ @ApiOperation(value = "Deletes the policy instances for the given policy type.")
+ @DeleteMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{"
+ + POLICY_INSTANCE_ID_NAME + "}")
+ @Secured({ DashboardConstants.ROLE_ADMIN })
+ public void deletePolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
+ @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
+ logger.debug("deletePolicyInstance typeId: {}, instanceId: {}", policyTypeIdString, policyInstanceId);
+ this.policyAgentApi.deletePolicy(policyInstanceId);
+ }
+
+ private void checkHttpError(String httpCode) {
+ logger.debug("Http Response Code: {}", httpCode);
+ if (httpCode.equals(String.valueOf(HttpStatus.NOT_FOUND.value()))) {
+ logger.error("Caught HttpNotFoundException");
+ throw new HttpNotFoundException("Not Found Exception");
+ } else if (httpCode.equals(String.valueOf(HttpStatus.BAD_REQUEST.value()))) {
+ logger.error("Caught HttpBadRequestException");
+ throw new HttpBadRequestException("Bad Request Exception");
+ } else if (httpCode.equals(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()))) {
+ logger.error("Caught HttpInternalServerErrorException");
+ throw new HttpInternalServerErrorException("Internal Server Error Exception");
+ } else if (httpCode.equals(String.valueOf(HttpStatus.NOT_IMPLEMENTED.value()))) {
+ logger.error("Caught HttpNotImplementedException");
+ throw new HttpNotImplementedException("Not Implemented Exception");
+ }
+ }
+}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInfo.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInfo.java
new file mode 100644
index 0000000..ca1b79d
--- /dev/null
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInfo.java
@@ -0,0 +1,41 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 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.ric.portal.dashboard.model;
+
+import org.immutables.gson.Gson;
+import org.immutables.value.Value;
+
+@Value.Immutable
+@Gson.TypeAdapters
+public interface PolicyInfo {
+
+ public String id();
+
+ public String type();
+
+ public String ric();
+
+ public String json();
+
+ public String service();
+
+ public String lastModified();
+
+}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstance.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstance.java
deleted file mode 100644
index b699b3c..0000000
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstance.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 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.ric.portal.dashboard.model;
-
-public class PolicyInstance implements IDashboardResponse {
- private String instanceId;
- private Object instance;
-
- public PolicyInstance(String id, Object instance) {
- this.instanceId = id;
- this.instance = instance;
- }
-
- public String getInstanceId() {
- return instanceId;
- }
- public void setInstanceId(String instanceId) {
- this.instanceId = instanceId;
- }
- public Object getInstance() {
- return instance;
- }
- public void setInstance(Object instance) {
- this.instance = instance;
- }
-
- @Override
- public String toString() {
- return PolicyInstance.class.getName() + ": [id:" + instanceId + ", instance: " + instance + "]";
- }
-}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java
index c750487..eb6b455 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java
@@ -21,7 +21,7 @@
import java.util.ArrayList;
-public class PolicyInstances extends ArrayList<PolicyInstance> {
+public class PolicyInstances extends ArrayList<PolicyInfo> {
private static final long serialVersionUID = -928428052502491021L;
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java
index efe4010..ea51cc5 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java
@@ -23,29 +23,17 @@
public class PolicyType {
- @JsonProperty("policy_type_id")
- Integer policyTypeId;
-
@JsonProperty("name")
String name;
@JsonProperty("schema")
String schema;
- public PolicyType(Integer policyId, String name, String schema) {
- this.policyTypeId = policyId;
+ public PolicyType(String name, String schema) {
this.name = name;
this.schema = schema;
}
- public Integer getPolicyTypeId() {
- return policyTypeId;
- }
-
- public void setPolicyTypeId(Integer policyTypeId) {
- this.policyTypeId = policyTypeId;
- }
-
public String getName() {
return name;
}
@@ -64,6 +52,6 @@
@Override
public String toString() {
- return "[policy_type_id:" + policyTypeId + ", name:" + name + ", schema:" + schema + "]";
+ return "[name:" + name + ", schema:" + schema + "]";
}
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java
new file mode 100644
index 0000000..41f3c12
--- /dev/null
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java
@@ -0,0 +1,37 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 AT&T Intellectual Property
+ * %%
+ * 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.ric.portal.dashboard.policyagentapi;
+
+import org.oransc.ric.portal.dashboard.model.PolicyInstances;
+import org.oransc.ric.portal.dashboard.model.PolicyTypes;
+import org.springframework.web.client.RestClientException;
+
+public interface PolicyAgentApi {
+
+ public PolicyTypes getAllPolicyTypes() throws RestClientException;
+
+ public PolicyInstances getPolicyInstancesForType(String type);
+
+ public String getPolicyInstance(String id) throws RestClientException;
+
+ public void putPolicy(String policyTypeIdString, String policyInstanceId, String json) throws RestClientException;
+
+ public void deletePolicy(String policyInstanceId) throws RestClientException;
+}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java
new file mode 100644
index 0000000..8236de1
--- /dev/null
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java
@@ -0,0 +1,145 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 AT&T Intellectual Property
+ * %%
+ * 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.ric.portal.dashboard.policyagentapi;
+
+import org.oransc.ric.portal.dashboard.DashboardConstants;
+import org.oransc.ric.portal.dashboard.model.ImmutablePolicyInfo;
+import org.oransc.ric.portal.dashboard.model.PolicyInfo;
+import org.oransc.ric.portal.dashboard.model.PolicyInstances;
+import org.oransc.ric.portal.dashboard.model.PolicyType;
+import org.oransc.ric.portal.dashboard.model.PolicyTypes;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Map;
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Type;
+
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.SerializedName;
+import com.google.gson.reflect.TypeToken;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.immutables.gson.Gson;
+import org.immutables.value.Value;
+
+@Component("PolicyAgentApi")
+public class PolicyAgentApiImpl implements PolicyAgentApi {
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ RestTemplate restTemplate = new RestTemplate();
+
+ private static com.google.gson.Gson gson = new GsonBuilder() //
+ .serializeNulls() //
+ .create(); //
+
+ private final String urlPrefix;
+
+ @Autowired
+ public PolicyAgentApiImpl(
+ @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
+ logger.debug("ctor prefix '{}'", urlPrefix);
+ this.urlPrefix = urlPrefix;
+ }
+
+ private String baseUrl() {
+ return urlPrefix;
+ }
+
+ @Value.Immutable
+ @Gson.TypeAdapters
+ interface PolicyTypeInfo {
+
+ public String name();
+
+ public String schema();
+ }
+
+ private PolicyType toPolicyType(PolicyTypeInfo i) {
+ return new PolicyType(i.name(), i.schema());
+ }
+
+ @Override
+ public PolicyTypes getAllPolicyTypes() throws RestClientException {
+ String url = baseUrl() + "/policy_types";
+ String rsp = this.restTemplate.getForObject(url, String.class);
+
+ Type listType = new TypeToken<List<ImmutablePolicyTypeInfo>>() {
+ }.getType();
+ List<PolicyTypeInfo> rspParsed = gson.fromJson(rsp, listType);
+
+ PolicyTypes result = new PolicyTypes();
+ for (PolicyTypeInfo i : rspParsed) {
+ result.add(toPolicyType(i));
+ }
+ return result;
+ }
+
+ @Override
+ public PolicyInstances getPolicyInstancesForType(String type) {
+ String url = baseUrl() + "/policies?type={type}";
+ Map<String, ?> uriVariables = Map.of("type", type);
+ String rsp = this.restTemplate.getForObject(url, String.class, uriVariables);
+
+ Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {
+ }.getType();
+ List<PolicyInfo> rspParsed = gson.fromJson(rsp, listType);
+
+ PolicyInstances result = new PolicyInstances();
+ for (PolicyInfo p : rspParsed) {
+ result.add(p);
+ }
+ return result;
+
+ }
+
+ @Override
+ public String getPolicyInstance(String id) throws RestClientException {
+ String url = baseUrl() + "/policy?instance={id}";
+ Map<String, ?> uriVariables = Map.of("id", id);
+
+ return this.restTemplate.getForObject(url, String.class, uriVariables);
+ }
+
+ @Override
+ public void putPolicy(String policyTypeIdString, String policyInstanceId, String json) throws RestClientException {
+ String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}";
+ Map<String, ?> uriVariables = Map.of( //
+ "type", policyTypeIdString, //
+ "instance", policyInstanceId, //
+ "ric", "ric1", // TODO
+ "service", "dashboard");
+
+ this.restTemplate.put(url, json, uriVariables);
+ }
+
+ @Override
+ public void deletePolicy(String policyInstanceId) throws RestClientException {
+ String url = baseUrl() + "/policy?instance={instance}";
+ Map<String, ?> uriVariables = Map.of("instance", policyInstanceId);
+ this.restTemplate.delete(url, uriVariables);
+ }
+
+}
diff --git a/dashboard/webapp-backend/src/main/resources/application.properties b/dashboard/webapp-backend/src/main/resources/application.properties
index 3aa2406..b7753a7 100644
--- a/dashboard/webapp-backend/src/main/resources/application.properties
+++ b/dashboard/webapp-backend/src/main/resources/application.properties
@@ -44,9 +44,8 @@
# endpoint URLs must be supplied at deployment time
# NOTE: change a1controller.url.prefix to http://localhost:8282 when running
# dashboard locally (i.e., not inside the docker container)
-# A1 Controller
-a1controller.url.prefix = http://a1-controller-container:8181
-a1controller.url.suffix = /restconf/operations
+policycontroller.url.prefix = http://localhost:8081
+
# Kubernetes API via https://github.com/nokia/caas-ingress
# Set insecure=true to disable SSL certificate and hostname checking
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java
index df1a51c..a6c0a1e 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java
@@ -19,6 +19,8 @@
*/
package org.oransc.ric.portal.dashboard;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.lang.invoke.MethodHandles;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
@@ -45,7 +47,6 @@
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
-@ActiveProfiles("test")
public class DashboardTestServer {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -65,5 +66,6 @@
} catch (Exception ex) {
logger.warn(ex.toString());
}
+ assertEquals(1, 2);
}
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1ControllerMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1ControllerMockConfiguration.java
deleted file mode 100644
index 5706a91..0000000
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1ControllerMockConfiguration.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 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.ric.portal.dashboard.config;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import com.fasterxml.jackson.core.JsonProcessingException;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.invoke.MethodHandles;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.oransc.ric.a1controller.client.api.A1ControllerApi;
-import org.oransc.ric.a1controller.client.invoker.ApiClient;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidPISchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidPIidSchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidPTidSchema;
-import org.oransc.ric.a1controller.client.model.InputNRRidSchema;
-import org.oransc.ric.a1controller.client.model.OutputCodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputCodeSchemaOutput;
-import org.oransc.ric.a1controller.client.model.OutputDescNamePTCodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputDescNamePTCodeSchemaOutput;
-import org.oransc.ric.a1controller.client.model.OutputPICodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputPICodeSchemaOutput;
-import org.oransc.ric.a1controller.client.model.OutputPIidsListCodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputPIidsListCodeSchemaOutput;
-import org.oransc.ric.a1controller.client.model.OutputPTidsListCodeSchema;
-import org.oransc.ric.a1controller.client.model.OutputPTidsListCodeSchemaOutput;
-import org.oransc.ric.portal.dashboard.model.PolicyType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.http.HttpStatus;
-
-/**
- * Creates a mock implementation of the A1 controller client API.
- */
-@Profile("test")
-@Configuration
-public class A1ControllerMockConfiguration {
-
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- // A "control" is an element in the XApp descriptor
- public static final String AC_CONTROL_NAME = "admission_control_policy";
-
- // Simulate remote method delay for UI testing
- @Value("${mock.config.delay:0}")
- private int delayMs;
-
- public A1ControllerMockConfiguration() {
- logger.info("Configuring mock A1 Mediator");
- }
-
- private ApiClient apiClient() {
- ApiClient mockClient = mock(ApiClient.class);
- when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
- return mockClient;
- }
-
- @Bean
- // Use the same name as regular configuration
- public A1ControllerApi a1ControllerApi() {
- ApiClient apiClient = apiClient();
- A1ControllerApi mockApi = mock(A1ControllerApi.class);
-
- when(mockApi.getApiClient()).thenReturn(apiClient);
-
- doAnswer(inv -> {
- if (delayMs > 0) {
- logger.debug("a1ControllerGetHandler sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- List<Integer> types = database.getTypes();
- OutputPTidsListCodeSchemaOutput output = new OutputPTidsListCodeSchemaOutput();
- output.setPolicyTypeIdList(types);
- output.setCode(String.valueOf(HttpStatus.OK.value()));
- OutputPTidsListCodeSchema outputSchema = new OutputPTidsListCodeSchema();
- outputSchema.setOutput(output);
- return outputSchema;
- }).when(mockApi).a1ControllerGetAllPolicyTypes(any(InputNRRidSchema.class));
-
- doAnswer(inv -> {
- if (delayMs > 0) {
- logger.debug("a1ControllerGetPolicyType sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- InputNRRidPTidSchema input = inv.<InputNRRidPTidSchema>getArgument(0);
- PolicyType policyType = database.getPolicyType(input.getInput().getPolicyTypeId());
- OutputDescNamePTCodeSchemaOutput type = new OutputDescNamePTCodeSchemaOutput();
- type.setName(policyType.getName());
- type.setPolicyType(database.normalize(policyType.getSchema()));
- type.setCode(String.valueOf(HttpStatus.OK.value()));
- OutputDescNamePTCodeSchema outputSchema = new OutputDescNamePTCodeSchema();
- outputSchema.setOutput(type);
- return outputSchema;
- }).when(mockApi).a1ControllerGetPolicyType(any(InputNRRidPTidSchema.class));
-
- doAnswer(inv -> {
- if (delayMs > 0) {
- logger.debug("a1ControllerGetHandler sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- InputNRRidPTidSchema input = inv.<InputNRRidPTidSchema>getArgument(0);
- List<String> instances = database.getInstances(Optional.of(input.getInput().getPolicyTypeId()));
- OutputPIidsListCodeSchemaOutput instancesOutput = new OutputPIidsListCodeSchemaOutput();
- instancesOutput.setPolicyInstanceIdList(instances);
- instancesOutput.setCode(String.valueOf(HttpStatus.OK.value()));
- OutputPIidsListCodeSchema outputSchema = new OutputPIidsListCodeSchema();
- outputSchema.setOutput(instancesOutput);
- return outputSchema;
- }).when(mockApi).a1ControllerGetAllInstancesForType(any(InputNRRidPTidSchema.class));
-
- doAnswer(inv -> {
- if (delayMs > 0) {
- logger.debug("a1ControllerGetHandler sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- InputNRRidPTidPIidSchema input = inv.<InputNRRidPTidPIidSchema>getArgument(0);
- Integer polcyTypeId = input.getInput().getPolicyTypeId();
- String instanceId = input.getInput().getPolicyInstanceId();
- String instance = database.normalize(database.getInstance(polcyTypeId, instanceId));
- OutputPICodeSchemaOutput instanceOutput = new OutputPICodeSchemaOutput();
- instanceOutput.setPolicyInstance(instance);
- instanceOutput.setCode(String.valueOf(HttpStatus.OK.value()));
- OutputPICodeSchema outputSchema = new OutputPICodeSchema();
- outputSchema.setOutput(instanceOutput);
- return outputSchema;
- }).when(mockApi).a1ControllerGetPolicyInstance(any(InputNRRidPTidPIidSchema.class));
-
- doAnswer(inv -> {
- if (delayMs > 0) {
- logger.debug("a1ControllerGetHandler sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- InputNRRidPTidPIidPISchema input = inv.<InputNRRidPTidPIidPISchema>getArgument(0);
- Integer polcyTypeId = input.getInput().getPolicyTypeId();
- String instanceId = input.getInput().getPolicyInstanceId();
- String instance = input.getInput().getPolicyInstance();
- database.putInstance(polcyTypeId, instanceId, instance);
- OutputCodeSchemaOutput outputCodeSchemaOutput = new OutputCodeSchemaOutput();
- outputCodeSchemaOutput.setCode(String.valueOf(HttpStatus.CREATED.value()));
- OutputCodeSchema outputCodeSchema = new OutputCodeSchema();
- outputCodeSchema.setOutput(outputCodeSchemaOutput);
- return outputCodeSchema;
- }).when(mockApi).a1ControllerCreatePolicyInstance(any(InputNRRidPTidPIidPISchema.class));
-
- doAnswer(inv -> {
- if (delayMs > 0) {
- logger.debug("a1ControllerGetHandler sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- InputNRRidPTidPIidSchema input = inv.<InputNRRidPTidPIidSchema>getArgument(0);
- Integer polcyTypeId = input.getInput().getPolicyTypeId();
- String instanceId = input.getInput().getPolicyInstanceId();
- database.deleteInstance(polcyTypeId, instanceId);
- OutputCodeSchemaOutput outputCodeSchemaOutput = new OutputCodeSchemaOutput();
- outputCodeSchemaOutput.setCode(String.valueOf(HttpStatus.NO_CONTENT.value()));
- OutputCodeSchema outputCodeSchema = new OutputCodeSchema();
- outputCodeSchema.setOutput(outputCodeSchemaOutput);
- return outputCodeSchema;
- }).when(mockApi).a1ControllerDeletePolicyInstance(any(InputNRRidPTidPIidSchema.class));
-
- return mockApi;
- }
-
- class Database {
-
- public class PolicyException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public PolicyException(String message) {
- super(message);
- System.out.println("**** Exception " + message);
- }
- }
-
- private class PolicyTypeHolder {
- PolicyTypeHolder(PolicyType pt) {
- this.policyType = pt;
- }
-
- String getInstance(String instanceId) throws PolicyException {
- String instance = instances.get(instanceId);
- if (instance == null) {
- throw new PolicyException("Instance not found: " + instanceId);
- }
- return instance;
- }
-
- PolicyType getPolicyType() {
- return policyType;
- }
-
- void putInstance(String id, String data) {
- instances.put(id, data);
- }
-
- void deleteInstance(String id) {
- instances.remove(id);
- }
-
- List<String> getInstances() {
- return new ArrayList<>(instances.keySet());
- }
-
- private final PolicyType policyType;
- private Map<String, String> instances = new HashMap<>();
- }
-
- Database() {
- String schema = getStringFromFile("anr-policy-schema.json");
- PolicyType policy = new PolicyType(1, "ANR", schema);
- types.put(1, new PolicyTypeHolder(policy));
-
- schema = getStringFromFile("demo-policy-schema-1.json");
- policy = new PolicyType(2, "type2", schema);
- types.put(2, new PolicyTypeHolder(policy));
-
- schema = getStringFromFile("demo-policy-schema-2.json");
- policy = new PolicyType(3, "type3", schema);
- types.put(3, new PolicyTypeHolder(policy));
-
- schema = getStringFromFile("demo-policy-schema-3.json");
- policy = new PolicyType(4, "type4", schema);
- types.put(4, new PolicyTypeHolder(policy));
- try {
- putInstance(1, "ANR-1", getStringFromFile("anr-policy-instance.json"));
- } catch (JsonProcessingException | PolicyException e) {
- // Nothing
- }
- }
-
- private String getStringFromFile(String path) {
- try {
- InputStream inputStream = MethodHandles.lookup().lookupClass().getClassLoader()
- .getResourceAsStream(path);
- return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n"));
- } catch (Exception e) {
- logger.error("Cannot read file :" + path, e);
- return "";
- }
- }
-
- String normalize(String str) {
- return str.replace('\n', ' ');
- }
-
- void putInstance(Integer typeId, String instanceId, String instanceData)
- throws JsonProcessingException, PolicyException {
- PolicyTypeHolder type = getTypeHolder(typeId);
- type.putInstance(instanceId, instanceData);
- }
-
- void deleteInstance(Integer typeId, String instanceId) throws JsonProcessingException, PolicyException {
- PolicyTypeHolder type = getTypeHolder(typeId);
- type.deleteInstance(instanceId);
- }
-
- String getInstance(Integer typeId, String instanceId) throws JsonProcessingException, PolicyException {
- return getTypeHolder(typeId).getInstance(instanceId);
- }
-
- List<Integer> getTypes() {
- return new ArrayList<>(types.keySet());
- }
-
- List<String> getInstances(Optional<Integer> typeId) throws PolicyException {
- if (typeId.isPresent()) {
- return getTypeHolder(typeId.get()).getInstances();
- } else {
- Set<String> res = new HashSet<String>();
- for (Iterator<PolicyTypeHolder> i = types.values().iterator(); i.hasNext();) {
- res.addAll(i.next().getInstances());
- }
- return new ArrayList<>(res);
- }
- }
-
- private PolicyTypeHolder getTypeHolder(Integer typeId) throws PolicyException {
- PolicyTypeHolder typeHolder = types.get(typeId);
- if (typeHolder == null) {
- throw new PolicyException("Type not found: " + typeId);
- }
- return typeHolder;
- }
-
- private PolicyType getPolicyType(Integer typeId) throws PolicyException {
- PolicyTypeHolder typeHolder = getTypeHolder(typeId);
- return typeHolder.getPolicyType();
- }
-
- private Map<Integer, PolicyTypeHolder> types = new HashMap<>();
-
- }
-
- private final Database database = new Database();
-}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java
new file mode 100644
index 0000000..4213488
--- /dev/null
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java
@@ -0,0 +1,182 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 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.ric.portal.dashboard.config;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import org.oransc.ric.portal.dashboard.model.ImmutablePolicyInfo;
+import org.oransc.ric.portal.dashboard.model.PolicyInfo;
+import org.oransc.ric.portal.dashboard.model.PolicyInstances;
+import org.oransc.ric.portal.dashboard.model.PolicyType;
+import org.oransc.ric.portal.dashboard.model.PolicyTypes;
+import org.oransc.ric.portal.dashboard.policyagentapi.PolicyAgentApi;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestClientException;
+
+/**
+ * Creates a mock implementation of the policy controller client API.
+ */
+@TestConfiguration
+public class PolicyControllerMockConfiguration {
+
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ @Bean
+ public PolicyAgentApi policyAgentApi() {
+ MockPolicyAgentApi apiClient = new MockPolicyAgentApi();
+ return apiClient;
+ }
+
+ class MockPolicyAgentApi implements PolicyAgentApi {
+ private final Database database = new Database();
+
+ @Override
+ public String getPolicyInstance(String id) throws RestClientException {
+ return database.getInstance(id);
+ }
+
+ @Override
+ public void putPolicy(String policyTypeIdString, String policyInstanceId, String json)
+ throws RestClientException {
+ database.putInstance(policyTypeIdString, policyInstanceId, json);
+ }
+
+ @Override
+ public void deletePolicy(String policyInstanceId) throws RestClientException {
+ database.deleteInstance(policyInstanceId);
+ }
+
+ @Override
+ public PolicyTypes getAllPolicyTypes() throws RestClientException {
+ PolicyTypes result = new PolicyTypes();
+ result.addAll(database.getTypes());
+ return result;
+ }
+
+ @Override
+ public PolicyInstances getPolicyInstancesForType(String type) {
+ PolicyInstances result = new PolicyInstances();
+ List<PolicyInfo> inst = database.getInstances(Optional.of(type));
+ result.addAll(inst);
+ return result;
+ }
+
+ }
+
+ class Database {
+
+ Database() {
+ String schema = getStringFromFile("anr-policy-schema.json");
+ PolicyType policy = new PolicyType("ANR", schema);
+ types.put("ANR", policy);
+
+ schema = getStringFromFile("demo-policy-schema-1.json");
+ policy = new PolicyType("type2", schema);
+ types.put("type2", policy);
+
+ schema = getStringFromFile("demo-policy-schema-2.json");
+ policy = new PolicyType("type3", schema);
+ types.put("type3", policy);
+
+ schema = getStringFromFile("demo-policy-schema-3.json");
+ policy = new PolicyType("type4", schema);
+ types.put("type4", policy);
+ try {
+ putInstance("ANR", "ANR-1", getStringFromFile("anr-policy-instance.json"));
+ } catch (Exception e) {
+ // Nothing
+ }
+ }
+
+ private String getStringFromFile(String path) {
+ try {
+ InputStream inputStream = MethodHandles.lookup().lookupClass().getClassLoader()
+ .getResourceAsStream(path);
+ return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n"));
+ } catch (Exception e) {
+ logger.error("Cannot read file :" + path, e);
+ return "";
+ }
+ }
+
+ String normalize(String str) {
+ return str.replace('\n', ' ');
+ }
+
+ private String getTimeStampUTC() {
+ return java.time.Instant.now().toString();
+ }
+
+ void putInstance(String typeId, String instanceId, String instanceData) {
+ PolicyInfo i = ImmutablePolicyInfo.builder().json(instanceData).lastModified(getTimeStampUTC())
+ .id(instanceId).ric("ricXX").service("service").type(typeId).build();
+ instances.put(instanceId, i);
+ }
+
+ public void deleteInstance(String instanceId) {
+ instances.remove(instanceId);
+ }
+
+ String getInstance(String id) throws RestClientException {
+ PolicyInfo i = instances.get(id);
+ if (i == null) {
+ throw new RestClientException("Type not found: " + id);
+ }
+ return i.json();
+ }
+
+ public Collection<PolicyType> getTypes() {
+ return types.values();
+ }
+
+ public List<PolicyInfo> getInstances(Optional<String> typeId) {
+ ArrayList<PolicyInfo> result = new ArrayList<>();
+ for (PolicyInfo i : instances.values()) {
+ if (typeId.isPresent()) {
+ if (i.type().equals(typeId.get())) {
+ result.add(i);
+ }
+
+ } else {
+ result.add(i);
+ }
+ }
+ return result;
+ }
+
+ private Map<String, PolicyType> types = new HashMap<>();
+ private Map<String, PolicyInfo> instances = new HashMap<>();
+
+ }
+
+}
diff --git a/dashboard/webapp-frontend/src/app/interfaces/policy.types.ts b/dashboard/webapp-frontend/src/app/interfaces/policy.types.ts
index e694bb6..b6ecce6 100644
--- a/dashboard/webapp-frontend/src/app/interfaces/policy.types.ts
+++ b/dashboard/webapp-frontend/src/app/interfaces/policy.types.ts
@@ -21,15 +21,17 @@
// Models of data used by the Policy Control
export interface PolicyType {
- policy_type_id: number;
name: string;
schema: string;
schemaObject: any;
}
export interface PolicyInstance {
- instanceId: string;
- instance: string;
+ id: string;
+ json: string;
+ ric: string;
+ service: string;
+ lastModified: string;
}
export interface PolicyInstanceAck {
diff --git a/dashboard/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts b/dashboard/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts
index d69400d..5b5cc00 100644
--- a/dashboard/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts
+++ b/dashboard/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts
@@ -80,7 +80,6 @@
public policyInstanceId: string;
public policyTypeName: string;
darkMode: boolean;
- private policyTypeId: number;
constructor(
@@ -93,7 +92,6 @@
this.formActive = false;
this.policyInstanceId = data.instanceId;
this.policyTypeName = data.name;
- this.policyTypeId = data.policyTypeId;
this.jsonSchemaObject = data.createSchema;
this.jsonObject = this.parseJson(data.instanceJson);
}
@@ -115,7 +113,7 @@
}
const policyJson: string = this.prettyLiveFormData;
const self: PolicyInstanceDialogComponent = this;
- this.dataService.putPolicy(this.policyTypeId, this.policyInstanceId, policyJson).subscribe(
+ this.dataService.putPolicy(this.policyTypeName, this.policyInstanceId, policyJson).subscribe(
{
next(value) {
self.notificationService.success('Policy ' + self.policyTypeName + ':' + self.policyInstanceId + ' submitted');
@@ -194,10 +192,9 @@
}
export function getPolicyDialogProperties(policyType: PolicyType, instance: PolicyInstance, darkMode: boolean): MatDialogConfig {
- const policyTypeId = policyType.policy_type_id;
const createSchema = policyType.schemaObject;
- const instanceId = instance ? instance.instanceId : null;
- const instanceJson = instance ? instance.instance : null;
+ const instanceId = instance ? instance.id : null;
+ const instanceJson = instance ? instance.json : null;
const name = policyType.name;
return {
maxWidth: '1200px',
@@ -207,7 +204,6 @@
disableClose: false,
panelClass: darkMode ? 'dark-theme' : '',
data: {
- policyTypeId,
createSchema,
instanceId,
instanceJson,
diff --git a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.html b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.html
index e1a67dd..8c305e4 100644
--- a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.html
+++ b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.html
@@ -22,7 +22,25 @@
<ng-container matColumnDef="instanceId">
<mat-header-cell mat-sort-header *matHeaderCellDef>Instance</mat-header-cell>
- <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{element.instanceId}}
+ <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{element.id}}
+ </mat-cell>
+ </ng-container>
+
+ <ng-container matColumnDef="ric">
+ <mat-header-cell mat-sort-header *matHeaderCellDef>Ric</mat-header-cell>
+ <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{element.ric}}
+ </mat-cell>
+ </ng-container>
+
+ <ng-container matColumnDef="service">
+ <mat-header-cell mat-sort-header *matHeaderCellDef>Owner</mat-header-cell>
+ <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{element.service}}
+ </mat-cell>
+ </ng-container>
+
+ <ng-container matColumnDef="lastModified">
+ <mat-header-cell mat-sort-header *matHeaderCellDef>Last modified</mat-header-cell>
+ <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{toLocalTime(element.lastModified)}}
</mat-cell>
</ng-container>
@@ -42,9 +60,10 @@
<mat-footer-cell *matFooterCellDef>No records found.</mat-footer-cell>
</ng-container>
- <mat-header-row *matHeaderRowDef="['instanceId', 'action']" [ngClass]="{'display-none': !this.hasInstances()}">
+ <mat-header-row *matHeaderRowDef="['instanceId', 'ric', 'service', 'lastModified', 'action']"
+ [ngClass]="{'display-none': !this.hasInstances()}">
</mat-header-row>
- <mat-row *matRowDef="let instance; columns: ['instanceId', 'action'];"></mat-row>
+ <mat-row *matRowDef="let instance; columns: ['instanceId', 'ric', 'service', 'lastModified', 'action'];"></mat-row>
<mat-footer-row *matFooterRowDef="['noRecordsFound']" [ngClass]="{'display-none': this.hasInstances()}">
</mat-footer-row>
diff --git a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.scss b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.scss
index b6a29a4..6a18c34 100644
--- a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.scss
+++ b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.scss
@@ -19,13 +19,21 @@
*/
.instances-table {
- width: 60%;
- min-width: 600px;
+ width: 90%;
+ min-width: 1200px;
margin-top: 10px;
margin-bottom: 10px;
background-color: grayscale($color: #eeeaea);
}
+.mat-column-instanceId {
+ word-wrap: break-word;
+ white-space: unset;
+ flex: 0 0 28%;
+ width: 28%;
+}
+
+
.table-dark {
background-color: #2d2d3d;
}
diff --git a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.ts b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.ts
index b62deb4..ecf6f36 100644
--- a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.ts
+++ b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.component.ts
@@ -76,9 +76,9 @@
}
modifyInstance(instance: PolicyInstance): void {
- this.policySvc.getPolicy(this.policyType.policy_type_id, instance.instanceId).subscribe(
+ this.policySvc.getPolicy(this.policyType.name, instance.id).subscribe(
(refreshedJson: any) => {
- instance.instance = JSON.stringify(refreshedJson);
+ instance.json = JSON.stringify(refreshedJson);
this.dialog.open(PolicyInstanceDialogComponent, getPolicyDialogProperties(this.policyType, instance, this.darkMode));
},
(httpError: HttpErrorResponse) => {
@@ -92,13 +92,20 @@
return this.instanceDataSource.rowCount > 0;
}
+ toLocalTime(utcTime: string): string {
+ const date = new Date(utcTime);
+ const toutc = date.toUTCString();
+ return new Date(toutc + " UTC").toLocaleString();
+
+ }
+
deleteInstance(instance: PolicyInstance): void {
this.confirmDialogService
.openConfirmDialog('Are you sure you want to delete this policy instance?')
.afterClosed().subscribe(
(res: any) => {
if (res) {
- this.policySvc.deletePolicy(this.policyType.policy_type_id, instance.instanceId)
+ this.policySvc.deletePolicy(this.policyType.name, instance.id)
.subscribe(
(response: HttpResponse<Object>) => {
switch (response.status) {
diff --git a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.datasource.ts b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.datasource.ts
index 53a6239..b82ee75 100644
--- a/dashboard/webapp-frontend/src/app/policy-control/policy-instance.datasource.ts
+++ b/dashboard/webapp-frontend/src/app/policy-control/policy-instance.datasource.ts
@@ -51,7 +51,7 @@
loadTable() {
this.loadingSubject.next(true);
- this.policySvc.getPolicyInstances(this.policyType.policy_type_id)
+ this.policySvc.getPolicyInstances(this.policyType.name)
.pipe(
catchError((her: HttpErrorResponse) => {
this.notificationService.error('Failed to get policy instances: ' + her.message);
@@ -88,7 +88,10 @@
return data.sort((a, b) => {
const isAsc = this.sort.direction === 'asc';
switch (this.sort.active) {
- case 'instanceId': return compare(a.instanceId, b.instanceId, isAsc);
+ case 'instanceId': return compare(a.id, b.id, isAsc);
+ case 'ric': return compare(a.ric, b.ric, isAsc);
+ case 'service': return compare(a.service, b.service, isAsc);
+ case 'lastModified': return compare(a.lastModified, b.lastModified, isAsc)
default: return 0;
}
});
diff --git a/dashboard/webapp-frontend/src/app/rd-routing.module.ts b/dashboard/webapp-frontend/src/app/rd-routing.module.ts
index 520f9a5..57b9d57 100644
--- a/dashboard/webapp-frontend/src/app/rd-routing.module.ts
+++ b/dashboard/webapp-frontend/src/app/rd-routing.module.ts
@@ -22,20 +22,20 @@
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';
import { MainComponent } from './main/main.component';
-import { PolicyControlComponent} from './policy-control/policy-control.component';
+import { PolicyControlComponent } from './policy-control/policy-control.component';
const routes: Routes = [
- {path: '', component: MainComponent},
- {path: 'policy', component: PolicyControlComponent}
+ { path: '', component: MainComponent },
+ { path: 'policy', component: PolicyControlComponent }
];
@NgModule({
- imports: [
- CommonModule,
- RouterModule.forRoot(routes)],
- exports: [
- RouterModule
+ imports: [
+ CommonModule,
+ RouterModule.forRoot(routes)],
+ exports: [
+ RouterModule
],
declarations: []
})
diff --git a/dashboard/webapp-frontend/src/app/services/policy/policy.service.ts b/dashboard/webapp-frontend/src/app/services/policy/policy.service.ts
index 1c87081..fc0f306 100644
--- a/dashboard/webapp-frontend/src/app/services/policy/policy.service.ts
+++ b/dashboard/webapp-frontend/src/app/services/policy/policy.service.ts
@@ -66,7 +66,7 @@
return this.httpClient.get<PolicyType[]>(url);
}
- getPolicyInstances(policyTypeId: number): Observable<PolicyInstance[]> {
+ getPolicyInstances(policyTypeId: string): Observable<PolicyInstance[]> {
const url = this.buildPath(this.policyTypePath, policyTypeId, this.policyPath);
return this.httpClient.get<PolicyInstance[]>(url);
}
@@ -75,7 +75,7 @@
* Gets policy parameters.
* @returns Observable that should yield a policy instance
*/
- getPolicy(policyTypeId: number, policyInstanceId: string): Observable<any> {
+ getPolicy(policyTypeId: string, policyInstanceId: string): Observable<any> {
const url = this.buildPath(this.policyTypePath, policyTypeId, this.policyPath, policyInstanceId);
return this.httpClient.get<any>(url);
}
@@ -87,7 +87,7 @@
* @param policyJson Json with the policy content
* @returns Observable that should yield a response code, no data
*/
- putPolicy(policyTypeId: number, policyInstanceId: string, policyJson: string): Observable<any> {
+ putPolicy(policyTypeId: string, policyInstanceId: string, policyJson: string): Observable<any> {
const url = this.buildPath(this.policyTypePath, policyTypeId, this.policyPath, policyInstanceId);
return this.httpClient.put<PolicyInstanceAck>(url, policyJson, { observe: 'response' });
}
@@ -97,7 +97,7 @@
* @param policyTypeId
* @returns Observable that should yield a response code, no data
*/
- deletePolicy(policyTypeId: number, policyInstanceId: string): Observable<any> {
+ deletePolicy(policyTypeId: string, policyInstanceId: string): Observable<any> {
const url = this.buildPath(this.policyTypePath, policyTypeId, this.policyPath, policyInstanceId);
return this.httpClient.delete(url, { observe: 'response' });
}