private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static com.google.gson.Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
@Bean
public PolicyAgentApi policyAgentApi() {
@Override
public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, String json,
- String ric) {
+ String ric) {
database.putInstance(policyTypeIdString, policyInstanceId, json, ric);
return new ResponseEntity<>("Policy was put successfully", HttpStatus.OK);
}
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);
+ String schema = getStringFromFile("demo-policy-schema-1.json");
+ PolicyType policyType = new PolicyType("type2", schema);
+ types.put("type2", policyType);
schema = getStringFromFile("demo-policy-schema-2.json");
- policy = new PolicyType("type3", schema);
- types.put("type3", policy);
+ policyType = new PolicyType("type3", schema);
+ types.put("type3", policyType);
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"), "ric_1");
- } catch (Exception e) {
- // Nothing
- }
+ policyType = new PolicyType("type4", schema);
+ types.put("type4", policyType);
}
private String getStringFromFile(String path) {
try {
- InputStream inputStream =
- MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(path);
+ 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);
void putInstance(String typeId, String instanceId, String instanceData, String ric) {
PolicyInfo i = ImmutablePolicyInfo.builder().json(instanceData).lastModified(getTimeStampUTC())
- .id(instanceId).ric(ric).service("service").type(typeId).build();
+ .id(instanceId).ric(ric).service("service").type(typeId).build();
instances.put(instanceId, i);
}
+++ /dev/null
-{
- "$schema": "http://json-schema.org/draft-07/schema#",
- "title": "ANR",
- "description": "ANR Neighbour Cell Relation Policy",
- "type": "object",
- "properties": {
- "servingCellNrcgi": {
- "type": "string",
- "description": "Serving Cell Identifier (NR CGI)"
- },
- "neighborCellNrpci": {
- "type": "string",
- "description": "Neighbor Cell Identifier (NR PCI)"
- },
- "neighborCellNrcgi": {
- "type": "string",
- "description": "Neighbor Cell Identifier (NR CGI)"
- },
- "flagNoHo": {
- "type": "boolean",
- "description": "Flag for HANDOVER NOT ALLOWED"
- },
- "flagNoXn": {
- "type": "boolean",
- "description": "Flag for Xn CONNECTION NOT ALLOWED"
- },
- "flagNoRemove": {
- "type": "boolean",
- "description": "Flag for DELETION NOT ALLOWED"
- }
- },
- "required": [
- "servingCellNrcgi",
- "neighborCellNrpci",
- "neighborCellNrcgi",
- "flagNoHo",
- "flagNoXn",
- "flagNoRemove"
- ]
-}
\ No newline at end of file
+++ /dev/null
-{
- "$schema": "http://json-schema.org/draft-07/schema#",
- "title": "ANR",
- "description": "ANR Neighbour Cell Relation Policy",
- "type": "object",
- "properties": {
- "servingCellNrcgi": {
- "type": "string",
- "description": "Serving Cell Identifier (NR CGI)"
- },
- "neighborCellNrpci": {
- "type": "string",
- "description": "Neighbor Cell Identifier (NR PCI)"
- },
- "neighborCellNrcgi": {
- "type": "string",
- "description": "Neighbor Cell Identifier (NR CGI)"
- },
- "flagNoHo": {
- "type": "boolean",
- "description": "Flag for HANDOVER NOT ALLOWED"
- },
- "flagNoXn": {
- "type": "boolean",
- "description": "Flag for Xn CONNECTION NOT ALLOWED"
- },
- "flagNoRemove": {
- "type": "boolean",
- "description": "Flag for DELETION NOT ALLOWED"
- }
- },
- "required": [
- "servingCellNrcgi",
- "neighborCellNrpci",
- "neighborCellNrcgi",
- "flagNoHo",
- "flagNoXn",
- "flagNoRemove"
- ]
-}
\ No newline at end of file