YMS broker and Notification handler

Change-Id: Ic3659b2c2ad26ea2db1f03725b4883f19db2cc41
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/Ydt.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/Ydt.java
index 72790e2..9b27d5e 100644
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/Ydt.java
+++ b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/Ydt.java
@@ -16,8 +16,6 @@
 
 package org.onosproject.yms.ydt;
 
-import org.onosproject.yms.ymsm.YmsOperationType;
-
 /**
  * Abstraction of an entity which represent YANG data tree. This is used
  * for exchanging information between YANG management system and NBI protocol.
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtBuilder.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtBuilder.java
index b31ce04..f6a7f6e 100644
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtBuilder.java
+++ b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtBuilder.java
@@ -183,14 +183,26 @@
     void addLeaf(String name, String namespace, Set<String> valueSet);
 
     /**
-     * Adds YANG list's keys value in the order defined in list's key statement.
-     * All the keys must be present any missing key or invalid key will result
-     * in exception.
+     * Adds an instance of a child list node, or adds a child leaf list with
+     * multiple instance.
+     * In case the name and namespace identifies the child list node, then
+     * the values for all the key leaves must be passed in the same order of
+     * schema. Then the effective YANG data tree will be like adding a  list
+     * node, followed by adding the key leaves as the child to the list node.
+     * After this operation, the call to getCurNode will return the list node.
+     * In case the name and namespace identifies the child leaf-list, then
+     * the values identifies the instance of leaf list.
+     * After this operation, the call to getCurNode will return the leaf-list
+     * node.
      *
-     * @param keysValueList values of the keys in URI in the same order
-     *                      as defined in YANG file
+     * @param name      name of child to be added
+     * @param namespace namespace of child to be added, if it's null, parent's
+     *                  namespace will be applied to child
+     * @param valueList values of the keys in URI in the same order
+     *                  as defined in YANG file
      */
-    void addKeyLeafs(List<String> keysValueList);
+    void addMultiInstanceChild(String name, String namespace,
+                               List<String> valueList);
 
     /**
      * Traverses up in YANG data tree to the parent node, it is to be used when
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextResponseInfo.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextResponseInfo.java
index 279d33e..b912fcf 100644
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextResponseInfo.java
+++ b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextResponseInfo.java
@@ -22,5 +22,11 @@
  * operation result etc.
  */
 public interface YdtContextResponseInfo {
-    //TODO
+
+    /**
+     * Retrieve the context specific error information.
+     *
+     * @return context specific error information
+     */
+    YdtErrorInfo getYdtErrorInfo();
 }
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtErrorInfo.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtErrorInfo.java
new file mode 100644
index 0000000..283bee4
--- /dev/null
+++ b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtErrorInfo.java
@@ -0,0 +1,39 @@
+/*
+ * 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.yms.ydt;
+
+/**
+ * Abstraction of an entity which contains context specific error info.
+ */
+public interface YdtErrorInfo {
+    /**
+     * Retrieves the application specific error tag corresponding to the
+     * error context in operation.
+     *
+     * @return application specific error tag corresponding to the error
+     * context in operation
+     */
+    String getErrorAppTag();
+
+    /**
+     * Retrieves the error message corresponding to the error context in
+     * operation.
+     *
+     * @return the error message corresponding to the error context in operation
+     */
+    String getErrorMessage();
+}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationExecutionStatus.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationExecutionStatus.java
index 3ac63ee..2213a3f 100644
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationExecutionStatus.java
+++ b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationExecutionStatus.java
@@ -26,9 +26,22 @@
  * YANG management system is responsible to split the protocol operation
  * across application(s) which needs to participate, and collate the
  * response(s) from application(s) and return an effective result of the
- * operation request. The result of the operation request is returned in
- * YMS operation result.
+ * operation request. The status of the operation execution is returned.
  */
-public interface YmsOperationExecutionStatus {
-    // TODO
+public enum YmsOperationExecutionStatus {
+
+    /**
+     * Successful execution of the operation.
+     */
+    EXECUTION_SUCCESS,
+
+    /**
+     * Exception in execution of the operation.
+     */
+    EXECUTION_EXCEPTION,
+
+    /**
+     * Error in execution of the operation.
+     */
+    ERROR_EXCEPTION
 }
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationType.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationType.java
new file mode 100644
index 0000000..f31e230
--- /dev/null
+++ b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationType.java
@@ -0,0 +1,104 @@
+/*
+ * 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.yms.ydt;
+
+/**
+ * Represents type of root level operation for the request.
+ *
+ * This is used by protocols to specify the root level operation associated
+ * with the request. YMS data validation and data handling will vary based
+ * on the edit operation type, for an instance YANG specified "mandatory"
+ * leafs needn't be present for QUERY_CONFIG and QUERY, but they may be
+ * mandatory to be present in request for EDIT_CONFIG type. The validation
+ * and handling is further dependent on edit operation type.
+ *
+ * In SBI, driver/provider must provide this information to YMS which needs
+ * to encode this information in corresponding data format.
+ *
+ * YmsOperationType MUST be specified by protocol.
+ */
+
+/*
+ * Yang interaction type with RESTCONF and NETCONF as example:
+ * +--------------+-------------------+-------------+
+ * | RESTCONF     | NETCONF           | EditOpType  |
+ * +--------------+-------------------+-------------+
+ * | OPTIONS      | NA                | NA          |
+ * | HEAD         | NA                | NA          |
+ * | GET          | <get>             | QUERY       |
+ * | none         | <get-config>      | QUERY_CONFIG|
+ * | POST (data)  | <edit-config>     | EDIT_CONFIG |
+ * | PUT          | <edit-config>     | EDIT_CONFIG |
+ * | PATCH        | <edit-config>     | EDIT_CONFIG |
+ * | DELETE       | <edit-config>     | EDIT_CONFIG |
+ * | POST (op)    | <rpc>             | RPC         |
+ * +--------------+-------------------+-------------+
+ *
+ * Note: Additionally RESTCONF must use API resource to figure out whether
+ * request contains data resource or it's for data model specific operation.
+ * +--rw restconf
+ * +--rw data
+ * +--rw operations
+ */
+public enum YmsOperationType {
+    /**
+     * The YANG based request is to edit a config node / subtree in the data
+     * store.
+     */
+    EDIT_CONFIG_REQUEST,
+
+    /**
+     * The YANG based request is to query a config node / subtree in the data
+     * store.
+     */
+    QUERY_CONFIG_REQUEST,
+
+    /**
+     * The YANG based request is to query a node / subtree in the data store.
+     */
+    QUERY_REQUEST,
+
+    /**
+     * The YANG based request is to execute an RPC defined in YANG.
+     */
+    RPC_REQUEST,
+
+    /**
+     * The YANG based response is for edit operation.
+     */
+    EDIT_CONFIG_REPLY,
+
+    /**
+     * The YANG based response is for query config operation.
+     */
+    QUERY_CONFIG_REPLY,
+
+    /**
+     * The YANG based response is for query operation.
+     */
+    QUERY_REPLY,
+
+    /**
+     * The YANG based response is for a RPC operation.
+     */
+    RPC_REPLY,
+
+    /**
+     * The YANG based request is to execute an RPC defined in YANG.
+     */
+    NOTIFICATION
+}