Opened 16 years ago

Last modified 16 years ago

#1742 closed New Feature

[Java-filemanager] Custom directory for each resource type — at Version 3

Reported by: Michael Osipov Owned by:
Priority: Normal Milestone: FCKeditor.Java 2.4
Component: Server : Java Version: FCKeditor.Java 2.4 Beta
Keywords: Cc:

Change History (4)

comment:1 Changed 16 years ago by Michael Osipov

[Java-filemanager] Custom directory for each resource type Private: (?) No [Java-filemanager] Specify different custom directories for different resource types for Java Connector & Uploader

This is related to patch/request ID - 1312834 and offers Java implementation for specifying different custom directories for different resources. The directories can be specified in the web.xml of your application by adding following init params for com.fredck.FCKeditor.connector.ConnectorServlet (Connector) and com.fredck.FCKeditor.uploader.SimpleUploaderServlet (Uploader.

<!-- include these params if you want to specify custom directory for each resource type --> <!-- The directory should not contain trailing "/" as a param value e.g. - /mydir/mypath --> <!-- Remove parameters if you want the files in the default directory --> <init-param> <param-name>ConfigDirectoriesFile</param-name> <param-value></param-value> </init-param> <init-param> <param-name>ConfigDirectoriesImage</param-name> <param-value></param-value> </init-param> <init-param> <param-name>ConfigDirectoriesFlash</param-name> <param-value></param-value> </init-param> <init-param> <param-name>ConfigDirectoriesMedia</param-name> <param-value></param-value> </init-param>

The code in both these servlets (Connector & Uploader) is changed such that if any of the above init parameters is present, the browse directory or upload directory for that particular resource type is taken as value of the corresponding init param.

(1) The ConnectorServlet changes - ===================================== (a) The ConnectorServlet has a Hashtable to store values of different resource types directories. private static Hashtable configDirectories;

(b) The init method of ConnectorServlet checks if any of these parameters is present and stores custom directory value for that resource type. (Add this below initialization of baseDir)

configDirectories = new Hashtable(4); if(null != getInitParameter("ConfigDirectoriesFile")){ configDirectories.put("File", getInitParameter("ConfigDirectoriesFile")); } if(null != getInitParameter("ConfigDirectoriesImage")){ configDirectories.put("Image", getInitParameter("ConfigDirectoriesImage")); } if(null != getInitParameter("ConfigDirectoriesFlash")){ configDirectories.put("Flash", getInitParameter("ConfigDirectoriesFlash")); } if(null != getInitParameter("ConfigDirectoriesMedia")){ configDirectories.put("Media", getInitParameter("ConfigDirectoriesMedia")); }

(c) In doGet() and doPost() methods of ConnectorServlet, the currentPath is constructed with the specified custom directory if it is specified for that resource type; otherwise the currentPath is constructed with the baseDir & Type string as before.

String currentPath= null; if(null != configDirectories.get(typeStr)){ currentPath= configDirectories.get(typeStr)+currentFolderStr; }else{ currentPath=baseDir+typeStr+currentFolderStr; } String currentDirPath=getServletContext().getRealPath(currentPath);

This completes the changes required for ConnectorServlet.

(2) The SimpleUploaderServlet changes - ============================================ The changes are similar to ConnectorServlet changes here. These changes allow user to upload a specific file type to a custom directory instead of the default directory for that resource type.

(a) The SimpleUploaderServlet has a Hashtable to store values of different resource types directories. private static Hashtable configDirectories;

(b) The init method of SimpleUploaderServlet checks if any of these parameters is present and stores custom directory value for that resource type. (Add this below initialization of deniedExtensions Hashtable)

configDirectories = new Hashtable(4); if(null != getInitParameter("ConfigDirectoriesFile")){ configDirectories.put("File", getInitParameter("ConfigDirectoriesFile")); } if(null != getInitParameter("ConfigDirectoriesImage")){ configDirectories.put("Image", getInitParameter("ConfigDirectoriesImage")); } if(null != getInitParameter("ConfigDirectoriesFlash")){ configDirectories.put("Flash", getInitParameter("ConfigDirectoriesFlash")); } if(null != getInitParameter("ConfigDirectoriesMedia")){ configDirectories.put("Media", getInitParameter("ConfigDirectoriesMedia")); }

(c) In doPost() method of SimpleUploaderServlet, the currentPath is constructed with the specified custom directory if it is specified for that resource type; otherwise the currentPath is constructed with the baseDir & Type string as before.

String currentPath=null; if(null != configDirectories.get(typeStr)){ currentPath=""+configDirectories.get(typeStr); }else{ currentPath=baseDir+typeStr; } String currentDirPath=getServletContext().getRealPath(currentPath);

This completes the changes required for SimpleUploaderServlet.

The attached jar file contains complete FCKeditor Java bundle with source Java files (for connector & uploader) with all the above mentioned changes done. Also the included "web.xml" file shows how different custom directories can be specified for different resource types for Java Connector & Uploader.

Changed 16 years ago by Michael Osipov

Attachment: FCKeditor-2.3.jar added

comment:2 Changed 16 years ago by Michael Osipov

Type: BugNew Feature

comment:3 Changed 16 years ago by Alfonso Martínez de Lizarrondo

Description: modified (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy