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 1622)
+++ /FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/ConnectorServlet.java	(revision 1623)
@@ -56,10 +56,9 @@
  * Servlet to upload and browse files.<br>
  * 
- * This servlet accepts 4 commands used to retrieve and create files and folders
- * from a server directory. The allowed commands are:
+ * This servlet accepts 4 commands used to retrieve and create files and folders from a server
+ * directory. The allowed commands are:
  * <ul>
- * <li>GetFolders: Retrive the list of directory under the current folder
- * <li>GetFoldersAndFiles: Retrive the list of files and directory under the
- * current folder
+ * <li>GetFolders: Retrive the list of directory under the current folder
+ * <li>GetFoldersAndFiles: Retrive the list of files and directory under the current folder
  * <li>CreateFolder: Create a new directory under the current folder
  * <li>FileUpload: Send a new file to the server (must be sent with a POST)
@@ -71,11 +70,9 @@
 
 	private static final long serialVersionUID = -5742008970929377161L;
-	private static final Logger logger = LoggerFactory
-			.getLogger(ConnectorServlet.class);
+	private static final Logger logger = LoggerFactory.getLogger(ConnectorServlet.class);
 
 	/**
 	 * Initialize the servlet.<br>
-	 * The init parameters will be read and used to adjust the defaults of the
-	 * {@link ConfigurationHandler} and the {@link ExtensionsHandler}.
+	 * The default directory for user files will be constructed.
 	 */
 	public void init() throws ServletException, IllegalArgumentException {
@@ -83,19 +80,9 @@
 		String realDefaultUserFilesPath = getServletContext().getRealPath(
 		        ConnectorHandler.getDefaultUserFilesPath());
-		
+
 		File defaultUserFilesDir = new File(realDefaultUserFilesPath);
-		File fileDir = new File(defaultUserFilesDir, ResourceTypeHandler.FILE.getPath());
-		File flashDir = new File(defaultUserFilesDir, ResourceTypeHandler.FLASH.getPath());
-		File imageDir = new File(defaultUserFilesDir, ResourceTypeHandler.IMAGE.getPath());
-		File mediaDir = new File(defaultUserFilesDir, ResourceTypeHandler.MEDIA.getPath());
 		if (!defaultUserFilesDir.exists()) {
 			defaultUserFilesDir.mkdirs();
 		}
-		
-		fileDir.mkdir();
-		flashDir.mkdir();
-		imageDir.mkdir();
-		mediaDir.mkdir();
-
 		logger.info("ConnectorServlet successfull initialized!");
 	}
@@ -107,10 +94,9 @@
 	 * connector?Command=CommandName&Type=ResourceType&CurrentFolder=FolderPath<br>
 	 * <br>
-	 * It executes the command and then return the results to the client in XML
-	 * format.
+	 * It executes the command and then return the results to the client in XML format.
 	 * 
 	 */
 	public void doGet(HttpServletRequest request, HttpServletResponse response)
