Index: FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/AbstracLocalFileSystemConnector.java
===================================================================
--- FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/AbstracLocalFileSystemConnector.java	(revision 2621)
+++ FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/AbstracLocalFileSystemConnector.java	(revision 2621)
@@ -0,0 +1,207 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ * 
+ * == BEGIN LICENSE ==
+ * 
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ * 
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ * 
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ * 
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ * 
+ * == END LICENSE ==
+ */
+package net.fckeditor.connector.impl;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+import net.fckeditor.connector.Connector;
+import net.fckeditor.connector.exception.FolderAlreadyExistsException;
+import net.fckeditor.connector.exception.InvalidCurrentFolderException;
+import net.fckeditor.connector.exception.InvalidNewFolderNameException;
+import net.fckeditor.connector.exception.WriteException;
+import net.fckeditor.handlers.ConnectorHandler;
+import net.fckeditor.handlers.RequestCycleHandler;
+import net.fckeditor.handlers.ResourceType;
+import net.fckeditor.requestcycle.ThreadLocalData;
+import net.fckeditor.tool.UtilsFile;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFileFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of the {@link Connector} for the file system. All path are
+ * interpreted as sub-directories of the
+ * {@link ConnectorHandler#getUserFilesPath()}.<br>
+ * 
+ * @version $Id$
+ */
+public abstract class AbstracLocalFileSystemConnector implements Connector {
+
+	// TODO log outputs should display extending classes only
+	private static final Logger logger = LoggerFactory
+			.getLogger(AbstracLocalFileSystemConnector.class);
+	protected static ServletContext servletContext;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see net.fckeditor.connector.Connector#init()
+	 */
+	public void init(final ServletContext servletContext) {
+		// create user's default dir
+		AbstracLocalFileSystemConnector.servletContext = servletContext;
+		String defaultAbsolutePath = getRealUserFilesAbsolutePath(ConnectorHandler
+				.getUserFilesPath());
+		File defaultUserFilesDir = new File(defaultAbsolutePath);
+		UtilsFile.checkDirAndCreate(defaultUserFilesDir);
+		logger.info("Initialized!");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seenet.fckeditor.connector.Connector#fileUpload(net.fckeditor.handlers.
+	 * ResourceType, java.lang.String, java.lang.String, java.io.InputStream)
+	 */
+	public String fileUpload(final ResourceType type,
+			final String currentFolder, final String fileName,
+			final InputStream inputStream) throws SecurityException,
+			InvalidCurrentFolderException, WriteException {
+		String absolutePath = getRealUserFilesAbsolutePath(RequestCycleHandler
+				.getUserFilesAbsolutePath(ThreadLocalData.getRequest()));
+		File typeDir = getOrCreateResourceTypeDir(absolutePath, type);
+		File currentDir = new File(typeDir, currentFolder);
+		if (!currentDir.exists() || !currentDir.isDirectory())
+			throw new InvalidCurrentFolderException();
+		File newFile = new File(currentDir, fileName);
+		File fileToSave = UtilsFile.getUniqueFile(newFile.getAbsoluteFile());
+		try {
+			IOUtils.copyLarge(inputStream, new FileOutputStream(fileToSave));
+		} catch (SecurityException e) {
+			// not explicitly thrown by anyone but in case that a
+			// SecurityManager is deployed, this could restrict writing on disk
+			throw e;
+		} catch (Exception e) {
+			throw new WriteException();
+		}
+		return fileToSave.getName();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * net.fckeditor.connector.Connector#createFolder(net.fckeditor.handlers
+	 * .ResourceType, java.lang.String, java.lang.String)
+	 */
+	public void createFolder(final ResourceType type,
+			final String currentFolder, final String newFolder)
+			throws InvalidCurrentFolderException, SecurityException,
+			InvalidNewFolderNameException, FolderAlreadyExistsException {
+		String absolutePath = getRealUserFilesAbsolutePath(RequestCycleHandler
+				.getUserFilesAbsolutePath(ThreadLocalData.getRequest()));
+		File typeDir = getOrCreateResourceTypeDir(absolutePath, type);
+		File currentDir = new File(typeDir, currentFolder);
+		if (!currentDir.exists() || !currentDir.isDirectory())
+			throw new InvalidCurrentFolderException();
+		File newDir = new File(currentDir, newFolder);
+		if (newDir.exists())
+			throw new FolderAlreadyExistsException();
+		try {
+			if (!newDir.mkdir())
+				throw new InvalidNewFolderNameException();
+		} catch (SecurityException e) {
+			throw e;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seenet.fckeditor.connector.Connector#getFiles(net.fckeditor.handlers.
+	 * ResourceType, java.lang.String)
+	 */
+	public List<Map<String, Object>> getFiles(ResourceType type,
+			String currentFolder) throws InvalidCurrentFolderException,
+			SecurityException {
+		String absolutePath = getRealUserFilesAbsolutePath(RequestCycleHandler
+				.getUserFilesAbsolutePath(ThreadLocalData.getRequest()));
+		File typeDir = getOrCreateResourceTypeDir(absolutePath, type);
+		File currentDir = new File(typeDir, currentFolder);
+		if (!currentDir.exists() || !currentDir.isDirectory())
+			throw new InvalidCurrentFolderException();
+
+		// collect files
+		List<Map<String, Object>> files;
+		Map<String, Object> fileMap;
+		try {
+			File[] fileList = currentDir
+					.listFiles((FileFilter) FileFileFilter.FILE);
+			files = new ArrayList<Map<String, Object>>(fileList.length);
+			for (File file : fileList) {
+				fileMap = new HashMap<String, Object>(2);
+				fileMap.put(Connector.KEY_NAME, file.getName());
+				fileMap.put(Connector.KEY_SIZE, file.length());
+				files.add(fileMap);
+			}
+			return files;
+		} catch (SecurityException e) {
+			throw e;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seenet.fckeditor.connector.Connector#getFolders(net.fckeditor.handlers.
+	 * ResourceType, java.lang.String)
+	 */
+	public List<String> getFolders(final ResourceType type,
+			final String currentFolder) throws InvalidCurrentFolderException,
+			SecurityException {
+		String absolutePath = getRealUserFilesAbsolutePath(RequestCycleHandler
+				.getUserFilesAbsolutePath(ThreadLocalData.getRequest()));
+		File typeDir = getOrCreateResourceTypeDir(absolutePath, type);
+		File currentDir = new File(typeDir, currentFolder);
+		if (!currentDir.exists() || !currentDir.isDirectory())
+			throw new InvalidCurrentFolderException();
+
+		try {
+			String[] fileList = currentDir.list(DirectoryFileFilter.DIRECTORY);
+			return Arrays.asList(fileList);
+		} catch (SecurityException e) {
+			throw e;
+		}
+	}
+
+	protected abstract String getRealUserFilesAbsolutePath(String path);
+
+	private static File getOrCreateResourceTypeDir(final String baseDir,
+			final ResourceType type) throws SecurityException {
+		File dir = new File(baseDir, type.getPath());
+		if (!dir.exists())
+			dir.mkdirs();
+		return dir;
+	}
+}
Index: FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/ContextConnector.java
===================================================================
--- FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/ContextConnector.java	(revision 2621)
+++ FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/ContextConnector.java	(revision 2621)
@@ -0,0 +1,34 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ * 
+ * == BEGIN LICENSE ==
+ * 
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ * 
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ * 
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ * 
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ * 
+ * == END LICENSE ==
+ */
+package net.fckeditor.connector.impl;
+
+/**
+ * 
+ * @version $Id$
+ */
+public class ContextConnector extends AbstracLocalFileSystemConnector {
+
+	@Override
+	protected String getRealUserFilesAbsolutePath(String path) {
+		return servletContext.getRealPath(path);
+	}
+
+}
Index: FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/LocalConnector.java
===================================================================
--- FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/LocalConnector.java	(revision 2621)
+++ FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/LocalConnector.java	(revision 2621)
@@ -0,0 +1,34 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ * 
+ * == BEGIN LICENSE ==
+ * 
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ * 
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ * 
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ * 
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ * 
+ * == END LICENSE ==
+ */
+package net.fckeditor.connector.impl;
+
+/**
+ * 
+ * @version $Id$
+ */
+public class LocalConnector extends AbstracLocalFileSystemConnector {
+
+	@Override
+	protected String getRealUserFilesAbsolutePath(String path) {
+		return path;
+	}
+
+}
Index: FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/SimpleFileSystemConnector.java
===================================================================
--- FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/impl/SimpleFileSystemConnector.java	(revision 2612)
+++ 	(revision )
@@ -1,210 +1,0 @@
-/*
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net
- * Copyright (C) 2003-2008 Frederico Caldeira Knabben
- * 
- * == BEGIN LICENSE ==
- * 
- * Licensed under the terms of any of the following licenses at your
- * choice:
- * 
- *  - GNU General Public License Version 2 or later (the "GPL")
- *    http://www.gnu.org/licenses/gpl.html
- * 
- *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
- *    http://www.gnu.org/licenses/lgpl.html
- * 
- *  - Mozilla Public License Version 1.1 or later (the "MPL")
- *    http://www.mozilla.org/MPL/MPL-1.1.html
- * 
- * == END LICENSE ==
- */
-package net.fckeditor.connector.impl;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletContext;
-
-import net.fckeditor.connector.Connector;
-import net.fckeditor.connector.exception.FolderAlreadyExistsException;
-import net.fckeditor.connector.exception.InvalidCurrentFolderException;
-import net.fckeditor.connector.exception.InvalidNewFolderNameException;
-import net.fckeditor.connector.exception.WriteException;
-import net.fckeditor.handlers.ConnectorHandler;
-import net.fckeditor.handlers.RequestCycleHandler;
-import net.fckeditor.handlers.ResourceType;
-import net.fckeditor.requestcycle.ThreadLocalData;
-import net.fckeditor.tool.UtilsFile;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.filefilter.DirectoryFileFilter;
-import org.apache.commons.io.filefilter.FileFileFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of the {@link Connector} for the file system. All path are
- * interpreted as sub-directories of the
- * {@link ConnectorHandler#getUserFilesPath()}.<br>
- * 
- * TODO should we move the static methods into a util-class in package
- * net.fckeditor.connector.impl ???
- * 
- * @version $Id$
- */
-// FIXME the name is inappropriate, it should be ContextFileSystemConnector
-// we should provide another implementation which leads outside of the context
-// HINT: we should keep this name because it can run without any PathBuilder
-// implementation
-public class SimpleFileSystemConnector implements Connector {
-	private static final Logger logger = LoggerFactory
-			.getLogger(SimpleFileSystemConnector.class);
-	private static ServletContext servletContext;
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see net.fckeditor.connector.Connector#init()
-	 */
-	public void init(final ServletContext servletContext) {
-		// create user's default dir
-		SimpleFileSystemConnector.servletContext = servletContext;
-		String realDefaultUserFilesPath = SimpleFileSystemConnector.servletContext
-				.getRealPath(ConnectorHandler.getUserFilesPath());
-		File defaultUserFilesDir = new File(realDefaultUserFilesPath);
-		UtilsFile.checkDirAndCreate(defaultUserFilesDir);
-		logger.info("Initialized!");
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seenet.fckeditor.connector.Connector#fileUpload(net.fckeditor.handlers.
-	 * ResourceType, java.lang.String, java.lang.String, java.io.InputStream)
-	 */
-	public String fileUpload(final ResourceType type,
-			final String currentFolder, final String fileName,
-			final InputStream inputStream) throws SecurityException,
-			InvalidCurrentFolderException, WriteException {
-		String absolutePath = RequestCycleHandler
-				.getUserFilesAbsolutePath(ThreadLocalData.getRequest());
-		File typeDir = getAndCreateResourceTypeDir(absolutePath, type);
-		File currentDir = new File(typeDir, currentFolder);
-		if (!currentDir.exists() || !currentDir.isDirectory())
-			throw new InvalidCurrentFolderException();
-		File newFile = new File(currentDir, fileName);
-		File fileToSave = UtilsFile.getUniqueFile(newFile.getAbsoluteFile());
-		try {
-			IOUtils.copyLarge(inputStream, new FileOutputStream(fileToSave));
-		} catch (SecurityException e) {
-			// not explicitly thrown by anyone but in case that a
-			// SecurityManager is deployed, this could restrict writing on disk
-			throw e;
-		} catch (Exception e) {
-			throw new WriteException();
-		}
-		return fileToSave.getName();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * net.fckeditor.connector.Connector#createFolder(net.fckeditor.handlers
-	 * .ResourceType, java.lang.String, java.lang.String)
-	 */
-	public void createFolder(final ResourceType type,
-			final String currentFolder, final String newFolder)
-			throws InvalidCurrentFolderException, SecurityException,
-			InvalidNewFolderNameException, FolderAlreadyExistsException {
-		String absolutePath = RequestCycleHandler
-				.getUserFilesAbsolutePath(ThreadLocalData.getRequest());
-		File typeDir = getAndCreateResourceTypeDir(absolutePath, type);
-		File currentDir = new File(typeDir, currentFolder);
-		if (!currentDir.exists() || !currentDir.isDirectory())
-			throw new InvalidCurrentFolderException();
-		File newDir = new File(currentDir, newFolder);
-		if (newDir.exists())
-			throw new FolderAlreadyExistsException();
-		try {
-			if (!newDir.mkdir())
-				throw new InvalidNewFolderNameException();
-		} catch (SecurityException e) {
-			throw e;
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seenet.fckeditor.connector.Connector#getFiles(net.fckeditor.handlers.
-	 * ResourceType, java.lang.String)
-	 */
-	public List<Map<String, Object>> getFiles(ResourceType type,
-			String currentFolder) throws InvalidCurrentFolderException,
-			SecurityException {
-		String absolutePath = RequestCycleHandler
-				.getUserFilesAbsolutePath(ThreadLocalData.getRequest());
-		File typeDir = getAndCreateResourceTypeDir(absolutePath, type);
-		File currentDir = new File(typeDir, currentFolder);
-		if (!currentDir.exists() || !currentDir.isDirectory())
-			throw new InvalidCurrentFolderException();
-
-		// collect files
-		List<Map<String, Object>> files;
-		Map<String, Object> fileMap;
-		try {
-			File[] fileList = currentDir
-					.listFiles((FileFilter) FileFileFilter.FILE);
-			files = new ArrayList<Map<String, Object>>(fileList.length);
-			for (File file : fileList) {
-				fileMap = new HashMap<String, Object>(2);
-				fileMap.put(Connector.KEY_NAME, file.getName());
-				fileMap.put(Connector.KEY_SIZE, file.length());
-				files.add(fileMap);
-			}
-			return files;
-		} catch (SecurityException e) {
-			throw e;
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seenet.fckeditor.connector.Connector#getFolders(net.fckeditor.handlers.
-	 * ResourceType, java.lang.String)
-	 */
-	public List<String> getFolders(final ResourceType type,
-			final String currentFolder) throws InvalidCurrentFolderException,
-			SecurityException {
-		String absolutePath = RequestCycleHandler
-				.getUserFilesAbsolutePath(ThreadLocalData.getRequest());
-		File typeDir = getAndCreateResourceTypeDir(absolutePath, type);
-		File currentDir = new File(typeDir, currentFolder);
-		if (!currentDir.exists() || !currentDir.isDirectory())
-			throw new InvalidCurrentFolderException();
-
-		try {
-			String[] fileList = currentDir.list(DirectoryFileFilter.DIRECTORY);
-			return Arrays.asList(fileList);
-		} catch (SecurityException e) {
-			throw e;
-		}
-	}
-
-	private static File getAndCreateResourceTypeDir(final String baseDir,
-			final ResourceType type) throws SecurityException {
-		File dir = new File(servletContext.getRealPath(baseDir), type.getPath());
-		if (!dir.exists())
-			dir.mkdirs();
-		return dir;
-	}
-}
