Bumping ONOS to point to ONOS YANG Tools 2.2.0-b2

Change-Id: I23b2ed67ed0fb5ef4ec0731a37dcd8b058102298
diff --git a/apps/yang/src/main/java/org/onosproject/yang/YangRuntimeManager.java b/apps/yang/src/main/java/org/onosproject/yang/YangRuntimeManager.java
index b1867f6..063051b 100644
--- a/apps/yang/src/main/java/org/onosproject/yang/YangRuntimeManager.java
+++ b/apps/yang/src/main/java/org/onosproject/yang/YangRuntimeManager.java
@@ -29,9 +29,12 @@
 import org.onosproject.yang.model.NodeKey;
 import org.onosproject.yang.model.ResourceData;
 import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.RpcContext;
 import org.onosproject.yang.model.SchemaContext;
 import org.onosproject.yang.model.SchemaContextProvider;
 import org.onosproject.yang.model.YangModel;
+import org.onosproject.yang.model.YangModule;
+import org.onosproject.yang.model.YangModuleId;
 import org.onosproject.yang.runtime.CompositeData;
 import org.onosproject.yang.runtime.CompositeStream;
 import org.onosproject.yang.runtime.ModelRegistrationParam;
@@ -41,6 +44,7 @@
 import org.onosproject.yang.runtime.YangSerializer;
 import org.onosproject.yang.runtime.YangSerializerRegistry;
 import org.onosproject.yang.runtime.impl.DefaultModelConverter;
+import org.onosproject.yang.runtime.impl.DefaultSchemaContextProvider;
 import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
 import org.onosproject.yang.runtime.impl.DefaultYangRuntimeHandler;
 import org.onosproject.yang.runtime.impl.DefaultYangSerializerRegistry;
@@ -73,14 +77,15 @@
     private DefaultYangSerializerRegistry serializerRegistry;
     private DefaultYangRuntimeHandler runtimeService;
     private DefaultModelConverter modelConverter;
+    private DefaultSchemaContextProvider schemaContextProvider;
 
     @Activate
     public void activate() {
         coreService.registerApplication(APP_ID);
         serializerRegistry = new DefaultYangSerializerRegistry();
         modelRegistry = new DefaultYangModelRegistry();
-        runtimeService =
-                new DefaultYangRuntimeHandler(serializerRegistry, modelRegistry);
+        runtimeService = new DefaultYangRuntimeHandler(serializerRegistry, modelRegistry);
+        schemaContextProvider = new DefaultSchemaContextProvider(modelRegistry);
         serializerRegistry.registerSerializer(new JsonSerializer());
         serializerRegistry.registerSerializer(new XmlSerializer());
         modelConverter = new DefaultModelConverter(modelRegistry);
@@ -109,6 +114,16 @@
     }
 
     @Override
+    public YangModel getModel(String s) {
+        return modelRegistry.getModel(s);
+    }
+
+    @Override
+    public YangModule getModule(YangModuleId yangModuleId) {
+        return modelRegistry.getModule(yangModuleId);
+    }
+
+    @Override
     public void registerSerializer(YangSerializer ys) {
         serializerRegistry.registerSerializer(ys);
     }
@@ -154,4 +169,9 @@
         log.info("To be implemented.");
         return null;
     }
+
+    @Override
+    public RpcContext getRpcContext(ResourceId resourceId) {
+        return schemaContextProvider.getRpcContext(resourceId);
+    }
 }
diff --git a/apps/yang/web/src/main/java/org/onosproject/yang/web/YangWebResource.java b/apps/yang/web/src/main/java/org/onosproject/yang/web/YangWebResource.java
index 471e891..41830fc 100644
--- a/apps/yang/web/src/main/java/org/onosproject/yang/web/YangWebResource.java
+++ b/apps/yang/web/src/main/java/org/onosproject/yang/web/YangWebResource.java
@@ -25,6 +25,7 @@
 import org.onosproject.yang.compiler.api.YangCompilerService;
 import org.onosproject.yang.compiler.datamodel.YangNode;
 import org.onosproject.yang.compiler.tool.DefaultYangCompilationParam;
+import org.onosproject.yang.compiler.tool.YangCompilerManager;
 import org.onosproject.yang.model.YangModel;
 import org.onosproject.yang.runtime.DefaultModelRegistrationParam;
 import org.onosproject.yang.runtime.ModelRegistrationParam;
@@ -48,9 +49,9 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.deSerializeDataModel;
+import static org.onosproject.yang.compiler.tool.YangCompilerManager.deSerializeDataModel;
+import static org.onosproject.yang.compiler.tool.YangCompilerManager.processYangModel;
 import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.deleteDirectory;
-import static org.onosproject.yang.runtime.helperutils.YangApacheUtils.processYangModel;
 
 /**
  * Yang files upload resource.
@@ -141,39 +142,40 @@
 
     private YangCompilationParam createCompilationParam(List<File> inputFiles)
             throws IOException {
-        YangCompilationParam param = new DefaultYangCompilationParam();
+        DefaultYangCompilationParam.Builder builder = DefaultYangCompilationParam.builder();
         for (File file : inputFiles) {
             if (file.getName().endsWith(JAR_FILE_EXTENSION)
                     || file.getName().endsWith(ZIP_FILE_EXTENSION)) {
                 List<File> files = decompressFile(file);
 
                 for (File f : files) {
-                    param = addToParam(param, f);
+                    addToParam(builder, f);
                 }
             } else {
-                param = addToParam(param, file);
+                addToParam(builder, file);
             }
         }
-        param.setCodeGenDir(Paths.get(CODE_GEN_DIR));
-        param.setMetadataGenDir(Paths.get(YANG_RESOURCES));
-        return param;
+        builder.setCodeGenDir(Paths.get(CODE_GEN_DIR));
+        builder.setMetadataGenDir(Paths.get(YANG_RESOURCES));
+        return builder.build();
     }
 
-    private YangCompilationParam addToParam(YangCompilationParam param,
+    private void addToParam(DefaultYangCompilationParam.Builder builder,
                                             File file) {
         if (file.getName().endsWith(YANG_FILE_EXTENSION)) {
-            param.addYangFile(Paths.get(file.getAbsolutePath()));
+            builder.addYangFile(Paths.get(file.getAbsolutePath()));
         } else if (file.getName().endsWith(SER_FILE_EXTENSION)) {
-            param.addDependentSchema(Paths.get(file.getAbsolutePath()));
+            builder.addDependentSchema(Paths.get(file.getAbsolutePath()));
         }
-        return param;
     }
 
     private ModelRegistrationParam getModelRegParam() throws IOException {
         String metaPath = YANG_RESOURCES + SERIALIZED_FILE_NAME;
         List<YangNode> curNodes = getYangNodes(metaPath);
+        // FIXME: extract or derive the model id from the web request
+        String modelId = "unknown";
         if (curNodes != null && !curNodes.isEmpty()) {
-            YangModel model = processYangModel(metaPath, curNodes);
+            YangModel model = processYangModel(metaPath, curNodes, modelId, false);
             return DefaultModelRegistrationParam.builder()
                     .setYangModel(model).build();
         }
@@ -184,7 +186,7 @@
         List<YangNode> nodes = new LinkedList<>();
         File file = new File(path);
         if (file.getName().endsWith(SER_FILE_EXTENSION)) {
-            nodes.addAll(deSerializeDataModel(file.toString()));
+            nodes.addAll(YangCompilerManager.getYangNodes(deSerializeDataModel(file.toString())));
         }
         return nodes;
     }