You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by mo...@apache.org on 2017/09/01 13:17:26 UTC

[28/64] [partial] knox git commit: KNOX-998 - Refactoring save 1

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java
deleted file mode 100644
index 9e08bcb..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRuleDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class UrlRewriteRulesDescriptorImpl implements UrlRewriteRulesDescriptor {
-
-  private Map<String,UrlRewriteFunctionDescriptor> funcMap = new HashMap<>();
-  private List<UrlRewriteFunctionDescriptor> funcList = new ArrayList<UrlRewriteFunctionDescriptor>();
-  private List<UrlRewriteRuleDescriptor> ruleList = new ArrayList<UrlRewriteRuleDescriptor>();
-  private Map<String,UrlRewriteRuleDescriptor> ruleMap = new HashMap<>();
-  private List<UrlRewriteFilterDescriptor> filterList = new ArrayList<UrlRewriteFilterDescriptor>();
-  private Map<String,UrlRewriteFilterDescriptor> filterMap = new HashMap<>();
-
-  @Override
-  public void addRules( UrlRewriteRulesDescriptor rules ) {
-    for( UrlRewriteRuleDescriptor rule : rules.getRules() ) {
-      addRule( rule );
-    }
-    for( UrlRewriteFilterDescriptor filter : rules.getFilters() ) {
-      addFilter( filter  );
-    }
-  }
-
-  @Override
-  public UrlRewriteRuleDescriptor getRule( String name ) {
-    return ruleMap.get( name );
-  }
-
-  @Override
-  public List<UrlRewriteRuleDescriptor> getRules() {
-    return ruleList;
-  }
-
-  @Override
-  public UrlRewriteRuleDescriptor addRule( String name ) {
-    UrlRewriteRuleDescriptor rule = newRule();
-    rule.name( name );
-    addRule( rule );
-    return rule;
-  }
-
-  @Override
-  public UrlRewriteRuleDescriptor newRule() {
-    return new UrlRewriteRuleDescriptorImpl();
-  }
-
-  @Override
-  public void addRule( UrlRewriteRuleDescriptor rule ) {
-    ruleList.add( rule );
-    String name = rule.name();
-    if( name != null && name.length() > 0 ) {
-      ruleMap.put( rule.name(), rule );
-    }
-  }
-
-  @Override
-  public List<UrlRewriteFunctionDescriptor> getFunctions() {
-    return funcList;
-  }
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public <T extends UrlRewriteFunctionDescriptor<?>> T getFunction( String name ) {
-    T descriptor = (T)funcMap.get( name );
-    return (T)descriptor;
-  }
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public <T extends UrlRewriteFunctionDescriptor<?>> T addFunction( String name ) {
-    T descriptor = (T)newFunction( name );
-    addFunction( descriptor );
-    return (T)descriptor;
-  }
-
-  @SuppressWarnings("unchecked")
-  protected <T extends UrlRewriteFunctionDescriptor<?>> T newFunction( String name ) {
-    T descriptor = (T)UrlRewriteFunctionDescriptorFactory.create( name );
-    return (T)descriptor;
-  }
-
-  protected void addFunction( UrlRewriteFunctionDescriptor descriptor ) {
-    funcList.add( descriptor );
-    funcMap.put( descriptor.name(), descriptor );
-  }
-
-
-  @Override
-  public List<UrlRewriteFilterDescriptor> getFilters() {
-    return filterList;
-  }
-
-  @Override
-  public UrlRewriteFilterDescriptor getFilter( String name ) {
-    return filterMap.get( name );
-  }
-
-  @Override
-  public UrlRewriteFilterDescriptor newFilter() {
-    return new UrlRewriteFilterDescriptorImpl();
-  }
-
-  @Override
-  public UrlRewriteFilterDescriptor addFilter( String name ) {
-    UrlRewriteFilterDescriptor filter = newFilter();
-    filter.name( name );
-    addFilter( filter );
-    return filter;
-  }
-
-  @Override
-  public void addFilter( UrlRewriteFilterDescriptor descriptor ) {
-    filterList.add( descriptor );
-    filterMap.put( descriptor.name(), descriptor );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorFactory.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorFactory.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorFactory.java
deleted file mode 100644
index 27f7f9f..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorFactory.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStepDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStepProcessor;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ServiceLoader;
-
-public abstract class UrlRewriteStepProcessorFactory {
-
-  private static final Map<Class<? extends UrlRewriteStepDescriptor>,Map<String,Class<? extends UrlRewriteStepProcessor>>> MAP
-      = loadStepProcessors();
-
-  private UrlRewriteStepProcessorFactory() {
-  }
-
-  public static UrlRewriteStepProcessor create( UrlRewriteStepDescriptor descriptor ) throws IllegalAccessException, InstantiationException {
-    UrlRewriteStepProcessor processor;
-    Map<String,Class<? extends UrlRewriteStepProcessor>> typeMap;
-    typeMap = MAP.get( descriptor.getClass() );
-    if( typeMap == null ) {
-      Class<? extends UrlRewriteStepDescriptor> descriptorInterface = getDescriptorInterface( descriptor );
-      typeMap = MAP.get( descriptorInterface );
-    }
-    if( typeMap == null ) {
-      throw new IllegalArgumentException( descriptor.getClass().getName() );
-    } else {
-      String type = descriptor.type();
-      Class<? extends UrlRewriteStepProcessor> processorClass = typeMap.get( type );
-      if( processorClass == null ) {
-        throw new IllegalArgumentException( type );
-      } else {
-        processor = processorClass.newInstance();
-      }
-    }
-    return processor;
-  }
-
-  private static Map<Class<? extends UrlRewriteStepDescriptor>,Map<String,Class<? extends UrlRewriteStepProcessor>>> loadStepProcessors() {
-    Map<Class<? extends UrlRewriteStepDescriptor>,Map<String,Class<? extends UrlRewriteStepProcessor>>> descriptorMap
-        = new HashMap<>();
-    ServiceLoader<UrlRewriteStepProcessor> processors = ServiceLoader.load( UrlRewriteStepProcessor.class );
-    for( UrlRewriteStepProcessor processor : processors ) {
-      Class<? extends UrlRewriteStepDescriptor> descriptorInterface = getDescriptorInterface( processor );
-      Map<String,Class<? extends UrlRewriteStepProcessor>> typeMap = descriptorMap.get( descriptorInterface );
-      if( typeMap == null ) {
-        typeMap = new HashMap<>();
-        descriptorMap.put( descriptorInterface, typeMap );
-      }
-      String processorType = processor.getType();
-      typeMap.put( processorType, processor.getClass() );
-    }
-    return descriptorMap;
-  }
-
-  private static Class<? extends UrlRewriteStepDescriptor> getDescriptorInterface( UrlRewriteStepDescriptor descriptor ) {
-    Class<? extends UrlRewriteStepDescriptor> descriptorClass = null;
-    for( Type interfaceType : descriptor.getClass().getGenericInterfaces() ) {
-      Class genericClass = (Class)interfaceType;
-      if( UrlRewriteStepDescriptor.class.isAssignableFrom( genericClass ) ) {
-        descriptorClass = uncheckedStepDescriptorClassCast( genericClass );
-        break;
-      }
-    }
-    return descriptorClass;
-  }
-
-  private static Class<? extends UrlRewriteStepDescriptor> getDescriptorInterface( UrlRewriteStepProcessor processor ) {
-    Class<? extends UrlRewriteStepDescriptor> descriptorClass = null;
-    Class<? extends UrlRewriteStepProcessor> processorClass = processor.getClass();
-    for( Type interfaceType : processorClass.getGenericInterfaces() ) {
-      if( UrlRewriteStepProcessor.class.isAssignableFrom( (Class)((ParameterizedType)interfaceType).getRawType() ) ) {
-        ParameterizedType interfaceClass = (ParameterizedType)interfaceType;
-        descriptorClass = uncheckedStepDescriptorClassCast( interfaceClass.getActualTypeArguments()[ 0 ] );
-        break;
-      }
-    }
-    return descriptorClass;
-  }
-
-  @SuppressWarnings("unchecked")
-  private static Class<? extends UrlRewriteStepDescriptor> uncheckedStepDescriptorClassCast( Type type ) {
-    return (Class<? extends UrlRewriteStepDescriptor>)type;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
deleted file mode 100644
index b365bc0..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFlowDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStepDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStepFlow;
-import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStepProcessor;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStepStatus;
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class UrlRewriteStepProcessorHolder implements UrlRewriteStepProcessor {
-
-  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
-
-  private boolean isCondition;
-  private UrlRewriteStepDescriptor descriptor;
-  private UrlRewriteStepProcessor processor;
-  private List<UrlRewriteStepProcessorHolder> childProcessors;
-
-  @Override
-  public String getType() {
-    return "system";
-  }
-
-  public boolean isCondition() {
-    return isCondition;
-  }
-
-  public boolean isAction() {
-    return !isCondition;
-  }
-
-  @Override
-  @SuppressWarnings( "unchecked" )
-  public void initialize( UrlRewriteEnvironment environment, UrlRewriteStepDescriptor descriptor ) throws Exception {
-    UrlRewriteStepProcessor processor = UrlRewriteStepProcessorFactory.create( descriptor );
-    processor.initialize( environment, descriptor );
-    initialize( environment, descriptor, processor );
-  }
-
-  // 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 );
-        }
-      }
-    }
-  }
-
-  // For unit testing.
-  UrlRewriteStepDescriptor getDescriptor() {
-    return descriptor;
-  }
-
-  // For unit testing.
-  UrlRewriteStepProcessor getProcessor() {
-    return processor;
-  }
-
-  @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;
-  }
-
-  private UrlRewriteStepStatus processAllFlow( UrlRewriteContext context ) throws Exception {
-    UrlRewriteStepProcessorState state = new UrlRewriteStepProcessorState( childProcessors.iterator() );
-    UrlRewriteStepStatus stepStatus = UrlRewriteStepStatus.SUCCESS;
-    UrlRewriteStepProcessorHolder step;
-    while( state.hasNext() ) {
-      while( state.hasNextCondition() ) {
-        step = state.nextCondition( stepStatus );
-        stepStatus = step.process( context );
-        if( stepStatus == UrlRewriteStepStatus.FINISHED ) {
-          return stepStatus;
-        }
-      }
-      stepStatus = processActions( context, state );
-      if( stepStatus == UrlRewriteStepStatus.FINISHED ) {
-        return stepStatus;
-      }
-    }
-    return UrlRewriteStepStatus.SUCCESS;
-  }
-
-  // All conditions proceeding a set of one or more actions must succeed for the actions to be executed.
-  private UrlRewriteStepStatus processAndFlow( UrlRewriteContext context ) throws Exception {
-    UrlRewriteStepProcessorState state = new UrlRewriteStepProcessorState( childProcessors.iterator() );
-    UrlRewriteStepStatus stepStatus = UrlRewriteStepStatus.SUCCESS;
-    UrlRewriteStepProcessorHolder step;
-    while( state.hasNext() ) {
-      while( state.hasNextCondition() ) {
-        step = state.nextCondition( stepStatus );
-        stepStatus = step.process( context );
-        if( !( stepStatus == UrlRewriteStepStatus.SUCCESS ) ) {
-          return stepStatus;
-        }
-      }
-      stepStatus = processActions( context, state );
-      if( !( stepStatus == UrlRewriteStepStatus.SUCCESS ) ) {
-        return stepStatus;
-      }
-    }
-    return UrlRewriteStepStatus.SUCCESS;
-  }
-
-  // At least one condition proceeding a set of one or more actions must succedd for the actions to be executed.
-  private UrlRewriteStepStatus processOrFlow( UrlRewriteContext context ) throws Exception {
-    UrlRewriteStepProcessorState state = new UrlRewriteStepProcessorState( childProcessors.iterator() );
-    UrlRewriteStepStatus status = UrlRewriteStepStatus.SUCCESS;
-    UrlRewriteStepProcessorHolder step;
-    while( state.hasNext() ) {
-      UrlRewriteStepStatus flowStatus = UrlRewriteStepStatus.FAILURE;
-      while( state.hasNextCondition() ) {
-        step = state.nextCondition( status );
-        if( flowStatus == UrlRewriteStepStatus.FAILURE ) {
-          status = step.process( context );
-          switch( status ) {
-            case SUCCESS:
-              flowStatus = UrlRewriteStepStatus.SUCCESS;
-              continue;
-            case FINISHED:
-              return status;
-          }
-        }
-      }
-      status = processActions( context, state );
-      if( status != UrlRewriteStepStatus.SUCCESS ) {
-        return status;
-      }
-    }
-    return UrlRewriteStepStatus.SUCCESS;
-  }
-
-  private UrlRewriteStepStatus processActions( UrlRewriteContext context, UrlRewriteStepProcessorState state )
-      throws Exception {
-    UrlRewriteStepStatus flowStatus = UrlRewriteStepStatus.SUCCESS;
-    while( state.hasNextAction() ) {
-      if( flowStatus == UrlRewriteStepStatus.SUCCESS ) {
-        UrlRewriteStepStatus stepStatus = UrlRewriteStepStatus.SUCCESS;
-        UrlRewriteStepProcessorHolder step = state.nextAction( stepStatus );
-        stepStatus = step.process( context );
-        switch( stepStatus ) {
-          case FAILURE:
-            flowStatus = UrlRewriteStepStatus.FAILURE;
-            continue;
-          case FINISHED:
-            return stepStatus;
-        }
-      }
-    }
-    return flowStatus;
-  }
-
-  @Override
-  public void destroy() throws Exception {
-    destroy( processor );
-    if( descriptor instanceof UrlRewriteFlowDescriptor ) {
-      for( UrlRewriteStepProcessorHolder childProcessor : childProcessors ) {
-        destroy( childProcessor );
-      }
-    }
-  }
-
-  public void destroy( UrlRewriteStepProcessor processor ) {
-    if( processor != null ) {
-      try {
-        processor.destroy();
-      } catch( Exception e ) {
-        // Maybe it makes sense to throw exception
-        LOG.failedToDestroyRewriteStepProcessor( e );
-      }
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorState.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorState.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorState.java
deleted file mode 100644
index b8c4f7c..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorState.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStepStatus;
-
-import java.util.Iterator;
-
-class UrlRewriteStepProcessorState {
-
-  private UrlRewriteStepStatus status;
-  private UrlRewriteStepProcessorHolder next;
-  private Iterator<UrlRewriteStepProcessorHolder> steps;
-
-  UrlRewriteStepProcessorState( Iterator<UrlRewriteStepProcessorHolder> steps ) {
-    this.status = UrlRewriteStepStatus.SUCCESS;
-    this.next = null;
-    this.steps = steps;
-  }
-
-  private UrlRewriteStepProcessorHolder peek() {
-    if( next == null && steps.hasNext() ) {
-      next = steps.next();
-      return next;
-    } else if ( next != null ) {
-      return next;
-    } else {
-      return null;
-    }
-  }
-
-  public boolean hasNextCondition() {
-    UrlRewriteStepProcessorHolder curr = peek();
-    return curr != null && curr.isCondition();
-  }
-
-  public boolean hasNextAction() {
-    UrlRewriteStepProcessorHolder curr = peek();
-    return curr != null && curr.isAction();
-  }
-
-  private UrlRewriteStepProcessorHolder take( UrlRewriteStepStatus lastStatus ) {
-    UrlRewriteStepProcessorHolder step = peek();
-    status = lastStatus;
-    next = null;
-    return step;
-  }
-
-  public UrlRewriteStepProcessorHolder nextCondition( UrlRewriteStepStatus lastStatus ){
-    if( hasNextCondition() ) {
-      return take( lastStatus );
-    } else {
-      return null;
-    }
-  }
-
-  public UrlRewriteStepProcessorHolder nextAction( UrlRewriteStepStatus lastStatus ){
-    if( hasNextAction() ) {
-      return take( lastStatus );
-    } else {
-      return null;
-    }
-  }
-
-  public UrlRewriteStepStatus status(){
-    return status;
-  }
-
-  public boolean hasNext() {
-      return next != null || steps.hasNext();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteUtil.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteUtil.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteUtil.java
deleted file mode 100644
index 720b392..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteUtil.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterApplyDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterPathDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
-
-import javax.activation.MimeType;
-
-public class UrlRewriteUtil {
-
-  public static String pickFirstRuleWithEqualsIgnoreCasePathMatch( UrlRewriteFilterContentDescriptor config, String name ) {
-    String rule = "*";
-    if( config != null && !config.getSelectors().isEmpty() && name != null ) {
-      rule = "";
-      for( UrlRewriteFilterPathDescriptor selector : config.getSelectors() ) {
-        if( name.equalsIgnoreCase( selector.path() ) ) {
-          if( selector instanceof UrlRewriteFilterApplyDescriptor ) {
-            rule = ((UrlRewriteFilterApplyDescriptor)selector).rule();
-          }
-          break;
-        }
-      }
-    }
-    return rule;
-  }
-
-  public static UrlRewriteFilterContentDescriptor getRewriteFilterConfig(
-      UrlRewriteRulesDescriptor config, String filterName, MimeType mimeType ) {
-    UrlRewriteFilterContentDescriptor filterContentConfig = null;
-    if( config != null ) {
-      UrlRewriteFilterDescriptor filterConfig = config.getFilter( filterName );
-      if( filterConfig != null ) {
-        filterContentConfig = filterConfig.getContent( mimeType );
-      }
-    }
-    return filterContentConfig;
-  }
-
-  public static String filterJavaScript( String inputValue, UrlRewriteFilterContentDescriptor config,
-      UrlRewriteFilterReader filterReader, UrlRewriteFilterPathDescriptor.Compiler<Pattern> regexCompiler ) {
-    StringBuffer tbuff = new StringBuffer();
-    StringBuffer sbuff = new StringBuffer();
-    sbuff.append( inputValue );
-    if( config != null && !config.getSelectors().isEmpty() ) {
-      for( UrlRewriteFilterPathDescriptor selector : config.getSelectors() ) {
-        if ( selector instanceof UrlRewriteFilterApplyDescriptor ) {
-          UrlRewriteFilterApplyDescriptor apply = (UrlRewriteFilterApplyDescriptor)selector;
-          Matcher matcher = apply.compiledPath( regexCompiler ).matcher( sbuff );
-          int index = 0;
-          while ( matcher.find() ) {
-            int start = matcher.start();
-            int end = matcher.end();
-            if ( start != -1 && end != -1 ) {
-              tbuff.append( sbuff, index, start );
-              String value = matcher.group();
-              value = filterReader.filterValueString( null, value, apply.rule() );
-              tbuff.append(value);
-              index = end;
-            }
-          }
-          tbuff.append( sbuff, index, sbuff.length() );
-          sbuff.setLength( 0 );
-          sbuff.append( tbuff );
-          tbuff.setLength( 0 );
-        }
-      }
-    }
-    return sbuff.toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java
deleted file mode 100644
index 57d11ce..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.form;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteUtil;
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringWriter;
-
-public class FormFilterReader extends Reader {
-
-  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
-
-  private int offset;
-  private StringWriter writer;
-  private StringBuffer buffer;
-  private Reader reader;
-  private FormReader parser;
-  private FormWriter generator;
-  private UrlRewriteFilterContentDescriptor config;
-
-  public FormFilterReader( Reader reader, UrlRewriteFilterContentDescriptor config ) throws IOException {
-    this.reader = reader;
-    this.config = config;
-    parser = new FormReader( reader );
-    writer = new StringWriter();
-    buffer = writer.getBuffer();
-    offset = 0;
-    generator = new FormWriter( writer );
-  }
-
-  @Override
-  public int read( char[] destBuffer, int destOffset, int destCount ) throws IOException {
-    int count = 0;
-    int available = buffer.length() - offset;
-
-    if( available == 0 ) {
-      FormPair pair = parser.getNextPair();
-      if( pair == null ) {
-        count = -1;
-      } else {
-        processPair();
-        available = buffer.length() - offset;
-      }
-    }
-
-    if( available > 0 ) {
-      count = Math.min( destCount, available );
-      buffer.getChars( offset, offset+count, destBuffer, destOffset );
-      offset += count;
-      if( offset == buffer.length() ) {
-        offset = 0;
-        buffer.setLength( 0 );
-      }
-    }
-
-    return count;
-  }
-
-  private void processPair() throws IOException {
-    FormPair pair = parser.getCurrentPair();
-    String name = pair.getName();
-    String value = pair.getValue();
-    String rule = UrlRewriteUtil.pickFirstRuleWithEqualsIgnoreCasePathMatch( config, name );
-    try {
-      value = filterValue( name, pair.getValue(), rule );
-      pair.setValue( value );
-    } catch( Exception e ) {
-      LOG.failedToFilterValue( pair.getValue(), rule, e );
-      // Write original value.
-    }
-    generator.writePair( pair );
-  }
-
-  protected String filterValue( String name, String value, String rule ) {
-    return value;
-  }
-
-  @Override
-  public void close() throws IOException {
-    writer.close();
-    reader.close();
-  }
-
-}
-

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormPair.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormPair.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormPair.java
deleted file mode 100644
index d39f8f0..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormPair.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.form;
-
-public class FormPair {
-
-  String name;
-  String value;
-
-  public FormPair() {
-    this.name = null;
-    this.value = null;
-  }
-
-  public FormPair( String name, String value ) {
-    this.name = name;
-    this.value = value;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName( String name ) {
-    this.name = name;
-  }
-
-  public String getValue() {
-    return value;
-  }
-
-  public void setValue( String value ) {
-    this.value = value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormReader.java
deleted file mode 100644
index d7d36ca..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormReader.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.form;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
-public class FormReader {
-
-  private static final String DEFFAULT_FORM_ENCODING = "UTF-8";
-
-  private static final int DEFAULT_BUFFER_SIZE = 1024;
-
-  private Reader reader;
-  private FormPair current;
-  private StringBuilder buffer;
-  private int sepIndex;
-
-  public FormReader( Reader reader ) {
-    this.reader = reader;
-    this.current = null;
-    this.buffer = new StringBuilder( DEFAULT_BUFFER_SIZE );
-    this.sepIndex = -1;
-  }
-
-  public FormPair getNextPair() throws IOException {
-    while( true ) {
-      int c = reader.read();
-      switch( c ) {
-        case '=':
-          sepIndex = buffer.length();
-          break;
-        case '&':
-          // Ignore adjacent &s.
-          if( buffer.length() == 0 ) {
-            sepIndex = -1;
-            continue;
-          } else {
-            return createCurrentPair();
-          }
-        case -1:
-          // Ignore adjacent &s.
-          if( buffer.length() == 0 ) {
-            sepIndex = -1;
-            return null;
-          } else {
-            return createCurrentPair();
-          }
-        default:
-          buffer.append( (char)c );
-          break;
-      }
-    }
-  }
-
-  private FormPair createCurrentPair() throws UnsupportedEncodingException {
-    String name;
-    String value;
-    if( sepIndex >= 0 ) {
-      name = buffer.substring( 0, sepIndex );
-      value = buffer.substring( sepIndex );
-    } else {
-      name = buffer.toString();
-      value = "";
-    }
-    name = URLDecoder.decode( name, DEFFAULT_FORM_ENCODING );
-    value = URLDecoder.decode( value, DEFFAULT_FORM_ENCODING );
-    FormPair pair = new FormPair( name, value );
-    current = pair;
-    buffer.setLength( 0 );
-    sepIndex = -1;
-    return pair;
-  }
-
-  public FormPair getCurrentPair() {
-    return current;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteFilterReader.java
deleted file mode 100644
index 70e2173..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteFilterReader.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.form;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Resolver;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.net.URISyntaxException;
-
-public class FormUrlRewriteFilterReader extends FormFilterReader {
-
-  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
-
-  private Resolver resolver;
-  private UrlRewriter rewriter;
-  private UrlRewriter.Direction direction;
-
-  public FormUrlRewriteFilterReader( Reader reader, UrlRewriter rewriter, Resolver resolver, UrlRewriter.Direction direction, UrlRewriteFilterContentDescriptor config  ) throws IOException {
-    super( reader, config );
-    this.resolver = resolver;
-    this.rewriter = rewriter;
-    this.direction = direction;
-  }
-
-  //TODO: Need to limit which values are attempted to be filtered by the name.
-  @Override
-  protected String filterValue( String name, String value, String rule ) {
-    try {
-      Template input = Parser.parseLiteral( value );
-      Template output = rewriter.rewrite( resolver, input, direction, rule );
-      value = output.getPattern();
-    } catch( URISyntaxException e ) {
-      LOG.failedToParseValueForUrlRewrite( value );
-    }
-    return value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteStreamFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteStreamFilter.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteStreamFilter.java
deleted file mode 100644
index 35f8318..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormUrlRewriteStreamFilter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.form;
-
-import org.apache.commons.io.input.ReaderInputStream;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStreamFilter;
-import org.apache.hadoop.gateway.util.urltemplate.Resolver;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-public class FormUrlRewriteStreamFilter implements UrlRewriteStreamFilter {
-
-  private static String[] TYPES = new String[]{ "application/x-www-form-urlencoded", "*/x-www-form-urlencoded" };
-  private static String[] NAMES = new String[]{ null };
-
-  @Override
-  public String[] getTypes() {
-    return TYPES;
-  }
-
-  @Override
-  public String[] getNames() {
-    return NAMES;
-  }
-
-  @Override
-  public InputStream filter(
-      InputStream stream,
-      String encoding,
-      UrlRewriter rewriter,
-      Resolver resolver,
-      UrlRewriter.Direction direction,
-      UrlRewriteFilterContentDescriptor config )
-          throws IOException {
-    return new ReaderInputStream(
-        new FormUrlRewriteFilterReader(
-            new InputStreamReader( stream, encoding ), rewriter, resolver, direction, config ), encoding );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormWriter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormWriter.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormWriter.java
deleted file mode 100644
index c130d89..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormWriter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.form;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.net.URLEncoder;
-
-public class FormWriter {
-
-  private static final String DEFFAULT_FORM_ENCODING = "UTF-8";
-
-  private Writer writer;
-  boolean first;
-
-  public FormWriter( Writer writer ) {
-    this.writer = writer;
-    this.first = true;
-  }
-
-  public void writePair( FormPair pair ) throws IOException {
-    if( first ) {
-      first = false;
-    } else {
-      writer.write( "&" );
-    }
-    writer.write( URLEncoder.encode( pair.getName(), DEFFAULT_FORM_ENCODING ) );
-    writer.write( "=" );
-    writer.write( URLEncoder.encode( pair.getValue(), DEFFAULT_FORM_ENCODING ) );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReader.java
deleted file mode 100644
index c61553e..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-
-import java.io.IOException;
-import java.io.Reader;
-
-//map.put( "meta", buildTagPattern( ".*url\\s*=\\s*['\"]?(.*?)[;\\s'\"\\/>].*" ) );
-//map.put( "link", buildTagPattern( ".*href\\s*=\\s*['\"]?(.*?)['\"\\>].*" ) );
-//map.put( "a", buildTagPattern( ".*href\\s*=\\s*['\"]?(.*?)['\"\\>].*" ) );
-//map.put( "th", buildTagPattern( ".*window.document.location\\s*=\\s*['\"]?(.*?)['\"\\>].*" ) );
-//    assertMatch( pattern, "<meta HTTP-EQUIV=\"REFRESH\" content=\"0;url=dfshealth.jsp\"/>", "meta" );
-//String markup = "<link href=\"/static/org.apache.hadoop.css\" rel=\"stylesheet\" type=\"text/css\" >";
-//String markup = "<a href=\"dfsnodelist.jsp?whatNodes=DECOMMISSIONING\">";
-//String markup = "th class=headerASC onClick=\"window.document.location='/dfsnodelist.jsp?whatNodes=LIVE&sorter/field=name&sorter/order=DSC'\" title=\"sort on this column\">";
-
-public abstract class HtmlFilterReader extends HtmlFilterReaderBase {
-
-  public HtmlFilterReader( Reader reader ) throws IOException, ParserConfigurationException {
-    super( reader );
-  }
-
-  public HtmlFilterReader( Reader reader, UrlRewriteFilterContentDescriptor config ) throws IOException, ParserConfigurationException {
-    super( reader, config );
-  }
-
-  protected abstract String filterAttribute( String tagName, String attributeName, String attributeValue, String ruleName );
-
-  protected abstract String filterText( String tagName, String text, String ruleName );
-
-  @Override
-  protected final String filterAttribute( QName elementName, QName attributeName, String attributeValue, String ruleName ) {
-    return filterAttribute( elementName.getLocalPart(), attributeName.getLocalPart(), attributeValue, ruleName );
-  }
-
-  @Override
-  protected final String filterText( QName elementName, String text, String ruleName ) {
-    return filterText( elementName.getLocalPart(), text, ruleName );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBase.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBase.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBase.java
deleted file mode 100644
index 6be7010..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBase.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import net.htmlparser.jericho.Attribute;
-import net.htmlparser.jericho.Attributes;
-import net.htmlparser.jericho.EndTag;
-import net.htmlparser.jericho.Segment;
-import net.htmlparser.jericho.StartTag;
-import net.htmlparser.jericho.StreamedSource;
-import net.htmlparser.jericho.Tag;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterApplyDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterPathDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteFilterReader;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteUtil;
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-import org.apache.hadoop.gateway.util.XmlUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Stack;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public abstract class HtmlFilterReaderBase extends Reader implements UrlRewriteFilterReader {
-
-  private static final String SCRIPTTAG = "script";
-  private static final UrlRewriteFilterPathDescriptor.Compiler<Pattern> REGEX_COMPILER = new RegexCompiler();
-
-  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
-
-  private Document document;
-  private Stack<Level> stack;
-  private Reader reader;
-  private StreamedSource parser;
-  private Iterator<Segment> iterator;
-  private int lastSegEnd;
-  private int offset;
-  private StringWriter writer;
-  private StringBuffer buffer;
-  private UrlRewriteFilterContentDescriptor config = null;
-
-  protected HtmlFilterReaderBase( Reader reader ) throws IOException, ParserConfigurationException {
-    this.reader = reader;
-    document = XmlUtils.createDocument( false );
-    stack = new Stack<Level>();
-    parser = new StreamedSource( reader );
-    iterator = parser.iterator();
-    writer = new StringWriter();
-    buffer = writer.getBuffer();
-    offset = 0;
-  }
-
-  protected HtmlFilterReaderBase( Reader reader, UrlRewriteFilterContentDescriptor config ) throws IOException, ParserConfigurationException {
-    this(reader);
-    this.config = config;
-  }
-
-  protected abstract String filterAttribute( QName elementName, QName attributeName, String attributeValue, String ruleName );
-
-  protected abstract String filterText( QName elementName, String text, String ruleName );
-
-  @Override
-  public int read( char[] destBuffer, int destOffset, int destCount ) throws IOException {
-    int count = 0;
-    int available = buffer.length() - offset;
-
-    if( available == 0 ) {
-      if( iterator.hasNext() ) {
-        iterator.next();
-        processCurrentSegment();
-        available = buffer.length() - offset;
-      } else {
-        count = -1;
-      }
-    }
-
-    if( available > 0 ) {
-      count = Math.min( destCount, available );
-      buffer.getChars( offset, offset + count, destBuffer, destOffset );
-      offset += count;
-      if( offset == buffer.length() ) {
-        offset = 0;
-        buffer.setLength( 0 );
-      }
-    }
-
-    return count;
-  }
-
-  private void processCurrentSegment() {
-    Segment segment = parser.getCurrentSegment();
-    // If this tag is inside the previous tag (e.g. a server tag) then
-    // ignore it as it was already output along with the previous tag.
-    if( segment.getEnd() <= lastSegEnd ) {
-      return;
-    }
-    lastSegEnd = segment.getEnd();
-    if( segment instanceof Tag ) {
-      if( segment instanceof StartTag ) {
-        processStartTag( (StartTag)segment );
-      } else if ( segment instanceof EndTag ) {
-        processEndTag( (EndTag)segment );
-      } else {
-        writer.write( segment.toString() );
-      }
-    } else {
-      processText( segment );
-    }
-  }
-
-  private void processEndTag( EndTag tag ) {
-    while( !stack.isEmpty() ) {
-      Level popped = stack.pop();
-      if( popped.getTag().getName().equalsIgnoreCase( tag.getName() ) ) {
-        break;
-      }
-    }
-    writer.write( tag.toString() );
-  }
-
-  private void processStartTag( StartTag tag ) {
-    if( "<".equals( tag.getTagType().getStartDelimiter() ) ) {
-      Element e = document.createElement( tag.getNameSegment().toString() );
-      stack.push( new Level( tag ) );
-      writer.write( "<" );
-      writer.write( tag.getNameSegment().toString() );
-      Attributes attributes = tag.getAttributes();
-      if( !attributes.isEmpty() ) {
-        for( Attribute attribute : attributes ) {
-          processAttribute( attribute );
-        }
-      }
-      if( tag.toString().trim().endsWith( "/>" ) || tag.isEmptyElementTag() ) {
-        stack.pop();
-        writer.write( "/>" );
-      } else {
-        writer.write( ">" );
-      }
-    } else {
-      writer.write( tag.toString() );
-    }
-  }
-
-  private void processAttribute( Attribute attribute ) {
-    writer.write( " " );
-    writer.write( attribute.getName() );
-    if(attribute.hasValue()) {
-      /*
-       * non decoded value, return the raw value of the attribute as it appears
-       * in the source document, without decoding, see KNOX-791.
-       */
-      String inputValue = attribute.getValueSegment().toString();
-      String outputValue = inputValue;
-      try {
-        Level tag = stack.peek();
-        String name = getRuleName(inputValue);
-        outputValue = filterAttribute( tag.getQName(), tag.getQName( attribute.getName() ), inputValue, name );
-        if( outputValue == null ) {
-          outputValue = inputValue;
-        }
-      } catch ( Exception e ) {
-        LOG.failedToFilterAttribute( attribute.getName(), e );
-      }
-      writer.write( "=" );
-      writer.write( attribute.getQuoteChar() );
-      writer.write( outputValue );
-      writer.write( attribute.getQuoteChar() );
-    }
-  }
-
-  private String getRuleName(String inputValue) {
-    if( config != null && !config.getSelectors().isEmpty() ) {
-      for( UrlRewriteFilterPathDescriptor selector : config.getSelectors() ) {
-        if ( selector instanceof UrlRewriteFilterApplyDescriptor ) {
-          UrlRewriteFilterApplyDescriptor apply = (UrlRewriteFilterApplyDescriptor)selector;
-          Matcher matcher = apply.compiledPath( REGEX_COMPILER ).matcher( inputValue );
-            if (matcher.matches()) {
-              return apply.rule();
-            }
-          }
-        }
-      }
-      return null;
-    }
-
-  private void processText( Segment segment ) {
-    String inputValue = segment.toString();
-    String outputValue = inputValue;
-    try {
-      if( stack.isEmpty() ) {
-        // This can happen for whitespace outside of the root element.
-        //outputValue = filterText( null, inputValue );
-      } else {
-        String tagName = stack.peek().getTag().getName();
-        if (SCRIPTTAG.equals(tagName) && config != null && !config.getSelectors().isEmpty() ) {
-          // embedded javascript content
-          outputValue = UrlRewriteUtil.filterJavaScript( inputValue, config, this, REGEX_COMPILER );
-        } else {
-          outputValue = filterText( stack.peek().getQName(), inputValue, getRuleName(inputValue) );
-        }
-      }
-      if( outputValue == null ) {
-        outputValue = inputValue;
-      }
-    } catch ( Exception e ) {
-      LOG.failedToFilterValue( inputValue, null, e );
-    }
-    writer.write( outputValue );
-  }
-
-  @Override
-  public void close() throws IOException {
-    parser.close();
-    reader.close();
-    writer.close();
-    stack.clear();
-  }
-
-  private String getNamespace( String prefix ) {
-    String namespace = null;
-    for( Level level : stack ) {
-      namespace = level.getNamespace( prefix );
-      if( namespace != null ) {
-        break;
-      }
-    }
-    return namespace;
-  }
-
-  private static class Level {
-    private StartTag tag;
-    private QName name;
-    private Map<String,String> namespaces;
-
-    private Level( StartTag tag ) {
-      this.tag = tag;
-      this.name = null;
-      this.namespaces = null;
-    }
-
-    private StartTag getTag() {
-      return tag;
-    }
-
-    private QName getQName() {
-      if( name == null ) {
-        name = getQName( tag.getName() );
-      }
-      return name;
-    }
-
-    private String getNamespace( String prefix ) {
-      return getNamespaces().get( prefix );
-    }
-
-    private QName getQName( String name ) {
-      String prefix;
-      String local;
-      int colon = ( name == null ? -1 : name.indexOf( ':' ) );
-      if( colon < 0 ) {
-        prefix = "";
-        local = name;
-      } else {
-        prefix = name.substring( 0, colon );
-        local = ( colon + 1 < name.length() ? name.substring( colon + 1 ) : "" );
-      }
-      String namespace = getNamespace( prefix );
-      return new QName( namespace, local, prefix );
-    }
-
-    private Map<String,String> getNamespaces() {
-      if( namespaces == null ) {
-        namespaces = new HashMap<>();
-        parseNamespaces();
-      }
-      return namespaces;
-    }
-
-    private void parseNamespaces() {
-      Attributes attributes = tag.getAttributes();
-      if( attributes != null ) {
-        for( Attribute attribute : tag.getAttributes() ) {
-          String name = attribute.getName();
-          if( name.toLowerCase().startsWith( "xmlns" ) ) {
-            int colon = name.indexOf( ":", 5 );
-            String prefix;
-            if( colon <= 0 ) {
-              prefix = "";
-            } else {
-              prefix = name.substring( colon );
-            }
-            namespaces.put( prefix, attribute.getValue() );
-          }
-        }
-      }
-    }
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionDescriptor.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionDescriptor.java
deleted file mode 100644
index e5bddfd..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionDescriptor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class HtmlImportFunctionDescriptor implements UrlRewriteFunctionDescriptor<HtmlImportFunctionDescriptor> {
-
-  public static final String FUNCTION_NAME = "import";
-
-  @Override
-  public String name() {
-    return FUNCTION_NAME;
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java
deleted file mode 100644
index 27d6ef5..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.FrontendFunctionDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteFunctionProcessorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * This function enhances the 'frontend' function with the ability to add a prefix to the rewritten frontend portion
- * along with the '@import' literal. This is a workaround for the requirement to provide the ability to rewrite
- * a portion of html content that contains a tag like the following
- *
- * <head> <style type=\"text/css\">@import "pretty.css";</style></head>
- *
- * and needs to be rewritten to something like
- *
- * <head> <style type=\"text/css\">@import "http://localhost:8443/sandbox/service/pretty.css";</style></head>
- *
- * The rewrite rule could then contain the $import function that would delegate to the frontend function.
- *
- * If there are more than one params passed, the first one is used as a prefix to the value of the frontend function.
- *
- */
-public class HtmlImportFunctionProcessor implements UrlRewriteFunctionProcessor<HtmlImportFunctionDescriptor> {
-
-  private static final String IMPORT_LITERAL = "@import";
-
-  private UrlRewriteFunctionProcessor frontend;
-
-  @Override
-  public void initialize(UrlRewriteEnvironment environment, HtmlImportFunctionDescriptor descriptor) throws Exception {
-    UrlRewriteFunctionDescriptor frontendDescriptor = UrlRewriteFunctionDescriptorFactory.create(FrontendFunctionDescriptor.FUNCTION_NAME);
-    frontend = UrlRewriteFunctionProcessorFactory.create(FrontendFunctionDescriptor.FUNCTION_NAME, frontendDescriptor);
-    frontend.initialize(environment, frontendDescriptor);
-  }
-
-  @Override
-  public void destroy() throws Exception {
-    frontend.destroy();
-  }
-
-  @Override
-  public List<String> resolve(UrlRewriteContext context, List<String> parameters) throws Exception {
-    String prefix = "";
-    if ( parameters != null && parameters.size() > 1 ) {
-      prefix = parameters.get(0);
-      parameters = parameters.subList(1, parameters.size());
-    }
-    List<String> frontendValues = frontend.resolve(context, parameters);
-    StringBuffer buffer = new StringBuffer(IMPORT_LITERAL);
-    buffer.append(" ");
-    buffer.append(prefix);
-    if ( frontendValues != null && frontendValues.size() > 0 ) {
-      for ( String value : frontendValues ) {
-        buffer.append(value);
-      }
-    }
-    return Arrays.asList(buffer.toString());
-  }
-
-  @Override
-  public String name() {
-    return HtmlImportFunctionDescriptor.FUNCTION_NAME;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixDescriptor.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixDescriptor.java
deleted file mode 100644
index f0386a1..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixDescriptor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership.  The ASF
- * licenses this file to you 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.
- */
-
-/**
- * {@link UrlRewriteFunctionDescriptor} for the variable {@link
- * HtmlPrefixDescriptor#FUNCTION_NAME}
- *
- * @since 0.14.0
- */
-public class HtmlPrefixDescriptor
-    implements UrlRewriteFunctionDescriptor<HtmlPrefixDescriptor> {
-
-  /**
-   * variable name used in rewrite.xml
-   */
-  public static final String FUNCTION_NAME = "prefix";
-
-  /**
-   * Create an instance
-   */
-  public HtmlPrefixDescriptor() {
-    super();
-  }
-
-  @Override
-  public String name() {
-    return FUNCTION_NAME;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java
deleted file mode 100644
index 8ded069..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership.  The ASF
- * licenses this file to you 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.FrontendFunctionDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteFunctionProcessorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * This function enhances the 'frontend' function with the ability to add a
- * prefix to the rewritten frontend portion along with the literals
- * provided as an argument.
- * <p>
- * <div ng-include src=\"'components/navbar/navbar.html?v=1498928142479'\"></div>
- * <p>
- * and needs to be rewritten to something like
- * <p>
- * <div ng-include src=\"'http://localhost:8443/sandbox/service/components/navbar/navbar.html?v=1498928142479'\"></div>
- * <p>
- * The rewrite rule could then contain the $prefix function that would delegate
- * to the frontend function.
- * <p>
- * The parameter to the function would be the symbol used as a prefix.
- */
-
-public class HtmlPrefixProcessor
-    implements UrlRewriteFunctionProcessor<HtmlPrefixDescriptor> {
-
-  private UrlRewriteFunctionProcessor frontend;
-
-  /**
-   * Create an instance
-   */
-  public HtmlPrefixProcessor() {
-    super();
-  }
-
-  @Override
-  public void initialize(final UrlRewriteEnvironment environment,
-      final HtmlPrefixDescriptor descriptor) throws Exception {
-
-    final UrlRewriteFunctionDescriptor frontendDescriptor = UrlRewriteFunctionDescriptorFactory
-        .create(FrontendFunctionDescriptor.FUNCTION_NAME);
-
-    frontend = UrlRewriteFunctionProcessorFactory
-        .create(FrontendFunctionDescriptor.FUNCTION_NAME, frontendDescriptor);
-
-    frontend.initialize(environment, frontendDescriptor);
-  }
-
-  @Override
-  public String name() {
-    return HtmlPrefixDescriptor.FUNCTION_NAME;
-  }
-
-  @Override
-  public void destroy() throws Exception {
-    frontend.destroy();
-  }
-
-  @Override
-  public List<String> resolve(UrlRewriteContext context,
-      List<String> parameters) throws Exception {
-    String prefix = "";
-
-    if ((parameters != null) && (parameters.size() > 1)) {
-      prefix = parameters.get(0);
-      parameters = parameters.subList(1, parameters.size());
-    }
-
-    final List<String> frontendValues = frontend.resolve(context, parameters);
-
-    final StringBuffer buffer = new StringBuffer();
-    buffer.append(prefix);
-    if (frontendValues != null && frontendValues.size() > 0) {
-      for (final String value : frontendValues) {
-        buffer.append(value);
-      }
-    }
-
-    return Arrays.asList(buffer.toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java
deleted file mode 100644
index 76b7c38..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Resolver;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.Reader;
-import java.net.URISyntaxException;
-
-public class HtmlUrlRewriteFilterReader extends HtmlFilterReader {
-
-  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
-  
-  private Resolver resolver;
-  private UrlRewriter rewriter;
-  private UrlRewriter.Direction direction;
-
-  public HtmlUrlRewriteFilterReader( Reader reader, UrlRewriter rewriter, Resolver resolver, UrlRewriter.Direction direction, UrlRewriteFilterContentDescriptor config )
-      throws IOException, ParserConfigurationException {
-    super( reader, config );
-    this.resolver = resolver;
-    this.rewriter = rewriter;
-    this.direction = direction;
-  }
-
-  //TODO: Need to limit which values are attempted to be filtered by the name.
-  @Override
-  public String filterValueString( String name, String value, String rule ) {
-    try {
-      Template input = Parser.parseLiteral( value );
-      Template output = rewriter.rewrite( resolver, input, direction, rule );
-      if( output != null ) {
-        value = output.getPattern();
-      }
-    } catch( URISyntaxException e ) {
-      LOG.failedToParseValueForUrlRewrite( value );
-    }
-    return value;
-  }
-
-  @Override
-  protected String filterAttribute( String tagName, String attributeName, String attributeValue, String ruleName ) {
-    return filterValueString( attributeName, attributeValue, ruleName );
-  }
-
-  @Override
-  protected String filterText( String tagName, String text, String ruleName ) {
-    return filterValueString( tagName, text, ruleName );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteStreamFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteStreamFilter.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteStreamFilter.java
deleted file mode 100644
index b51a328..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteStreamFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.html;
-
-import org.apache.commons.io.input.ReaderInputStream;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStreamFilter;
-import org.apache.hadoop.gateway.util.urltemplate.Resolver;
-
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-public class HtmlUrlRewriteStreamFilter implements UrlRewriteStreamFilter {
-
-  private static String[] TYPES = new String[]{ "application/html", "text/html", "*/html" };
-  private static String[] NAMES = new String[]{ null };
-
-  @Override
-  public String[] getTypes() {
-    return TYPES;
-  }
-
-  @Override
-  public String[] getNames() {
-    return NAMES;
-  }
-
-  @Override
-  public InputStream filter(
-      InputStream stream,
-      String encoding,
-      UrlRewriter rewriter,
-      Resolver resolver,
-      UrlRewriter.Direction direction,
-      UrlRewriteFilterContentDescriptor config )
-          throws IOException {
-    try {
-      return new ReaderInputStream(
-          new HtmlUrlRewriteFilterReader(
-              new InputStreamReader( stream, encoding ), rewriter, resolver, direction, config ), encoding );
-    } catch( ParserConfigurationException e ) {
-      throw new IOException( e );
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptFilterReader.java
deleted file mode 100644
index 46e630a..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptFilterReader.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.javascript;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterPathDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteFilterReader;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteUtil;
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.util.regex.Pattern;
-
-public abstract class JavaScriptFilterReader extends Reader implements UrlRewriteFilterReader {
-
-  private static final UrlRewriteFilterPathDescriptor.Compiler<Pattern> REGEX_COMPILER = new RegexCompiler();
-
-  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
-
-  private BufferedReader reader;
-  private int offset;
-  private StringWriter writer;
-  private StringBuffer buffer;
-  private UrlRewriteFilterContentDescriptor config;
-
-  protected JavaScriptFilterReader( Reader reader, UrlRewriteFilterContentDescriptor config ) throws IOException {
-    this.reader = new BufferedReader( reader );
-    this.config = config;
-    writer = new StringWriter();
-    buffer = writer.getBuffer();
-    offset = 0;
-  }
-
-  @Override
-  public abstract String filterValueString( String name, String value, String rule );
-
-  @Override
-  public int read( char[] destBuffer, int destOffset, int destCount ) throws IOException {
-    int count = 0;
-    int available = buffer.length() - offset;
-    String cbuff;
-    if( available == 0 ) {
-      cbuff = reader.readLine();
-      if( cbuff != null ) {
-        count = cbuff.length();
-        writer.write( UrlRewriteUtil.filterJavaScript( cbuff, config, this, REGEX_COMPILER ) );
-        writer.write( '\n' );
-        available = buffer.length() - offset;
-      } else {
-        count = -1;
-      }
-    }
-
-    if( available > 0 ) {
-      count = Math.min( destCount, available );
-      buffer.getChars( offset, offset + count, destBuffer, destOffset );
-      offset += count;
-      if( offset == buffer.length() ) {
-        offset = 0;
-        buffer.setLength( 0 );
-      }
-    }
-
-    return count;
-  }
-
-  @Override
-  public void close() throws IOException {
-    reader.close();
-    writer.close();
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptUrlRewriteFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptUrlRewriteFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptUrlRewriteFilterReader.java
deleted file mode 100644
index af9a36f..0000000
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/javascript/JavaScriptUrlRewriteFilterReader.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.hadoop.gateway.filter.rewrite.impl.javascript;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.net.URISyntaxException;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Resolver;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-public class JavaScriptUrlRewriteFilterReader extends JavaScriptFilterReader {
-
-  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
-
-  private Resolver resolver;
-  private UrlRewriter rewriter;
-  private UrlRewriter.Direction direction;
-
-  public JavaScriptUrlRewriteFilterReader( Reader reader, UrlRewriter rewriter, Resolver resolver, UrlRewriter.Direction direction, UrlRewriteFilterContentDescriptor config )
-      throws IOException {
-    super( reader, config );
-    this.resolver = resolver;
-    this.rewriter = rewriter;
-    this.direction = direction;
-  }
-
-  @Override
-  public String filterValueString( String name, String value, String rule ) {
-    try {
-      Template input = Parser.parseLiteral( value );
-      Template output = rewriter.rewrite( resolver, input, direction, rule );
-      if( output != null ) {
-        value = output.getPattern();
-      }
-    } catch( URISyntaxException e ) {
-      LOG.failedToParseValueForUrlRewrite( value );
-    }
-    return value;
-  }
-
-}