Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#1742 closed New Feature (fixed)

[Java-filemanager] Custom directory for each resource type

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

Attachments (1)

FCKeditor-2.3.jar (209.3 KB) - added by Michael Osipov 17 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 17 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 17 years ago by Michael Osipov

Attachment: FCKeditor-2.3.jar added

comment:2 Changed 17 years ago by Michael Osipov

Type: BugNew Feature

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

Description: modified (diff)

comment:4 Changed 17 years ago by Frederico Caldeira Knabben

I haven't investigated the proposed solution, but as a not for it, we should implement a similar configuration model just like all other connectors. The PHP connector could be takes as the base for it.

comment:5 Changed 17 years ago by Michael Osipov

Component: Server : JavaFile Browser

Moved component from Java to general File Browser since this should be configured for all connectors

comment:6 Changed 17 years ago by Alfonso Martínez de Lizarrondo

Component: File BrowserServer : Java

This is already done in the rest of the connectors.

For example this is from the config.php

$Config['FileTypesPath']['File']	= $Config['UserFilesPath'] . 'file/' ;
$Config['FileTypesAbsolutePath']['File']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'file/' ;
$Config['QuickUploadPath']['File']		= $Config['UserFilesPath'] ;
$Config['QuickUploadAbsolutePath']['File']= $Config['UserFilesAbsolutePath'] ;

and this is from the config.asp

ConfigFileTypesPath.Add "File", ConfigUserFilesPath & "file/"
ConfigFileTypesAbsolutePath.Add "File", ""
ConfigQuickUploadPath.Add "File", ConfigUserFilesPath
ConfigQuickUploadAbsolutePath.Add "File", ""

comment:7 Changed 17 years ago by Michael Osipov

Milestone: FCKeditor.Java 2.4
Owner: set to Michael Osipov

comment:8 Changed 17 years ago by Michael Osipov

Owner: changed from Michael Osipov to Thilo Schwarz

comment:9 Changed 17 years ago by Thilo Schwarz

Resolution: fixed
Status: newclosed
Version: FCKeditor.Java 2.4 Beta

In svn#1585 a new properties handling is introduced. There you can specify the UserFilePath and a sub folder name for each resource type. So I think this feature is implemented.

comment:10 in reply to:  9 Changed 17 years ago by Michael Osipov

Replying to th-schwarz:

In svn#1585 a new properties handling is introduced. There you can specify the UserFilePath and a sub folder name for each resource type. So I think this feature is implemented.

Refering to [1585]

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