gt: 		if (file.getFile().exists()) {
context: package org.javlo.module.file;
  
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.LinkedHashMap;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Map;
  import java.util.logging.Logger;
  
  import javax.imageio.metadata.IIOMetadata;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.commons.fileupload.FileItem;
  import org.javlo.context.ContentContext;
  import org.javlo.helper.ResourceHelper;
  import org.javlo.helper.StringHelper;
  import org.javlo.helper.URLHelper;
  import org.javlo.image.ImageEngine;
  import org.javlo.service.RequestService;
  
  /**
   * 
   * @author Benoit Dumont de Chassart
   * 
   */
  public abstract class ELFinder {
  
  	private static Logger logger = Logger.getLogger(ELFinder.class.getName());
  
  	private static final String PROTOCOL_VERSION = "2.0";
  	private static final String DEFAULT_MIME_TYPE = "application/octet-stream";
  
  	public void process(Writer out, HttpServletRequest request, HttpServletResponse response) throws Exception {
  
  		Map<String, Object> apiResponse = new LinkedHashMap<String, Object>();
  		
  		boolean writeJSON = true;
  		
  		try {
  			RequestService rs = RequestService.getInstance(request);
  			String command = rs.getParameter("cmd", null);
  			if ("file".equals(command)) {
  				ELFile file = getFile(request, "target");				
  				if (file != null) {					
  					response.addHeader("Content-Descriptionn", "File Transfer");
  					response.addHeader("Content-Type", ResourceHelper.getFileExtensionToMineType(StringHelper.getFileExtension(file.getFile().getName())));
  					response.addHeader("Content-Disposition", "attachment; filename="+ file.getFile().getName()); 
  					response.addHeader("Content-Transfer-Encoding", "binary");
  					response.addHeader("Connection","Keep-Alive");
  					response.addHeader("Expires","0");
  					response.addHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
  					response.addHeader("Pragma","public");
  					response.addHeader("Content-Length",""+file.getFile().length());					
  					ResourceHelper.writeFileToStream(file.getFile(), response.getOutputStream());
  					writeJSON = false;
  				} else {
  					response.setStatus(HttpServletResponse.SC_NOT_FOUND);
  				}
  			} else if ("open".equals(command)) {
  				open(getBoolean(request, "init", false), getFile(request, "target"), getBoolean(request, "tree", false), apiResponse);
  			} else if ("parents".equals(command)) {
  				parents(getFile(request, "target"), apiResponse);
  			} else if ("tree".equals(command)) {
  				tree(getFile(request, "target"), apiResponse);
  			} else if ("mkfile".equals(command)) {
  				createFile(request.getParameter("target"), request.getParameter("name"), apiResponse);
  			} else if ("mkdir".equals(command)) {
  				createDir(request.getParameter("target"), request.getParameter("name"), apiResponse);
  			} else if ("rm".equals(command)) {
  				deleteFile(request, rs.getParameterValues("targets[]", null), apiResponse);
  			} else if ("duplicate".equals(command)) {
  				duplicateFile(rs.getParameterValues("targets[]", null), apiResponse);
  			} else if ("put".equals(command)) {
  				updateFile(rs.getParameter("content", null), rs.getParameter("target", null), apiResponse);
  			} else if ("search".equals(command)) {
  				searchFiles(rs.getParameter("q", null), apiResponse);
  			} else if ("get".equals(command)) {
  				getFile(rs.getParameter("target", null), apiResponse);
  			} else if ("rename".equals(command)) {
  				renameFile(request, response, rs.getParameter("target", null), rs.getParameter("name", null), apiResponse);
  			} else if ("upload".equals(command)) {
  				uploadFile(rs.getParameter("target", null), rs.getFileItemMap().get("upload[]"), rs.getParameter("name", null), apiResponse);
  			} else if ("archive".equals(command)) {
  				compressFiles(rs.getParameterValues("targets[]", null), rs.getParameter("type", null), apiResponse);
  			} else if ("extract".equals(command)) {
  				extractFile(rs.getParameter("target", null), apiResponse);
  			} else if ("resize".equals(command)) {
  				String mode = rs.getParameter("mode", null);
  				String target = rs.getParameter("target", null);
  				int height = Integer.parseInt(rs.getParameter("height", "-1"));
  				int width = Integer.parseInt(rs.getParameter("width", "-1"));
  				int degree = Integer.parseInt(rs.getParameter("degree", "0"));
  				int x = Integer.parseInt(rs.getParameter("x", "-1"));
  				int y = Integer.parseInt(rs.getParameter("y", "-1"));
  				transformFile(target, mode, width, height, x, y, degree, apiResponse);
  			} else if ("paste".equals(command)) {
  				pasteFiles(rs.getParameter("src", null), rs.getParameter("dst", null), rs.getParameterValues("targets[]", null), StringHelper.isTrue(rs.getParameter("cut", "false")), apiResponse);
  			}
  			if (request.getSession().getAttribute("ELPath") != null) {
  				apiResponse.clear();
  				init("" + request.getSession().getAttribute("ELPath"), apiResponse);
  				request.getSession().removeAttribute("ELPath");
  			}
  		} catch (ELFinderException elEx) {
  			elEx.printStackTrace();
  			apiResponse.clear();
  			apiResponse.put("error", elEx.getMessage());
  		} catch (Throwable ex) {
  			ex.printStackTrace();
  			apiResponse.clear();
  			apiResponse.put("error", "Exception: " + ex.toString());
  		}
  
  		if (writeJSON) {
  			JSONSerializer.writeJSONString(apiResponse, out);
  		}
  
  	}
  
  	private void init(String inFolder, Map<String, Object> apiResponse) {
  		String[] folders = inFolder.split("/");
  		ELFile currentFile = null;
  		if (folders.length > 1) {
  			/*
  			 * String volName = folders[1]; ELFile currentFile = null; for
  			 * (ELFile volume : getVolumeFiles()) { if
  			 * (volume.getFile().getName().equals(volName)) { currentFile =
  			 * volume; } }
  			 */
  			currentFile = getVolumeFiles().iterator().next();
  			if (currentFile != null) {
  				for (int i = 1; i < folders.length; i++) {
  					for (ELFile file : currentFile.getChildren()) {
  						if (file.getFile().getName().equals(folders[i])) {
  							currentFile = file;
  						}
  					}
  				}
  			}
  		}
  		open(true, currentFile, true, apiResponse);
  	}
  
  	protected abstract void pasteFiles(String srcHashFolder, String dstHashFolder, String[] files, boolean cut, Map<String, Object> apiResponse) throws IOException;
  
  	/*
  	 * ELFile dstFolder = hashToFile(dstHashFolder); List<ELFile> addedFiles =
  	 * new LinkedList<ELFile>(); List<ELFile> removeFiles = new
  	 * LinkedList<ELFile>(); for (String file : files) { ELFile oldFile =
  	 * hashToFile(file); File newFile = new
  	 * File(URLHelper.mergePath(dstFolder.getFile().getAbsolutePath(),
  	 * oldFile.getFile().getName())); if (!newFile.exists()) { if
  	 * (oldFile.getFile().isFile()) { ELFile newELFile = createELFile(dstFolder,
  	 * newFile); ResourceHelper.writeFileToFile(oldFile.getFile(), newFile);
  	 * addedFiles.add(newELFile); if (cut) { oldFile.getFile().delete();
  	 * removeFiles.add(oldFile); } } else {
  	 * FileUtils.moveDirectory(oldFile.getFile(), newFile); ELFile newELFile =
  	 * createELFile(dstFolder, newFile); addedFiles.add(newELFile); } } }
  	 * apiResponse.put("added", printFiles(addedFiles));
  	 * apiResponse.put("removed", printFiles(removeFiles)); }
  	 */
  
  	protected abstract ELFile createELFile(ELFile parent, File file);
  
  	protected abstract void uploadFile(String folderHash, FileItem[] filesItem, String parameter, Map<String, Object> apiResponse) throws Exception;
  
  	protected abstract void extractFile(String fileHash, Map<String, Object> apiResponse) throws Exception;
  
  	protected abstract void compressFiles(String[] files, String type, Map<String, Object> apiResponse) throws Exception;
  
  	protected abstract void renameFile(HttpServletRequest request, HttpServletResponse response, String fileHash, String name, Map<String, Object> apiResponse) throws ELFinderException, Exception;
  
  	protected abstract void duplicateFile(String[] filesHash, Map<String, Object> apiResponse) throws IOException;
  
  	protected void transformFile(String fileHash, String mode, int width, int height, int x, int y, int degree, Map<String, Object> apiResponse) throws Exception {
  		ELFile file = hashToFile(fileHash);
  		if (file.getFile().exists()) {
  			IIOMetadata metadata = ResourceHelper.getImageMetadata(file.getFile());			
  			if ("resize".equals(mode)) {
  				BufferedImage img = ImageEngine.loadImage(file.getFile());
  				img = ImageEngine.resizeImage(img, width, height);
  				ImageEngine.storeImage(img, file.getFile());
  				ResourceHelper.writeImageMetadata(metadata, file.getFile());
  				apiResponse.put("changed", printFiles(Arrays.asList(new ELFile[] { file })));
  			} else if ("crop".equals(mode)) {
  				BufferedImage img = ImageEngine.loadImage(file.getFile());
  				img = ImageEngine.cropImage(img, width, height, x, y);
  				ImageEngine.storeImage(img, file.getFile());
  				ResourceHelper.writeImageMetadata(metadata, file.getFile());
  				apiResponse.put("changed", printFiles(Arrays.asList(new ELFile[] { file })));
  			} else if ("rotate".equals(mode)) {
  				BufferedImage img = ImageEngine.loadImage(file.getFile());
  				img = ImageEngine.rotate(img, degree, null);
  				ImageEngine.storeImage(img, file.getFile());
  				ResourceHelper.writeImageMetadata(metadata, file.getFile());
  				apiResponse.put("changed", printFiles(Arrays.asList(new ELFile[] { file })));
  			}			
  		}
  	}
  
  	private void getFile(String fileHash, Map<String, Object> apiResponse) throws FileNotFoundException, IOException {
  		JavloELFile file = (JavloELFile) hashToFile(fileHash);
  		if (file.getFile().exists()) {
  			apiResponse.put("content", ResourceHelper.loadStringFromFile(file.getFile()));
  		}
  	}
  
  	private static void searchFiles(ELFile file, String q, boolean inside, List<ELFile> result) throws FileNotFoundException, IOException {
  		if (file.getFile().isFile()) {
  			if (file.getFile().getName().contains(q)) {
  				result.add(file);
  			} else if (inside) {
  				if (ResourceHelper.getFileContent(file.getFile()).contains(q)) {
  					result.add(file);
  				}
  			}
  		} else {
  			List<ELFile> children = file.getChildren();
  			for (ELFile elFile : children) {
  				searchFiles(elFile, q, inside, result);
  			}
  		}
  	}
  
  	private void searchFiles(String q, Map<String, Object> apiResponse) throws FileNotFoundException, IOException {
  		q = q.trim();
  		boolean inside = !q.startsWith("name:");
  		if (!inside) {
  			q = q.replaceFirst("name:", "");
  			q = q.trim();
  		}
  		List<ELFile> searchResult = new LinkedList<ELFile>();
  		List<ELVolume> volumes = getVolumes();
  		for (ELVolume elVolume : volumes) {
  			searchFiles(elVolume.getRoot(), q, inside, searchResult);
  		}
  
  		apiResponse.put("files", printFiles(searchResult));
  	}
  
  	private void updateFile(String content, String fileHash, Map<String, Object> apiResponse) throws IOException {
  		ELFile file = hashToFile(fileHash);
  