- public static boolean isDataEditOperation(final QName rpc) {
- return NETCONF_URI.equals(rpc.getNamespace())
- && rpc.getLocalName().equals(NETCONF_EDIT_CONFIG_QNAME.getLocalName());
- }
-
- /**
- * Creates artificial schema node for edit-config rpc. This artificial schema looks like:
- * <pre>
- * {@code
- * rpc
- * edit-config
- * config
- * // All schema nodes from remote schema
- * config
- * edit-config
- * rpc
- * }
- * </pre>
- *
- * This makes the translation of rpc edit-config request(especially the config node)
- * to xml use schema which is crucial for some types of nodes e.g. identity-ref.
- */
- public static DataNodeContainer createSchemaForEdit(final SchemaContext schemaContext) {
- final QName config = QName.create(NETCONF_EDIT_CONFIG_QNAME, "config");
- final QName editConfig = QName.create(NETCONF_EDIT_CONFIG_QNAME, "edit-config");
- final NodeContainerProxy configProxy = new NodeContainerProxy(config, schemaContext.getChildNodes());
- final NodeContainerProxy editConfigProxy = new NodeContainerProxy(editConfig, Sets.<DataSchemaNode>newHashSet(configProxy));
- return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(editConfigProxy));
- }
-
- /**
- * Creates artificial schema node for edit-config rpc. This artificial schema looks like:
- * <pre>
- * {@code
- * rpc
- * get
- * filter
- * // All schema nodes from remote schema
- * filter
- * get
- * rpc
- * }
- * </pre>
- *
- * This makes the translation of rpc get request(especially the config node)
- * to xml use schema which is crucial for some types of nodes e.g. identity-ref.
- */
- public static DataNodeContainer createSchemaForGet(final SchemaContext schemaContext) {
- final QName filter = QName.create(NETCONF_GET_QNAME, "filter");
- final QName get = QName.create(NETCONF_GET_QNAME, "get");
- final NodeContainerProxy configProxy = new NodeContainerProxy(filter, schemaContext.getChildNodes());
- final NodeContainerProxy editConfigProxy = new NodeContainerProxy(get, Sets.<DataSchemaNode>newHashSet(configProxy));
- return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(editConfigProxy));
- }
-
- /**
- * Creates artificial schema node for get rpc. This artificial schema looks like:
- * <pre>
- * {@code
- * rpc
- * get-config
- * filter
- * // All schema nodes from remote schema
- * filter
- * get-config
- * rpc
- * }
- * </pre>
- *
- * This makes the translation of rpc get-config request(especially the config node)
- * to xml use schema which is crucial for some types of nodes e.g. identity-ref.
- */
- public static DataNodeContainer createSchemaForGetConfig(final SchemaContext schemaContext) {
- final QName filter = QName.create(NETCONF_GET_CONFIG_QNAME, "filter");
- final QName getConfig = QName.create(NETCONF_GET_CONFIG_QNAME, "get-config");
- final NodeContainerProxy configProxy = new NodeContainerProxy(filter, schemaContext.getChildNodes());
- final NodeContainerProxy editConfigProxy = new NodeContainerProxy(getConfig, Sets.<DataSchemaNode>newHashSet(configProxy));
- return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(editConfigProxy));
- }
-
-
- public static Optional<RpcDefinition> findSchemaForRpc(final QName rpcName, final SchemaContext schemaContext) {
- Preconditions.checkNotNull(rpcName);
- Preconditions.checkNotNull(schemaContext);
-
- for (final RpcDefinition rpcDefinition : schemaContext.getOperations()) {
- if(rpcDefinition.getQName().equals(rpcName)) {
- return Optional.of(rpcDefinition);
- }
- }
-
- return Optional.absent();