summaryrefslogtreecommitdiffstats
path: root/restconf-client
diff options
context:
space:
mode:
Diffstat (limited to 'restconf-client')
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java27
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java59
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java94
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java28
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java81
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java119
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java28
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java66
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java4
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java32
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java100
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java28
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java216
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java15
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java91
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java33
16 files changed, 974 insertions, 47 deletions
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java
new file mode 100644
index 000000000..7be54690a
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java
@@ -0,0 +1,27 @@
+/*-
+ * ============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;
+
+/**
+ * Abstraction of entity representing child's to data node.
+ */
+public interface DataNodeChild extends NodeChild {
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java
new file mode 100644
index 000000000..52bec3412
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.HashMap;
+import java.util.Map;
+
+/**
+ * Abstraction of an entity that represents holder node to multi instance node
+ * in properties data tree.
+ *
+ * @param <T> type of child
+ */
+public abstract class HolderNode<T extends NodeChild> extends PropertiesNode {
+
+ private Map<String, T> children = new HashMap<>();
+
+ protected HolderNode(String name, Namespace namespace, String uri,
+ PropertiesNode parent, Object appInfo,
+ NodeType nodeType) {
+ super(name, namespace, uri, parent, appInfo, nodeType);
+ }
+
+ /**
+ * Returns children.
+ *
+ * @return children
+ */
+ public Map<String, T> children() {
+ return children;
+ }
+
+ /**
+ * Returns child based on index.
+ *
+ * @return child based on index
+ */
+ public T child(String index) {
+ return children.get(index);
+ }
+}
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
new file mode 100644
index 000000000..21f0b7c03
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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 org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Abstraction of an entity that represents an inner node to properties data
+ * tree.
+ *
+ * @param <T> type of child
+ */
+public abstract class InnerNode<T extends NodeChild> extends PropertiesNode {
+
+ private Map<String, T> children = new HashMap<String, T>();
+
+ protected InnerNode(String name, Namespace namespace, String uri,
+ PropertiesNode parent, Object appInfo, NodeType nodeType) {
+ super(name, namespace, uri, parent, appInfo, nodeType);
+ }
+
+ /**
+ * Returns children.
+ *
+ * @return children
+ */
+ public Map<String, T> children() {
+ return children;
+ }
+
+ /**
+ * Sets children.
+ *
+ * @param children child nodes
+ */
+ public void children(Map<String, T> children) {
+ this.children = children;
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type, String value,
+ Namespace valuens,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ String value, Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java
new file mode 100644
index 000000000..e43249a3d
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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;
+
+/**
+ * Abstraction of entity representing child's to leaf list holder.
+ */
+public interface LeafListHolderChild extends NodeChild {
+
+}
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
new file mode 100644
index 000000000..aa10e3307
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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 org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+/**
+ * Representation of leaf list holder node which will hold multi instance leaf
+ * node in properties data tree.
+ */
+public class LeafListHolderNode extends HolderNode<LeafListHolderChild> implements DataNodeChild {
+
+ /**
+ * Creates an instance of LeafListHolderNode.
+ *
+ * @param name name of the leaf-list node
+ * @param namespace namespace of the leaf-list node
+ * @param uri uri of the leaf-list node
+ * @param parent parent node of the leaf-list
+ * @param appInfo application info
+ * @param nodeType node type
+ */
+ public LeafListHolderNode(String name, Namespace namespace,
+ String uri, PropertiesNode parent,
+ Object appInfo, NodeType nodeType) {
+ super(name, namespace, uri, parent, appInfo, nodeType);
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type, String value,
+ Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Leaf cannot be child of leaf-list" +
+ " holder node");
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Container cannot be child of leaf-list" +
+ " holder node");
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("List cannot be child of leaf-list" +
+ " holder node");
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ String value, Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java
new file mode 100644
index 000000000..c9cf95ba3
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java
@@ -0,0 +1,119 @@
+/*-
+ * ============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 org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+/**
+ * Representation of leaf node in properties data tree.
+ */
+public class LeafNode extends PropertiesNode implements LeafListHolderChild, DataNodeChild {
+
+ private String value;
+ private Namespace valueNs;
+
+ /**
+ * Creates an instance of leaf node.
+ *
+ * @param name name of the leaf node
+ * @param namespace namespace of the leaf node
+ * @param uri uri of the leaf node
+ * @param parent parent of the leaf node
+ * @param appInfo application info
+ * @param nodeType node type
+ * @param value value of the leaf
+ */
+ public LeafNode(String name, Namespace namespace,
+ String uri, PropertiesNode parent,
+ Object appInfo, NodeType nodeType,
+ String value) {
+ super(name, namespace, uri, parent, appInfo, nodeType);
+ this.value = value;
+ }
+
+ /**
+ * Returns value of the leaf.
+ *
+ * @return value of the leaf
+ */
+ public String value() {
+ return value;
+ }
+
+ /**
+ * Sets value of the leaf.
+ *
+ * @param value value of the leaf
+ */
+ public void value(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Returns value namespace.
+ *
+ * @return value namespace
+ */
+ public Namespace valueNs() {
+ return valueNs;
+ }
+
+ /**
+ * Sets value namespace.
+ *
+ * @param valueNs value namespace
+ */
+ public void valueNs(Namespace valueNs) {
+ this.valueNs = valueNs;
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Leaf cannot hold child nodes");
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type, String value,
+ Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Leaf cannot hold child nodes");
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Leaf cannot hold child nodes");
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace,
+ NodeType type, String value,
+ Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Leaf cannot hold child nodes");
+ }
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java
new file mode 100644
index 000000000..ec9cc2a0f
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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;
+
+/**
+ * Abstraction of entity representing child's to list holder.
+ */
+public interface ListHolderChild extends NodeChild {
+
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java
new file mode 100644
index 000000000..9d1168b8f
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java
@@ -0,0 +1,66 @@
+/*-
+ * ============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 org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+/**
+ * Representation of list holder node which will hold multi instance node in
+ * properties data tree.
+ */
+public class ListHolderNode extends HolderNode<ListHolderChild> implements DataNodeChild {
+
+ protected ListHolderNode(String name, Namespace namespace, String uri,
+ PropertiesNode parent, Object appInfo, NodeType nodeType) {
+ super(name, namespace, uri, parent, appInfo, nodeType);
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type, String value,
+ Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Leaf cannot be child of list holder node");
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Container cannot be child of list holder node");
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ String value, Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ throw new SvcLogicException("Leaf-list cannot be child of list holder 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 67e9c1e59..05e1ac1e6 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
@@ -20,10 +20,12 @@
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
-import java.util.Map;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.slf4j.Logger;
+
+import java.util.Map;
+
import static org.slf4j.LoggerFactory.getLogger;
/**
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java
new file mode 100644
index 000000000..c251cdaea
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java
@@ -0,0 +1,32 @@
+/*-
+ * ============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;
+
+/**
+ * Representation of multi instance node in properties data tree.
+ */
+public class MultiInstanceNode extends InnerNode<DataNodeChild> implements ListHolderChild {
+
+ public MultiInstanceNode(String name, Namespace namespace, String uri,
+ PropertiesNode parent, Object appinfo, NodeType nodeType) {
+ super(name, namespace, uri, parent, appinfo, nodeType);
+ }
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java
new file mode 100644
index 000000000..4f27ee1e7
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java
@@ -0,0 +1,100 @@
+/*-
+ * ============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.net.URI;
+
+/**
+ * Representation of YANG namespace.
+ */
+public class Namespace {
+ private String moduleName;
+ private URI moduleNs;
+ private String revision;
+
+ /**
+ * Creates an instance of namespace with specified module name,
+ * namespace and revision.
+ *
+ * @param modulename module name
+ * @param moduleNs module namespace
+ * @param revision revision
+ */
+ public Namespace(String modulename, URI moduleNs, String revision) {
+ this.moduleName = modulename;
+ this.moduleNs = moduleNs;
+ this.revision = revision;
+ }
+
+ /**
+ * Returns module name.
+ *
+ * @return module name
+ */
+ public String moduleName() {
+ return moduleName;
+ }
+
+ /**
+ * Sets module name.
+ *
+ * @param moduleName module name
+ */
+ public void moduleName(String moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ /**
+ * Sets module namespace.
+ *
+ * @return module namespace
+ */
+ public URI moduleNs() {
+ return moduleNs;
+ }
+
+ /**
+ * Sets module namespace.
+ *
+ * @param moduleNs module namespace
+ */
+ public void moduleNs(URI moduleNs) {
+ this.moduleNs = moduleNs;
+ }
+
+ /**
+ * Returns revision.
+ *
+ * @return revision
+ */
+ public String revision() {
+ return revision;
+ }
+
+ /**
+ * Sets revision.
+ *
+ * @param revision revision
+ */
+ public void revision(String revision) {
+ this.revision = revision;
+ }
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java
new file mode 100644
index 000000000..d482c6763
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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;
+
+/**
+ * Abstraction of an entity that represents child's of a node.
+ */
+public interface NodeChild {
+
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java
index fccfa6a9d..bb07382a4 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java
@@ -20,24 +20,25 @@
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
/**
* Abstraction of properties node data tree. This intermediate representation
* will enable data format serializers to be agnostic of DG context memory
- * nuances and thereby will enable faster development of new data faormat
+ * nuances and thereby will enable faster development of new data format
* serializers.
*/
public abstract class PropertiesNode {
private String name;
- private String namespace;
+ private Namespace namespace;
private String uri;
private PropertiesNode parent;
-
- /**
- * Creates an instance of properties node.
- */
- protected PropertiesNode() {
- }
+ private Object appInfo;
+ private NodeType nodeType;
+ private Multimap<Object, PropertiesNode> augmentations = ArrayListMultimap.create();
/**
* Creates an instance of properties node.
@@ -47,78 +48,213 @@ public abstract class PropertiesNode {
* @param uri URI of this node, if null its calculated based on parent and
* current value of name and namespace
* @param parent parent's node
+ * @param appInfo application related information
+ * @param nodeType node type
*/
- protected PropertiesNode(String name, String namespace, String uri, PropertiesNode parent) {
+ protected PropertiesNode(String name, Namespace namespace, String uri,
+ PropertiesNode parent, Object appInfo, NodeType nodeType) {
this.name = name;
this.namespace = namespace;
this.uri = uri;
this.parent = parent;
+ this.appInfo = appInfo;
+ this.nodeType = nodeType;
}
/**
- * Adds a child to a current node.
+ * Sets name.
*
- * @param name name of child
- * @param namespace namespace of child, null represents parent namespace
- * @param type type of node
- * @return added properties node
+ * @param name name of the node
*/
- public abstract PropertiesNode addChild(String name, String namespace, NodeType type);
+ public void name(String name) {
+ this.name = name;
+ }
/**
- * Adds a child with value to a current node.
+ * Sets namespace.
*
- * @param name name of child
- * @param namespace namespace of child, null represents parent namespace
- * @param type type of node
- * @param value value of node
- * @return added properties node
+ * @param namespace namespace of the node
*/
- public abstract PropertiesNode addChild(String name, String namespace, NodeType type, String value);
+ public void namespace(Namespace namespace) {
+ this.namespace = namespace;
+ }
/**
- * Adds a child at a given index to a current node. To be used in case of
- * leaf holder child's which is multi instance node.
+ * Sets uri.
*
- * @param index index at which node is to be added
- * @param name name of child
- * @param namespace namespace of child, null represents parent namespace
- * @param type type of node
- * @return added properties node
+ * @param uri uri of the node
*/
- public abstract PropertiesNode addChild(String index, String name, String namespace, NodeType type);
-
- public void name(String name) {
- this.name = name;
- }
-
- public void namespace(String namespace) {
- this.namespace = namespace;
- }
-
public void uri(String uri) {
this.uri = uri;
}
+ /**
+ * Sets parent node.
+ *
+ * @param parent parent node
+ */
public void parent(PropertiesNode parent) {
this.parent = parent;
}
+ /**
+ * Sets application info.
+ *
+ * @param appInfo application info
+ */
+ public void appInfo(Object appInfo) {
+ this.appInfo = appInfo;
+ }
+
+ /**
+ * Returns parent.
+ *
+ * @return parent node
+ */
public PropertiesNode parent() {
return parent;
}
+ /**
+ * Returns name.
+ *
+ * @return name of the node
+ */
public String name() {
return name;
}
- public String namespace() {
+ /**
+ * Returns namespace.
+ *
+ * @return namespace of the node
+ */
+ public Namespace namespace() {
return namespace;
}
+ /**
+ * Returns uri.
+ *
+ * @return uri of the node
+ */
public String uri() {
return uri;
}
+ /**
+ * Returns application info.
+ *
+ * @return application info
+ */
+ public Object appInfo() {
+ return appInfo;
+ }
+
+ /**
+ * Returns node type.
+ *
+ * @return node type
+ */
+ public NodeType nodeType() {
+ return nodeType;
+ }
+
+ /**
+ * Returns augmentations.
+ *
+ * @return augmentations
+ */
+ public Multimap<Object, PropertiesNode> augmentations() {
+ return augmentations;
+ }
+
+ /**
+ * Sets augmentations.
+ *
+ * @param augmentations augmentations of the node
+ */
+ public void augmentations(Multimap<Object, PropertiesNode> augmentations) {
+ this.augmentations = augmentations;
+ }
+
+ /**
+ * Adds a child to a current node.
+ *
+ * @param name name of child
+ * @param namespace namespace of child, null represents parent namespace
+ * @param type type of node
+ * @param appInfo application info
+ * @return added properties node
+ */
+ public abstract PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException;
+
+ /**
+ * Adds a child with value to a current node.
+ *
+ * @param name name of child
+ * @param namespace namespace of child, null represents parent namespace
+ * @param type type of node
+ * @param value value of node
+ * @param valueNs value namespace
+ * @param appInfo application info
+ * @throws SvcLogicException if failed to add child
+ * @return added properties node
+ */
+ public abstract PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type, String value,
+ Namespace valueNs,
+ Object appInfo) throws SvcLogicException;
+
+ /**
+ * Adds a child at a given index to a current node. To be used in case of
+ * leaf holder child's which is multi instance node.
+ *
+ * @param index index at which node is to be added
+ * @param name name of child
+ * @param namespace namespace of child, null represents parent namespace
+ * @param type type of node
+ * @param appInfo application info
+ * @throws SvcLogicException if failed to add child
+ * @return added properties node
+ */
+ public abstract PropertiesNode addChild(String index, String name,
+ Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException;
+
+ /**
+ * Adds a child at a given index to a current node. To be used in case of
+ * leaf holder child's which is multi instance node.
+ *
+ * @param index index at which node is to be added
+ * @param name name of child
+ * @param namespace namespace of child, null represents parent namespace
+ * @param type type of node
+ * @param value value of node
+ * @param valueNs value namespace
+ * @param appInfo application info
+ * @throws SvcLogicException if failed to add child
+ * @return added properties node
+ */
+ public abstract PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ String value, Namespace valueNs,
+ Object appInfo) throws SvcLogicException;
+
+ /**
+ * Returns root node.
+ *
+ * @return root node
+ */
+ public PropertiesNode endNode() {
+ PropertiesNode node = this;
+ while (node.parent() != null){
+ node = node.parent();
+ }
+ return node;
+ }
}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java
index 81609a6da..3e3483721 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java
@@ -20,6 +20,8 @@
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
import java.util.Map;
/**
@@ -62,29 +64,30 @@ public abstract class PropertiesNodeSerializer<T, P> {
this.uri = uri;
}
-
/**
* Encodes from properties to properties-node tree.
*
* @param paramMap parameter map
+ * @throws SvcLogicException fails to encode properties to properties node
* @return properties node
*/
- public abstract PropertiesNode encode(Map<String, String> paramMap);
+ public abstract PropertiesNode encode(Map<String, String> paramMap) throws SvcLogicException;
/**
* Decodes from properties-node to properties map.
*
* @param propertiesNode properties-node
+ * @throws SvcLogicException fails to decode properties node to properties
* @return parameter map
*/
- public abstract Map<String, String> decode(PropertiesNode propertiesNode);
+ public abstract Map<String, String> decode(PropertiesNode propertiesNode) throws SvcLogicException;
/**
* Returns the schema node of the property
*
* @return schema node
*/
- public T getSchemaNode(){
+ public T schemaNode(){
return schemaNode;
}
@@ -93,7 +96,7 @@ public abstract class PropertiesNodeSerializer<T, P> {
*
* @return schema node
*/
- public P getSchemaCtx() {
+ public P schemaCtx() {
return schemaCtx;
}
@@ -102,7 +105,7 @@ public abstract class PropertiesNodeSerializer<T, P> {
*
* @return uri
*/
- public String getUri() {
+ public String uri() {
return uri;
}
}
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
new file mode 100644
index 000000000..5cb8e4c97
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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 org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Abstraction of node representing properties data tree.
+ */
+public class RootNode<T extends NodeChild> extends PropertiesNode {
+
+ private Map<String, T> children = new HashMap<String, T>();
+
+ protected RootNode(String name, Namespace namespace,
+ Object appInfo, String uri) {
+ super(name, namespace, uri, null, appInfo, null);
+ }
+
+ /**
+ * Returns children.
+ *
+ * @return children
+ */
+ public Map<String, T> children() {
+ return children;
+ }
+
+ /**
+ * Sets children.
+ *
+ * @param children child nodes
+ */
+ public void children(Map<String, T> children) {
+ this.children = children;
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+
+ @Override
+ public PropertiesNode addChild(String name, Namespace namespace,
+ NodeType type, String value,
+ Namespace valuens,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+
+ @Override
+ public PropertiesNode addChild(String index, String name,
+ Namespace namespace, NodeType type,
+ String value, Namespace valueNs,
+ Object appInfo) throws SvcLogicException {
+ // TODO : to be implemented
+ return null;
+ }
+}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java
new file mode 100644
index 000000000..6eb24c1a4
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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;
+
+/**
+ * Representation of single instance node in properties data tree.
+ */
+public class SingleInstanceNode extends InnerNode<DataNodeChild> implements DataNodeChild {
+
+ public SingleInstanceNode(String name, Namespace namespace, String uri,
+ PropertiesNode parent, Object appInfo,
+ NodeType nodeType) {
+ super(name, namespace, uri, parent, appInfo, nodeType);
+ }
+}