Index: /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/ConnectorServlet.java
===================================================================
--- /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/ConnectorServlet.java	(revision 1689)
+++ /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/ConnectorServlet.java	(revision 1690)
@@ -79,7 +79,7 @@
 
 		File defaultUserFilesDir = new File(realDefaultUserFilesPath);
-		if (!defaultUserFilesDir.exists()) {
-			defaultUserFilesDir.mkdirs();
-		}
+		UtilsFile.checkDirAndCreate(defaultUserFilesDir);
+		
+		// FIXME wrong spelling
 		logger.info("ConnectorServlet successfull initialized!");
 	}
@@ -113,20 +113,21 @@
 		XmlResponse xr;
 		
-		if (!CommandHandler.isValidForGet(commandStr))
+		if (!SessionDataHandler.isEnabledForFileBrowsing(request))
 			xr = new XmlResponse(XmlResponse.EN_ERROR,
-					XmlResponse.CM_INVALID_COMMAND);
-		else if (!SessionDataHandler.isEnabledForFileBrowsing(request))
+					Messages.NOT_AUTHORIZED_FOR_BROWSING);
+		else if (!CommandHandler.isValidForGet(commandStr))
 			xr = new XmlResponse(XmlResponse.EN_ERROR,
-					XmlResponse.CM_NOT_AUTHORIZED);
+					Messages.INVALID_COMMAND); 
 		else if (typeStr != null && !ResourceTypeHandler.isValid(typeStr))
 			xr = new XmlResponse(XmlResponse.EN_ERROR,
-					XmlResponse.CM_INVALID_TYPE);
+					Messages.INVALID_TYPE);
 		else if (!UtilsFile.isValidPath(currentFolderStr))
-			xr = new XmlResponse(XmlResponse.EN_INVALID_FOLDER_NAME);
+			xr = new XmlResponse(XmlResponse.EN_ERROR, 
+					Messages.INVALID_CURRENT_FOLDER);
 		else {
 			CommandHandler command = CommandHandler.getCommand(commandStr);
 			ResourceTypeHandler resourceType = ResourceTypeHandler
 					.getDefaultResourceType(typeStr);
-			// TODO clean up this folder handling mess somehow?!
+
 			String typePath = constructResourceTypeUrl(resourceType, request);
 			String typeDirPath = getServletContext().getRealPath(typePath);
@@ -134,8 +135,5 @@
 
 			File typeDir = new File(typeDirPath);
-			if (!typeDir.exists()) {
-				typeDir.mkdirs();
-				logger.debug("Type dir '{}' successfully created", typeDirPath);
-			}
+			UtilsFile.checkDirAndCreate(typeDir);
 
 			File currentDir = new File(typeDir, currentFolderStr);
@@ -204,12 +202,10 @@
 
 		logger.debug("Parameter Command: {}", commandStr);
+		logger.debug("Parameter Type: {}", typeStr);
 		logger.debug("Parameter CurrentFolder: {}", currentFolderStr);
-		logger.debug("Parameter Type: {}", typeStr);
-
-		if (!ResourceTypeHandler.isValid(typeStr))
-			logger.warn("Unknown Type requested: {}", typeStr);
-
-		ResourceTypeHandler fileType = ResourceTypeHandler.getDefaultResourceType(typeStr);
-
+
+		UploadResponse ur;
+		
+		// FIXME improve comment
 		// if this is a QuickUpload-Request, 'commandStr' and 'currentFolderStr' are empty and have
 		// to preset and construct the full resource type path !!
@@ -217,36 +213,41 @@
 			commandStr = "QuickUpload";
 			currentFolderStr = "/";
-			String quickUploadFolder = constructResponseUrl(fileType, currentFolderStr,
-			        request);
-			File file = new File(getServletContext().getRealPath(quickUploadFolder));
-			if (!file.exists())
-				file.mkdirs();
 		}
