summaryrefslogtreecommitdiffstats
path: root/restconf-client/provider/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'restconf-client/provider/src/main/java')
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java95
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java7
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java1
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java7
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java4
5 files changed, 108 insertions, 6 deletions
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java
new file mode 100644
index 00000000..a8a9b493
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java
@@ -0,0 +1,95 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE;
+import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE;
+
+/**
+ * Represents implementation of PropertiesNodeListener.
+ */
+public class DefaultPropertiesNodeListener implements PropertiesNodeListener {
+
+ private Map<String, String> params = new HashMap<>();
+
+ @Override
+ public void start(PropertiesNode node) {
+ // do nothing
+ }
+
+ @Override
+ public void end(PropertiesNode node) {
+ exitPropertiesNode(node);
+ }
+
+ @Override
+ public void enterPropertiesNode(PropertiesNode node) {
+ /*
+ * Only if it is leaf node or leaf-list node,
+ * then create a property entry and add to map
+ */
+ if (node.nodeType() == SINGLE_INSTANCE_LEAF_NODE
+ || node.nodeType() == MULTI_INSTANCE_LEAF_NODE) {
+ params.put(node.uri(), ((LeafNode) node).value());
+ }
+ }
+
+ @Override
+ public void exitPropertiesNode(PropertiesNode node) {
+ if (!node.augmentations().isEmpty()) {
+ for (Map.Entry<Object, Collection<PropertiesNode>> augmentationTochild
+ : node.augmentations().asMap().entrySet()) {
+ Collection<PropertiesNode> childsFromAugmentations = augmentationTochild
+ .getValue();
+ if (!childsFromAugmentations.isEmpty()) {
+ PropertiesNodeWalker walker = new DefaultPropertiesNodeWalker<>();
+ for (PropertiesNode pNode : childsFromAugmentations) {
+ enterPropertiesNode(pNode);
+ walker.walk(this, pNode);
+ exitPropertiesNode(pNode);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns properties.
+ *
+ * @return properties
+ */
+ public Map<String, String> params() {
+ return params;
+ }
+
+ /**
+ * Sets properties.
+ *
+ * @param params properties
+ */
+ public void params(Map<String, String> params) {
+ this.params = params;
+ }
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java
index 063c3d05..0711a7cf 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java
@@ -104,7 +104,7 @@ public abstract class InnerNode<T extends NodeChild> extends PropertiesNode {
@Override
public PropertiesNode addChild(String name, Namespace namespace,
NodeType type, String value,
- Namespace valuens,
+ Namespace valueNs,
Object appInfo) throws SvcLogicException {
LeafNode node = ((LeafNode) children.get(name));
if (node != null) {
@@ -120,6 +120,7 @@ public abstract class InnerNode<T extends NodeChild> extends PropertiesNode {
String uri = getUri(this, name, namespace);
node = new LeafNode(name, namespace, uri, this,
appInfo, type, value);
+ node.valueNs(valueNs);
if (augSchema != null && !isNamespaceAsParent(this, node)) {
addToAugmentations(augSchema, this, node);
@@ -196,12 +197,12 @@ public abstract class InnerNode<T extends NodeChild> extends PropertiesNode {
children.put(localName, ((T) node));
}
- node = node.addChild(index, localName, namespace, type, value, null, appInfo);
+ node = node.addChild(index, localName, namespace, type, value, valueNs, appInfo);
} else if (node instanceof LeafListHolderNode) {
LeafNode child = ((LeafNode) ((HolderNode) node).child(index));
node = (child != null ? child : node.addChild(index, localName,
namespace, type,
- value, null,
+ value, valueNs,
appInfo));
} else {
throw new SvcLogicException("Duplicate node exist with same node");
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java
index 94892dca..985bc1da 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java
@@ -82,6 +82,7 @@ public class LeafListHolderNode extends HolderNode<LeafListHolderChild> implemen
String uri = this.uri() + "[" + index + "]";
node = (node != null) ? node : new LeafNode(name, namespace, uri,
this, appInfo, type, value);
+ node.valueNs(valueNs);
children().put(index, node);
return node;
}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
index 405e2412..146e581f 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
@@ -86,7 +86,10 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<Sche
@Override
public Map<String, String> decode(PropertiesNode propertiesNode) {
- return null;
+ PropertiesNodeWalker walker = new DefaultPropertiesNodeWalker<>();
+ DefaultPropertiesNodeListener listener = new DefaultPropertiesNodeListener();
+ walker.walk(listener, propertiesNode);
+ return listener.params();
}
private RootNode createRootNode(String lastNodeName, String rootUri) {
@@ -128,6 +131,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<Sche
node = node.endNode();
curSchema = ((SchemaNode) node.appInfo());
break;
+ default:
+ throw new SvcLogicException("Invalid node type");
}
}
}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java
index 0159683a..7d9035e0 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java
@@ -189,12 +189,12 @@ public class RootNode<T extends NodeChild> extends PropertiesNode {
} else {
children.put(localName, ((T) node));
}
- node = node.addChild(index, localName, namespace, type, value, null, appInfo);
+ node = node.addChild(index, localName, namespace, type, value, valueNs, appInfo);
} else if (node instanceof LeafListHolderNode) {
LeafNode child = ((LeafNode) ((HolderNode) node).child(index));
node = (child != null ? child : node.addChild(index, localName,
namespace, type,
- value, null,
+ value, valueNs,
appInfo));
} else {
throw new SvcLogicException("Duplicate node exist with same node");