summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main/java/org
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2021-10-08 14:08:59 +0200
committerPatrikBuhr <patrik.buhr@est.tech>2021-10-11 15:58:16 +0200
commite81a9de40bc0acb4a15ecf9fd60500a6f71344e4 (patch)
treefe5cba1d66e1aeab40a0a433b5a17d5e8166b0e8 /a1-policy-management/src/main/java/org
parent8efef0513821e7a586de4831a982833050be03e8 (diff)
Create a json schema for validation of the configuration of the A1 PMS - A1 Jakarta
Enabling the feature by default and fixing so that the schema can be loaded from the jar. Issue-ID: CCSDK-3468 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> Change-Id: I49a41b9124b74d5019200cc9b6eb48c5d46b043d
Diffstat (limited to 'a1-policy-management/src/main/java/org')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
index 3cab8aa0..726d67fc 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
@@ -20,14 +20,15 @@
package org.onap.ccsdk.oran.a1policymanagementservice.configuration;
+import com.google.common.io.CharStreams;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import java.io.File;
import java.io.IOException;
-import java.net.URL;
-import java.nio.file.Files;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -46,6 +47,7 @@ import org.json.JSONObject;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
/**
* Parser for the Json representing of the component configuration.
@@ -129,13 +131,15 @@ public class ApplicationConfigParser {
}
}
- private String readSchemaFile() throws IOException {
- ClassLoader classLoader = getClass().getClassLoader();
+ private String readSchemaFile() throws IOException, ServiceException {
String filePath = applicationConfig.getConfigurationFileSchemaPath();
- URL url = classLoader.getResource(filePath);
- File file = new File(url.getFile());
- return new String(Files.readAllBytes(file.toPath()));
-
+ InputStream in = getClass().getResourceAsStream(filePath);
+ logger.debug("Reading application schema file from: {} with: {}", filePath, in);
+ if (in == null) {
+ throw new ServiceException("Could not read application configuration schema file: " + filePath,
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ return CharStreams.toString(new InputStreamReader(in, StandardCharsets.UTF_8));
}
private void checkConfigurationConsistency(List<RicConfig> ricConfigs,