-
-		UploadResponse ur = null;
-
-		if (Utils.isEmpty(commandStr) || Utils.isEmpty(currentFolderStr)
-		        || Utils.isEmpty(typeStr))
-			ur = UploadResponse.UR_BAD_REQUEST;
+		
+		if (!SessionDataHandler.isEnabledForFileUpload(request))
+			ur = new UploadResponse(UploadResponse.EN_SECURITY_ERROR, null,
+					null, Messages.NOT_AUTHORIZED_FOR_UPLOAD);
 		else if (!CommandHandler.isValidForPost(commandStr))
-			ur = UploadResponse.UR_SECURITY_ERROR;
-		else if (!UtilsFile.isValidPath(currentFolderStr)) {
-			ur = new UploadResponse(UploadResponse.EN_SECURITY_ERROR, null, null,
-			        "'currentFolderStr' isn't valid!");
-		} else if (!SessionDataHandler.isEnabledForFileUpload(request)) {
-			ur = new UploadResponse(UploadResponse.EN_SECURITY_ERROR, null, null,
-			        "The current user isn't authorized for uploading files!");
-		} else {
-			String currentPath = constructResponseUrl(fileType, currentFolderStr, request);
-			File currentDirPath = new File(getServletContext().getRealPath(currentPath));
-
-			if (!UtilsFile.isValidPath(currentFolderStr) || !currentDirPath.exists())
-				ur = UploadResponse.UR_BAD_REQUEST;
+			ur = new UploadResponse(UploadResponse.EN_ERROR, null, null,
+					Messages.INVALID_COMMAND);
+		else if (typeStr != null && !ResourceTypeHandler.isValid(typeStr))
+			ur = new UploadResponse(UploadResponse.EN_ERROR, null, null,
+					Messages.INVALID_TYPE);
+		else if (!UtilsFile.isValidPath(currentFolderStr))
+			ur = new UploadResponse(UploadResponse.EN_ERROR, null, null,
+					Messages.INVALID_CURRENT_FOLDER);
+		else {
+			ResourceTypeHandler resourceType = ResourceTypeHandler.getDefaultResourceType(typeStr);
+			
+			String typePath = constructResourceTypeUrl(resourceType, request);
+			String typeDirPath = getServletContext().getRealPath(typePath);
+			String currentPath = typePath + currentFolderStr;
+
+			File typeDir = new File(typeDirPath);
+			UtilsFile.checkDirAndCreate(typeDir);
+
+			File currentDir = new File(typeDir, currentFolderStr);
+
+			if (!currentDir.exists())
+				ur = new UploadResponse(UploadResponse.EN_ERROR, null, null,
+						Messages.INVALID_CURRENT_FOLDER);
 			else {
-
+				
 				String newFilename = null;
 				FileItemFactory factory = new DiskFileItemFactory();
 				ServletFileUpload upload = new ServletFileUpload(factory);
+				
 				try {
+					
 					List<FileItem> items = upload.parseRequest(request);
 
@@ -258,50 +259,50 @@
 					String extension = FilenameUtils.getExtension(filename);
 
-					boolean validExtension = ExtensionsHandler.isAllowed(fileType, extension);
-
-					if (!validExtension)
-						ur = UploadResponse.UR_INVALID_EXTENSION;
+					if (!ExtensionsHandler.isAllowed(resourceType, extension))
+						ur = new UploadResponse(UploadResponse.EN_INVALID_EXTENSION);
 					else {
 
 						// construct an unique file name
-						File pathToSave = new File(currentDirPath, filename);
+						File pathToSave = new File(currentDir, filename);
 						int counter = 1;
 						while (pathToSave.exists()) {
-							newFilename = baseName.concat("(").concat(String.valueOf(counter))
-							        .concat(")").concat(".").concat(extension);
-							pathToSave = new File(currentDirPath, newFilename);
+							newFilename = baseName.concat("(").concat(
+									String.valueOf(counter)).concat(")")
+									.concat(".").concat(extension);
+							pathToSave = new File(currentDir, newFilename);
 							counter++;
 						}
 
-						if (Utils.isEmpty(newFilename)) {
+						if (Utils.isEmpty(newFilename))
 							ur = new UploadResponse(UploadResponse.EN_OK, Utils
-							        .constructServerAddress(request, currentPath).concat(filename));
-						} else {
-							ur = new UploadResponse(UploadResponse.EN_RENAMED, Utils
-							        .constructServerAddress(request, currentPath).concat(
-							                newFilename), newFilename);
-						}
+									.constructServerAddress(request,
+											currentPath).concat(filename));
+						else
+							ur = new UploadResponse(UploadResponse.EN_RENAMED,
+									Utils.constructServerAddress(request,
+											currentPath).concat(newFilename),
+									newFilename);
 
 						// secure image check
-						if (fileType.equals(ResourceTypeHandler.IMAGE) && ConnectorHandler.isSecureImageUploads()) {
-							boolean check = UtilsFile.isImage(uplFile.getInputStream());
-							if (check) {
+						if (resourceType.equals(ResourceTypeHandler.IMAGE)
+								&& ConnectorHandler.isSecureImageUploads()) {
+							if (UtilsFile.isImage(uplFile.getInputStream()))
 								uplFile.write(pathToSave);
-							} else {
+							else {
 								uplFile.delete();
-								ur = UploadResponse.UR_INVALID_EXTENSION;
+								ur = new UploadResponse(
+										UploadResponse.EN_INVALID_EXTENSION);
 							}
-						} else {
+						} else
 							uplFile.write(pathToSave);
-						}
 
 					}
-				} catch (FileUploadException ex) {
-					ur = UploadResponse.UR_BAD_REQUEST;
 				} catch (Exception e) {
-					ur = UploadResponse.UR_SECURITY_ERROR;
+					ur = new UploadResponse(UploadResponse.EN_SECURITY_ERROR);
 				}
 			}
-		}
+				
+		}			
+		
 		out.print(ur);
 		out.flush();
@@ -322,5 +323,5 @@
 	
 	/**
-	 * TODO document me
+	 * TODO document me!
 	 * @param resourceType
 	 * @param request
Index: /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/Messages.java
===================================================================
--- /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/Messages.java	(revision 1690)
+++ /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/Messages.java	(revision 1690)
@@ -0,0 +1,20 @@
+package net.fckeditor.connector;
+
+public class Messages {
+
+	/** Error message NOT AUTHORIZED FOR FILE UPLOAD */
+	public static final String NOT_AUTHORIZED_FOR_UPLOAD = "The current user isn't authorized for file upload!";
+
+	/** Error message NOT AUTHORIZED FOR FILE BROWSING */
+	public static final String NOT_AUTHORIZED_FOR_BROWSING = "The current user isn't authorized for file browsing!";
+
+	/** Error message INVALID COMMAND SUPPLIED */
+	public static final String INVALID_COMMAND = "Invalid command specified";
+
+	/** Error message INVALID TYPE SUPPLIED */
+	public static final String INVALID_TYPE = "Invalid resource type specified";
+
+	/** Error message INVALID CURRENT FOLDER */
+	public static final String INVALID_CURRENT_FOLDER = "Invalid current folder specified";
+
+}
Index: /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/response/UploadResponse.java
===================================================================
--- /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/response/UploadResponse.java	(revision 1689)
+++ /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/response/UploadResponse.java	(revision 1690)
@@ -21,4 +21,5 @@
 package net.fckeditor.response;
 
+import net.fckeditor.connector.Messages;
 import net.fckeditor.tool.Utils;
 
@@ -55,7 +56,4 @@
 	public static final int EN_ERROR = 1;
 
-	/** Error number WARNING */
-	public static final int EN_WARNING = 101;
-
 	/** Error number RENAMED */
 	public static final int EN_RENAMED = 201;
@@ -66,26 +64,4 @@
 	/** Error number SECURITY ERROR */
 	public static final int EN_SECURITY_ERROR = 203;
