http.proxy-type: HTTP
# path where the service can store data
vardata-directory: /var/policy-management-service
- config-file-schema-path:
+ # the config-file-schema-path referres to a location in the jar file. If this property is empty or missing,
+ # no schema validation will be executed.
+ config-file-schema-path: /application_configuration_schema.json
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;
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.
}
}
- 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,
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
"app.webclient.trust-store=./config/truststore.jks", //
- "app.vardata-directory=./target"})
+ "app.vardata-directory=./target", //
+ "app.config-file-schema-path=/application_configuration_schema.json"})
@SuppressWarnings("java:S3577") // Class name should start or end with Test. This is not a test class per se,
// but a mock
// of the server.