use of org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFilterScopeDescriptor in project knox by apache.
the class XmlFilterReader method processStartElement.
private void processStartElement(StartElement event) throws XPathExpressionException {
// System.out.println( "SE=" + event );
// Create a new "empty" element and add it to the document.
Element element = bufferElement(event);
Level parent = stack.peek();
parent.node.appendChild(element);
// Note: Don't currently support nested buffer or scope descriptors.
if (currentlyBuffering()) {
pushLevel(parent, event, element, parent.scopeNode, parent.scopeConfig);
bufferAttributes(event, element);
// Else not currently buffering
} else {
// See if there is a matching path descriptor in the current scope.
UrlRewriteFilterPathDescriptor descriptor = pickFirstMatchingPath(parent);
if (descriptor != null) {
// If this is a buffer descriptor then switch to buffering and buffer the attributes.
if (descriptor instanceof UrlRewriteFilterBufferDescriptor) {
pushLevel(parent, event, element, element, (UrlRewriteFilterBufferDescriptor) descriptor);
bufferAttributes(event, element);
// Otherwise if this is a scope descriptor then change the scope and stream the attributes.
} else if (descriptor instanceof UrlRewriteFilterScopeDescriptor) {
pushLevel(parent, event, element, element, (UrlRewriteFilterScopeDescriptor) descriptor);
streamElement(event, element);
// Else found an unexpected matching path.
} else {
// This is likely because there is an <apply> targeted at the text of an element.
// That "convenience" config will be taken care of in the streamElement() processing.
pushLevel(parent, event, element, parent.scopeNode, parent.scopeConfig);
streamElement(event, element);
}
// If there is no matching path descriptor then continue streaming.
} else {
pushLevel(parent, event, element, parent.scopeNode, parent.scopeConfig);
streamElement(event, element);
}
}
}
Aggregations