use of org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFlowDescriptor in project knox by apache.
the class UrlRewriteStepProcessorHolder method process.
@Override
public UrlRewriteStepStatus process(UrlRewriteContext context) throws Exception {
UrlRewriteStepStatus status = UrlRewriteStepStatus.SUCCESS;
// If initialization failed then fail processing
if (processor != null) {
status = processor.process(context);
if (UrlRewriteStepStatus.SUCCESS == status && descriptor instanceof UrlRewriteFlowDescriptor && !childProcessors.isEmpty()) {
UrlRewriteFlowDescriptor flowDescriptor = (UrlRewriteFlowDescriptor) descriptor;
UrlRewriteStepFlow flow = flowDescriptor.flow();
if (flow == null) {
flow = UrlRewriteStepFlow.AND;
}
switch(flow) {
case ALL:
return processAllFlow(context);
case AND:
return processAndFlow(context);
case OR:
return processOrFlow(context);
}
}
}
return status;
}
use of org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFlowDescriptor in project knox by apache.
the class UrlRewriteStepProcessorHolder method initialize.
// For unit testing.
@SuppressWarnings("unchecked")
void initialize(UrlRewriteEnvironment environment, UrlRewriteStepDescriptor descriptor, UrlRewriteStepProcessor processor) throws Exception {
this.descriptor = descriptor;
this.processor = processor;
this.isCondition = descriptor instanceof UrlRewriteFlowDescriptor;
this.childProcessors = new ArrayList<UrlRewriteStepProcessorHolder>();
if (isCondition) {
UrlRewriteFlowDescriptor flowDescriptor = (UrlRewriteFlowDescriptor) descriptor;
List<UrlRewriteStepDescriptor> stepList = flowDescriptor.steps();
if (stepList != null && !stepList.isEmpty()) {
Iterator<UrlRewriteStepDescriptor> stepIterator = stepList.iterator();
while (stepIterator.hasNext()) {
UrlRewriteStepDescriptor stepDescriptor = stepIterator.next();
UrlRewriteStepProcessorHolder stepProcessor = new UrlRewriteStepProcessorHolder();
stepProcessor.initialize(environment, stepDescriptor);
childProcessors.add(stepProcessor);
}
}
}
}
use of org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFlowDescriptor in project knox by apache.
the class XmlUrlRewriteRulesExporter method createStep.
private Element createStep(Document document, UrlRewriteStepDescriptor step) throws IntrospectionException, InvocationTargetException, NoSuchMethodException, IllegalAccessException {
Element parentElement = createElement(document, step.type(), step);
if (step instanceof UrlRewriteFlowDescriptor) {
UrlRewriteFlowDescriptor flow = (UrlRewriteFlowDescriptor) step;
for (Object child : flow.steps()) {
UrlRewriteStepDescriptor childStep = (UrlRewriteStepDescriptor) child;
Element childElement = createStep(document, childStep);
parentElement.appendChild(childElement);
}
}
return parentElement;
}
Aggregations