// Path: src/main/java/com/difference/historybook/index/Index.java
// public interface Index extends AutoCloseable {
// 	/**
// 	 * Adds a given page to an index collection
// 	 * 
// 	 * @param collection      a namespace for an index. Allows storing multiple indexes within the same backing store.
// 	 * @param url             the url of the page being indexed
// 	 * @param timestamp       the timestamp representing when the page was retrieved
// 	 * @param body            the textual content of the page (binaries are unsupported)
// 	 * @throws IndexException
// 	 */
// 	public void indexPage(String collection, String url, Instant timestamp, String body) throws IndexException;
// 	
// 	/**
// 	 * Executes a given query against the index in the specified collection namespace and returns up to the requested page size of results.
// 	 * 
// 	 * @param collection        a namespace for an index. Allows storing multiple indexes within the same backing store.
// 	 * @param query             the search query to execute. The supported syntax of this is determined by the underlying @Index implementation
// 	 * @param offset            the 0-based offset to begin retrieving results from. Specifying an offset greater than the actual number of results will result in an empty result.
// 	 * @param size              the maximum number of results to return. The actual number of results returned may be fewer.
// 	 * @return                  the search results for the specified query along with relevant metadata.
// 	 * @see SearchResultWrapper
// 	 * @throws IndexException
// 	 */
// 	default public SearchResultWrapper search(String collection, String query, int offset, int size) throws IndexException {
// 		return search(collection, query, offset, size, false);
// 	}
// 
// 	/**
// 	 * Executes a given query against the index in the specified collection namespace and returns up to the requested page size of results.
// 	 * 
// 	 * @param collection        a namespace for an index. Allows storing multiple indexes within the same backing store.
// 	 * @param query             the search query to execute. The supported syntax of this is determined by the underlying @Index implementation
// 	 * @param offset            the 0-based offset to begin retrieving results from. Specifying an offset greater than the actual number of results will result in an empty result.
// 	 * @param size              the maximum number of results to return. The actual number of results returned may be fewer.
// 	 * @param includeDebug		include implementation dependent debug information for search result
// 	 * @return                  the search results for the specified query along with relevant metadata.
// 	 * @see SearchResultWrapper
// 	 * @throws IndexException
// 	 */
// 	public SearchResultWrapper search(String collection, String query, int offset, int size, boolean includeDebug) throws IndexException;
// }
// 
// Path: src/main/java/com/difference/historybook/proxy/ProxyFilter.java
// public interface ProxyFilter {
// 	/**
// 	 * Perform arbitrary processing based on a given @ProxyRequest
// 	 * @param request 
// 	 */
// 	public void processRequest(ProxyRequest request);
// 
// 	/**
// 	 * Perform arbitrary processing based on a given @ProxyResponse
// 	 * @param response 
// 	 */
// 	public void processResponse(ProxyResponse response);
// }
// 
// Path: src/main/java/com/difference/historybook/proxy/ProxyFilterFactory.java
// public interface ProxyFilterFactory {
// 	/**
// 	 * Return a new @ProxyFilter for use with a new request/response pair.
// 	 * @return @ProxyFilter Note that this should be a new object with each call unless the given proxy filter is stateless.
// 	 */
// 	public ProxyFilter getInstance();
// }


import com.difference.historybook.index.Index;
import com.difference.historybook.proxy.ProxyFilter;
import com.difference.historybook.proxy.ProxyFilterFactory;
/*
 * Copyright 2016 Andrew W. Buchanan (buchanan@difference.com)
 * 
 * Licensed 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 com.difference.historybook.proxyfilter;


/**
 * Implementation of @ProxyFilterFactory that returns IndexingProxyFilters 
 */
public class IndexingProxyFilterFactory implements ProxyFilterFactory {
	private final Index index;
	private final String defaultCollection;
	
	/**
	 * Constructor for IndexingProxyFilterFactory
	 * 
	 * @param index the @Index to submit the indexing request to
	 * @param defaultCollection The collection namespace to use for indexing requests
	 */
	public IndexingProxyFilterFactory(Index index, String defaultCollection) {
		this.index = index;
		this.defaultCollection = defaultCollection;
	}
	
	@Override
	public ProxyFilter getInstance() {
// Path: src/main/java/com/difference/historybook/index/Index.java
// public interface Index extends AutoCloseable {
// 	/**
// 	 * Adds a given page to an index collection
// 	 * 
// 	 * @param collection      a namespace for an index. Allows storing multiple indexes within the same backing store.
// 	 * @param url             the url of the page being indexed
// 	 * @param timestamp       the timestamp representing when the page was retrieved
// 	 * @param body            the textual content of the page (binaries are unsupported)
// 	 * @throws IndexException
// 	 */
// 	public void indexPage(String collection, String url, Instant timestamp, String body) throws IndexException;
// 	
// 	/**
// 	 * Executes a given query against the index in the specified collection namespace and returns up to the requested page size of results.
// 	 * 
// 	 * @param collection        a namespace for an index. Allows storing multiple indexes within the same backing store.
// 	 * @param query             the search query to execute. The supported syntax of this is determined by the underlying @Index implementation
// 	 * @param offset            the 0-based offset to begin retrieving results from. Specifying an offset greater than the actual number of results will result in an empty result.
// 	 * @param size              the maximum number of results to return. The actual number of results returned may be fewer.
// 	 * @return                  the search results for the specified query along with relevant metadata.
// 	 * @see SearchResultWrapper
// 	 * @throws IndexException
// 	 */
// 	default public SearchResultWrapper search(String collection, String query, int offset, int size) throws IndexException {
// 		return search(collection, query, offset, size, false);
// 	}
// 
// 	/**
// 	 * Executes a given query against the index in the specified collection namespace and returns up to the requested page size of results.
// 	 * 
// 	 * @param collection        a namespace for an index. Allows storing multiple indexes within the same backing store.
// 	 * @param query             the search query to execute. The supported syntax of this is determined by the underlying @Index implementation
// 	 * @param offset            the 0-based offset to begin retrieving results from. Specifying an offset greater than the actual number of results will result in an empty result.
// 	 * @param size              the maximum number of results to return. The actual number of results returned may be fewer.
// 	 * @param includeDebug		include implementation dependent debug information for search result
// 	 * @return                  the search results for the specified query along with relevant metadata.
// 	 * @see SearchResultWrapper
// 	 * @throws IndexException
// 	 */
// 	public SearchResultWrapper search(String collection, String query, int offset, int size, boolean includeDebug) throws IndexException;
// }
// 
// Path: src/main/java/com/difference/historybook/proxy/ProxyFilter.java
// public interface ProxyFilter {
// 	/**
// 	 * Perform arbitrary processing based on a given @ProxyRequest
// 	 * @param request 
// 	 */
// 	public void processRequest(ProxyRequest request);
// 
// 	/**
// 	 * Perform arbitrary processing based on a given @ProxyResponse
// 	 * @param response 
// 	 */
// 	public void processResponse(ProxyResponse response);
// }
// 
// Path: src/main/java/com/difference/historybook/proxy/ProxyFilterFactory.java
// public interface ProxyFilterFactory {
// 	/**
// 	 * Return a new @ProxyFilter for use with a new request/response pair.
// 	 * @return @ProxyFilter Note that this should be a new object with each call unless the given proxy filter is stateless.
// 	 */
// 	public ProxyFilter getInstance();
// }


// Path: src/main/java/com/difference/historybook/proxyfilter/IndexingProxyFilterFactory.java
import com.difference.historybook.index.Index;
import com.difference.historybook.proxy.ProxyFilter;
import com.difference.historybook.proxy.ProxyFilterFactory;

/*
 * Copyright 2016 Andrew W. Buchanan (buchanan@difference.com)
 * 
 * Licensed 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 com.difference.historybook.proxyfilter;


/**
 * Implementation of @ProxyFilterFactory that returns IndexingProxyFilters 
 */
public class IndexingProxyFilterFactory implements ProxyFilterFactory {
	private final Index index;
	private final String defaultCollection;
	
	/**
	 * Constructor for IndexingProxyFilterFactory
	 * 
	 * @param index the @Index to submit the indexing request to
	 * @param defaultCollection The collection namespace to use for indexing requests
	 */
	public IndexingProxyFilterFactory(Index index, String defaultCollection) {
		this.index = index;
		this.defaultCollection = defaultCollection;
	}
	
	@Override
	public ProxyFilter getInstance() {
		return new IndexingProxyFilter(index, defaultCollection);