Remove old RESTCONF server implemenation
Change-Id: I8a225a6bfc3552acdfbb2148a73e85cbb9ca3d93
diff --git a/protocols/restconf/server/BUCK b/protocols/restconf/server/BUCK
index e08b996..b6ac9d4 100644
--- a/protocols/restconf/server/BUCK
+++ b/protocols/restconf/server/BUCK
@@ -1,8 +1,5 @@
BUNDLES = [
- '//protocols/restconf/server/api:onos-protocols-restconf-server-api',
- '//protocols/restconf/server/restconfmgr:onos-protocols-restconf-server-restconfmgr',
'//protocols/restconf/server/rpp:onos-protocols-restconf-server-rpp',
- '//protocols/restconf/server/utils:onos-protocols-restconf-server-utils',
]
onos_app (
diff --git a/protocols/restconf/server/api/BUCK b/protocols/restconf/server/api/BUCK
deleted file mode 100644
index 97d99aa..0000000
--- a/protocols/restconf/server/api/BUCK
+++ /dev/null
@@ -1,10 +0,0 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//lib:jersey-client',
- '//lib:javax.ws.rs-api',
- '//lib:jersey-server',
-]
-
-osgi_jar_with_tests (
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/restconf/server/api/pom.xml b/protocols/restconf/server/api/pom.xml
deleted file mode 100644
index e262726..0000000
--- a/protocols/restconf/server/api/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-restconf-server</artifactId>
- <version>1.10.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-restconf-server-api</artifactId>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-core-serializers</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet</artifactId>
- </dependency>
- </dependencies>
-
-</project>
-
diff --git a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/Patch.java b/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/Patch.java
deleted file mode 100644
index 5004944..0000000
--- a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/Patch.java
+++ /dev/null
@@ -1,32 +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.protocol.restconf.server.api;
-
-import javax.ws.rs.HttpMethod;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates that the annotated method responds to HTTP PATCH requests.
- */
-@Target({ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@HttpMethod("PATCH")
-public @interface Patch {
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfException.java b/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfException.java
deleted file mode 100644
index e6b572c..0000000
--- a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfException.java
+++ /dev/null
@@ -1,67 +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.protocol.restconf.server.api;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-
-import static javax.ws.rs.core.Response.Status;
-
-/**
- * Exceptions raised during RESTCONF operations. This class extends
- * WebApplicationException. The design intention is to create a place holder
- * for RESTCONF specific errors and to be able to add more functions as the
- * subsystem grows.
- */
-public class RestconfException extends WebApplicationException {
-
- // This is a randomly generated value. A WebApplicationException class is required to define it.
- private static final long SERIAL_VERSION_UID = 3275970397584007046L;
-
- /**
- * Constructs a new RESTCONF server error exception. The caller raising this
- * exception may pass in a HTTP error status code and an error message. The
- * error code will be displayed to the RESTCONF client as part of the
- * response from the RESTCONF server. The error message is a string which
- * may be saved in a log file and may be later retrieved by the
- * getMessage() method.
- *
- * @param message the detailed error message
- * @param status HTTP error status
- * @throws IllegalArgumentException in case the status code is null or is not from
- * javax.ws.rs.core.Response.Status.Family
- * status code family
- */
- public RestconfException(String message, Status status) {
- super(message, null, Response.status(status).build());
- }
-
- /**
- * Constructs a new RESTCONF server error exception. The caller raising
- * this exception may pass in the numerical value of a HTTP error
- * status code, The error code will be displayed to the RESTCONF client
- * as a response from the RESTCONF server.
- *
- * @param status HTTP error status
- * @throws IllegalArgumentException in case the status code is not a valid
- * HTTP status code or if it is not from the
- * javax.ws.rs.core.Response.Status.Family
- * status code family
- */
- public RestconfException(int status) {
- super((Throwable) null, Response.status(status).build());
- }
-}
diff --git a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfService.java b/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfService.java
deleted file mode 100644
index fb8a975..0000000
--- a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfService.java
+++ /dev/null
@@ -1,134 +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.protocol.restconf.server.api;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.glassfish.jersey.server.ChunkedOutput;
-
-/**
- * Abstraction of RESTCONF Server functionality according to the
- * RESTCONF RFC (no official RFC number yet).
- * <p>
- * NOTE: This interface will be obsolete and will be replaced by the one
- * in the RESTCONF application.
- */
-@Deprecated
-public interface RestconfService {
- /**
- * Processes a GET request against a data resource. The
- * target data resource is identified by its URI. If the
- * GET operation cannot be fulfilled due to reasons such
- * as the nonexistence of the target resource, then a
- * RestconfException exception is raised. The proper
- * HTTP error status code is enclosed in the exception, so
- * that the caller may return it to the RESTCONF client to
- * display.
- *
- * @param uri URI of the target data resource
- * @return JSON representation of the data resource
- * @throws RestconfException if the GET operation cannot be fulfilled
- */
- ObjectNode runGetOperationOnDataResource(String uri)
- throws RestconfException;
-
- /**
- * Processes a POST request against a data resource. The location of
- * the target resource is passed in as a URI. And the resource's
- * content is passed in as a JSON ObjectNode. If the POST operation
- * cannot be fulfilled due to reasons such as wrong input URIs or
- * syntax errors in the JSON payloads, a RestconfException exception
- * is raised. The proper HTTP error status code is enclosed in the
- * exception.
- *
- * @param uri URI of the data resource to be created
- * @param rootNode JSON representation of the data resource
- * @throws RestconfException if the POST operation cannot be fulfilled
- */
- void runPostOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException;
-
- /**
- * Processes a PUT request against a data resource. The location of
- * the target resource is passed in as a URI. And the resource's
- * content is passed in as a JSON ObjectNode. If the PUT operation
- * cannot be fulfilled due to reasons such as wrong input URIs or
- * syntax errors in the JSON payloads, a RestconfException exception
- * is raised. The proper HTTP error status code is enclosed in the
- * exception.
- *
- * @param uri URI of the data resource to be created or updated
- * @param rootNode JSON representation of the data resource
- * @throws RestconfException if the PUT operation cannot be fulfilled
- */
- void runPutOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException;
-
- /**
- * Processes the DELETE operation against a data resource. The target
- * data resource is identified by its URI. If the DELETE operation
- * cannot be fulfilled due reasons such as the nonexistence of the
- * target resource, a RestconfException exception is raised. The
- * proper HTTP error status code is enclosed in the exception.
- *
- * @param uri URI of the data resource to be deleted
- * @throws RestconfException if the DELETE operation cannot be fulfilled
- */
- void runDeleteOperationOnDataResource(String uri) throws RestconfException;
-
- /**
- * Processes a PATCH operation on a data resource. The target data
- * resource is identified by its URI passed in by the caller.
- * And the content of the data resource is passed in as a JSON ObjectNode.
- * If the PATCH operation cannot be fulfilled due reasons such as
- * the nonexistence of the target resource, a RestconfException
- * exception is raised. The proper HTTP error status code is
- * enclosed in the exception.
- *
- * @param uri URI of the data resource to be patched
- * @param rootNode JSON representation of the data resource
- * @throws RestconfException if the PATCH operation cannot be fulfilled
- */
- void runPatchOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException;
-
- /**
- * Retrieves the RESTCONF Root directory.
- *
- * @return the RESTCONF Root directory
- */
- String getRestconfRootPath();
-
- /**
- * Handles an Event Stream subscription request. This function creates
- * a worker thread to listen to events and writes to a ChunkedOutput,
- * which is passed in from the caller. (The worker thread blocks if
- * no events arrive.) The ChuckedOutput is a pipe to which this
- * function acts as the writer and the caller the reader.
- * <p>
- * If the Event Stream cannot be subscribed due to reasons such as
- * the nonexistence of the target stream or failure to allocate
- * worker thread to handle the request, a RestconfException exception
- * is raised. The proper HTTP error status code is enclosed in the
- * exception, so that the caller may return it to the RESTCONF client
- * to display.
- *
- * @param streamId ID of the RESTCONF stream to subscribe
- * @param output A string data stream
- * @throws RestconfException if the Event Stream cannot be subscribed
- */
- void subscribeEventStream(String streamId, ChunkedOutput<String> output)
- throws RestconfException;
-}
diff --git a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfServiceBroker.java b/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfServiceBroker.java
deleted file mode 100644
index b5a0c53..0000000
--- a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/RestconfServiceBroker.java
+++ /dev/null
@@ -1,130 +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.protocol.restconf.server.api;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.glassfish.jersey.server.ChunkedOutput;
-
-/**
- * Representation of a RESTCONF service broker. The broker
- * provides services to the RESTCONF protocol proxy.
- */
-public interface RestconfServiceBroker {
- /**
- * Processes a GET request against a data resource. The
- * target data resource is identified by its URI. If the
- * GET operation cannot be fulfilled due to reasons such
- * as the nonexistence of the target resource, then a
- * RestconfException exception is raised. The proper
- * HTTP error status code is enclosed in the exception, so
- * that the caller may return it to the RESTCONF client to
- * display.
- *
- * @param uri URI of the target data resource
- * @return JSON representation of the data resource
- * @throws RestconfException if the GET operation cannot be fulfilled
- */
- ObjectNode runGetOperationOnDataResource(String uri)
- throws RestconfException;
-
- /**
- * Processes a POST request against a data resource. The location of
- * the target resource is passed in as a URI. And the resource's
- * content is passed in as a JSON ObjectNode. If the POST operation
- * cannot be fulfilled due to reasons such as wrong input URIs or
- * syntax errors in the JSON payloads, a RestconfException exception
- * is raised. The proper HTTP error status code is enclosed in the
- * exception.
- *
- * @param uri URI of the data resource to be created
- * @param rootNode JSON representation of the data resource
- * @throws RestconfException if the POST operation cannot be fulfilled
- */
- void runPostOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException;
-
- /**
- * Processes a PUT request against a data resource. The location of
- * the target resource is passed in as a URI. And the resource's
- * content is passed in as a JSON ObjectNode. If the PUT operation
- * cannot be fulfilled due to reasons such as wrong input URIs or
- * syntax errors in the JSON payloads, a RestconfException exception
- * is raised. The proper HTTP error status code is enclosed in the
- * exception.
- *
- * @param uri URI of the data resource to be created or updated
- * @param rootNode JSON representation of the data resource
- * @throws RestconfException if the PUT operation cannot be fulfilled
- */
- void runPutOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException;
-
- /**
- * Processes the DELETE operation against a data resource. The target
- * data resource is identified by its URI. If the DELETE operation
- * cannot be fulfilled due reasons such as the nonexistence of the
- * target resource, a RestconfException exception is raised. The
- * proper HTTP error status code is enclosed in the exception.
- *
- * @param uri URI of the data resource to be deleted
- * @throws RestconfException if the DELETE operation cannot be fulfilled
- */
- void runDeleteOperationOnDataResource(String uri) throws RestconfException;
-
- /**
- * Processes a PATCH operation on a data resource. The target data
- * resource is identified by its URI passed in by the caller.
- * And the content of the data resource is passed in as a JSON ObjectNode.
- * If the PATCH operation cannot be fulfilled due reasons such as
- * the nonexistence of the target resource, a RestconfException
- * exception is raised. The proper HTTP error status code is
- * enclosed in the exception.
- *
- * @param uri URI of the data resource to be patched
- * @param rootNode JSON representation of the data resource
- * @throws RestconfException if the PATCH operation cannot be fulfilled
- */
- void runPatchOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException;
-
- /**
- * Retrieves the RESTCONF Root directory.
- *
- * @return the RESTCONF Root directory
- */
- String getRestconfRootPath();
-
- /**
- * Handles an Event Stream subscription request. This function creates
- * a worker thread to listen to events and writes to a ChunkedOutput,
- * which is passed in from the caller. (The worker thread blocks if
- * no events arrive.) The ChuckedOutput is a pipe to which this
- * function acts as the writer and the caller the reader.
- * <p>
- * If the Event Stream cannot be subscribed due to reasons such as
- * the nonexistence of the target stream or failure to allocate
- * worker thread to handle the request, a RestconfException exception
- * is raised. The proper HTTP error status code is enclosed in the
- * exception, so that the caller may return it to the RESTCONF client
- * to display.
- *
- * @param streamId ID of the RESTCONF stream to subscribe
- * @param output A string data stream
- * @throws RestconfException if the Event Stream cannot be subscribed
- */
- void subscribeEventStream(String streamId, ChunkedOutput<String> output)
- throws RestconfException;
-}
diff --git a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/package-info.java b/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/package-info.java
deleted file mode 100644
index e0bb150..0000000
--- a/protocols/restconf/server/api/src/main/java/org/onosproject/protocol/restconf/server/api/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.
- */
-
-/**
- * RESTCONF Server Public Interface. All public interfaces/APIs that might be used by
- * external applications should be packaged here.
- */
-package org.onosproject.protocol.restconf.server.api;
diff --git a/protocols/restconf/server/app/app.xml b/protocols/restconf/server/app/app.xml
index 28775b6..af3eee8 100644
--- a/protocols/restconf/server/app/app.xml
+++ b/protocols/restconf/server/app/app.xml
@@ -19,8 +19,5 @@
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
features="${project.artifactId}" >
<description>${project.description}</description>
- <artifact>mvn:${project.groupId}/onos-restconf-server-api/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-restconf-server-restconfmanager/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-restconf-server-rpp/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-restconf-server-utils/${project.version}</artifact>
</app>
diff --git a/protocols/restconf/server/app/features.xml b/protocols/restconf/server/app/features.xml
index 2ef4707..d38c562 100644
--- a/protocols/restconf/server/app/features.xml
+++ b/protocols/restconf/server/app/features.xml
@@ -18,9 +18,6 @@
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
- <bundle>mvn:${project.groupId}/onos-restconf-server-api/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-restconf-server-restconfmanager/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-restconf-server-rpp/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-restconf-server-utils/${project.version}</bundle>
</feature>
</features>
diff --git a/protocols/restconf/server/pom.xml b/protocols/restconf/server/pom.xml
index 31e5fb4..31947c6 100644
--- a/protocols/restconf/server/pom.xml
+++ b/protocols/restconf/server/pom.xml
@@ -30,12 +30,9 @@
<packaging>pom</packaging>
<modules>
- <module>api</module>
- <module>restconfmgr</module>
<module>rpp</module>
<module>app</module>
- <module>utils</module>
</modules>
- <description>RESTCONF Server Module</description>
+ <description>RESTCONF Server-side Protocol Module</description>
</project>
diff --git a/protocols/restconf/server/restconfmgr/BUCK b/protocols/restconf/server/restconfmgr/BUCK
deleted file mode 100644
index 8b01d0e..0000000
--- a/protocols/restconf/server/restconfmgr/BUCK
+++ /dev/null
@@ -1,17 +0,0 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//lib:jersey-client',
- '//lib:jersey-server',
- '//lib:javax.ws.rs-api',
- '//utils/rest:onlab-rest',
- '//core/store/serializers:onos-core-serializers',
- '//incubator/api:onos-incubator-api',
- '//apps/restconf/api:onos-apps-restconf-api',
- '//protocols/restconf/server/api:onos-protocols-restconf-server-api',
- '//protocols/restconf/server/utils:onos-protocols-restconf-server-utils',
- '//apps/yms/api:onos-apps-yms-api',
-]
-
-osgi_jar_with_tests (
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/restconf/server/restconfmgr/pom.xml b/protocols/restconf/server/restconfmgr/pom.xml
deleted file mode 100644
index aaed7cc..0000000
--- a/protocols/restconf/server/restconfmgr/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-restconf-server</artifactId>
- <version>1.10.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-restconf-server-restconfmanager</artifactId>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-restconf-server-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-rest</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-rest</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-misc</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-restconf-server-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-yms-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-restconf-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfBrokerImpl.java b/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfBrokerImpl.java
deleted file mode 100644
index e59805f..0000000
--- a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfBrokerImpl.java
+++ /dev/null
@@ -1,184 +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.protocol.restconf.server.restconfmanager;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.glassfish.jersey.server.ChunkedOutput;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.config.basics.ConfigException;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.protocol.restconf.server.api.RestconfException;
-import org.onosproject.protocol.restconf.server.api.RestconfServiceBroker;
-import org.onosproject.restconf.api.RestconfService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UPDATED;
-import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
-
-/**
- * Implementation of the RestconfServiceBroker interface.
- */
-@Component(immediate = true)
-@Service
-public class RestconfBrokerImpl implements RestconfServiceBroker {
-
- private static final String APP_NAME = "org.onosproject.protocols.restconfserver";
- private static final String CONFIG_KEY = "restconfCfg";
- private static final String DYN_CONFIG_MODE = "true";
- private static final String RESTCONF_ROOT = "/onos/restconf";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected NetworkConfigRegistry cfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected org.onosproject.protocol.restconf.server.api.RestconfService restconfYms;
-
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected RestconfService restconfDynConfig;
-
- private ApplicationId appId;
- private boolean useDynamicConfig = true;
-
- private final NetworkConfigListener cfgLister = new InternalConfigListener();
- private final ConfigFactory<ApplicationId, RestconfConfig> factory =
- new ConfigFactory<ApplicationId, RestconfConfig>(APP_SUBJECT_FACTORY,
- RestconfConfig.class,
- CONFIG_KEY,
- false) {
- @Override
- public RestconfConfig createConfig() {
- return new RestconfConfig();
- }
- };
-
- @Activate
- protected void activate() {
- appId = coreService.registerApplication(APP_NAME);
- cfgService.registerConfigFactory(factory);
- cfgService.addListener(cfgLister);
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- cfgService.removeListener(cfgLister);
- cfgService.unregisterConfigFactory(factory);
- log.info("Stopped");
- }
-
- @Override
- public ObjectNode runGetOperationOnDataResource(String uri)
- throws RestconfException {
- return useDynamicConfig ?
- restconfDynConfig.runGetOperationOnDataResource(uri) :
- restconfYms.runGetOperationOnDataResource(uri);
- }
-
-
- @Override
- public void runPostOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException {
- if (useDynamicConfig) {
- restconfDynConfig.runPostOperationOnDataResource(uri, rootNode);
- } else {
- restconfYms.runPostOperationOnDataResource(uri, rootNode);
- }
- }
-
- @Override
- public void runPutOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException {
- if (useDynamicConfig) {
- restconfDynConfig.runPutOperationOnDataResource(uri, rootNode);
- } else {
- restconfYms.runPutOperationOnDataResource(uri, rootNode);
- }
- }
-
- @Override
- public void runDeleteOperationOnDataResource(String uri)
- throws RestconfException {
- if (useDynamicConfig) {
- restconfDynConfig.runDeleteOperationOnDataResource(uri);
- } else {
- restconfYms.runDeleteOperationOnDataResource(uri);
- }
- }
-
- @Override
- public void runPatchOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException {
- if (useDynamicConfig) {
- restconfDynConfig.runPatchOperationOnDataResource(uri, rootNode);
- } else {
- restconfYms.runPatchOperationOnDataResource(uri, rootNode);
- }
- }
-
- @Override
- public String getRestconfRootPath() {
- return RESTCONF_ROOT;
- }
-
- @Override
- public void subscribeEventStream(String streamId,
- ChunkedOutput<String> output)
- throws RestconfException {
- if (useDynamicConfig) {
- restconfDynConfig.subscribeEventStream(streamId, output);
- } else {
- restconfYms.subscribeEventStream(streamId, output);
- }
- }
-
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- try {
- useDynamicConfig = cfgService.getConfig(appId, RestconfConfig.class)
- .useDynamicConfig().equals(DYN_CONFIG_MODE);
- } catch (ConfigException e) {
- log.error("Configuration error {}", e);
- }
- }
-
- @Override
- public boolean isRelevant(NetworkConfigEvent event) {
- return event.configClass().equals(RestconfConfig.class) &&
- (event.type() == CONFIG_ADDED ||
- event.type() == CONFIG_UPDATED);
- }
- }
-}
diff --git a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfConfig.java b/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfConfig.java
deleted file mode 100644
index 2dd6bb0..0000000
--- a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfConfig.java
+++ /dev/null
@@ -1,45 +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.protocol.restconf.server.restconfmanager;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.config.basics.ConfigException;
-import org.onosproject.net.config.Config;
-
-/**
- * Configuration for TE Topology parameters.
- */
-public class RestconfConfig extends Config<ApplicationId> {
- private static final String CONFIG_VALUE_ERROR = "Error parsing config value";
- private static final String USE_DNY_CONFIG = "use-dyn-config";
-
-
- /**
- * Retrieves whether RESTCONF should use Dynamic Config service.
- *
- * @return string value of true or false
- * @throws ConfigException if the parameters are not correctly configured or
- * conversion of the parameters fails
- */
- public String useDynamicConfig() throws ConfigException {
- try {
- return object.path(USE_DNY_CONFIG).asText();
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
- }
-
-}
diff --git a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfManager.java b/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfManager.java
deleted file mode 100644
index e041f1c..0000000
--- a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/RestconfManager.java
+++ /dev/null
@@ -1,423 +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.protocol.restconf.server.restconfmanager;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.glassfish.jersey.server.ChunkedOutput;
-import org.onosproject.event.ListenerTracker;
-import org.onosproject.protocol.restconf.server.api.RestconfException;
-import org.onosproject.protocol.restconf.server.api.RestconfService;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtResponse;
-import org.onosproject.yms.ydt.YmsOperationExecutionStatus;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ymsm.YmsService;
-import org.onosproject.yms.ynh.YangNotificationEvent;
-import org.onosproject.yms.ynh.YangNotificationListener;
-import org.onosproject.yms.ynh.YangNotificationService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Map.Entry;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.convertJsonToYdt;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.convertUriToYdt;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.convertYdtToJson;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.getJsonNameFromYdtNode;
-import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.REPLACE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YmsOperationExecutionStatus.EXECUTION_EXCEPTION;
-import static org.onosproject.yms.ydt.YmsOperationExecutionStatus.EXECUTION_SUCCESS;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
-
-/*
- * Skeletal ONOS RESTCONF Server application. The RESTCONF Manager
- * implements the main logic of the RESTCONF Server.
- *
- * The design of the RESTCONF subsystem contains 2 major bundles:
- *
- * 1. RESTCONF Protocol Proxy (RPP). This bundle is implemented as a
- * JAX-RS application. It acts as the frond-end of the RESTCONF server.
- * It intercepts/handles HTTP requests that are sent to the RESTCONF
- * Root Path. It then calls the RESTCONF Manager to process the requests.
- *
- * 2. RESTCONF Manager. This bundle module is the back-end of the server.
- * It provides the main logic of the RESTCONF server. It interacts with
- * the YMS (YANG Management System) to run operations on the YANG data
- * objects (i.e., data resources).
- *
- * NOTE: This implementation will be obsolete and will be replaced by the
- * RESTCONF application.
- */
-
-/**
- * Implementation of the RestconfService interface. The class is designed
- * as a Apache Flex component. Note that to avoid unnecessary
- * activation, the @Component annotation's immediate parameter is set to false.
- * So the component is not activated until a RESTCONF request is received by
- * the RESTCONF Protocol Proxy (RPP) module, which consumes the service.
- */
-@Component(immediate = false)
-@Service
-public class RestconfManager implements RestconfService {
-
- private static final String RESTCONF_ROOT = "/onos/restconf";
- private static final int THREAD_TERMINATION_TIMEOUT = 10;
-
- // Jersey's default chunk parser uses "\r\n" as the chunk separator.
- private static final String EOL = "\r\n";
-
- private final int maxNumOfWorkerThreads = 5;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected YmsService ymsService;
-
- protected YangNotificationService ymsNotificationService;
-
- private ListenerTracker listeners;
-
- private ConcurrentMap<String, BlockingQueue<ObjectNode>> eventQueueList =
- new ConcurrentHashMap<>();
-
- private ExecutorService workerThreadPool;
-
- @Activate
- protected void activate() {
- workerThreadPool = Executors
- .newFixedThreadPool(maxNumOfWorkerThreads,
- new ThreadFactoryBuilder()
- .setNameFormat("restconf-worker")
- .build());
- ymsNotificationService = ymsService.getYangNotificationService();
- listeners = new ListenerTracker();
- listeners.addListener(ymsNotificationService, new InternalYangNotificationListener());
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- listeners.removeListeners();
- shutdownAndAwaitTermination(workerThreadPool);
- log.info("Stopped");
- }
-
- @Override
- public ObjectNode runGetOperationOnDataResource(String uri)
- throws RestconfException {
- YdtBuilder ydtBuilder = getYdtBuilder(QUERY_REQUEST);
- //Convert the URI to ydtBuilder
- convertUriToYdt(uri, ydtBuilder, NONE);
- YdtResponse ydtResponse = ymsService.executeOperation(ydtBuilder);
- YmsOperationExecutionStatus status = ydtResponse
- .getYmsOperationResult();
- if (status != EXECUTION_SUCCESS) {
- throw new RestconfException("YMS GET operation failed",
- INTERNAL_SERVER_ERROR);
- }
-
- YdtContext rootNode = ydtResponse.getRootNode();
- YdtContext curNode = ydtBuilder.getCurNode();
-
- ObjectNode result = convertYdtToJson(getJsonNameFromYdtNode(curNode),
- rootNode,
- ymsService.getYdtWalker());
- //if the query URI contain a key, something like list=key
- //here should only get get child with the specific key
- YdtContext child = curNode.getFirstChild();
- if (child != null &&
- child.getYdtType() == SINGLE_INSTANCE_LEAF_VALUE_NODE) {
-
- ArrayNode jsonNode = (ArrayNode) result.get(getJsonNameFromYdtNode(curNode));
- for (JsonNode next : jsonNode) {
- if (next.findValue(getJsonNameFromYdtNode(child))
- .asText().equals(child.getValue())) {
- return (ObjectNode) next;
- }
- }
- throw new RestconfException(String.format("No content for %s = %s",
- getJsonNameFromYdtNode(child),
- child.getValue()),
- INTERNAL_SERVER_ERROR);
- }
- return result;
- }
-
- private YmsOperationExecutionStatus
- invokeYmsOp(String uri, ObjectNode rootNode,
- YdtContextOperationType opType) {
- YdtBuilder ydtBuilder = getYdtBuilder(EDIT_CONFIG_REQUEST);
- //Convert the URI to ydtBuilder
- convertUriToYdt(uri, ydtBuilder, opType);
-
- //set default operation type for the payload node
- ydtBuilder.setDefaultEditOperationType(opType);
- //convert the payload json body to ydt
- convertJsonToYdt(rootNode, ydtBuilder);
-
- YmsOperationExecutionStatus status = EXECUTION_EXCEPTION;
-
- try {
- status = ymsService.executeOperation(ydtBuilder).getYmsOperationResult();
- } catch (Exception e) {
- log.error("YMS operation failed: {}", e.getMessage());
- log.debug("Exception in invokeYmsOp: ", e);
- }
-
- return status;
- }
-
- @Override
- public void runPostOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException {
- YmsOperationExecutionStatus status =
- invokeYmsOp(uri, rootNode, CREATE);
-
- if (status != EXECUTION_SUCCESS) {
- throw new RestconfException("YMS post operation failed.",
- INTERNAL_SERVER_ERROR);
- }
- }
-
- @Override
- public void runPutOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException {
- YmsOperationExecutionStatus status =
- invokeYmsOp(uri, rootNode, REPLACE);
-
- if (status != EXECUTION_SUCCESS) {
- throw new RestconfException("YMS put operation failed.",
- INTERNAL_SERVER_ERROR);
- }
- }
-
- @Override
- public void runDeleteOperationOnDataResource(String uri)
- throws RestconfException {
- //Get a root ydtBuilder
- YdtBuilder ydtBuilder = getYdtBuilder(EDIT_CONFIG_REQUEST);
- //Convert the URI to ydtBuilder
- convertUriToYdt(uri, ydtBuilder, DELETE);
- //Execute the delete operation
- YmsOperationExecutionStatus status = ymsService
- .executeOperation(ydtBuilder)
- .getYmsOperationResult();
- if (status != EXECUTION_SUCCESS) {
- throw new RestconfException("YMS delete operation failed.",
- INTERNAL_SERVER_ERROR);
- }
- }
-
- @Override
- public void runPatchOperationOnDataResource(String uri, ObjectNode rootNode)
- throws RestconfException {
- YmsOperationExecutionStatus status = invokeYmsOp(uri, rootNode, MERGE);
-
- if (status != EXECUTION_SUCCESS) {
- throw new RestconfException("YMS patch operation failed.",
- INTERNAL_SERVER_ERROR);
- }
- }
-
- @Override
- public String getRestconfRootPath() {
- return RESTCONF_ROOT;
- }
-
- /**
- * Creates a worker thread to listen to events and write to chunkedOutput.
- * The worker thread blocks if no events arrive.
- *
- * @param streamId the RESTCONF stream id to which the client subscribes
- * @param output the string data stream
- * @throws RestconfException if the worker thread fails to create
- */
- @Override
- public void subscribeEventStream(String streamId,
- ChunkedOutput<String> output)
- throws RestconfException {
- if (workerThreadPool instanceof ThreadPoolExecutor) {
- if (((ThreadPoolExecutor) workerThreadPool).getActiveCount() >=
- maxNumOfWorkerThreads) {
- throw new RestconfException("no more work threads left to " +
- "handle event subscription",
- INTERNAL_SERVER_ERROR);
- }
- } else {
- throw new RestconfException("Server ERROR: workerThreadPool NOT " +
- "instanceof ThreadPoolExecutor",
- INTERNAL_SERVER_ERROR);
-
- }
-
- BlockingQueue<ObjectNode> eventQueue = new LinkedBlockingQueue<>();
- workerThreadPool.submit(new EventConsumer(output, eventQueue));
- }
-
- /**
- * Shutdown a pool cleanly if possible.
- *
- * @param pool an executorService
- */
- private void shutdownAndAwaitTermination(ExecutorService pool) {
- pool.shutdown(); // Disable new tasks from being submitted
- try {
- // Wait a while for existing tasks to terminate
- if (!pool.awaitTermination(THREAD_TERMINATION_TIMEOUT, SECONDS)) {
- pool.shutdownNow(); // Cancel currently executing tasks
- // Wait a while for tasks to respond to being cancelled
- if (!pool.awaitTermination(THREAD_TERMINATION_TIMEOUT,
- SECONDS)) {
- log.error("Pool did not terminate");
- }
- }
- } catch (Exception ie) {
- // (Re-)Cancel if current thread also interrupted
- pool.shutdownNow();
- // Preserve interrupt status
- Thread.currentThread().interrupt();
- }
- }
-
- /**
- * Implementation of a worker thread which reads data from a
- * blocking queue and writes the data to a given chunk output stream.
- * The thread is blocked when no data arrive to the queue and is
- * terminated when the chunk output stream is closed (i.e., the
- * HTTP-keep-alive session is closed).
- */
- private class EventConsumer implements Runnable {
-
- private String queueId;
- private final ChunkedOutput<String> output;
- private final BlockingQueue<ObjectNode> bqueue;
-
- public EventConsumer(ChunkedOutput<String> output,
- BlockingQueue<ObjectNode> q) {
- this.output = output;
- this.bqueue = q;
- }
-
- @Override
- public void run() {
- try {
- queueId = String.valueOf(Thread.currentThread().getId());
- eventQueueList.put(queueId, bqueue);
- log.debug("EventConsumer thread created: {}", queueId);
-
- ObjectNode chunk;
- while ((chunk = bqueue.take()) != null) {
- output.write(chunk.toString().concat(EOL));
- }
- } catch (IOException e) {
- log.debug("chunkedOuput is closed: {}", this.bqueue.toString());
- /*
- * Remove queue from the queue list, so that the event producer
- * (i.e., listener) would stop working.
- */
- eventQueueList.remove(this.queueId);
- } catch (InterruptedException e) {
- log.error("ERROR: EventConsumer: bqueue.take() " +
- "has been interrupted.");
- log.debug("EventConsumer Exception:", e);
- } finally {
- try {
- output.close();
- log.debug("EventConsumer thread terminated: {}", queueId);
- } catch (IOException e) {
- log.error("ERROR: EventConsumer: ", e);
- }
- }
- }
- }
-
- private YdtBuilder getYdtBuilder(YmsOperationType ymsOperationType) {
- return ymsService.getYdtBuilder(RESTCONF_ROOT, null, ymsOperationType);
- }
-
- /**
- * The listener class acts as the event producer for the event queues. The
- * queues are created by the event consumer threads and are removed when the
- * threads terminate.
- */
- private class InternalYangNotificationListener implements YangNotificationListener {
-
- @Override
- public void event(YangNotificationEvent event) {
- if (event.type() != YangNotificationEvent.Type.YANG_NOTIFICATION) {
- // For now, we only handle YANG notification events.
- return;
- }
-
- if (eventQueueList.isEmpty()) {
- /*
- * There is no consumer waiting to consume, so don't have to
- * produce this event.
- */
- log.debug("Q list is empty");
- return;
- }
-
- try {
- YdtContext ydtNode = event.subject().getNotificationRootContext();
- ObjectNode jsonNode = convertYdtToJson(getJsonNameFromYdtNode(ydtNode),
- ydtNode,
- ymsService.getYdtWalker());
- /*
- * Put the event to every queue out there. Each queue is
- * corresponding to an event stream session. The queue is
- * removed when the session terminates.
- */
- for (Entry<String, BlockingQueue<ObjectNode>> entry : eventQueueList
- .entrySet()) {
- entry.getValue().put(jsonNode);
- }
- } catch (InterruptedException e) {
- log.error("Failed to put event in queue: {}", e.getMessage());
- log.debug("Exception trace in InternalYangNotificationListener: ", e);
- throw new RestconfException("Failed to put event in queue",
- INTERNAL_SERVER_ERROR);
- }
- }
- }
-}
diff --git a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/package-info.java b/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/package-info.java
deleted file mode 100644
index 866663d..0000000
--- a/protocols/restconf/server/restconfmgr/src/main/java/org/onosproject/protocol/restconf/server/restconfmanager/package-info.java
+++ /dev/null
@@ -1,20 +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.
- */
-
-/**
- * RESTCONF Service Manager implementation.
- */
-package org.onosproject.protocol.restconf.server.restconfmanager;
diff --git a/protocols/restconf/server/rpp/BUCK b/protocols/restconf/server/rpp/BUCK
index 20d2d45..6531f88 100644
--- a/protocols/restconf/server/rpp/BUCK
+++ b/protocols/restconf/server/rpp/BUCK
@@ -4,8 +4,7 @@
'//lib:jersey-server',
'//lib:javax.ws.rs-api',
'//utils/rest:onlab-rest',
- '//protocols/restconf/server/api:onos-protocols-restconf-server-api',
- '//protocols/restconf/server/restconfmgr:onos-protocols-restconf-server-restconfmgr',
+ '//apps/restconf/api:onos-apps-restconf-api',
]
osgi_jar_with_tests (
diff --git a/protocols/restconf/server/rpp/pom.xml b/protocols/restconf/server/rpp/pom.xml
index 264d03e..bc0dfbb 100644
--- a/protocols/restconf/server/rpp/pom.xml
+++ b/protocols/restconf/server/rpp/pom.xml
@@ -42,12 +42,7 @@
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
- <artifactId>onos-restconf-server-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-restconf-server-restconfmanager</artifactId>
+ <artifactId>onos-app-restconf-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
diff --git a/protocols/restconf/server/rpp/src/main/java/org/onosproject/protocol/restconf/server/rpp/RestconfWebResource.java b/protocols/restconf/server/rpp/src/main/java/org/onosproject/protocol/restconf/server/rpp/RestconfWebResource.java
index 0e0a686..ceba1e0 100644
--- a/protocols/restconf/server/rpp/src/main/java/org/onosproject/protocol/restconf/server/rpp/RestconfWebResource.java
+++ b/protocols/restconf/server/rpp/src/main/java/org/onosproject/protocol/restconf/server/rpp/RestconfWebResource.java
@@ -19,10 +19,10 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.glassfish.jersey.server.ChunkedOutput;
-import org.onosproject.protocol.restconf.server.api.Patch;
-import org.onosproject.protocol.restconf.server.api.RestconfException;
-import org.onosproject.protocol.restconf.server.api.RestconfServiceBroker;
import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.restconf.api.Patch;
+import org.onosproject.restconf.api.RestconfException;
+import org.onosproject.restconf.api.RestconfService;
import org.slf4j.Logger;
import javax.ws.rs.Consumes;
@@ -62,7 +62,7 @@
@Context
UriInfo uriInfo;
- private final RestconfServiceBroker service = get(RestconfServiceBroker.class);
+ private final RestconfService service = get(RestconfService.class);
private final Logger log = getLogger(getClass());
/**
diff --git a/protocols/restconf/server/utils/BUCK b/protocols/restconf/server/utils/BUCK
deleted file mode 100644
index dde27c3..0000000
--- a/protocols/restconf/server/utils/BUCK
+++ /dev/null
@@ -1,9 +0,0 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//apps/yms/api:onos-apps-yms-api',
- '//apps/yms/app:onos-apps-yms-app',
-]
-
-osgi_jar_with_tests (
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/restconf/server/utils/pom.xml b/protocols/restconf/server/utils/pom.xml
deleted file mode 100644
index ba80532..0000000
--- a/protocols/restconf/server/utils/pom.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>onos-restconf-server</artifactId>
- <groupId>org.onosproject</groupId>
- <version>1.10.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>onos-restconf-server-utils</artifactId>
- <packaging>bundle</packaging>
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-yms-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-yms</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/JsonParseException.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/JsonParseException.java
deleted file mode 100644
index cd178c5..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/JsonParseException.java
+++ /dev/null
@@ -1,42 +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.protocol.restconf.server.utils.exceptions;
-
-/**
- * Represents class of errors related to Json parse utils.
- */
-public class JsonParseException extends RuntimeException {
-
- /**
- * Constructs an exception with the specified message.
- *
- * @param message the message describing the specific nature of the error
- */
- public JsonParseException(String message) {
- super(message);
- }
-
- /**
- * Constructs an exception with the specified message and the underlying
- * cause.
- *
- * @param message the message describing the specific nature of the error
- * @param cause the underlying cause of this error
- */
- public JsonParseException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/YdtParseException.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/YdtParseException.java
deleted file mode 100644
index c2e121b..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/YdtParseException.java
+++ /dev/null
@@ -1,42 +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.protocol.restconf.server.utils.exceptions;
-
-/**
- * Represents class of errors related to YDT parse utils.
- */
-public class YdtParseException extends RuntimeException {
- /**
- * Constructs an exception with the specified message.
- *
- * @param message the message describing the specific nature of the error
- */
- public YdtParseException(String message) {
- super(message);
- }
-
- /**
- * Constructs an exception with the specified message and the underlying
- * cause.
- *
- * @param message the message describing the specific nature of the error
- * @param cause the underlying cause of this error
- */
- public YdtParseException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/package-info.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/package-info.java
deleted file mode 100644
index 508bca0..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +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.
- */
-
-/**
- * Parse utils custom exceptions.
- */
-package org.onosproject.protocol.restconf.server.utils.exceptions;
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonBuilder.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonBuilder.java
deleted file mode 100644
index f56422f..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonBuilder.java
+++ /dev/null
@@ -1,81 +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.protocol.restconf.server.utils.parser.api;
-
-import com.fasterxml.jackson.databind.node.JsonNodeType;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import java.util.Set;
-
-/**
- * Abstraction of an entity which provides interfaces to build and obtain JSON
- * data tree.
- */
-public interface JsonBuilder {
-
- /**
- * Adds a to half (a left brace/bracket and the field name) of a JSON
- * object/array to the JSON tree. This method is used by protocols which
- * knows the nature (object/array) of node.
- *
- * @param fieldName name of child to be added
- * @param nodeType the type of the child
- */
- void addNodeTopHalf(String fieldName, JsonNodeType nodeType);
-
- /**
- * Adds a child with value and a comma to the JSON tree.
- * Protocols unaware of nature of node (single/multiple) will use it to add
- * both single instance and multi instance node. Protocols aware of nature
- * of node will use it for single instance value node addition.
- *
- * @param fieldName name of child to be added
- * @param value the type of the child
- */
- void addNodeWithValueTopHalf(String fieldName, String value);
-
- /**
- * Adds a child with list of values to JSON data tree. This method is
- * used by protocols which knows the nature (object/array) of node for
- * ArrayNode addition.
- *
- * @param fieldName name of child to be added
- * @param sets the value list of the child
- */
- void addNodeWithSetTopHalf(String fieldName, Set<String> sets);
-
- /**
- * Adds the bottom half(a right brace/bracket) of a JSON object/array to
- * the JSON tree. for the text, a comma should be taken out.
- *
- * @param nodeType the type of the child
- */
- void addNodeBottomHalf(JsonNodeType nodeType);
-
- /**
- * Returns the JSON tree after build operations in the format of string.
- *
- * @return the final string JSON tree after build operations
- */
- String getTreeString();
-
- /**
- * Returns the JSON tree after build operations in the format of ObjectNode.
- *
- * @return the final ObjectNode JSON tree after build operations
- */
- ObjectNode getTreeNode();
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonListener.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonListener.java
deleted file mode 100644
index 7432dd3..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonListener.java
+++ /dev/null
@@ -1,48 +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.protocol.restconf.server.utils.parser.api;
-
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Abstraction of an entity which provide call back methods which are called
- * by JSON walker while walking the JSON data tree. This interface needs to be
- * implemented by protocol implementing listener's based call backs while JSON
- * walk.
- */
-public interface JsonListener {
-
- /**
- * Callback invoked during a node entry.
- * All the related information about the node can be obtain from the JSON
- * object.
- *
- * @param fieldName the field name of the JSON Node value
- * @param node the JsonNode which is walked through
- */
- void enterJsonNode(String fieldName, JsonNode node);
-
- /**
- * Callback invoked during a node exit.
- * All the related information about the node can be obtain from the JSON
- * node.
- *
- * @param jsonNode JSON node which has been walked through
- */
- void exitJsonNode(JsonNode jsonNode);
-
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonWalker.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonWalker.java
deleted file mode 100644
index 59ce2ab..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/JsonWalker.java
+++ /dev/null
@@ -1,39 +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.protocol.restconf.server.utils.parser.api;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Abstraction of an entity which provides interfaces for Json walk.
- * This interface serve as common tools for anyone who needs to parse
- * the json node with depth-first algorithm.
- */
-public interface JsonWalker {
-
- /**
- * Walks the JSON data tree. Protocols implements JSON listener service
- * and walks JSON tree with input as implemented object. JSON walker
- * provides call backs to implemented methods. For the original json
- * node(come from NB), there is a field name which is something like the
- * module name of a YANG model. If not, the fieldName can be null.
- *
- * @param jsonListener Json listener implemented by the user
- * @param fieldName the original object node field
- * @param node the json node which needs to be walk
- */
- void walk(JsonListener jsonListener, String fieldName, ObjectNode node);
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/NormalizedYangNode.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/NormalizedYangNode.java
deleted file mode 100644
index 31a1423..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/NormalizedYangNode.java
+++ /dev/null
@@ -1,56 +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.protocol.restconf.server.utils.parser.api;
-
-/**
- * Abstraction of an entity which represents a simple YANG node. This entity
- * is usually described by a path segment in URI, or a field name in a JSON
- * node.
- */
-public class NormalizedYangNode {
- private final String namespace;
- private final String name;
-
- /**
- * Creates an instance of normalized YANG node using the supplied information.
- *
- * @param namespace namespace of a YANG node
- * @param name name of a YANG node
- */
- public NormalizedYangNode(String namespace, String name) {
- this.namespace = namespace;
- this.name = name;
- }
-
- /**
- * Returns the namespace info of a YANG node.
- *
- * @return namespace info
- */
- public String getNamespace() {
- return namespace;
- }
-
- /**
- * Returns the name of a YANG node.
- *
- * @return name
- */
- public String getName() {
- return name;
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/package-info.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/package-info.java
deleted file mode 100644
index 51d28df..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/api/package-info.java
+++ /dev/null
@@ -1,20 +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.
- */
-
-/**
- * Provider json related process interface.
- */
-package org.onosproject.protocol.restconf.server.utils.parser.api;
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonBuilder.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonBuilder.java
deleted file mode 100644
index 90a28b2..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonBuilder.java
+++ /dev/null
@@ -1,188 +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.protocol.restconf.server.utils.parser.json;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeType;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.protocol.restconf.server.utils.exceptions.JsonParseException;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-/**
- * Represents implementation of interfaces to build and obtain JSON data tree.
- */
-public class DefaultJsonBuilder implements JsonBuilder {
-
- private static final String LEFT_BRACE = "{";
- private static final String RIGHT_BRACE = "}";
- private static final String LEFT_BRACKET = "[";
- private static final String RIGHT_BRACKET = "]";
- private static final String COMMA = ",";
- private static final String COLON = ":";
- private static final String QUOTE = "\"";
- private static final String E_UNSUP_TYPE = "Unsupported node type %s " +
- "field name is %s fieldName";
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- private StringBuilder treeString;
-
- /**
- * Creates a Default Json Builder with a specific root name.
- *
- * @param rootName the start string of the Json builder
- */
- public DefaultJsonBuilder(String rootName) {
- checkNotNull(rootName);
- treeString = new StringBuilder(rootName);
- }
-
- /**
- * Creates a Default Json Builder with a default root name.
- */
- public DefaultJsonBuilder() {
- treeString = new StringBuilder(LEFT_BRACE);
- }
-
- @Override
- public void addNodeTopHalf(String fieldName, JsonNodeType nodeType) {
-
- appendField(fieldName);
-
- switch (nodeType) {
- case OBJECT:
- treeString.append(LEFT_BRACE);
- break;
- case ARRAY:
- treeString.append(LEFT_BRACKET);
- break;
- default:
- throw new JsonParseException(String.format(E_UNSUP_TYPE,
- nodeType, fieldName));
- }
- }
-
- @Override
- public void addNodeWithValueTopHalf(String fieldName, String value) {
- if (isNullOrEmpty(fieldName)) {
- return;
- }
- appendField(fieldName);
-
- // If the value is null, then it's a empty leaf-node
- if (value == null) {
- treeString.append(QUOTE)
- .append(QUOTE + COMMA);
- return;
- }
-
- // If the value is empty, then it's a non-leaf node
- if (value.isEmpty()) {
- return;
- }
-
- // It's a non-empty leaf node
- treeString.append(QUOTE)
- .append(value)
- .append(QUOTE + COMMA);
- }
-
- @Override
- public void addNodeWithSetTopHalf(String fieldName, Set<String> sets) {
- if (isNullOrEmpty(fieldName)) {
- return;
- }
- appendField(fieldName);
- treeString.append(LEFT_BRACKET);
- for (String el : sets) {
- treeString.append(QUOTE)
- .append(el)
- .append(QUOTE + COMMA);
- }
- }
-
- @Override
- public void addNodeBottomHalf(JsonNodeType nodeType) {
-
- switch (nodeType) {
- case OBJECT:
- removeCommaIfExist();
- treeString.append(RIGHT_BRACE + COMMA);
- break;
-
- case ARRAY:
- removeCommaIfExist();
- treeString.append(RIGHT_BRACKET + COMMA);
- break;
-
- case BINARY:
- case BOOLEAN:
- case MISSING:
- case NULL:
- case NUMBER:
- case POJO:
- case STRING:
- log.trace("Unimplemented node type {}", nodeType);
- break;
-
- default:
- throw new JsonParseException("Unsupported json node type " +
- nodeType);
- }
- }
-
- @Override
- public String getTreeString() {
- removeCommaIfExist();
- return treeString.append(RIGHT_BRACE).toString();
- }
-
- @Override
- public ObjectNode getTreeNode() {
- ObjectNode node = null;
- try {
- node = (ObjectNode) (new ObjectMapper()).readTree(getTreeString());
- } catch (IOException e) {
- log.error("Parse json string failed {}", e.getMessage());
- }
- return node;
- }
-
-
- private void appendField(String fieldName) {
- if (!isNullOrEmpty(fieldName)) {
- treeString.append(QUOTE)
- .append(fieldName)
- .append(QUOTE + COLON);
- }
- }
-
- private void removeCommaIfExist() {
- int lastIndex = treeString.length() - 1;
- if (treeString.charAt(lastIndex) == COMMA.charAt(0)) {
- treeString.deleteCharAt(lastIndex);
- }
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonWalker.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonWalker.java
deleted file mode 100644
index c1802ac..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonWalker.java
+++ /dev/null
@@ -1,109 +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.protocol.restconf.server.utils.parser.json;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonWalker;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonListener;
-
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Represents implementation of JSON walk, which walks the JSON object node.
- */
-public class DefaultJsonWalker implements JsonWalker {
- @Override
- public void walk(JsonListener jsonListener, String fieldName,
- ObjectNode objectNode) {
-
- //enter the object node, the original ObjectNode should have a module
- //name as fieldName.
- jsonListener.enterJsonNode(fieldName, objectNode);
- //the node has no children, then exist and return.
- if (!objectNode.isContainerNode()) {
- jsonListener.exitJsonNode(objectNode);
- return;
- }
-
- Iterator<Map.Entry<String, JsonNode>> fields = objectNode.fields();
- while (fields.hasNext()) {
- //get the children entry of the node
- Map.Entry<String, JsonNode> currentChild = fields.next();
- String key = currentChild.getKey();
- JsonNode value = currentChild.getValue();
- //if the entry's value has its own children, do a recursion.
- //if the entry has no children, store the key and value.
- //for we don't know the specific type of the entry's value, we
- // should give it to a method which can handle JsonNode
- if (value.isContainerNode()) {
- walkJsonNode(jsonListener, key, value);
- } else {
- jsonListener.enterJsonNode(key, value);
- jsonListener.exitJsonNode(value);
- }
- }
- jsonListener.exitJsonNode(objectNode);
- }
-
- /**
- * Walks the JSON data tree. This method is called when we don't know
- * the exact type of a json node.
- *
- * @param jsonListener Json listener implemented by the user
- * @param fieldName the original object node field
- * @param rootNode the json node which needs to be walk
- */
- private void walkJsonNode(JsonListener jsonListener, String fieldName,
- JsonNode rootNode) {
- if (rootNode.isObject()) {
- walk(jsonListener, fieldName, (ObjectNode) rootNode);
- return;
- }
-
- if (rootNode.isArray()) {
- walkArrayNode(jsonListener, fieldName, (ArrayNode) rootNode);
- }
- }
-
- /**
- * Walks the JSON data tree. This method is called when the user knows the
- * json node type is ArrayNode.
- *
- * @param jsonListener Json listener implemented by the user
- * @param fieldName the original object node field
- * @param rootNode the json node which needs to be walk
- */
- private void walkArrayNode(JsonListener jsonListener, String fieldName,
- ArrayNode rootNode) {
- if (rootNode == null) {
- return;
- }
- //enter the array node.
- jsonListener.enterJsonNode(fieldName, rootNode);
- Iterator<JsonNode> children = rootNode.elements();
- while (children.hasNext()) {
- JsonNode currentChild = children.next();
- if (currentChild.isContainerNode()) {
- walkJsonNode(jsonListener, null, currentChild);
- }
- }
- jsonListener.exitJsonNode(rootNode);
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/JsonToYdtListener.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/JsonToYdtListener.java
deleted file mode 100644
index a9df870..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/JsonToYdtListener.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.protocol.restconf.server.utils.parser.json;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.JsonNodeType;
-import org.onosproject.protocol.restconf.server.utils.exceptions.JsonParseException;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonListener;
-import org.onosproject.protocol.restconf.server.utils.parser.api.NormalizedYangNode;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.slf4j.Logger;
-
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.Stack;
-
-import static com.fasterxml.jackson.databind.node.JsonNodeType.ARRAY;
-import static com.fasterxml.jackson.databind.node.JsonNodeType.MISSING;
-import static com.fasterxml.jackson.databind.node.JsonNodeType.NULL;
-import static com.fasterxml.jackson.databind.node.JsonNodeType.POJO;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.buildNormalizedNode;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Represents default implementation of codec JSON listener.
- */
-public class JsonToYdtListener implements JsonListener {
-
- private static final String INPUT_FIELD_NAME = "input";
- private static final String COLON = ":";
- private static final int INPUT_FIELD_LENGTH = 2;
- private static final String E_UNSUP_TYPE = "Unsupported node type %s " +
- "field name is %s fieldName";
- private static final String EMPTY_STRING = "null";
-
- private Logger log = getLogger(getClass());
-
- private YdtBuilder ydtBuilder;
- private NormalizedYangNode defaultMultiInsNode;
- private Stack<NormalizedYangNode> nameStack = new Stack<>();
- private YdtContext rpcModule;
- private boolean isListArray = false;
-
- /**
- * Creates a listener for the process of a Json Object, the listener will
- * try to transfer the JSON object to a Ydt builder.
- *
- * @param ydtBuilder the YDT builder to build a YDT object
- */
- public JsonToYdtListener(YdtBuilder ydtBuilder) {
- this.ydtBuilder = ydtBuilder;
- }
-
- @Override
- public void enterJsonNode(String fieldName, JsonNode node) {
- if (isNullOrEmpty(fieldName)) {
- if (defaultMultiInsNode != null) {
- ydtBuilder.addChild(defaultMultiInsNode.getName(),
- defaultMultiInsNode.getNamespace(),
- MULTI_INSTANCE_NODE);
- }
- return;
- }
- NormalizedYangNode normalizedNode = buildNormalizedNode(fieldName);
- JsonNodeType nodeType = node.getNodeType();
- switch (nodeType) {
- case OBJECT:
- processObjectNode(normalizedNode);
- break;
-
- case ARRAY:
- processArrayNode(normalizedNode, node);
- break;
-
- //TODO for now, just process the following three node type
- case STRING:
- case NUMBER:
- case BOOLEAN:
- processLeafNode(normalizedNode, node.asText());
- break;
-
- case BINARY:
- case MISSING:
- case NULL:
- case POJO:
- log.trace("Unimplemented node type {}", nodeType);
- break;
-
- default:
- throw new JsonParseException(String.format(E_UNSUP_TYPE,
- nodeType, fieldName));
- }
- }
-
- @Override
- public void exitJsonNode(JsonNode jsonNode) {
-
- if (isListArray) {
- isListArray = false;
- ydtBuilder.traverseToParent();
- return;
- }
-
- if (jsonNode.getNodeType() == ARRAY) {
- // Since node is not pushed to stack when array node is empty.
- // It should not be poped.
- ArrayNode arrayNode = (ArrayNode) jsonNode;
- if (arrayNode.size() == 0) {
- return;
- }
-
- //check empty before pop
- if (nameStack.empty()) {
- return;
- }
- nameStack.pop();
- //check empty after pop
- if (nameStack.empty()) {
- return;
- }
- defaultMultiInsNode = nameStack.get(nameStack.size() - 1);
- return;
- }
- // Since node is not added to ydt when node types are binary, missing,
- // null and pojo, traverse to parent should not be called.
- JsonNodeType nodeType = jsonNode.getNodeType();
- if (nodeType != JsonNodeType.BINARY && nodeType != MISSING &&
- nodeType != NULL && nodeType != POJO) {
- ydtBuilder.traverseToParent();
- }
- }
-
- private void processObjectNode(NormalizedYangNode node) {
- ydtBuilder.addChild(node.getName(), node.getNamespace(),
- SINGLE_INSTANCE_NODE);
- }
-
- private void processLeafNode(NormalizedYangNode node, String value) {
- String leafValue = value.equalsIgnoreCase(EMPTY_STRING) ? null : value;
- ydtBuilder.addLeaf(node.getName(), node.getNamespace(), leafValue);
- }
-
- private void processArrayNode(NormalizedYangNode normalizedNode,
- JsonNode node) {
- ArrayNode arrayNode = (ArrayNode) node;
- if (arrayNode.size() == 0) {
- return;
- }
- Set<String> sets = new LinkedHashSet<>();
- Iterator<JsonNode> elements = arrayNode.elements();
- boolean isLeafList = true;
- while (elements.hasNext()) {
- JsonNode element = elements.next();
- JsonNodeType eleType = element.getNodeType();
-
- if (eleType == JsonNodeType.STRING ||
- eleType == JsonNodeType.NUMBER ||
- eleType == JsonNodeType.BOOLEAN) {
- sets.add(element.asText());
- } else {
- isLeafList = false;
- }
- }
- if (isLeafList) {
- //leaf-list
- ydtBuilder.addLeaf(normalizedNode.getName(),
- normalizedNode.getNamespace(), sets);
- isListArray = true;
- } else {
- defaultMultiInsNode = normalizedNode;
- nameStack.push(defaultMultiInsNode);
- }
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/ParserUtils.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/ParserUtils.java
deleted file mode 100644
index c00e265..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/ParserUtils.java
+++ /dev/null
@@ -1,583 +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.protocol.restconf.server.utils.parser.json;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
-import org.onosproject.protocol.restconf.server.utils.exceptions.JsonParseException;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonBuilder;
-import org.onosproject.protocol.restconf.server.utils.parser.api.NormalizedYangNode;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtSingleInstanceLeafNode;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtListener;
-import org.onosproject.yms.ydt.YdtType;
-import org.onosproject.yms.ydt.YdtWalker;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-/**
- * Utils to complete the conversion between JSON and YDT(YANG DATA MODEL).
- */
-public final class ParserUtils {
-
- private static final Splitter SLASH_SPLITTER = Splitter.on('/');
- private static final Splitter COMMA_SPLITTER = Splitter.on(',');
- private static final String EQUAL = "=";
- private static final String COMMA = ",";
- private static final String COLON = ":";
- private static final String SLASH = "/";
- private static final String URI_ENCODING_CHAR_SET = "ISO-8859-1";
- private static final String ERROR_LIST_MSG = "List/Leaf-list node should be " +
- "in format \"nodeName=key\"or \"nodeName=instance-value\"";
- private static final String ERROR_MODULE_MSG = "First node should be in " +
- "format \"moduleName:nodeName\"";
-
- // no instantiation
- private ParserUtils() {
- }
-
- /**
- * Converts URI identifier to YDT builder.
- *
- * @param id the uri identifier from web request
- * @param builder the base ydt builder
- * @param opType the ydt operation type for the uri
- */
- public static void convertUriToYdt(String id,
- YdtBuilder builder,
- YdtContextOperationType opType) {
- checkNotNull(id, "uri identifier should not be null");
- List<String> paths = urlPathArgsDecode(SLASH_SPLITTER.split(id));
- if (!paths.isEmpty()) {
- processPathSegments(paths, builder, opType, true);
- }
- }
-
- /**
- * Converts JSON objectNode to YDT builder. The objectNode can be any
- * standard JSON node, node just for RESTconf payload.
- *
- * @param objectNode the objectNode from web request
- * @param builder the base ydt builder
- */
- public static void convertJsonToYdt(ObjectNode objectNode,
- YdtBuilder builder) {
-
- JsonToYdtListener listener = new JsonToYdtListener(builder);
- new DefaultJsonWalker().walk(listener, null, objectNode);
- }
-
- /**
- * Converts a Ydt context tree to a JSON object.
- *
- * @param rootName the name of the YdtContext from which the YdtListener
- * start to builder a Json Object
- * @param context a abstract data model for YANG data
- * @param walker abstraction of an entity which provides interfaces for
- * YDT walk
- * @return the JSON node corresponding the YANG data
- */
- public static ObjectNode convertYdtToJson(String rootName,
- YdtContext context,
- YdtWalker walker) {
- JsonBuilder builder = new DefaultJsonBuilder();
- YdtListener listener = new YdtToJsonListener(rootName, builder);
- walker.walk(listener, context);
- return builder.getTreeNode();
- }
-
- /**
- * Converts a list of path segments to a YDT builder tree.
- *
- * @param paths the list of path segments split from URI
- * @param builder the base YDT builder
- * @param opType the YDT operation type for the Path segment
- * @param isFirstIteration true if paths contains all the URI segments
- * @return the YDT builder with the tree info of paths
- */
- private static YdtBuilder processPathSegments(List<String> paths,
- YdtBuilder builder,
- YdtContextOperationType opType,
- boolean isFirstIteration) {
- if (paths.isEmpty()) {
- return builder;
- }
-
- boolean isLastSegment = paths.size() == 1;
-
- /*
- * Process the first segment in path.
- *
- * BUG ONOS-5500: YMS requires the treatment for the very first
- * segment in the URI path to be different than the rest. So,
- * we added a parameter, isFirstIteration, to this function.
- * It is set to true by the caller when this function is called
- * the very first time (i.e,, "paths" contains all the segments).
- *
- */
- YdtContextOperationType opTypeForThisSegment = isLastSegment ? opType : NONE;
- String segment = paths.iterator().next();
- processSinglePathSegment(segment, builder, opTypeForThisSegment, isFirstIteration);
-
- if (isLastSegment) {
- // We have hit the base case of recursion.
- return builder;
- }
-
- /*
- * Chop off the first segment, and recursively process the rest
- * of the path segments.
- */
- List<String> remainPaths = paths.subList(1, paths.size());
- processPathSegments(remainPaths, builder, opType, false);
-
- return builder;
- }
-
- private static void processSinglePathSegment(String pathSegment,
- YdtBuilder builder,
- YdtContextOperationType opType,
- boolean isTopLevelSegment) {
- if (pathSegment.contains(COLON)) {
- processPathSegmentWithNamespace(pathSegment, builder, opType, isTopLevelSegment);
- } else {
- processPathSegmentWithoutNamespace(pathSegment, builder, opType);
- }
- }
-
- private static void processPathSegmentWithNamespace(String pathSegment,
- YdtBuilder builder,
- YdtContextOperationType opType,
- boolean isTopLevelSegment) {
- if (isTopLevelSegment) {
- /*
- * BUG ONOS-5500: If this segment refers to the first node in
- * the path (i.e., top level of the model hierarchy), then
- * YMS requires 2 YDT nodes to be added instead of one. The
- * first one contains the namespace, and the second contains
- * the node name. For other segments in the path, only one
- * YDT node is needed.
- */
- addModule(builder, pathSegment);
- }
-
- String nodeName = getLatterSegment(pathSegment, COLON);
- String namespace = getPreSegment(pathSegment, COLON);
- convertPathSegmentToYdtNode(nodeName, namespace, builder, opType);
- }
-
- private static void processPathSegmentWithoutNamespace(String pathSegment,
- YdtBuilder builder,
- YdtContextOperationType opType) {
- convertPathSegmentToYdtNode(pathSegment, null, builder, opType);
- }
-
- private static void convertPathSegmentToYdtNode(String pathSegment,
- String namespace,
- YdtBuilder builder,
- YdtContextOperationType opType) {
- if (pathSegment.contains(EQUAL)) {
- addListOrLeafList(pathSegment, namespace, builder, opType);
- } else {
- addLeaf(pathSegment, namespace, builder, opType);
- }
- }
-
- private static YdtBuilder addListOrLeafList(String path,
- String namespace,
- YdtBuilder builder,
- YdtContextOperationType opType) {
- String nodeName = getPreSegment(path, EQUAL);
- String keyStr = getLatterSegment(path, EQUAL);
- if (keyStr == null) {
- throw new JsonParseException(ERROR_LIST_MSG);
- }
-
- if (keyStr.contains(COMMA)) {
- List<String> keys = Lists.
- newArrayList(COMMA_SPLITTER.split(keyStr));
- builder.addMultiInstanceChild(nodeName, namespace, keys, opType);
- } else {
- builder.addMultiInstanceChild(nodeName, namespace,
- Lists.newArrayList(keyStr), opType);
- }
- return builder;
- }
-
- private static YdtBuilder addLeaf(String path,
- String namespace,
- YdtBuilder builder,
- YdtContextOperationType opType) {
- checkNotNull(path);
- builder.addChild(path, namespace, opType);
- return builder;
- }
-
- private static YdtBuilder addModule(YdtBuilder builder, String path) {
- String moduleName = getPreSegment(path, COLON);
- if (moduleName == null) {
- throw new JsonParseException(ERROR_MODULE_MSG);
- }
- builder.addChild(moduleName, null, YdtType.SINGLE_INSTANCE_NODE);
- return builder;
- }
-
- private static YdtBuilder addNode(String path, YdtBuilder builder,
- YdtContextOperationType opType) {
- String nodeName = getLatterSegment(path, COLON);
- builder.addChild(nodeName,
- null,
- YdtType.SINGLE_INSTANCE_NODE,
- opType);
- return builder;
- }
-
- /**
- * Returns the previous segment of a path which is separated by a split char.
- * For example:
- * <pre>
- * "foo:bar", ":" --> "foo"
- * </pre>
- *
- * @param path the original path string
- * @param splitChar char used to split the path
- * @return the previous segment of the path
- */
- private static String getPreSegment(String path, String splitChar) {
- int idx = path.indexOf(splitChar);
- if (idx == -1) {
- return null;
- }
-
- if (path.indexOf(splitChar, idx + 1) != -1) {
- return null;
- }
-
- return path.substring(0, idx);
- }
-
- /**
- * Returns the latter segment of a path which is separated by a split char.
- * For example:
- * <pre>
- * "foo:bar", ":" --> "bar"
- * </pre>
- *
- * @param path the original path string
- * @param splitChar char used to split the path
- * @return the latter segment of the path
- */
- private static String getLatterSegment(String path, String splitChar) {
- int idx = path.indexOf(splitChar);
- if (idx == -1) {
- return path;
- }
-
- if (path.indexOf(splitChar, idx + 1) != -1) {
- return null;
- }
-
- return path.substring(idx + 1);
- }
-
- /**
- * Converts a list of path from the original format to ISO-8859-1 code.
- *
- * @param paths the original paths
- * @return list of decoded paths
- */
- public static List<String> urlPathArgsDecode(Iterable<String> paths) {
- try {
- List<String> decodedPathArgs = new ArrayList<>();
- for (String pathArg : paths) {
- String decode = URLDecoder.decode(pathArg,
- URI_ENCODING_CHAR_SET);
- decodedPathArgs.add(decode);
- }
- return decodedPathArgs;
- } catch (UnsupportedEncodingException e) {
- throw new JsonParseException("Invalid URL path arg '" +
- paths + "': ", e);
- }
- }
-
- /**
- * Converts a field to a simple YANG node description which contains the
- * namespace and name information.
- *
- * @param field field name of a JSON body, or a segment of a URI
- * in a request of RESTCONF
- * @return a simple normalized YANG node
- */
- public static NormalizedYangNode buildNormalizedNode(String field) {
- String namespace = getPreSegment(field, COLON);
- String name = getLatterSegment(field, COLON);
- return new NormalizedYangNode(namespace, name);
- }
-
-
- /**
- * Extracts the node name from a YDT node and encodes it in JSON format.
- * A JSON encoded node name has the following format:
- * <p>
- * module_name ":" node_name
- * <p>
- * where module_name is name of the YANG module in which the data
- * resource is defined, and node_name is the name of the data resource.
- * <p>
- * If the YDT node is null or its node name field is null, then the function
- * returns null. If the node name field is not null but module name field is,
- * then the function returns only the node name.
- *
- * @param ydtContext YDT node of the target data resource
- * @return JSON encoded name of the target data resource
- */
- public static String getJsonNameFromYdtNode(YdtContext ydtContext) {
- if (ydtContext == null) {
- return null;
- }
-
- String nodeName = ydtContext.getName();
- if (nodeName == null) {
- return null;
- }
-
- /*
- * The namespace field in YDT node is a string which contains a list
- * of identifiers separated by colon (:). e.g.,
- *
- * {identifier ":" identifier}+
- *
- * The last identifier in the string is the YANG module name.
- */
- String moduleName = getModuleNameFromNamespace(ydtContext.getNamespace());
- if (moduleName == null) {
- return nodeName;
- } else {
- return moduleName + COLON + nodeName;
- }
- }
-
- private static String getModuleNameFromNamespace(String namespace) {
- if (namespace == null) {
- return null;
- }
-
- String moduleName = null;
-
- if (namespace.contains(COLON)) {
- String[] tokens = namespace.split(COLON);
- moduleName = tokens[tokens.length - 1];
- }
-
- return moduleName;
- }
-
- /**
- * Extracts the URI from the given YANG Data Tree (YDT). The URI is
- * presented in string format. If no URI is found in the YDT, an
- * empty string is returned.
- *
- * @param ydtBuilder the YDT from which the URI is extracted
- * @return URI
- */
- public static String getUriInCompositeYdt(YdtBuilder ydtBuilder) {
- checkNotNull(ydtBuilder, "ydt cannot be null");
-
- StringBuilder uriBuilder = new StringBuilder();
- YdtContext ydtNode = ydtBuilder.getRootNode().getFirstChild();
- String currModuleName = null;
-
- boolean isLastNodeInUri = false;
- int levelNum = 0;
- while (((YdtExtendedContext) ydtNode).getYdtContextOperationType() == NONE ||
- isLastNodeInUri) {
- currModuleName = addNodeToUri(ydtNode, currModuleName,
- levelNum, uriBuilder);
-
- if (ydtNode.getYdtType() == YdtType.MULTI_INSTANCE_NODE) {
- if (isLastNodeInUri) {
- addKeyNodeToUri(ydtNode, uriBuilder);
- break;
- }
-
- YdtContext firstChild = ydtNode.getFirstChild();
- YdtContext lastChild = ydtNode.getLastChild();
- if ((firstChild.getYdtType() == YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE) &&
- ((YdtSingleInstanceLeafNode) firstChild).isKeyLeaf()) {
- currModuleName = addNodeToUri(firstChild,
- currModuleName,
- levelNum,
- uriBuilder);
- ydtNode = lastChild;
- } else {
- currModuleName = addNodeToUri(lastChild,
- currModuleName,
- levelNum,
- uriBuilder);
- ydtNode = firstChild;
- }
- } else {
- ydtNode = ydtNode.getFirstChild();
- }
-
- if (isLastNodeInUri) {
- break;
- }
-
- if (((YdtExtendedContext) ydtNode).getYdtContextOperationType() != NONE) {
- isLastNodeInUri = true;
- }
-
- levelNum++;
- }
-
- return uriBuilder.toString();
- }
-
- /**
- * Finds the key leaf node from the given multi-instance YDT node and
- * appends the key value to the given URI string.
- * <p>
- * If no key leaf node is found, then the given URI is unchanged.
- *
- * @param ydtNode YDT node under which the key leaf node is found
- * @param uriBuilder URI
- */
- private static void addKeyNodeToUri(YdtContext ydtNode,
- StringBuilder uriBuilder) {
- YdtContext child = ydtNode.getFirstChild();
-
- while (child != null) {
- if (child.getYdtType() == YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE) {
- if (((YdtSingleInstanceLeafNode) child).isKeyLeaf()) {
- uriBuilder.append(EQUAL).append(ydtNode.getValue());
- break;
- }
- }
- child = child.getNextSibling();
- }
- }
-
- /**
- * Extracts the path segment from a given YANG Data Tree (YDT) node and
- * appends it to the given URI string.
- *
- * @param ydtNode YDT node from which the URI segment is extracted
- * @param currModuleName current YANG module name in URI
- * @param ydtNodeDepth depth of the YDT node's position in the tree
- * @param uriBuilder URI to which the URI segment appends
- * @return YANG module name extracted from the YDT node
- */
- private static String addNodeToUri(YdtContext ydtNode,
- String currModuleName,
- int ydtNodeDepth,
- StringBuilder uriBuilder) {
- YdtType nodeType = ydtNode.getYdtType();
-
- /*
- * The given YDT node is the root of the YDT. Only the module name
- * needs to be extracted and added to URI.
- */
- if (ydtNodeDepth == 0) {
- String moduleName = ydtNode.getModuleNameAsNameSpace();
- uriBuilder.append(moduleName);
- return moduleName;
- }
-
- if (ydtNodeDepth == 1) {
- String moduleName = ydtNode.getModuleNameAsNameSpace();
- uriBuilder.append(COLON);
- uriBuilder.append(ydtNode.getName());
- return moduleName;
- }
-
- if (nodeType == YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE &&
- ((YdtSingleInstanceLeafNode) ydtNode).isKeyLeaf()) {
- uriBuilder.append(EQUAL).append(ydtNode.getValue());
- return currModuleName;
- } else {
- uriBuilder.append(SLASH);
- }
-
- String moduleName = ydtNode.getModuleNameAsNameSpace();
-
- if (currModuleName == null || !currModuleName.equals(moduleName)) {
- uriBuilder.append(moduleName).append(COLON);
- }
-
- uriBuilder.append(ydtNode.getName());
-
- return moduleName;
- }
-
- /**
- * Retrieves the top data node of the subtree from the given composite
- * YANG Data Tree (YDT) which contains both the URI path and the data
- * subtree to which the URI points.
- * <p>
- * A null is returned if no data subtree is found.
- *
- * @param ydtBuilder the given YDT
- * @return the top data node of the data subtree.
- */
- public static YdtContext findTopNodeInCompositeYdt(YdtBuilder ydtBuilder) {
- checkNotNull(ydtBuilder, "ydt cannot be null");
-
- YdtContext ydtNode = ydtBuilder.getRootNode().getFirstChild();
- YdtContextOperationType opType = ((YdtExtendedContext) ydtNode).getYdtContextOperationType();
- while (opType == NONE) {
- if (ydtNode.getYdtType() == YdtType.MULTI_INSTANCE_NODE) {
- YdtContext firstChild = ydtNode.getFirstChild();
- YdtContext lastChild = ydtNode.getLastChild();
- if (firstChild.getYdtType() == YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE &&
- ((YdtSingleInstanceLeafNode) firstChild).isKeyLeaf()) {
- ydtNode = lastChild;
- } else {
- ydtNode = firstChild;
- }
- } else {
- ydtNode = ydtNode.getFirstChild();
- }
-
- if (ydtNode == null) {
- // There is no more node to find in YDT
- return null;
- }
-
- if (((YdtExtendedContext) ydtNode).getYdtContextOperationType() != NONE) {
- // We found last node
- break;
- }
-
-
- opType = ((YdtExtendedContext) ydtNode).getYdtContextOperationType();
- }
-
- return ydtNode;
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/YdtToJsonListener.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/YdtToJsonListener.java
deleted file mode 100644
index 9479d97..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/YdtToJsonListener.java
+++ /dev/null
@@ -1,132 +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.protocol.restconf.server.utils.parser.json;
-
-import com.fasterxml.jackson.databind.node.JsonNodeType;
-import org.onosproject.protocol.restconf.server.utils.exceptions.YdtParseException;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtListener;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.getJsonNameFromYdtNode;
-
-/**
- * Represents implementation of codec YDT listener.
- */
-public class YdtToJsonListener implements YdtListener {
-
- private static final String EMPTY = "";
- private JsonBuilder jsonBuilder;
- //the root name of the json
- //the input YdtContext is usually a total tree of a YANG resource
- //this property is used to mark the start of the request node.
- private String rootName;
- //the parse state
- private boolean isBegin;
-
- /**
- * Creates a listener for the process of a Ydt, the listener will try to
- * transfer the Ydt to a JSON Object.
- *
- * @param rootName the name of a specific YdtContext begin to process
- * @param jsonBuilder the JSON builder to build a JSON object
- */
- public YdtToJsonListener(String rootName, JsonBuilder jsonBuilder) {
- this.jsonBuilder = jsonBuilder;
- this.rootName = rootName;
- this.isBegin = isNullOrEmpty(rootName);
- }
-
- @Override
- public void enterYdtNode(YdtContext ydtContext) {
- String name = getJsonNameFromYdtNode(ydtContext);
-
- if (!isBegin && name != null && name.equals(rootName)) {
- isBegin = true;
- }
- if (!isBegin) {
- return;
- }
-
- switch (ydtContext.getYdtType()) {
-
- case SINGLE_INSTANCE_NODE:
- jsonBuilder.addNodeTopHalf(name, JsonNodeType.OBJECT);
- break;
- case MULTI_INSTANCE_NODE:
- YdtContext preNode = ydtContext.getPreviousSibling();
- if (preNode == null || !getJsonNameFromYdtNode(preNode).equals(name)) {
- jsonBuilder.addNodeTopHalf(name, JsonNodeType.ARRAY);
- }
- jsonBuilder.addNodeTopHalf(EMPTY, JsonNodeType.OBJECT);
- break;
- case SINGLE_INSTANCE_LEAF_VALUE_NODE:
- jsonBuilder.addNodeWithValueTopHalf(name, ydtContext.getValue());
- break;
- case MULTI_INSTANCE_LEAF_VALUE_NODE:
- jsonBuilder.addNodeWithSetTopHalf(name, ydtContext.getValueSet());
- break;
- case LOGICAL_ROOT_NODE:
- break;
- default:
- throw new YdtParseException("unknown Ydt type " +
- ydtContext.getYdtType());
- }
-
- }
-
- @Override
- public void exitYdtNode(YdtContext ydtContext) {
-
- if (!isBegin) {
- return;
- }
-
- String curName = getJsonNameFromYdtNode(ydtContext);
- YdtContext nextNode = ydtContext.getNextSibling();
- switch (ydtContext.getYdtType()) {
-
- case SINGLE_INSTANCE_NODE:
- jsonBuilder.addNodeBottomHalf(JsonNodeType.OBJECT);
- break;
- case MULTI_INSTANCE_NODE:
- if (nextNode == null || !getJsonNameFromYdtNode(nextNode).equals(curName)) {
- jsonBuilder.addNodeBottomHalf(JsonNodeType.OBJECT);
- jsonBuilder.addNodeBottomHalf(JsonNodeType.ARRAY);
- } else {
- jsonBuilder.addNodeBottomHalf(JsonNodeType.OBJECT);
- }
- break;
- case SINGLE_INSTANCE_LEAF_VALUE_NODE:
- jsonBuilder.addNodeBottomHalf(JsonNodeType.STRING);
- break;
- case MULTI_INSTANCE_LEAF_VALUE_NODE:
- jsonBuilder.addNodeBottomHalf(JsonNodeType.ARRAY);
- break;
- case LOGICAL_ROOT_NODE:
- break;
- default:
- throw new YdtParseException("Unknown Ydt type " +
- ydtContext.getYdtType());
- }
- if (curName.equals(rootName) &&
- (nextNode == null || !getJsonNameFromYdtNode(nextNode).equals(rootName))) {
- isBegin = false;
- }
- }
-}
diff --git a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/package-info.java b/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/package-info.java
deleted file mode 100644
index 3e3c49b..0000000
--- a/protocols/restconf/server/utils/src/main/java/org/onosproject/protocol/restconf/server/utils/parser/json/package-info.java
+++ /dev/null
@@ -1,22 +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.
- */
-
-/**
- * Provider utilities to support the data format based encoding and decoding,
- * used by YMSC to operate on different data format and YDT(YANG DATA TYPE).
- */
-
-package org.onosproject.protocol.restconf.server.utils.parser.json;
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYangSchemaId.java b/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYangSchemaId.java
deleted file mode 100644
index fb04710..0000000
--- a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYangSchemaId.java
+++ /dev/null
@@ -1,82 +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.protocol.restconf.server.utils.parser.api;
-
-import java.util.Objects;
-
-/**
- * A test class which represents YANG data node identifier which is a
- * combination of name and namespace.
- */
-public class TestYangSchemaId {
- private String name;
- private String namespace;
-
- /**
- * Returns the name of the node.
- *
- * @return name of the node
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * Sets name of the node.
- *
- * @param name name of the node
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Returns namespace of the node.
- *
- * @return namespace of the node
- */
- public String getNameSpace() {
- return this.namespace;
- }
-
- /**
- * Sets namespace of the node.
- *
- * @param namespace namespace of the node
- */
- public void setNameSpace(String namespace) {
- this.namespace = namespace;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- } else if (!(obj instanceof TestYangSchemaId)) {
- return false;
- } else {
- TestYangSchemaId other = (TestYangSchemaId) obj;
- return Objects.equals(this.name, other.name) &&
- Objects.equals(this.namespace, other.namespace);
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(this.name, this.namespace);
- }
-}
diff --git a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYdtBuilder.java b/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYdtBuilder.java
deleted file mode 100644
index 03cddba..0000000
--- a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYdtBuilder.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.protocol.restconf.server.utils.parser.api;
-
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtType;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-
-/**
- * A test class which represents YANG request work bench which contains all
- * parameters for request handling and methods to build and obtain YANG data
- * tree which is data (sub)instance representation, abstract of protocol.
- */
-public class TestYdtBuilder implements YdtBuilder {
-
- private TestYdtNode curNode;
-
- private TestYdtNode rootNode;
-
- private final YmsOperationType ymsOperationType;
-
- private YdtContextOperationType ydtDefaultOpType;
-
- /**
- * Creates an instance of YANG request work bench which is use to initialize
- * logical rootNode and and schema registry.
- *
- * @param name name of logical container of a protocol
- * which is a holder of the complete tree
- * @param namespace namespace of logical container
- * @param opType type of operation done by using YANG
- * interface
- */
- public TestYdtBuilder(String name, String namespace,
- YmsOperationType opType) {
- TestYangSchemaId nodeId = new TestYangSchemaId();
- nodeId.setName(name);
- nodeId.setNameSpace(namespace);
- setRootNode(new TestYdtNode(nodeId, SINGLE_INSTANCE_NODE));
- ymsOperationType = opType;
- }
-
- private void setRootNode(TestYdtNode node) {
- rootNode = node;
- curNode = node;
- }
-
- @Override
- public YdtContext getRootNode() {
- return rootNode;
- }
-
- @Override
- public YmsOperationType getYmsOperationType() {
- return ymsOperationType;
- }
-
- @Override
- public void setRootTagAttributeMap(Map<String, String> attributeTag) {
-
- }
-
- @Override
- public Map<String, String> getRootTagAttributeMap() {
- return null;
- }
-
- @Override
- public void addChild(String name, String namespace) {
- addChild(name, namespace, SINGLE_INSTANCE_NODE, NONE);
- }
-
- @Override
- public void addChild(String name, String namespace, YdtType ydtType) {
- addChild(name, namespace, ydtType, NONE);
- }
-
- @Override
- public void addChild(String name, String namespace,
- YdtContextOperationType opType) {
- addChild(name, namespace, SINGLE_INSTANCE_NODE, opType);
- }
-
- @Override
- public void addChild(String name, String namespace, YdtType ydtType,
- YdtContextOperationType opType) {
- TestYangSchemaId id = new TestYangSchemaId();
- id.setName(name);
- String ns = namespace != null ? namespace :
- curNode.getYdtNodeIdentifier().getNameSpace();
- id.setNameSpace(ns);
- TestYdtNode childNode = new TestYdtNode(id, ydtType);
-
- YdtContextOperationType type = opType == null ? NONE : opType;
- childNode.setYdtContextOperationType(type);
-
- curNode.addChild(childNode);
-
- // Updating the curNode.
- curNode = childNode;
- }
-
- @Override
- public void addLeaf(String name, String namespace, String value) {
- addLeaf(name, namespace, value, null, SINGLE_INSTANCE_LEAF_VALUE_NODE);
- }
-
- @Override
- public void addLeaf(String name, String namespace, Set<String> valueSet) {
- addLeaf(name, namespace, null, valueSet, MULTI_INSTANCE_LEAF_VALUE_NODE);
- }
-
- @Override
- public void addMultiInstanceChild(String name, String namespace,
- List<String> valueList,
- YdtContextOperationType operationType) {
- addChild(name, namespace, MULTI_INSTANCE_LEAF_VALUE_NODE,
- operationType);
- if (curNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) {
- for (String value : valueList) {
- curNode.addValue(value);
- }
- }
- }
-
- private void addLeaf(String name, String namespace, String value,
- Set<String> valueSet, YdtType ydtType) {
- addChild(name, namespace, ydtType, NONE);
-
- if (value != null) {
- curNode.addValue(value);
- } else if (valueSet != null) {
- curNode.addValueSet(valueSet);
- }
- }
-
- @Override
- public void traverseToParent() {
- curNode = curNode.getParent();
- }
-
- @Override
- public YdtContext getCurNode() {
- return curNode;
- }
-
- @Override
- public void setDefaultEditOperationType(YdtContextOperationType opType) {
- ydtDefaultOpType = opType;
- }
-
- /**
- * Returns the default context operation type of a YDT builder.
- *
- * @return default context operation type
- */
- public YdtContextOperationType getYdtDefaultOpType() {
- return ydtDefaultOpType;
- }
-
- @Override
- public void addNode(String name, String namespace) throws IllegalArgumentException {
- addChild(name, namespace, SINGLE_INSTANCE_NODE, null);
- }
-}
diff --git a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYdtNode.java b/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYdtNode.java
deleted file mode 100644
index c7a9bbf..0000000
--- a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/api/TestYdtNode.java
+++ /dev/null
@@ -1,237 +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.protocol.restconf.server.utils.parser.api;
-
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtExtendedInfoType;
-import org.onosproject.yms.ydt.YdtType;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A test class which represents a general instance node in YANG data tree.
- */
-public class TestYdtNode implements YdtContext {
-
- private TestYdtNode parent;
- private TestYdtNode child;
- private TestYdtNode nextSibling;
- private TestYdtNode previousSibling;
- private TestYdtNode lastChild;
- private YdtType ydtType;
- private String value;
- private final Set<String> valueSet = new HashSet<>();
- private TestYangSchemaId id;
- private YdtContextOperationType ydtContextOperationType;
-
- /**
- * Creates a general YANG instance node object.
- *
- * @param id node identifier of YDT multi instance node .
- * @param ydtType type of YDT node to be added
- */
- public TestYdtNode(TestYangSchemaId id, YdtType ydtType) {
- this.id = id;
- this.ydtType = ydtType;
- }
-
- @Override
- public String getName() {
- return id.getName();
- }
-
- @Override
- public String getNamespace() {
- return id.getNameSpace();
- }
-
- @Override
- public String getModuleNameAsNameSpace() {
- return null;
- }
-
- @Override
- public <T> T getYdtContextExtendedInfo() {
- return null;
- }
-
- @Override
- public YdtExtendedInfoType getYdtExtendedInfoType() {
- return null;
- }
-
- @Override
- public YdtType getYdtType() {
- return ydtType;
- }
-
- @Override
- public TestYdtNode getParent() {
- return parent;
- }
-
- @Override
- public TestYdtNode getFirstChild() {
- return child;
- }
-
- @Override
- public TestYdtNode getLastChild() {
- return lastChild;
- }
-
- @Override
- public TestYdtNode getNextSibling() {
- return nextSibling;
- }
-
- @Override
- public YdtContext getPreviousSibling() {
- return previousSibling;
- }
-
- @Override
- public String getValue() {
- return value;
- }
-
- @Override
- public Set<String> getValueSet() {
- return valueSet;
- }
-
- /**
- * Sets the parent of node.
- *
- * @param parent node
- */
- public void setParent(TestYdtNode parent) {
- this.parent = parent;
- }
-
- /**
- * Sets the first instance of a child node.
- *
- * @param child is only child to be set
- */
- public void setChild(TestYdtNode child) {
- this.child = child;
- }
-
- /**
- * Sets the last instance of a child node.
- *
- * @param child is last child to be set
- */
- public void setLastChild(TestYdtNode child) {
- lastChild = child;
- }
-
- /**
- * Sets the next sibling of node.
- *
- * @param sibling YANG node
- */
- public void setNextSibling(TestYdtNode sibling) {
- nextSibling = sibling;
- }
-
- /**
- * Sets the previous sibling.
- *
- * @param previousSibling points to predecessor sibling
- */
- public void setPreviousSibling(TestYdtNode previousSibling) {
- this.previousSibling = previousSibling;
- }
-
- /**
- * Returns object node identifier.
- *
- * @return node identifier
- */
- public TestYangSchemaId getYdtNodeIdentifier() {
- return id;
- }
-
- /**
- * Adds a child node.
- * The children sibling list will be sorted based on node
- * type. This will add single child or sub-tree based on isAtomic flag.
- *
- * @param newChild refers to a new child to be added
- */
- public void addChild(YdtContext newChild) {
- TestYdtNode node = (TestYdtNode) newChild;
-
- if (node.getParent() == null) {
- node.setParent(this);
- }
-
- // If new node needs to be added as first child.
- if (getFirstChild() == null) {
- setChild(node);
- setLastChild(node);
- return;
- }
-
- // If new node needs to be added as last child.
- TestYdtNode curNode = getLastChild();
- curNode.setNextSibling(node);
- node.setPreviousSibling(curNode);
- setLastChild(node);
- }
-
- /**
- * Adds the given value to the non single instance leaf node.
- *
- * @param value value in a single instance node
- */
- public void addValue(String value) {
- this.value = value;
- }
-
- /**
- * Adds the given valueSet to the non multi instance leaf node.
- *
- * @param values value set in a multi instance leaf node
- */
- public void addValueSet(Set<String> values) {
- valueSet.addAll(values);
- }
-
-
- /**
- * Sets the context operation type for the YDT node.
- *
- * @param opType context operation type
- */
- public void setYdtContextOperationType(YdtContextOperationType opType) {
- this.ydtContextOperationType = opType;
- }
-
- /**
- * Returns the context operation type for the YDT node.
- *
- * @return context operation type
- */
- public YdtContextOperationType getYdtContextOperationType() {
- return ydtContextOperationType;
- }
-}
diff --git a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonWalkerTest.java b/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonWalkerTest.java
deleted file mode 100644
index 0c4f9b0..0000000
--- a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/json/DefaultJsonWalkerTest.java
+++ /dev/null
@@ -1,143 +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.protocol.restconf.server.utils.parser.json;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonListener;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-public class DefaultJsonWalkerTest {
-
- private static final String[] EXP_TEXT_ARRAY = {
- "Enter: type is OBJECT name is null",
- "Enter: type is STRING name is name",
- "Exit: type is STRING",
- "Enter: type is STRING name is surname",
- "Exit: type is STRING",
- "Exit: type is OBJECT"
- };
-
- private static final String[] EXP_NODE_LIST_ARRAY = {
- "Enter: type is OBJECT name is null",
- "Enter: type is STRING name is surname",
- "Exit: type is STRING",
- "Enter: type is ARRAY name is networklist",
- "Exit: type is ARRAY",
- "Exit: type is OBJECT"
- };
-
- private static final String[] EXP_NODE_WITH_ARRAY = {
- "Enter: type is OBJECT name is null",
- "Enter: type is STRING name is surname",
- "Exit: type is STRING",
- "Enter: type is ARRAY name is networklist",
- "Enter: type is OBJECT name is null",
- "Enter: type is STRING name is network-id",
- "Exit: type is STRING",
- "Enter: type is STRING name is server-provided",
- "Exit: type is STRING",
- "Exit: type is OBJECT",
- "Enter: type is OBJECT name is null",
- "Enter: type is STRING name is network-id",
- "Exit: type is STRING",
- "Enter: type is STRING name is server-provided",
- "Exit: type is STRING",
- "Exit: type is OBJECT",
- "Enter: type is OBJECT name is null",
- "Enter: type is STRING name is network-id",
- "Exit: type is STRING",
- "Enter: type is STRING name is server-provided",
- "Exit: type is STRING",
- "Exit: type is OBJECT",
- "Exit: type is ARRAY",
- "Exit: type is OBJECT"
- };
- private static final String WRONG_CONTENT_MSG = "Wrong content in array";
-
- private final List<String> logger = new ArrayList<>();
-
- DefaultJsonWalker defaultJsonWalker = new DefaultJsonWalker();
- InternalJsonListener jsonListener = new InternalJsonListener();
-
- ObjectNode arrayNode;
- ObjectNode textNode;
- ObjectNode listNode;
-
- @Before
- public void setup() throws Exception {
- textNode = loadJsonFile("/textNode.json");
- listNode = loadJsonFile("/listNode.json");
- arrayNode = loadJsonFile("/arrayNode.json");
- }
-
- private ObjectNode loadJsonFile(String path) throws Exception {
- InputStream jsonStream = getClass().getResourceAsStream(path);
- ObjectMapper mapper = new ObjectMapper();
- return (ObjectNode) mapper.readTree(jsonStream);
- }
-
- private void assertWalkResult(String[] expectArray, List<String> logger) {
- for (int i = 0; i < expectArray.length; i++) {
- assertThat(WRONG_CONTENT_MSG,
- true,
- is(logger.get(i).contentEquals(expectArray[i])));
- }
- }
-
- @Test
- public void testWalkTextNode() throws Exception {
-
- defaultJsonWalker.walk(jsonListener, null, textNode);
- assertWalkResult(EXP_TEXT_ARRAY, logger);
- }
-
- @Test
- public void testWalkNodeWithList() throws Exception {
- defaultJsonWalker.walk(jsonListener, null, listNode);
- assertWalkResult(EXP_NODE_LIST_ARRAY, logger);
- }
-
- @Test
- public void testWalkNodeWithArray() throws Exception {
- defaultJsonWalker.walk(jsonListener, null, arrayNode);
- assertWalkResult(EXP_NODE_WITH_ARRAY, logger);
- }
-
- private class InternalJsonListener implements JsonListener {
-
- @Override
- public void enterJsonNode(String fieldName, JsonNode node) {
- logger.add("Enter: type is " + node.getNodeType() + " name is " +
- fieldName);
- }
-
- @Override
- public void exitJsonNode(JsonNode node) {
- logger.add("Exit: type is " + node.getNodeType());
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/json/JsonToYdtListenerTest.java b/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/json/JsonToYdtListenerTest.java
deleted file mode 100644
index 07cc223..0000000
--- a/protocols/restconf/server/utils/src/test/java/org/onosproject/protocol/restconf/server/utils/parser/json/JsonToYdtListenerTest.java
+++ /dev/null
@@ -1,136 +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.protocol.restconf.server.utils.parser.json;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableSet;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.protocol.restconf.server.utils.parser.api.JsonWalker;
-import org.onosproject.protocol.restconf.server.utils.parser.api.TestYdtBuilder;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.InputStream;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.onosproject.yms.ydt.YdtType.*;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
-
-/**
- * Unit tests for JsonToYtdListener.
- */
-public class JsonToYdtListenerTest {
- private static final String RESTCONF_ROOT = "/onos/restconf";
- private static final String WRONG_STRUCTURE = "The Ydt structure is wrong!";
- private static final String WRONG_TYPE = "The Ydt type is wrong!";
-
- private YdtBuilder builder;
- private JsonToYdtListener listener;
- private JsonWalker jsonWalker;
-
- @Before
- public void setup() throws Exception {
- builder = new TestYdtBuilder(RESTCONF_ROOT, null, QUERY_REQUEST);
- listener = new JsonToYdtListener(builder);
- jsonWalker = new DefaultJsonWalker();
- }
-
- private ObjectNode loadJsonFile(String path) throws Exception {
- InputStream jsonStream = getClass().getResourceAsStream(path);
- ObjectMapper mapper = new ObjectMapper();
- return (ObjectNode) mapper.readTree(jsonStream);
- }
-
- @Test
- public void testArrayNodeTransfer() throws Exception {
- ObjectNode arrayNode = loadJsonFile("/arrayNode.json");
- jsonWalker.walk(listener, null, arrayNode);
- YdtContext rootNode = builder.getRootNode();
- YdtContext firstChild = rootNode.getFirstChild();
- YdtContext nextSibling = firstChild.getNextSibling();
- assertEquals(WRONG_TYPE, SINGLE_INSTANCE_LEAF_VALUE_NODE,
- firstChild.getYdtType());
- assertEquals(WRONG_STRUCTURE, "surname", firstChild.getName());
- assertEquals(WRONG_TYPE, MULTI_INSTANCE_NODE, nextSibling.getYdtType());
- assertEquals(WRONG_STRUCTURE, "networklist", nextSibling.getName());
- assertEquals(WRONG_STRUCTURE, "networklist",
- nextSibling.getNextSibling().getName());
- assertEquals(WRONG_STRUCTURE, "networklist",
- rootNode.getLastChild().getName());
- }
-
- @Test
- public void testListInListNodeTransfer() throws Exception {
- ObjectNode arrayNode = loadJsonFile("/listInList.json");
- jsonWalker.walk(listener, null, arrayNode);
- YdtContext rootNode = builder.getRootNode();
- YdtContext firstChild = rootNode.getFirstChild();
- YdtContext levelOneArray = firstChild.getFirstChild();
- assertEquals(WRONG_STRUCTURE, "container-identifier1",
- firstChild.getName());
- assertEquals(WRONG_STRUCTURE, "list-identifier2",
- levelOneArray.getName());
- assertEquals(WRONG_STRUCTURE, "list-identifier2",
- levelOneArray.getNextSibling().getName());
-
- YdtContext identifier3Node = levelOneArray.getLastChild();
- assertEquals(WRONG_STRUCTURE, "container-identifier3",
- identifier3Node.getName());
- YdtContext identifier4Node = identifier3Node.getLastChild();
- assertEquals(WRONG_STRUCTURE, "list-identifier4",
- identifier4Node.getName());
- YdtContext identifier5ListNode = identifier4Node.getLastChild();
- assertEquals(WRONG_STRUCTURE, "leaf-list-identifier5",
- identifier5ListNode.getName());
- assertEquals(WRONG_TYPE, MULTI_INSTANCE_LEAF_VALUE_NODE,
- identifier5ListNode.getYdtType());
- }
-
- @Test
- public void testListAfterLeafList() throws Exception {
- ObjectNode arrayNode = loadJsonFile("/listAfterLeaflist.json");
- jsonWalker.walk(listener, null, arrayNode);
- YdtContext rootNode = builder.getRootNode();
- YdtContext firstChild = rootNode.getFirstChild();
- YdtContext second = firstChild.getNextSibling();
- YdtContext lastChild = rootNode.getLastChild();
- assertEquals(WRONG_STRUCTURE, "leaf-identifier1", firstChild.getName());
- assertEquals(WRONG_STRUCTURE, "leaf-list-identifier1", second.getName());
- assertEquals(WRONG_STRUCTURE, "list-identifier1", lastChild.getName());
- }
-
- @Test
- public void testLeafListAfterList() throws Exception {
- ObjectNode arrayNode = loadJsonFile("/leaflistAfterlist.json");
- jsonWalker.walk(listener, null, arrayNode);
- YdtContext rootNode = builder.getRootNode();
- YdtContext firstChild = rootNode.getFirstChild();
- YdtContext second = firstChild.getNextSibling();
- YdtContext lastChild = rootNode.getLastChild();
- assertEquals(WRONG_STRUCTURE, "leaf-identifier1", firstChild.getName());
- assertEquals(WRONG_STRUCTURE, "list-identifier1", second.getName());
- YdtContext level2Child = second.getFirstChild();
- assertEquals(WRONG_STRUCTURE, "leaf-identifier2", level2Child.getName());
- assertEquals(WRONG_STRUCTURE, "5", level2Child.getValue());
- assertEquals(WRONG_STRUCTURE, "leaf-list-identifier1", lastChild.getName());
- Set<String> sets = ImmutableSet.of("5", "12");
- assertEquals(WRONG_STRUCTURE, sets, lastChild.getValueSet());
- }
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/resources/arrayNode.json b/protocols/restconf/server/utils/src/test/resources/arrayNode.json
deleted file mode 100644
index 2035e82..0000000
--- a/protocols/restconf/server/utils/src/test/resources/arrayNode.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "surname": "Bangalore",
- "networklist":[
- {
- "network-id": "520",
- "server-provided": "123"
- },
- {
- "network-id": "521",
- "server-provided": "124"
- },
- {
- "network-id": "523",
- "server-provided": "125"
- }
-
- ]
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/resources/leaflistAfterlist.json b/protocols/restconf/server/utils/src/test/resources/leaflistAfterlist.json
deleted file mode 100644
index 8b0c4e1..0000000
--- a/protocols/restconf/server/utils/src/test/resources/leaflistAfterlist.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "leaf-identifier1": "1",
- "list-identifier1": [
- {
- "leaf-identifier2": "5"
- }
- ],
- "leaf-list-identifier1": [
- "5",
- "12"
- ]
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/resources/listAfterLeaflist.json b/protocols/restconf/server/utils/src/test/resources/listAfterLeaflist.json
deleted file mode 100644
index bbe25e1..0000000
--- a/protocols/restconf/server/utils/src/test/resources/listAfterLeaflist.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "leaf-identifier1": "1",
- "leaf-list-identifier1": [
- "5",
- "12"
- ],
- "list-identifier1": [
- {
- "leaf-identifier2": "5"
- }
- ]
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/resources/listInList.json b/protocols/restconf/server/utils/src/test/resources/listInList.json
deleted file mode 100644
index 185d878..0000000
--- a/protocols/restconf/server/utils/src/test/resources/listInList.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "container-identifier1": {
- "list-identifier2": [
- {
- "leaf-identifier3": "enum1",
- "container-identifier3": {
- "leaf-identifier4": "",
- "leaf-list-identifier4": [
- "type-pattern-string6"
- ],
- "list-identifier4": [
- {
- "leaf-identifier5": "type-pattern-string7",
- "leaf-list-identifier5": [
- "type-pattern-string7",
- "type-pattern-string7",
- "type-pattern-string7"
- ]
- }
- ]
- }
- },
- {
- "leaf-identifier3": "enum2",
- "list-identifier3": [
- {
- "leaf-identifier4": "myidentity",
- "container-identifier4": {
- "leaf-identifier5": "type-pattern-string3",
- "leaf-list-identifier5": [
- "type-pattern-string3"
- ]
- }
- }
- ]
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/resources/listNode.json b/protocols/restconf/server/utils/src/test/resources/listNode.json
deleted file mode 100644
index c7902f5..0000000
--- a/protocols/restconf/server/utils/src/test/resources/listNode.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "surname": "Bangalore",
- "networklist":[
- "0.79",
- "1.04",
- "3.14"
- ]
-}
\ No newline at end of file
diff --git a/protocols/restconf/server/utils/src/test/resources/textNode.json b/protocols/restconf/server/utils/src/test/resources/textNode.json
deleted file mode 100644
index 8894cfb..0000000
--- a/protocols/restconf/server/utils/src/test/resources/textNode.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "Huawei",
- "surname": "Bangalore"
-}
\ No newline at end of file