Menu

#295 [Java-filemanager] Custom directory for each resource type

Version 2.x
closed
nobody
Editor (144)
5
2008-01-12
2006-08-31
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.

Discussion

  • Manish Hatwalne

    Manish Hatwalne - 2006-08-31

    Complete FCKeditor 2.3 Java bundle with required patch changes

     
  • Manish Hatwalne

    Manish Hatwalne - 2006-09-01

    Logged In: YES
    user_id=764730

    Just assigning it to "fredck" because I don't know who else
    is looking into FCKeditor Java development.

     
  • Manish Hatwalne

    Manish Hatwalne - 2006-09-01
    • assigned_to: nobody --> fredck
     
  • Frederico Caldeira Knabben

    • assigned_to: fredck --> nobody
     
  • Alfonso Martinez

    Logged In: YES
    user_id=1356422
    Originator: NO

    Moved to http://dev.fckeditor.net/ticket/1742

     
  • Alfonso Martinez

    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB