// Path: src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutor.java
// public interface CommandExecutor
// {
// 	void execute(CommandExecutionContext commandExecutionContext)
// 			throws Exception;
// }
// 
// Path: src/main/java/org/grapheco/elfinder/util/FsItemFilterUtils.java
// public abstract class FsItemFilterUtils
// {
// 	public static FsItemFilter FILTER_ALL = new FsItemFilter()
// 	{
// 		@Override
// 		public boolean accepts(FsItemEx item)
// 		{
// 			return true;
// 		}
// 	};
// 
// 	public static FsItemFilter FILTER_FOLDER = new FsItemFilter()
// 	{
// 		@Override
// 		public boolean accepts(FsItemEx item)
// 		{
// 			return item.isFolder();
// 		}
// 	};
// 
// 	public static FsItemFilter createFileNameKeywordFilter(final String keyword)
// 	{
// 		return new FsItemFilter()
// 		{
// 			@Override
// 			public boolean accepts(FsItemEx item)
// 			{
// 				return item.getName().contains(keyword);
// 			}
// 		};
// 	}
// 
// 	public static FsItemEx[] filterFiles(FsItemEx[] sourceFiles,
// 			FsItemFilter filter)
// 	{
// 		List<FsItemEx> filtered = new ArrayList<FsItemEx>();
// 		for (FsItemEx file : sourceFiles)
// 		{
// 			if (filter.accepts(file))
// 				filtered.add(file);
// 		}
// 
// 		return filtered.toArray(new FsItemEx[0]);
// 	}
// 
// 	/**
// 	 * returns a FsItemFilter according to given mimeFilters
// 	 * 
// 	 * @param mimeFilters
// 	 *            An array of MIME types, if <code>null</code> no filtering is
// 	 *            done
// 	 * @return A filter that only accepts the supplied MIME types.
// 	 */
// 	public static FsItemFilter createMimeFilter(final String[] mimeFilters)
// 	{
// 		if (mimeFilters == null || mimeFilters.length == 0)
// 			return FILTER_ALL;
// 
// 		return new FsItemFilter()
// 		{
// 			@Override
// 			public boolean accepts(FsItemEx item)
// 			{
// 				String mimeType = item.getMimeType().toUpperCase();
// 
// 				for (String mf : mimeFilters)
// 				{
// 					mf = mf.toUpperCase();
// 					if (mimeType.startsWith(mf + "/") || mimeType.equals(mf))
// 						return true;
// 				}
// 				return false;
// 			}
// 		};
// 	}
// 
// }
// 
// Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java
// public abstract class AbstractJsonCommandExecutor extends
// 		AbstractCommandExecutor
// {
// 	@Override
// 	final public void execute(FsService fsService, HttpServletRequest request,
// 			HttpServletResponse response, ServletContext servletContext)
// 			throws Exception
// 	{
// 		JSONObject json = new JSONObject();
// 		try
// 		{
// 			execute(fsService, request, servletContext, json);
// 		}
// 		catch (ErrorException e)
// 		{
// 			if (e.getArgs() == null || e.getArgs().length == 0)
// 			{
// 				json.put("error", e.getError());
// 			}
// 			else
// 			{
// 				JSONArray errors = new JSONArray();
// 				errors.put(e.getError());
// 				for (String arg : e.getArgs())
// 				{
// 					errors.put(arg);
// 				}
// 				json.put("error", errors);
// 			}
// 		}
// 		catch (Exception e)
// 		{
// 			e.printStackTrace();
// 			json.put("error", e.getMessage());
// 		}
// 		finally
// 		{
// 			// response.setContentType("application/json; charset=UTF-8");
// 			response.setContentType("text/html; charset=UTF-8");
// 
// 			PrintWriter writer = response.getWriter();
// 			json.write(writer);
// 			writer.flush();
// 			writer.close();
// 		}
// 	}
// 
// 	protected abstract void execute(FsService fsService,
// 			HttpServletRequest request, ServletContext servletContext,
// 			JSONObject json) throws Exception;
// 
// }
// 
// Path: src/main/java/org/grapheco/elfinder/service/FsService.java
// public interface FsService
// {
// 	FsItem fromHash(String hash) throws IOException;
// 
// 	String getHash(FsItem item) throws IOException;
// 
// 	FsSecurityChecker getSecurityChecker();
// 
// 	String getVolumeId(FsVolume volume);
// 
// 	FsVolume[] getVolumes();
// 
// 	FsServiceConfig getServiceConfig();
// 
// 	/**
// 	 * find files by name pattern, this provides a simple recursively iteration
// 	 * based method lucene engines can be introduced to improve it! This
// 	 * searches across all volumes.
// 	 *
// 	 * @param filter
// 	 *            The filter to apply to select files.
// 	 * @return A collection of files that match the filter and gave the root as
// 	 *         a parent.
// 	 */
// 	// TODO: bad designs: FsItemEx should not used here top level interfaces
// 	// should only know FsItem instead of FsItemEx
// 	FsItemEx[] find(FsItemFilter filter);
// }


import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.grapheco.elfinder.controller.executor.CommandExecutor;
import org.grapheco.elfinder.util.FsItemFilterUtils;
import org.json.JSONObject;
import org.grapheco.elfinder.controller.executor.AbstractJsonCommandExecutor;
import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.controller.executors;




public class SearchCommandExecutor extends AbstractJsonCommandExecutor
		implements CommandExecutor
{
	@Override
// Path: src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutor.java
// public interface CommandExecutor
// {
// 	void execute(CommandExecutionContext commandExecutionContext)
// 			throws Exception;
// }
// 
// Path: src/main/java/org/grapheco/elfinder/util/FsItemFilterUtils.java
// public abstract class FsItemFilterUtils
// {
// 	public static FsItemFilter FILTER_ALL = new FsItemFilter()
// 	{
// 		@Override
// 		public boolean accepts(FsItemEx item)
// 		{
// 			return true;
// 		}
// 	};
// 
// 	public static FsItemFilter FILTER_FOLDER = new FsItemFilter()
// 	{
// 		@Override
// 		public boolean accepts(FsItemEx item)
// 		{
// 			return item.isFolder();
// 		}
// 	};
// 
// 	public static FsItemFilter createFileNameKeywordFilter(final String keyword)
// 	{
// 		return new FsItemFilter()
// 		{
// 			@Override
// 			public boolean accepts(FsItemEx item)
// 			{
// 				return item.getName().contains(keyword);
// 			}
// 		};
// 	}
// 
// 	public static FsItemEx[] filterFiles(FsItemEx[] sourceFiles,
// 			FsItemFilter filter)
// 	{
// 		List<FsItemEx> filtered = new ArrayList<FsItemEx>();
// 		for (FsItemEx file : sourceFiles)
// 		{
// 			if (filter.accepts(file))
// 				filtered.add(file);
// 		}
// 
// 		return filtered.toArray(new FsItemEx[0]);
// 	}
// 
// 	/**
// 	 * returns a FsItemFilter according to given mimeFilters
// 	 * 
// 	 * @param mimeFilters
// 	 *            An array of MIME types, if <code>null</code> no filtering is
// 	 *            done
// 	 * @return A filter that only accepts the supplied MIME types.
// 	 */
// 	public static FsItemFilter createMimeFilter(final String[] mimeFilters)
// 	{
// 		if (mimeFilters == null || mimeFilters.length == 0)
// 			return FILTER_ALL;
// 
// 		return new FsItemFilter()
// 		{
// 			@Override
// 			public boolean accepts(FsItemEx item)
// 			{
// 				String mimeType = item.getMimeType().toUpperCase();
// 
// 				for (String mf : mimeFilters)
// 				{
// 					mf = mf.toUpperCase();
// 					if (mimeType.startsWith(mf + "/") || mimeType.equals(mf))
// 						return true;
// 				}
// 				return false;
// 			}
// 		};
// 	}
// 
// }
// 
// Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java
// public abstract class AbstractJsonCommandExecutor extends
// 		AbstractCommandExecutor
// {
// 	@Override
// 	final public void execute(FsService fsService, HttpServletRequest request,
// 			HttpServletResponse response, ServletContext servletContext)
// 			throws Exception
// 	{
// 		JSONObject json = new JSONObject();
// 		try
// 		{
// 			execute(fsService, request, servletContext, json);
// 		}
// 		catch (ErrorException e)
// 		{
// 			if (e.getArgs() == null || e.getArgs().length == 0)
// 			{
// 				json.put("error", e.getError());
// 			}
// 			else
// 			{
// 				JSONArray errors = new JSONArray();
// 				errors.put(e.getError());
// 				for (String arg : e.getArgs())
// 				{
// 					errors.put(arg);
// 				}
// 				json.put("error", errors);
// 			}
// 		}
// 		catch (Exception e)
// 		{
// 			e.printStackTrace();
// 			json.put("error", e.getMessage());
// 		}
// 		finally
// 		{
// 			// response.setContentType("application/json; charset=UTF-8");
// 			response.setContentType("text/html; charset=UTF-8");
// 
// 			PrintWriter writer = response.getWriter();
// 			json.write(writer);
// 			writer.flush();
// 			writer.close();
// 		}
// 	}
// 
// 	protected abstract void execute(FsService fsService,
// 			HttpServletRequest request, ServletContext servletContext,
// 			JSONObject json) throws Exception;
// 
// }
// 
// Path: src/main/java/org/grapheco/elfinder/service/FsService.java
// public interface FsService
// {
// 	FsItem fromHash(String hash) throws IOException;
// 
// 	String getHash(FsItem item) throws IOException;
// 
// 	FsSecurityChecker getSecurityChecker();
// 
// 	String getVolumeId(FsVolume volume);
// 
// 	FsVolume[] getVolumes();
// 
// 	FsServiceConfig getServiceConfig();
// 
// 	/**
// 	 * find files by name pattern, this provides a simple recursively iteration
// 	 * based method lucene engines can be introduced to improve it! This
// 	 * searches across all volumes.
// 	 *
// 	 * @param filter
// 	 *            The filter to apply to select files.
// 	 * @return A collection of files that match the filter and gave the root as
// 	 *         a parent.
// 	 */
// 	// TODO: bad designs: FsItemEx should not used here top level interfaces
// 	// should only know FsItem instead of FsItemEx
// 	FsItemEx[] find(FsItemFilter filter);
// }


// Path: src/main/java/org/grapheco/elfinder/controller/executors/SearchCommandExecutor.java
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.grapheco.elfinder.controller.executor.CommandExecutor;
import org.grapheco.elfinder.util.FsItemFilterUtils;
import org.json.JSONObject;
import org.grapheco.elfinder.controller.executor.AbstractJsonCommandExecutor;
import org.grapheco.elfinder.service.FsService;

package org.grapheco.elfinder.controller.executors;




public class SearchCommandExecutor extends AbstractJsonCommandExecutor
		implements CommandExecutor
{
	@Override
	public void execute(FsService fsService, HttpServletRequest request,