summaryrefslogtreecommitdiffstats
path: root/adaptors/mdsal-resource
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2024-09-13 14:04:13 -0400
committerDan Timoney <dtimoney@att.com>2024-09-13 14:04:13 -0400
commite11aa082274ac41444a59d9461d204ecd8fa8375 (patch)
treed6c3a3428ef2e7916e6f17eb62b66108eed13935 /adaptors/mdsal-resource
parent4b27c1566071bf880b7ea1757530473ea2ee1b7f (diff)
Changes for RFC 8040 compliance
Updates to ccsdk/sli to migrate from Bierman version of RESTCONF to RFC 8040 Issue-ID: CCSDK-4056 Change-Id: Ic2d4bb01dc4f9c3f204a6209b4b9310a41ee2ca4 Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'adaptors/mdsal-resource')
-rw-r--r--adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java28
-rw-r--r--adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java11
2 files changed, 31 insertions, 8 deletions
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java
index e2e9bc230..402c334dc 100644
--- a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java
@@ -37,6 +37,7 @@ public class ConfigResource implements SvcLogicResource {
private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class);
private RestService restService;
+ private String useRfc8040 = "true";
public ConfigResource(MdsalResourcePropertiesProvider propProvider) {
LOG.info("Loading ConfigResource using property provider");
@@ -47,6 +48,7 @@ public class ConfigResource implements SvcLogicResource {
String sdncHost = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host", "localhost");
String sdncProtocol = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol", "https");
String sdncPort = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port", "8443");
+ useRfc8040 = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.use-rfc8040", "true");
restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML");
}
@@ -77,15 +79,33 @@ public class ConfigResource implements SvcLogicResource {
String orderBy, SvcLogicContext ctx) throws SvcLogicException {
String module = resource;
StringBuffer restQuery = new StringBuffer();
+ String queryPrefix;
+ String querySuffix;
+ String keySeparator;
+
+
+ if (this.useRfc8040.equals("true")) {
+ queryPrefix = "rests/data/";
+ querySuffix = "?content=config";
+ keySeparator = "=";
+ } else {
+ queryPrefix = "restconf/config";
+ querySuffix = "";
+ keySeparator = "/";
+ }
String[] keyParts = key.split("/");
for (String keyPart : keyParts) {
- if (restQuery.length() > 0) {
- restQuery.append("/");
- }
+
if (keyPart.startsWith("$")) {
+ // This is a variable, so the previous item must have been a list. Add an equals
+ // sign instead of a /
+ restQuery.append(keySeparator);
restQuery.append(ctx.resolve(keyPart.substring(1)));
} else {
+ if (restQuery.length() > 0) {
+ restQuery.append("/");
+ }
restQuery.append(keyPart);
}
}
@@ -96,7 +116,7 @@ public class ConfigResource implements SvcLogicResource {
restQueryStr = restQueryStr.substring(1, restQueryStr.length()-1);
}
- String urlString = "restconf/config/" + module + ":" + restQueryStr;
+ String urlString = queryPrefix + module + ":" + restQueryStr + querySuffix;
LOG.info("Querying resource: " + resource + ". At URL: " + urlString);
Document results = restService.get(urlString);
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java
index 320878126..9fba0a972 100644
--- a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java
@@ -75,12 +75,15 @@ public class OperationalResource implements SvcLogicResource {
String[] keyParts = key.split("/");
for (String keyPart : keyParts) {
- if (restQuery.length() > 0) {
- restQuery.append("/");
- }
if (keyPart.startsWith("$")) {
+ // This is a variable, so infer that previous part was a list name. Insert = instead of /
+ restQuery.append("=?");
restQuery.append(ctx.resolve(keyPart.substring(1)));
} else {
+
+ if (restQuery.length() > 0) {
+ restQuery.append("/");
+ }
restQuery.append(keyPart);
}
}
@@ -91,7 +94,7 @@ public class OperationalResource implements SvcLogicResource {
restQueryStr = restQueryStr.substring(1, restQueryStr.length() - 1);
}
- String urlString = "restconf/operational/" + module + ":" + restQueryStr;
+ String urlString = "rests/data/" + module + ":" + restQueryStr+"?content=nonconfig";
LOG.info("Querying resource: " + resource + ". At URL: " + urlString);
Document results = restService.get(urlString);