ONOS-5959 with YANG model integrated
Change-Id: I866b70ceebe8cb19d88cb2cc74530cbb4988b913
diff --git a/apps/config/BUCK b/apps/config/BUCK
index 22e1a08..c409e6c 100644
--- a/apps/config/BUCK
+++ b/apps/config/BUCK
@@ -1,6 +1,11 @@
+APPS = [
+ 'org.onosproject.yang',
+]
+
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//lib:org.apache.karaf.shell.console',
+ '//lib:onos-yang-model',
'//core/store/serializers:onos-core-serializers',
'//cli:onos-cli',
]
@@ -14,4 +19,5 @@
category = 'Utility',
url = 'http://onosproject.org',
description = 'Application to support the Dynamic configuration service and store.',
+ required_apps = APPS,
)
\ No newline at end of file
diff --git a/apps/config/pom.xml b/apps/config/pom.xml
index 6e2eb2d..1b8e334 100755
--- a/apps/config/pom.xml
+++ b/apps/config/pom.xml
@@ -36,6 +36,11 @@
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
+ <artifactId>onos-yang-model</artifactId>
+ <version>1.12-b3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
<artifactId>onos-core-serializers</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/apps/config/src/main/java/org/onosproject/config/DynamicConfigEvent.java b/apps/config/src/main/java/org/onosproject/config/DynamicConfigEvent.java
index a03125f..8b6a305 100755
--- a/apps/config/src/main/java/org/onosproject/config/DynamicConfigEvent.java
+++ b/apps/config/src/main/java/org/onosproject/config/DynamicConfigEvent.java
@@ -17,7 +17,7 @@
import com.google.common.annotations.Beta;
-import org.onosproject.config.model.ResourceId;
+import org.onosproject.yang.model.ResourceId;
import org.onosproject.event.AbstractEvent;
/**
diff --git a/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java b/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java
index da83d91..aaa3812 100755
--- a/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java
+++ b/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java
@@ -17,8 +17,8 @@
package org.onosproject.config;
import com.google.common.annotations.Beta;
-import org.onosproject.config.model.DataNode;
-import org.onosproject.config.model.ResourceId;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ResourceId;
import org.onosproject.event.ListenerService;
/**
diff --git a/apps/config/src/main/java/org/onosproject/config/DynamicConfigStore.java b/apps/config/src/main/java/org/onosproject/config/DynamicConfigStore.java
index de4a7e0..9ea34f2 100644
--- a/apps/config/src/main/java/org/onosproject/config/DynamicConfigStore.java
+++ b/apps/config/src/main/java/org/onosproject/config/DynamicConfigStore.java
@@ -16,8 +16,8 @@
package org.onosproject.config;
import com.google.common.annotations.Beta;
-import org.onosproject.config.model.DataNode;
-import org.onosproject.config.model.ResourceId;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ResourceId;
import org.onosproject.store.Store;
import java.util.concurrent.CompletableFuture;
diff --git a/apps/config/src/main/java/org/onosproject/config/Filter.java b/apps/config/src/main/java/org/onosproject/config/Filter.java
index 7fd5144..02afcbb 100755
--- a/apps/config/src/main/java/org/onosproject/config/Filter.java
+++ b/apps/config/src/main/java/org/onosproject/config/Filter.java
@@ -17,7 +17,7 @@
import com.google.common.annotations.Beta;
-import org.onosproject.config.model.ResourceId;
+import org.onosproject.yang.model.ResourceId;
import java.util.LinkedHashSet;
import java.util.Set;
diff --git a/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java b/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
new file mode 100755
index 0000000..7b7f5bd
--- /dev/null
+++ b/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * 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.
+ */
+package org.onosproject.config;
+
+import java.util.Iterator;
+import org.onosproject.yang.model.NodeKey;
+import org.onosproject.yang.model.ResourceId;
+
+/**
+ * Representation of an entity which identifies a resource in the logical tree
+ * data store. It is a list of node keys to identify the branch point
+ * hierarchy to reach a resource in the instance tree.
+ */
+
+public final class ResourceIdParser {
+
+ private ResourceIdParser() {
+
+ }
+ public static String asString(ResourceId path) {
+ StringBuilder bldr = new StringBuilder();
+ bldr.append("root.");
+ Iterator<NodeKey> iter = path.nodeKeys().iterator();
+ NodeKey key;
+ while (iter.hasNext()) {
+ key = iter.next();
+ //log.info("Iter: key {}", key.toString());
+ bldr.append(key.schemaId().name());
+ bldr.append("#");
+ bldr.append(key.schemaId().namespace());
+ if (iter.hasNext()) {
+ bldr.append(".");
+ }
+ }
+ return bldr.toString();
+ }
+}
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/RpcCommand.java b/apps/config/src/main/java/org/onosproject/config/RpcCommand.java
index d00b0c2..7c144c6 100644
--- a/apps/config/src/main/java/org/onosproject/config/RpcCommand.java
+++ b/apps/config/src/main/java/org/onosproject/config/RpcCommand.java
@@ -16,7 +16,7 @@
package org.onosproject.config;
import com.google.common.annotations.Beta;
-import org.onosproject.config.model.ResourceId;
+import org.onosproject.yang.model.ResourceId;
/**
* Abstract implementation of an RPC command.
*/
diff --git a/apps/config/src/main/java/org/onosproject/config/RpcInput.java b/apps/config/src/main/java/org/onosproject/config/RpcInput.java
index db61ab1..96ec581 100644
--- a/apps/config/src/main/java/org/onosproject/config/RpcInput.java
+++ b/apps/config/src/main/java/org/onosproject/config/RpcInput.java
@@ -16,7 +16,7 @@
package org.onosproject.config;
import com.google.common.annotations.Beta;
-import org.onosproject.config.model.DataNode;
+import org.onosproject.yang.model.DataNode;
/**
* Abstraction for RPC input.
diff --git a/apps/config/src/main/java/org/onosproject/config/RpcOutput.java b/apps/config/src/main/java/org/onosproject/config/RpcOutput.java
index 789c01c..f0d98a0 100644
--- a/apps/config/src/main/java/org/onosproject/config/RpcOutput.java
+++ b/apps/config/src/main/java/org/onosproject/config/RpcOutput.java
@@ -16,7 +16,7 @@
package org.onosproject.config;
import com.google.common.annotations.Beta;
-import org.onosproject.config.model.DataNode;
+import org.onosproject.yang.model.DataNode;
/**
* Abstraction for RPC output.
diff --git a/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java b/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
index c437ecd..741ae97 100644
--- a/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
+++ b/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
@@ -28,12 +28,15 @@
import org.onosproject.config.DynamicConfigStoreDelegate;
import org.onosproject.config.FailedException;
import org.onosproject.config.Filter;
-import org.onosproject.config.model.DataNode;
-import org.onosproject.config.model.InnerNode;
-import org.onosproject.config.model.LeafNode;
-import org.onosproject.config.model.NodeKey;
-import org.onosproject.config.model.ResourceId;
-import org.onosproject.config.model.SchemaId;
+import org.onosproject.config.ResourceIdParser;
+import org.onosproject.store.service.IllegalDocumentModificationException;
+import org.onosproject.store.service.NoSuchDocumentPathException;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.InnerNode;
+import org.onosproject.yang.model.LeafNode;
+import org.onosproject.yang.model.NodeKey;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.SchemaId;
import org.onosproject.store.AbstractStore;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.AsyncDocumentTree;
@@ -51,6 +54,7 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
/**
* Implementation of the dynamic config store.
@@ -65,9 +69,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
private AsyncDocumentTree<DataNode.Type> keystore;
- private ConsistentMap<ResourceId, LeafNode> objectStore;
+ private ConsistentMap<String, LeafNode> objectStore;
private final DocumentTreeListener<DataNode.Type> klistener = new InternalDocTreeListener();
- private final MapEventListener<ResourceId, LeafNode> olistener = new InternalMapListener();
+ private final MapEventListener<String, LeafNode> olistener = new InternalMapListener();
@Activate
public void activateStore() {
@@ -87,7 +91,7 @@
.withName("config-key-store")
.withRelaxedReadConsistency()
.buildDocumentTree();
- objectStore = storageService.<ResourceId, LeafNode>consistentMapBuilder()
+ objectStore = storageService.<String, LeafNode>consistentMapBuilder()
.withSerializer(Serializer.using(kryoBuilder.build()))
.withName("config-object-store")
.withRelaxedReadConsistency()
@@ -107,35 +111,13 @@
@Override
public CompletableFuture<Boolean>
addNode(ResourceId path, DataNode node) {
- CompletableFuture<Boolean> eventFuture = CompletableFuture.completedFuture(false);
- Boolean stat = false;
- DocumentPath dpath = DocumentPath.from(path.asString());
- log.info("STORE: dpath to parent {}", dpath);
- if (keystore.get(dpath).join() == null) {
- throw new FailedException("Some of the parents are not present in " +
- "the requested path, please use a recursive create");
- }
- ResourceId cpath = path.builder()
- .addBranchPointSchema(node.key().schemaId().name(),
- node.key().schemaId().namespace()).build();
- dpath = DocumentPath.from(cpath.asString());
- if (keystore.get(dpath).join() != null) {
- throw new FailedException("Requested node already present in the" +
- " store, please use an update method");
- }
- stat = checkNode(cpath, node);
- if (stat) {
- eventFuture = CompletableFuture.completedFuture(true);
- } else {
- log.info("STORE: FAILED to create node @ {}", path);
- }
- return eventFuture;
+ throw new FailedException("Not yet implemented");
}
@Override
public CompletableFuture<DataNode> readNode(ResourceId path, Filter filter) {
CompletableFuture<DataNode> eventFuture = CompletableFuture.completedFuture(null);
- DocumentPath dpath = DocumentPath.from(path.asString());
+ DocumentPath dpath = DocumentPath.from(ResourceIdParser.asString(path));
DataNode.Type type;
type = keystore.get(dpath).join().value();
if (type == null) {
@@ -150,7 +132,7 @@
} else {
int last = path.nodeKeys().size();
NodeKey key = path.nodeKeys().get(last - 1);
- DataNode.Builder superBldr = new InnerNode.Builder(key.schemaId().name(),
+ DataNode.Builder superBldr = InnerNode.builder(key.schemaId().name(),
key.schemaId().namespace()).type(type);
readInner(superBldr, path);
retVal = superBldr.build();
@@ -168,11 +150,10 @@
addRecursive(ResourceId path, DataNode node) {
CompletableFuture<Boolean> eventFuture = CompletableFuture.completedFuture(false);
Boolean stat = false;
- DocumentPath dpath = DocumentPath.from(path.asString());
- //TODO need to check for each parent in the path and recursively create all missing
- /*if (keystore.get(dpath).join() == null) {
+ DocumentPath dpath = DocumentPath.from(ResourceIdParser.asString(path));
+ if (keystore.get(dpath).join() == null) {
//recursivley craete all missing aprents
- }*/
+ }
if (keystore.get(dpath).join() != null) {
throw new FailedException("Requested node already present " +
"in the store, please use an update method");
@@ -213,16 +194,30 @@
@Override
public CompletableFuture<Boolean>
deleteNodeRecursive(ResourceId path) {
- throw new FailedException("Not yet implemented");
+ String spath = ResourceIdParser.asString(path);
+ DocumentPath dpath = DocumentPath.from(spath);
+ DataNode.Type type = null;
+ CompletableFuture<Versioned<DataNode.Type>> vtype = keystore.removeNode(dpath);
+ type = completeVersioned(vtype);
+ if (type == null) {
+ throw new FailedException("node delete failed");
+ }
+ Versioned<LeafNode> res = objectStore.remove(spath);
+ if (res == null) {
+ return CompletableFuture.completedFuture(false);
+ } else {
+ return CompletableFuture.completedFuture(true);
+ }
+
}
private Boolean addLeaf(ResourceId path, LeafNode node) {
- objectStore.put(path, node);
- return (keystore.create(DocumentPath.from(path.asString()), node.type()).join());
+ objectStore.put(ResourceIdParser.asString(path), node);
+ return (keystore.create(DocumentPath.from(ResourceIdParser.asString(path)), node.type()).join());
}
private Boolean addKey(ResourceId path, DataNode.Type type) {
- return (keystore.create(DocumentPath.from(path.asString()), type).join());
+ return (keystore.create(DocumentPath.from(ResourceIdParser.asString(path)), type).join());
}
private Boolean checkNode(ResourceId path, DataNode node) {
@@ -240,7 +235,7 @@
}
private LeafNode readLeaf(ResourceId path) {
- return objectStore.get(path).value();
+ return objectStore.get(ResourceIdParser.asString(path)).value();
}
private Boolean traverseInner(ResourceId path, InnerNode node) {
@@ -275,7 +270,7 @@
private void readInner(DataNode.Builder superBldr, ResourceId path) {
Map<String, Versioned<DataNode.Type>> entries = keystore.getChildren(
- DocumentPath.from(path.asString())).join();
+ DocumentPath.from(ResourceIdParser.asString(path))).join();
if (entries.size() == 0) {
throw new FailedException("Inner node cannot have empty children map");
}
@@ -318,13 +313,13 @@
ResourceId path;
switch (event.type()) {
case CREATED:
- log.info("key created in store");
+ log.info("NODE created in store");
break;
case UPDATED:
- log.info("key updated in store");
+ log.info("NODE updated in store");
break;
case DELETED:
- log.info("key deleted in store");
+ log.info("NODE deleted in store");
break;
default:
@@ -333,22 +328,56 @@
}
}
- public class InternalMapListener implements MapEventListener<ResourceId, LeafNode> {
+ public class InternalMapListener implements MapEventListener<String, LeafNode> {
@Override
- public void event(MapEvent<ResourceId, LeafNode> event) {
+ public void event(MapEvent<String, LeafNode> event) {
switch (event.type()) {
case INSERT:
- log.info("OBJECT created in store");
+ //log.info("NODE created in store");
break;
case UPDATE:
- log.info("OBJECT updated in store");
+ //log.info("NODE updated in store");
break;
case REMOVE:
default:
- log.info("OBJECT removed in store");
+ //log.info("NODE removed in store");
break;
}
//notify
}
}
+
+ private <T> T complete(CompletableFuture<T> future) {
+ try {
+ return future.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new FailedException(e.getCause().getMessage());
+ } catch (ExecutionException e) {
+ if (e.getCause() instanceof IllegalDocumentModificationException) {
+ throw new FailedException("Node or parent doesnot exist or is root or is not a Leaf Node");
+ } else if (e.getCause() instanceof NoSuchDocumentPathException) {
+ throw new FailedException("Resource id does not exist");
+ } else {
+ throw new FailedException("Datastore operation failed");
+ }
+ }
+ }
+
+ private <T> T completeVersioned(CompletableFuture<Versioned<T>> future) {
+ try {
+ return future.get().value();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new FailedException(e.getCause().getMessage());
+ } catch (ExecutionException e) {
+ if (e.getCause() instanceof IllegalDocumentModificationException) {
+ throw new FailedException("Node or parent does not exist or is root or is not a Leaf Node");
+ } else if (e.getCause() instanceof NoSuchDocumentPathException) {
+ throw new FailedException("Resource id does not exist");
+ } else {
+ throw new FailedException("Datastore operation failed");
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java b/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java
index 98a028f..154d014 100644
--- a/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java
+++ b/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java
@@ -34,8 +34,8 @@
import org.onosproject.config.RpcHandler;
import org.onosproject.config.RpcInput;
import org.onosproject.config.RpcOutput;
-import org.onosproject.config.model.DataNode;
-import org.onosproject.config.model.ResourceId;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ResourceId;
import org.onosproject.event.AbstractListenerManager;
import org.onosproject.event.EventDeliveryService;
import org.slf4j.Logger;
@@ -73,8 +73,7 @@
@Override
public void createNode(ResourceId path, DataNode node) {
- Boolean stat = false;
- stat = this.store.addNode(path, node).join();
+ throw new FailedException("Not yet implemented");
}
public void createNodeRecursive(ResourceId path, DataNode node) {
@@ -99,7 +98,7 @@
}
public void deleteNodeRecursive(ResourceId path) {
- throw new FailedException("Not yet implemented");
+ store.deleteNodeRecursive(path).join();
}
public void updateNodeRecursive(ResourceId path, DataNode node) {
diff --git a/apps/config/src/main/java/org/onosproject/config/model/DataNode.java b/apps/config/src/main/java/org/onosproject/config/model/DataNode.java
deleted file mode 100755
index f0a94f0..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/DataNode.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.
- */
-package org.onosproject.config.model;
-
-/**
- * Abstraction of an entity which represents data tree node. Information
- * exchange between YANG runtime, protocol and store will be based on this
- * node, agnostic of schema.
- */
-public abstract class DataNode {
-
- /*
- * Represents type of node in data store.
- */
- public enum Type {
-
- /**
- * Single instance node.
- */
- SINGLE_INSTANCE_NODE,
-
- /**
- * Multi instance node.
- */
- MULTI_INSTANCE_NODE,
-
- /**
- * Single instance leaf node.
- */
- SINGLE_INSTANCE_LEAF_VALUE_NODE,
-
- /**
- * Multi instance leaf node.
- */
- MULTI_INSTANCE_LEAF_VALUE_NODE
- }
-
- /**
- * Type of node in data store.
- */
- protected Type type;
-
- /**
- * Identifies a node uniquely among its siblings.
- */
- protected NodeKey key;
-
- /**
- * Returns the type of node.
- *
- * @return node type
- */
- public Type type() {
- return type;
- }
-
- /**
- * Returns the key to identify a branching node.
- *
- * @return key to identify a branching node
- */
- public NodeKey key() {
- return key;
- }
-
- /**
- * Creates an instance of data node.
- *
- * @param builder data node builder
- */
- protected DataNode(Builder builder) {
- type = builder.type;
- key = builder.key;
- }
-
- /**
- * Returns data node builder for a given data node.
- * It contains all the attributes from the data node. It is to provide
- * mutability of data node using builder pattern.
- *
- * @return data node builder
- */
- public abstract Builder copyBuilder();
-
- /**
- * Represents the implementation of data node builder class.
- *
- * @param <B> type of data node builder
- */
- public abstract static class Builder<B extends Builder<B>> {
-
- /**
- * Type of node in data store.
- */
- protected Type type;
-
- /**
- * Identifies a node uniquely among its siblings.
- */
- protected NodeKey key;
-
- /**
- * Node key builder.
- */
- protected NodeKey.NodeKeyBuilder keyBuilder;
-
- /**
- * Parent data node.
- */
- protected InnerNode.Builder parent;
-
- /**
- * Creates an instance of data node builder.
- */
- protected Builder() {
- }
-
- /**
- * Creates an instance of data node builder using old data node.
- *
- * @param node data node which
- */
- protected Builder(DataNode node) {
- type = node.type;
- key = node.key;
- }
-
- /**
- * Sets node key in builder object.
- * when serializers have an instance of key present with them they can
- * directly set the key value using this method.
- *
- * @param key node key identifier
- * @return data node builder object
- */
- public B key(NodeKey key) {
- this.key = key;
- return (B) this;
- }
-
- /**
- * Sets parent node's builder.
- *
- * @param node parent node builder
- * @return builder object
- */
- protected B parent(InnerNode.Builder node) {
- parent = node;
- return (B) this;
- }
-
- /**
- * Sets node type in builder object.
- *
- * @param type node type
- * @return data node builder
- */
- public B type(Type type) {
- this.type = type;
- return (B) this;
- }
-
- /**
- * Creates a child builder of type inner node and set a back reference
- * of parent node. it is used while creating a data tree.
- *
- * @param name name of inner node
- * @param nameSpace namespace of inner node
- * @return child node builder
- */
- public abstract InnerNode.Builder createChildBuilder(
- String name, String nameSpace);
-
- /**
- * Creates a child build of type leaf node and set a back reference
- * of parent node. it is used while creating a data tree. the value
- * of leaf is set while creation.
- *
- * @param name name of leaf node
- * @param nameSpace namespace of leaf node
- * @param value value for leaf node
- * @return child node builder
- */
- public abstract LeafNode.Builder createChildBuilder(
- String name, String nameSpace, Object value);
-
- /**
- * Deletes child node for a given node key from parent node.
- * <p>
- * for deleting a node from data tree , caller should parse resource
- * identifier to reach to the child node. while parsing the resource
- * identifier caller need to create a new data node using copy
- * builder. this copy builder can be used further to create child
- * nodes copy builders.
- *
- * @param key node key for child node
- * @return data node builder
- */
- public abstract InnerNode.Builder deleteChild(NodeKey key);
-
- /**
- * Returns a child node builder for a given node key. it contains all
- * the attribute of child node. it is used to modify the data tree
- * while delete or update operations.
- * <p>
- * this method provides copy builder of child node when a
- * update/delete request comes. it sets a back reference of parent
- * node as well in child node's copy builder.
- *
- * @param key data node key
- * @return child node
- */
- public abstract InnerNode.Builder getChildBuilder(NodeKey key);
-
-
- /**
- * Add key leaf for list node key. It can be used while handling a
- * list node when in your yang file you have multiple key leaves.
- * <p>
- * this method is used for adding multiple key leaves in you list
- * node. these keys will be added to key builder which is built while
- * while node building. To use this method caller should know about
- * schema of list and key leaves.
- *
- * @param name name of leaf node
- * @param nameSpace namespace of leaf node
- * @param val value of leaf
- * @return data node builder
- */
- public abstract InnerNode.Builder addKeyLeaf(String name, String nameSpace,
- Object val);
-
- /**
- * Add key value to leaf list key. this can be used while handling a
- * leaf list where you need to add multiple values.
- *
- * @param val value
- * @return data node builder
- */
- public abstract LeafNode.Builder addLeafListValue(Object val);
-
- /**
- * Builds data node.
- *
- * @return data node
- */
- public abstract DataNode build();
-
- /**
- * Returns parent node builder after building and adding the child
- * node to parent's child node map.
- * <p>
- * This method is used when caller has reached to the depth of the
- * subtree and then he wants to go back to its parent node so he
- * should build the node and then it should add it to parent node's
- * map. this method provides both the functionalities of build and
- * add to parent . Also it returns back the parent pointer so caller
- * can do further operations on data tree.
- *
- * @return parent's builder object
- */
- public InnerNode.Builder exitNode() {
- if (parent != null) {
- parent.addNode(build());
- }
- return parent;
- }
- }
-}
-
diff --git a/apps/config/src/main/java/org/onosproject/config/model/InnerNode.java b/apps/config/src/main/java/org/onosproject/config/model/InnerNode.java
deleted file mode 100644
index 2a0dfee..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/InnerNode.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.
- */
-package org.onosproject.config.model;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import static org.onosproject.config.model.ModelConstants.LEAF_IS_TERMINAL;
-
-/**
- * Abstraction of an entity which represents an inner node in data store.
- */
-public final class InnerNode extends DataNode {
-
- /**
- * Map containing info of all child data nodes with respect to their node
- * keys.
- */
- private Map<NodeKey, DataNode> childNodes = new LinkedHashMap<>();
-
- /**
- * Returns the children nodes to the current node.
- * Children nodes are identified based on the node key.
- *
- * @return read only linked map of children nodes
- */
- public Map<NodeKey, DataNode> childNodes() {
- return childNodes;
- }
-
- /**
- * Creates an instance of inner node.
- *
- * @param builder inner node builder
- */
- public InnerNode(Builder builder) {
- super(builder);
- childNodes = builder.childNodes;
- }
-
- /**
- * Returns inner node builder instance.
- *
- * @param name name of node
- * @param nameSpace namespace of node
- * @return inner node builder instance
- */
- public static Builder builder(String name, String nameSpace) {
- return new Builder(name, nameSpace);
- }
-
- /**
- * Returns inner node copy builder.
- *
- * @return inner node copy builder
- */
- @Override
- public Builder copyBuilder() {
- return new Builder(this);
- }
-
- /**
- * Builder with get and set functions to build inner node,
- * builder will be used both to create inner node from scratch or from a
- * given inner node.
- */
- public static class Builder extends DataNode.Builder<Builder> {
-
- /**
- * Map containing info of all child data nodes with respect to their
- * node keys.
- */
- private Map<NodeKey, DataNode> childNodes = new LinkedHashMap<>();
-
- public Builder() {
- }
- /**
- * Creates an instance of data node builder.
- *
- * @param name name of node
- * @param namespace namespace of node
- */
- public Builder(String name, String namespace) {
- keyBuilder = NodeKey.builder().schemaId(name, namespace);
- }
-
- /**
- * Creates an instance of inner node builder.
- *
- * @param node old inner node
- */
- public Builder(InnerNode node) {
- super(node);
- childNodes = node.childNodes;
- }
-
- /**
- * Adds node to the builder.
- *
- * @param node node to be added
- * @return inner node builder
- */
- public Builder addNode(DataNode node) {
- childNodes.put(node.key(), node);
- return this;
- }
-
- /**
- * Builds a inner node object.
- *
- * @return inner node
- */
- @Override
- public InnerNode build() {
- if (type == null) {
- throw new IllegalStateException("node should have a type.");
- }
- if (key == null) {
- key = keyBuilder.build();
- }
- return new InnerNode(this);
- }
-
- @Override
- public InnerNode.Builder createChildBuilder(String name, String nameSpace) {
- return InnerNode.builder(name, nameSpace)
- .parent(this);
- }
-
- @Override
- public LeafNode.Builder createChildBuilder(String name, String nameSpace,
- Object value) {
- return LeafNode.builder(name, nameSpace)
- .parent(this)
- .value(value);
- }
-
- @Override
- public InnerNode.Builder deleteChild(NodeKey key) {
- childNodes.remove(key);
- return this;
- }
-
- @Override
- public Builder getChildBuilder(NodeKey nodeKey) {
- DataNode node = childNodes.get(nodeKey);
- if (node == null) {
- throw new IllegalArgumentException(
- "Invalid key: no child nodes found for given key: " +
- nodeKey);
- }
- return (Builder) node.copyBuilder().parent(this);
- }
-
- @Override
- public Builder addKeyLeaf(String name, String nameSpace, Object val) {
- ListKey.ListKeyBuilder listKeyBuilder;
- if (!(keyBuilder instanceof ListKey.ListKeyBuilder)) {
- if (keyBuilder instanceof LeafListKey.LeafListKeyBuilder) {
- throw new ModelException(LEAF_IS_TERMINAL);
- }
-
- listKeyBuilder = new ListKey.ListKeyBuilder(keyBuilder);
- } else {
- listKeyBuilder = (ListKey.ListKeyBuilder) keyBuilder;
- }
-
- listKeyBuilder.addKeyLeaf(name, nameSpace, val);
- keyBuilder = listKeyBuilder;
- return this;
- }
-
- @Override
- public LeafNode.Builder addLeafListValue(Object val) {
- throw new IllegalStateException("node is not of leaf list type.");
- }
- }
-}
diff --git a/apps/config/src/main/java/org/onosproject/config/model/KeyLeaf.java b/apps/config/src/main/java/org/onosproject/config/model/KeyLeaf.java
deleted file mode 100644
index 1f21687..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/KeyLeaf.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * 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.
- */
-package org.onosproject.config.model;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static java.util.Objects.hash;
-
-/**
- * Represents the List's key leaf value.
- */
-public class KeyLeaf implements Cloneable {
-
- private SchemaId leafSchema;
- private Object leafVal;
-
- private KeyLeaf() {
- }
-
- /**
- * Constructs a key leaf with all the identifier and value initialized.
- *
- * @param name name of the leaf
- * @param nameSpace namespace of leaf
- * @param leafVal value of leaf
- */
- public KeyLeaf(String name, String nameSpace, Object leafVal) {
- leafSchema = new SchemaId(name, nameSpace);
- this.leafVal = leafVal;
- }
-
- /**
- * Creates and returns a deep copy of this object.
- *
- * @return cloned copy
- * @throws CloneNotSupportedException if the object's class does not
- * support the {@code Cloneable} interface
- */
- public KeyLeaf clone() throws CloneNotSupportedException {
- KeyLeaf clonedLeaf = (KeyLeaf) super.clone();
- clonedLeaf.leafSchema = leafSchema.clone();
- return clonedLeaf;
- }
-
- /**
- * Returns the node schema schemaId.
- *
- * @return node schema schemaId
- */
- public SchemaId leafSchema() {
- return leafSchema;
- }
-
- /**
- * Returns value contained in leaf node.
- *
- * @return value contained in leaf node
- */
- public Object leafValue() {
- return leafVal;
- }
-
- /**
- * Returns value as string, for usage in serializers.
- *
- * @return string representation of value
- */
- public String leafValAsString() {
- return leafVal.toString();
- }
-
- @Override
- public int hashCode() {
- return hash(leafSchema, leafVal);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
-
- KeyLeaf that = (KeyLeaf) obj;
- return Objects.equals(leafSchema, that.leafSchema) &&
- Objects.equals(leafVal, that.leafVal);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("schemaId", leafSchema)
- .add("leafValue", leafVal)
- .toString();
- }
-}
diff --git a/apps/config/src/main/java/org/onosproject/config/model/LeafListKey.java b/apps/config/src/main/java/org/onosproject/config/model/LeafListKey.java
deleted file mode 100644
index c532ae2..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/LeafListKey.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * 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.
- */
-
-package org.onosproject.config.model;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Representation of an entity which identifies a uniquely branching
- * leaf-list entry corresponding to a multi instance leaf schema.
- */
-public final class LeafListKey extends NodeKey<LeafListKey>
- implements Comparable<LeafListKey> {
- private Object val;
-
- /**
- * Create object from builder.
- *
- * @param builder initialized builder
- */
- private LeafListKey(LeafListKeyBuilder builder) {
- super(builder);
- val = builder.val;
- }
-
- /**
- * Returns value of node, this is only valid for multi-instance leaf, node.
- *
- * @return value maintained in the node
- */
- Object value() {
- return val;
- }
-
- /**
- * Returns value as string, for usage in serializers.
- *
- * @return string representation of value
- */
- String asString() {
- return val.toString();
- }
-
- /**
- * Creates and returns a deep copy of this object.
- *
- * @return cloned copy
- * @throws CloneNotSupportedException if the object's class does not
- * support the {@code Cloneable} interface
- */
- public LeafListKey clone() throws CloneNotSupportedException {
- return (LeafListKey) super.clone();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(schemaId, val);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (!getClass().equals(obj.getClass())) {
- return false;
- }
-
- LeafListKey that = (LeafListKey) obj;
- return Objects.equals(val, that.val) &&
- Objects.equals(schemaId, that.schemaId);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("value", val)
- .toString();
- }
-
- /**
- * Represents Leaf list key builder.
- */
- public static class LeafListKeyBuilder
- extends NodeKeyBuilder<LeafListKeyBuilder> {
-
- private Object val;
-
- /**
- * constructor used while constructing the key from scratch.
- */
- public LeafListKeyBuilder() {
-
- }
-
- /**
- * Adds the value for for the leaf list node identifier.
- *
- * @param val leaf list value
- * @return LeafListKeyBuilder
- */
- LeafListKeyBuilder value(Object val) {
- this.val = val;
- return this;
- }
-
- /**
- * Creates a leaf list entry identifier.
- *
- * @return leaf list entry identifier
- */
- public LeafListKey build() {
- return new LeafListKey(this);
- }
- }
-}
diff --git a/apps/config/src/main/java/org/onosproject/config/model/LeafNode.java b/apps/config/src/main/java/org/onosproject/config/model/LeafNode.java
deleted file mode 100644
index 44319c8..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/LeafNode.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.
- */
-
-package org.onosproject.config.model;
-
-import static org.onosproject.config.model.ModelConstants.NON_KEY_LEAF;
-
-/**
- * Abstraction of an entity which represents leaf data tree node.
- */
-public final class LeafNode extends DataNode {
-
- /**
- * Leaf node value.
- */
- private Object value;
-
- /**
- * Returns value contained in leaf node.
- *
- * @return value contained in leaf node
- */
- public Object value() {
- return value;
- }
-
- /**
- * Returns value as string, for usage in serializers.
- *
- * @return string representation of value
- */
- public String asString() {
- return String.valueOf(value);
- }
-
- /**
- * Creates an instance of leaf node.
- *
- * @param builder leaf node builder
- */
- public LeafNode(Builder builder) {
- super(builder);
- value = builder.value;
- }
-
- /**
- * Returns data node builder instance.
- *
- * @param name name of node
- * @param nameSpace namespace of node
- * @return data node builder instance
- */
- public static Builder builder(String name, String nameSpace) {
- return new Builder(name, nameSpace);
- }
-
- /**
- * Returns data node copy builder.
- *
- * @return data node copy builder
- */
- @Override
- public Builder copyBuilder() {
- return new Builder(this);
- }
-
- /**
- * Builder with get and set functions to build leaf node,
- * builder will be used both to create leaf node from scratch or from a
- * given leaf node.
- */
- public static final class Builder extends DataNode.Builder<Builder> {
-
- /**
- * Leaf node value.
- */
- private Object value;
-
- public Builder() {
- }
-
- /**
- * Creates an instance of data node builder.
- *
- * @param name name of node
- * @param namespace namespace of node
- */
- public Builder(String name, String namespace) {
- keyBuilder = NodeKey.builder().schemaId(name, namespace);
- }
-
- /**
- * Creates an instance of leaf node copy builder.
- *
- * @param node old leaf node
- */
- public Builder(LeafNode node) {
- super(node);
- value = node.value;
- }
-
- /**
- * Sets value of leaf node builder.
- *
- * @param value value
- * @return leaf node builder
- */
- public Builder value(Object value) {
- this.value = value;
- return this;
- }
-
- @Override
- public InnerNode.Builder createChildBuilder(String name, String nameSpace) {
- throw new IllegalStateException("leaf node can't have a child " +
- "node");
- }
-
- @Override
- public LeafNode.Builder createChildBuilder(String name, String nameSpace,
- Object value) {
- throw new IllegalStateException("leaf node can't have a child " +
- "node");
- }
-
- @Override
- public InnerNode.Builder deleteChild(NodeKey key) {
- throw new IllegalStateException("leaf node can't have a child " +
- "node");
- }
-
- @Override
- public InnerNode.Builder getChildBuilder(NodeKey key) {
- throw new IllegalStateException("leaf node can't have a child " +
- "node");
- }
-
-
- @Override
- public InnerNode.Builder addKeyLeaf(String name, String nameSpace, Object val) {
- throw new IllegalStateException("leaf node can't have a key " +
- "leaves node");
- }
-
- @Override
- public Builder addLeafListValue(Object val) {
- LeafListKey.LeafListKeyBuilder leafListKeyBuilder;
- if (!(keyBuilder instanceof LeafListKey.LeafListKeyBuilder)) {
- if (keyBuilder instanceof ListKey.ListKeyBuilder) {
- throw new ModelException(NON_KEY_LEAF);
- }
-
- leafListKeyBuilder = new LeafListKey.LeafListKeyBuilder();
- NodeKey key = keyBuilder.build();
- leafListKeyBuilder.schemaId(key.schemaId());
- } else {
- leafListKeyBuilder = (LeafListKey.LeafListKeyBuilder) keyBuilder;
- }
-
- leafListKeyBuilder.value(val);
- keyBuilder = leafListKeyBuilder;
- return this;
- }
-
- /**
- * Builds a leaf node object.
- *
- * @return leaf node
- */
- @Override
- public LeafNode build() {
- if (type == null) {
- throw new IllegalStateException("node should have a type.");
- }
- if (key == null) {
- key = keyBuilder.build();
- }
- return new LeafNode(this);
- }
- }
-}
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/model/ListKey.java b/apps/config/src/main/java/org/onosproject/config/model/ListKey.java
deleted file mode 100644
index 617efaf..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/ListKey.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * 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.
- */
-
-package org.onosproject.config.model;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents an entity which identifies a unique branching node
- * corresponding to a multi instance schema definition.
- */
-public final class ListKey extends NodeKey<ListKey> implements Comparable<ListKey> {
-
- private List<KeyLeaf> keyLeafs;
-
- /**
- * Create object from builder.
- *
- * @param builder initialized builder
- */
- private ListKey(ListKeyBuilder builder) {
- super(builder);
- keyLeafs = builder.keyLeafs;
- }
-
- /**
- * Returns the list of key leaf nodes of a multi instance node, which
- * uniquely identifies the branching node entry corresponding to a multi
- * instance schema definition.
- *
- * @return List of key leaf nodes
- */
- List<KeyLeaf> keyLeafs() {
- return keyLeafs;
- }
-
- /**
- * Creates and returns a deep copy of this object.
- *
- * @return cloned copy
- * @throws CloneNotSupportedException if the object's class does not
- * support the {@code Cloneable} interface
- */
- public ListKey clone() throws CloneNotSupportedException {
- ListKey clonedListKey = (ListKey) super.clone();
- List<KeyLeaf> clonedKeyLeafs = new LinkedList<>();
- for (KeyLeaf leaf : keyLeafs) {
- clonedKeyLeafs.add(leaf.clone());
- }
- clonedListKey.keyLeafs = clonedKeyLeafs;
- return clonedListKey;
- }
-
- public int compareTo(ListKey o) {
- //TODO: implement me
- return 0;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(schemaId, keyLeafs);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (!getClass().equals(obj.getClass())) {
- return false;
- }
-
- ListKey that = (ListKey) obj;
- List<KeyLeaf> thatList = that.keyLeafs;
- return keyLeafs.size() == thatList.size() &&
- keyLeafs.containsAll(thatList) &&
- Objects.equals(schemaId, that.schemaId);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("value", keyLeafs)
- .toString();
- }
-
- /**
- * Represents list key builder.
- */
- public static class ListKeyBuilder extends NodeKeyBuilder<ListKeyBuilder> {
- private List<KeyLeaf> keyLeafs = new LinkedList<>();
-
- /**
- * used to construct the key from scratch.
- */
- public ListKeyBuilder() {
- }
-
- /**
- * used to construct a key from an existing node key.
- *
- * @param base existing node key
- */
- public ListKeyBuilder(NodeKeyBuilder base) {
- super(base);
- }
-
- /**
- * Adds the key leaf for the list resource.
- *
- * @param name key leaf name
- * @param nameSpace key laef namespace
- * @param val value of key
- */
- void addKeyLeaf(String name, String nameSpace, Object val) {
- KeyLeaf keyLeaf = new KeyLeaf(name, nameSpace, val);
- keyLeafs.add(keyLeaf);
- }
-
- /**
- * Creates the list key object.
- *
- * @return list key
- */
- public ListKey build() {
- return new ListKey(this);
- }
- }
-}
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/model/ModelConstants.java b/apps/config/src/main/java/org/onosproject/config/model/ModelConstants.java
deleted file mode 100644
index 532de78..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/ModelConstants.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.
- */
-package org.onosproject.config.model;
-
-/**
- * Constants used in model package.
- */
-final class ModelConstants {
- private ModelConstants() {
-
- }
- static final String INCOMPLETE_SCHEMA_INFO = "Schema info is not complete";
- static final String LEAF_IS_TERMINAL = "Leaf must be the terminal node";
- static final String NON_KEY_LEAF = "Leaf list is not a key of list";
- static final String NO_KEY_SET = "Resource Identifier is empty";
-}
diff --git a/apps/config/src/main/java/org/onosproject/config/model/ModelException.java b/apps/config/src/main/java/org/onosproject/config/model/ModelException.java
deleted file mode 100755
index f2f6459..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/ModelException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.
- */
-package org.onosproject.config.model;
-
-/**
- * Exceptions for use by the {@code DynamicConfigService}.
- */
-public class ModelException extends RuntimeException {
-
- /**
- * Constructs a new runtime exception with no error message.
- */
- public ModelException() {
- super();
- }
-
- /**
- * Constructs a new runtime exception with the given error message.
- *
- * @param message error message
- */
- public ModelException(String message) {
- super(message);
- }
-}
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/model/NodeKey.java b/apps/config/src/main/java/org/onosproject/config/model/NodeKey.java
deleted file mode 100755
index 18919e3..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/NodeKey.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * 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.
- */
-
-package org.onosproject.config.model;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.hash;
-import static org.onosproject.config.model.ModelConstants.INCOMPLETE_SCHEMA_INFO;
-
-/**
- * Abstraction of an entity which identifies a node uniquely among its
- * siblings.
- */
-public class NodeKey<E extends NodeKey> implements Comparable<E>, Cloneable {
-
- protected SchemaId schemaId;
-
- /**
- * Create object from builder.
- *
- * @param builder initialized builder
- */
- protected NodeKey(NodeKeyBuilder builder) {
- schemaId = builder.schemaId;
- }
-
- /**
- * Returns node key builder.
- *
- * @return node key builder
- */
- public static NodeKeyBuilder builder() {
- return new NodeKeyBuilder();
- }
-
- /**
- * Returns the schema identifier as minimal key required to identify a
- * branching node.
- *
- * @return schema identifier of a key
- */
- public SchemaId schemaId() {
- return schemaId;
- }
-
- @Override
- public int compareTo(NodeKey o) {
- checkNotNull(o);
- return schemaId.compareTo(o.schemaId());
- }
-
- @Override
- public int hashCode() {
- return hash(schemaId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (!getClass().equals(obj.getClass())) {
- return false;
- }
-
- NodeKey that = (NodeKey) obj;
- return Objects.equals(schemaId, that.schemaId);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("schemaId", schemaId)
- .toString();
- }
-
- /**
- * Creates and returns a deep copy of this object.
- *
- * @return cloned copy
- * @throws CloneNotSupportedException if the object's class does not
- * support the {@code Cloneable} interface
- */
- public NodeKey clone() throws CloneNotSupportedException {
- NodeKey clonedKey = (NodeKey) super.clone();
- clonedKey.schemaId = schemaId.clone();
- return clonedKey;
- }
-
- /**
- * Builder for node key.
- *
- * @param <B> node key type
- */
- public static class NodeKeyBuilder<B extends NodeKeyBuilder<B>> {
- private SchemaId schemaId;
-
- /**
- * Create the node key from scratch.
- */
- public NodeKeyBuilder() {
- }
-
- /**
- * Support the derived object to inherit from existing node key builder.
- *
- * @param base existing node key builder
- */
- protected NodeKeyBuilder(NodeKeyBuilder base) {
- checkNotNull(base.schemaId, INCOMPLETE_SCHEMA_INFO);
- schemaId = base.schemaId;
- }
-
- /**
- * set the schema identifier.
- *
- * @param schema schema identifier
- * @return current builder
- */
- public B schemaId(SchemaId schema) {
- schemaId = schema;
- return (B) this;
- }
-
- /**
- * set the schema identifier.
- *
- * @param name name of the node
- * @param nameSpace name space of the node
- * @return current builder
- */
- public B schemaId(String name, String nameSpace) {
- schemaId = new SchemaId(name, nameSpace);
- return (B) this;
- }
-
- /**
- * construct the node key.
- *
- * @return node key
- */
- public NodeKey build() {
- checkNotNull(schemaId.name(), INCOMPLETE_SCHEMA_INFO);
- checkNotNull(schemaId.namespace(), INCOMPLETE_SCHEMA_INFO);
- return new NodeKey(this);
- }
- }
-}
-
diff --git a/apps/config/src/main/java/org/onosproject/config/model/ResourceId.java b/apps/config/src/main/java/org/onosproject/config/model/ResourceId.java
deleted file mode 100755
index a279d40..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/ResourceId.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * 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.
- */
-package org.onosproject.config.model;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.hash;
-import static org.onosproject.config.model.ModelConstants.*;
-
-/**
- * Representation of an entity which identifies a resource in the logical tree
- * data store. It is a list of node keys to identify the branch point
- * hierarchy to reach a resource in the instance tree.
- */
-
-public final class ResourceId {
-
- //private final Logger log = LoggerFactory.getLogger(getClass());
- /**
- * List of node keys.
- */
- private List<NodeKey> nodeKeyList;
-
- /**
- * Create object from builder.
- *
- * @param builder initialized builder
- */
- private ResourceId(Builder builder) {
- nodeKeyList = builder.nodeKeyList;
- }
-
- /**
- * Retrieves a new resource builder.
- *
- * @return resource builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Returns the list of node key used to uniquely identify the branch in the
- * logical tree starting from root.
- *
- * @return node key uniquely identifying the branch
- */
- public List<NodeKey> nodeKeys() {
- return nodeKeyList;
- }
-
- /**
- * Returns resource identifier builder for a given resource identifier.
- * It contains all the attributes from the resource identifier. It is to
- * provide mutability of resource identifier using builder pattern.
- *
- * @return data node builder
- * @throws CloneNotSupportedException if clone fails
- */
- public Builder copyBuilder() throws CloneNotSupportedException {
- return new Builder(this);
- }
-
- @Override
- public int hashCode() {
- return hash(nodeKeyList);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- ResourceId that = (ResourceId) obj;
- List<NodeKey> thatList = that.nodeKeyList;
- return nodeKeyList.size() == thatList.size() &&
- nodeKeyList.containsAll(thatList);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("nodeKeyList", nodeKeyList)
- .toString();
- }
-
- /**
- * Builder to construct resource identifier.
- */
- public static class Builder {
-
- /**
- * Application related information, this enables application to use
- * this builder as there work bench.
- */
- protected Object appInfo;
-
- private List<NodeKey> nodeKeyList;
- private NodeKey.NodeKeyBuilder curKeyBuilder = null;
-
- /**
- * Creates an instance of resource identifier builder.
- */
- public Builder() {
- nodeKeyList = new LinkedList<>();
- }
-
- /**
- * Creates an instance of resource identifier builder. This is used
- * in scenario when builder is required from a given resource
- * identifier.
- *
- * @param id old resource identifier
- * @throws CloneNotSupportedException if clone fails
- */
- public Builder(ResourceId id) throws CloneNotSupportedException {
- nodeKeyList = new LinkedList<>();
- for (NodeKey key : id.nodeKeyList) {
- nodeKeyList.add(key.clone());
- }
- }
-
- /**
- * Appends a given resource id to current builder.
- *
- * @param id resource identifier to be appended
- * @return builder
- * @throws CloneNotSupportedException if clone fails
- */
- public Builder append(ResourceId id) throws CloneNotSupportedException {
- processCurKey();
- curKeyBuilder = null;
- Builder ob = id.copyBuilder();
- nodeKeyList.addAll(ob.nodeKeyList);
- return this;
- }
-
- /**
- * Validates, build and add current key.
- */
- private void processCurKey() {
- if (curKeyBuilder != null) {
- if (curKeyBuilder instanceof LeafListKey.LeafListKeyBuilder) {
- throw new ModelException(LEAF_IS_TERMINAL);
- }
- nodeKeyList.add(curKeyBuilder.build());
- }
- }
-
- /**
- * Adds the descendent node's schema identity.
- *
- * @param name name of descendent node
- * @param nameSpace name space pf descendent node
- * @return updated builder pointing to the specified schema location
- */
- public Builder addBranchPointSchema(String name, String nameSpace) {
- processCurKey();
- curKeyBuilder = new NodeKey.NodeKeyBuilder();
- curKeyBuilder.schemaId(name, nameSpace);
- return this;
- }
-
- /**
- * Adds a multi instance attribute's node identity.
- *
- * @param name name of the leaf list
- * @param nameSpace name space of leaf list
- * @param val value of attribute to identify the instance
- * @return updated builder pointing to the specific attribute
- * value instance
- */
- public Builder addLeafListBranchPoint(String name, String nameSpace,
- Object val) {
- LeafListKey.LeafListKeyBuilder leafListKeyBuilder;
- if (curKeyBuilder instanceof LeafListKey.LeafListKeyBuilder) {
- throw new ModelException(NON_KEY_LEAF);
- }
- leafListKeyBuilder = new LeafListKey.LeafListKeyBuilder()
- .schemaId(name, nameSpace).value(val);
-
- curKeyBuilder = leafListKeyBuilder;
- return this;
- }
-
- /**
- * Adds a multi instance nodes key attribute value to identify
- * the branch point of instance tree.
- *
- * @param name name of the key attribute
- * @param nameSpace name space of key attribute
- * @param val value of the key leaf, to match in the list entry
- * @return updated builder with list branching information
- */
- public Builder addKeyLeaf(String name, String nameSpace, Object val) {
- ListKey.ListKeyBuilder listKeyBuilder;
- if (!(curKeyBuilder instanceof ListKey.ListKeyBuilder)) {
- if (curKeyBuilder instanceof LeafListKey.LeafListKeyBuilder) {
- throw new ModelException(LEAF_IS_TERMINAL);
- }
-
- listKeyBuilder = new ListKey.ListKeyBuilder(curKeyBuilder);
- } else {
- listKeyBuilder = (ListKey.ListKeyBuilder) curKeyBuilder;
- }
-
- listKeyBuilder.addKeyLeaf(name, nameSpace, val);
- curKeyBuilder = listKeyBuilder;
- return this;
- }
-
- /**
- * Builds a resource identifier to based on set path information of
- * the resource.
- *
- * @return built resource identifier
- */
- public ResourceId build() {
- checkNotNull(curKeyBuilder, NO_KEY_SET);
- nodeKeyList.add(curKeyBuilder.build());
- return new ResourceId(this);
- }
-
- /**
- * Returns application information. This enables application to use
- * this builder as there work bench.
- *
- * @return application information
- */
- public Object appInfo() {
- return appInfo;
- }
-
- /**
- * Sets application information. This enables application to use
- * this builder as there work bench.
- *
- * @param appInfo application related information
- */
- public void appInfo(Object appInfo) {
- appInfo = appInfo;
- }
- }
-
- public String asString() {
- StringBuilder bldr = new StringBuilder();
- bldr.append("root.");
- Iterator<NodeKey> iter = nodeKeyList.iterator();
- NodeKey key;
- while (iter.hasNext()) {
- key = iter.next();
- //log.info("Iter: key {}", key.toString());
- bldr.append(key.schemaId().name());
- bldr.append("#");
- bldr.append(key.schemaId().namespace());
- if (iter.hasNext()) {
- bldr.append(".");
- }
- }
- return bldr.toString();
- }
-
- public String lastNm() {
- int sz = nodeKeyList.size();
- return nodeKeyList.get(sz - 1).schemaId().name();
- }
-
- public String lastNmspc() {
- int sz = nodeKeyList.size();
- return nodeKeyList.get(sz - 1).schemaId().namespace();
- }
-}
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/model/SchemaId.java b/apps/config/src/main/java/org/onosproject/config/model/SchemaId.java
deleted file mode 100755
index c7ea7ef..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/SchemaId.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.
- */
-package org.onosproject.config.model;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.config.model.ModelConstants.INCOMPLETE_SCHEMA_INFO;
-
-/**
- * Representation of an entity which identifies a schema node in the schema /
- * data tree.
- */
-public class SchemaId implements Comparable<SchemaId>, Cloneable {
-
- private String name;
- private String nameSpace;
-
- private SchemaId() {
- }
-
- public SchemaId(String name, String nameSpace) {
- checkNotNull(name, INCOMPLETE_SCHEMA_INFO);
- checkNotNull(nameSpace, INCOMPLETE_SCHEMA_INFO);
- this.name = name;
- this.nameSpace = nameSpace;
- }
-
- /**
- * Returns node schema name. This is mandatory to identify node according
- * to schema.
- *
- * @return node name
- */
- public String name() {
- return name;
- }
-
- /**
- * Returns node's namespace. This is mandatory serializers must translate
- * any implicit namespace to explicit namespace.
- *
- * @return node's namespace
- */
- public String namespace() {
- return nameSpace;
- }
-
- /**
- * Creates and returns a deep copy of this object.
- *
- * @return cloned copy
- * @throws CloneNotSupportedException if the object's class does not
- * support the {@code Cloneable} interface
- */
- public SchemaId clone() throws CloneNotSupportedException {
- return (SchemaId) super.clone();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, nameSpace);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- SchemaId that = (SchemaId) obj;
- return Objects.equals(name, that.name) &&
- Objects.equals(nameSpace, that.nameSpace);
- }
-
- @Override
- public int compareTo(SchemaId o) {
- checkNotNull(o);
- if (name.equals(o.name)) {
- if (nameSpace.equals(o.nameSpace)) {
- return 0;
- }
- }
- return -1;
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("name", name)
- .add("nameSpace", nameSpace)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/model/package-info.java b/apps/config/src/main/java/org/onosproject/config/model/package-info.java
deleted file mode 100755
index c6e61b3..0000000
--- a/apps/config/src/main/java/org/onosproject/config/model/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.
- */
-
-/**
- * Dynamic config data model, hollow definitions for APIs.
- * Will be REMOVED when the yang/model/* are available.
- */
-package org.onosproject.config.model;
\ No newline at end of file