-			throws ServletException, IOException {
+	        throws ServletException, IOException {
 		logger.debug("Entering ConnectorServlet#doGet");
 
@@ -129,17 +115,16 @@
 		logger.debug("Parameter Type: {}", typeStr);
 
-		String currentPath = constructTypeBasedFolderString(fileType,
-				currentFolderStr, request);
+		String currentPath = constructTypeBasedFolderString(fileType, currentFolderStr, request);
 		String currentDirPath = getServletContext().getRealPath(currentPath);
 
 		File currentDir = new File(currentDirPath);
-		if (!currentDir.exists()
-				&& SessionDataHandler.isEnabledForFileBrowsing(request)) {
+		if (!currentDir.exists() && SessionDataHandler.isEnabledForFileBrowsing(request)) {
 			currentDir.mkdirs();
 			logger.debug("Dir successfully created: {}", currentDirPath);
 		}
 
-		XmlResponse xr = new XmlResponse(commandStr, fileType, currentFolderStr, currentPath, request);
-		
+		XmlResponse xr = new XmlResponse(commandStr, fileType, currentFolderStr, currentPath,
+		        request);
+
 		if (!SessionDataHandler.isEnabledForFileBrowsing(request)) {
 			xr.setError(1, "The current user isn't authorized for file browsing!");
@@ -183,10 +168,10 @@
 	 * connector?Command=FileUpload&Type=ResourceType&CurrentFolder=FolderPath<br>
 	 * <br>
-	 * It store the file (renaming it in case a file with the same name exists)
-	 * and then return an HTML file with a javascript command in it.
+	 * It store the file (renaming it in case a file with the same name exists) and then return an
+	 * HTML file with a javascript command in it.
 	 * 
 	 */
 	public void doPost(HttpServletRequest request, HttpServletResponse response)
-			throws ServletException, IOException {
+	        throws ServletException, IOException {
 		logger.debug("Entering Connector#doPost");
 
@@ -207,19 +192,26 @@
 			logger.warn("Unknown Type requested: {}", typeStr);
 
+		ResourceTypeHandler fileType = ResourceTypeHandler.getDefaultResourceType(typeStr);
+
+		// if this is a QuickUpload-Request, 'commandStr' and 'currentFolderStr' are empty and have
+		// to preset and construct the full resource type path !!
 		if (isEmpty(commandStr) && isEmpty(currentFolderStr)) {
 			commandStr = "QuickUpload";
 			currentFolderStr = "/";
-		}
-
-		ResourceTypeHandler fileType = ResourceTypeHandler.getDefaultResourceType(typeStr);
+			String quickUploadFolder = constructTypeBasedFolderString(fileType, currentFolderStr, request);
+			File file = new File(getServletContext().getRealPath(quickUploadFolder));
+			if (!file.exists())
+				file.mkdirs();
+		}
 
 		UploadResponse ur = null;
 
-		if (!SessionDataHandler.isEnabledForFileUpload(request)) {
-			ur = new UploadResponse(UploadResponse.EN_SECURITY_ERROR, null,
-					null,
-					"The current user isn't authorized for uploading files!");
-		} else if (isEmpty(commandStr) || isEmpty(currentFolderStr)
-				|| isEmpty(typeStr))
+		if (!Utils.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 if (isEmpty(commandStr) || isEmpty(currentFolderStr) || isEmpty(typeStr))
 			ur = UploadResponse.UR_BAD_REQUEST;
 		else if (!commandStr.matches("(File|Quick)Upload"))
@@ -227,11 +219,8 @@
 		else {
 
-			String currentPath = constructTypeBasedFolderString(fileType,
-					currentFolderStr, request);
-			String currentDirPath = getServletContext()
-					.getRealPath(currentPath);
-
-			if (!isValidPath(currentFolderStr)
-					|| !(new File(currentDirPath).exists()))
+			String currentPath = constructTypeBasedFolderString(fileType, currentFolderStr, request);
+			String currentDirPath = getServletContext().getRealPath(currentPath);
+
+			if (!isValidPath(currentFolderStr) || !(new File(currentDirPath).exists()))
 				ur = UploadResponse.UR_BAD_REQUEST;
 			else {
@@ -249,6 +238,5 @@
 					String extension = FilenameUtils.getExtension(filename);
 
-					boolean validExtension = ExtensionsHandler.isAllowed(
-							fileType, extension);
+					boolean validExtension = ExtensionsHandler.isAllowed(fileType, extension);
 
 					if (!validExtension)
@@ -264,6 +252,5 @@
 						int counter = 1;
 						while (pathToSave.exists()) {
-							newFilename = baseName + "(" + counter + ")" + "."
-									+ extension;
+							newFilename = baseName + "(" + counter + ")" + "." + extension;
 							pathToSave = new File(currentDirPath, newFilename);
 							counter++;
@@ -272,11 +259,11 @@
 						uplFile.write(pathToSave);
 						if (isEmpty(newFilename)) {
-							ur = new UploadResponse(UploadResponse.EN_OK,
-									Utils.constructServerAddress(request, currentPath)
-											+ filename);
+							ur = new UploadResponse(UploadResponse.EN_OK, Utils
+							        .constructServerAddress(request, currentPath)
+							        + filename);
 						} else {
-							ur = new UploadResponse(UploadResponse.EN_RENAMED,
-									Utils.constructServerAddress(request, currentPath)
-											+ newFilename, newFilename);
+							ur = new UploadResponse(UploadResponse.EN_RENAMED, Utils
+							        .constructServerAddress(request, currentPath)
+							        + newFilename, newFilename);
 						}
 					}
@@ -296,5 +283,5 @@
 
 	private String constructTypeBasedFolderString(final ResourceTypeHandler fileType,
-			final String currentFolderString, final HttpServletRequest request) {
+	        final String currentFolderString, final HttpServletRequest request) {
 		StringBuffer sb = new StringBuffer();
 		sb.append(ConnectorHandler.getUserFilesPath(request));
@@ -303,4 +290,4 @@
 		return replaceAll(sb.toString(), "//", "/");
 	}
-	
+
 }