-
-	/** Error number GENERIC ERROR */
-	public static final int EN_GENERIC_NUMBER = -1;
-
-	/** HTTP 400 Status text */
-	public static final String CM_HTTP_400 = "400 Bad request";
-
-	/** UploadResponse INVALID EXTENSION */
-	public static final UploadResponse UR_INVALID_EXTENSION = new UploadResponse(
-			EN_INVALID_EXTENSION);
-
-	/** UploadResponse SECURITY ERROR */
-	public static final UploadResponse UR_SECURITY_ERROR = new UploadResponse(
-			EN_SECURITY_ERROR);
-
-	/** UploadResponse GENERIC NUMBER */
-	public static final UploadResponse UR_GENERIC_NUMBER = new UploadResponse(
-			EN_GENERIC_NUMBER);
-
-	/** UploadResponse BAD REQUEST */
-	public static final UploadResponse UR_BAD_REQUEST = new UploadResponse(
-			EN_ERROR, null, null, CM_HTTP_400);
 
 	/**
Index: /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/response/XmlResponse.java
===================================================================
--- /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/response/XmlResponse.java	(revision 1689)
+++ /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/response/XmlResponse.java	(revision 1690)
@@ -76,13 +76,4 @@
 	/** Error number UNKNOWN ERROR */
 	public static final int EN_UKNOWN = 110;
-
-	/** Error message NOT AUTHORIZED FOR BROWSING */
-	public static final String CM_NOT_AUTHORIZED = "The current user isn't authorized for file browsing!";
-	
-	/** Error message INVALID TYPE SUPPLIED */
-	public static final String CM_INVALID_TYPE = "Invalid resource type specified";
-	
-	/** Error message INVALID TYPE SUPPLIED */
-	public static final String CM_INVALID_COMMAND = "Invalid command specified";
 
 	/**
Index: /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/tool/UtilsFile.java
===================================================================
--- /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/tool/UtilsFile.java	(revision 1689)
+++ /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/tool/UtilsFile.java	(revision 1690)
@@ -21,8 +21,11 @@
 package net.fckeditor.tool;
 
+import java.io.File;
 import java.io.InputStream;
 
 import org.apache.commons.io.FilenameUtils;
 import org.devlib.schmidt.imageinfo.ImageInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import net.fckeditor.handlers.ConnectorHandler;
@@ -34,4 +37,6 @@
  */
 public class UtilsFile {
+	
+	private static final Logger logger = LoggerFactory.getLogger(UtilsFile.class);
 
 	/**
@@ -125,4 +130,15 @@
     	return filename.matches("[^\\.]+\\.[^\\.]+");
     }
+    
+    /**
+	 * TODO - document me!
+	 * @param dir
+	 */
+	public static void checkDirAndCreate(File dir) {
+		if (!dir.exists()) {
+			dir.mkdirs();
+			logger.debug("Dir '{}' successfully created", dir);
+		}
+	}
 
 }
Index: /FCKeditor.Java/branches/2.4/src/test/java/net/fckeditor/tool/UploadResponseTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/src/test/java/net/fckeditor/tool/UploadResponseTest.java	(revision 1689)
+++ /FCKeditor.Java/branches/2.4/src/test/java/net/fckeditor/tool/UploadResponseTest.java	(revision 1690)
@@ -23,5 +23,5 @@
 		new UploadResponse("1");
 	}
-
+/*
 	@Test
 	public void onlyErrorNumber() throws Exception {
@@ -31,5 +31,5 @@
 		assertEquals(expected, actual.toString());
 	}
-	
+	*/
 	@Test
 	public void fourArguments() throws Exception {
@@ -47,5 +47,5 @@
 		assertEquals(expected, actual.toString());
 	}
-	
+/*	
 	@Test
 	public void customMessage() throws Exception {
@@ -56,5 +56,6 @@
 		assertEquals(expected, actual.toString());
 	}
-	
+*/
+/*
 	@Test
 	public void nullArguments() throws Exception {
@@ -64,4 +65,4 @@
 		assertEquals(expected, actual.toString());
 	}
-
+*/
 }
