Search in sources :

Example 1 with OperationNameAndNamespace

use of org.opendaylight.netconf.util.mapping.AbstractNetconfOperation.OperationNameAndNamespace in project netconf by opendaylight.

the class SubtreeFilter method applyRpcSubtreeFilter.

public static Document applyRpcSubtreeFilter(final Document requestDocument, final Document rpcReply) throws DocumentedException {
    OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument);
    if (XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(operationNameAndNamespace.getNamespace()) && XmlNetconfConstants.GET.equals(operationNameAndNamespace.getOperationName()) || XmlNetconfConstants.GET_CONFIG.equals(operationNameAndNamespace.getOperationName())) {
        // process subtree filtering here, in case registered netconf operations do
        // not implement filtering.
        Optional<XmlElement> maybeFilter = operationNameAndNamespace.getOperationElement().getOnlyChildElementOptionally(XmlNetconfConstants.FILTER, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
        if (maybeFilter.isEmpty()) {
            return rpcReply;
        }
        XmlElement filter = maybeFilter.get();
        if (isSupported(filter)) {
            // do
            return filtered(maybeFilter.get(), rpcReply);
        }
    }
    // return identical document
    return rpcReply;
}
Also used : XmlElement(org.opendaylight.netconf.api.xml.XmlElement) OperationNameAndNamespace(org.opendaylight.netconf.util.mapping.AbstractNetconfOperation.OperationNameAndNamespace)

Aggregations

XmlElement (org.opendaylight.netconf.api.xml.XmlElement)1 OperationNameAndNamespace (org.opendaylight.netconf.util.mapping.AbstractNetconfOperation.OperationNameAndNamespace)1