/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2004-2009 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*/
package editor;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import net.fckeditor.connector.Connector;
import net.fckeditor.connector.exception.FolderAlreadyExistsException;
import net.fckeditor.connector.exception.InvalidCurrentFolderException;
import net.fckeditor.connector.exception.InvalidNewFolderNameException;
import net.fckeditor.connector.exception.ReadException;
import net.fckeditor.connector.exception.WriteException;
import net.fckeditor.handlers.Command;
import net.fckeditor.handlers.ConnectorHandler;
import net.fckeditor.handlers.PropertiesLoader;
import net.fckeditor.handlers.RequestCycleHandler;
import net.fckeditor.handlers.ResourceType;
import net.fckeditor.requestcycle.Context;
import net.fckeditor.requestcycle.ThreadLocalData;
import net.fckeditor.response.GetResponse;
import net.fckeditor.response.UploadResponse;
import net.fckeditor.tool.Utils;
import net.fckeditor.tool.UtilsFile;
import net.fckeditor.tool.UtilsResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* File Browser request dispatcher. This class is the validating and managing
* instance between the {@link ConnectorServlet connector servlet} and the
* {@link Connector connector}. It receives the requests, parses the parameters,
* validates/sanitizes them and mandates them to the connector. After the
* connector has processed the request, this dispatcher passes the response back
* to the connector servlet. More over, it intercepts all
* {@link net.fckeditor.connector.exception specified exceptions} from a
* connector and emits appropriate (localized) messages to the user. The
* exceptions won't be logged, they simply indicate the connector state.
*
* @version $Id: Dispatcher.java 3764 2009-06-23 16:05:05Z mosipov $
*/
public class Dispatcher
{
private final Logger logger = LoggerFactory.getLogger(Dispatcher.class);
private Connector connector;
/**
* Initializes this dispatcher. It initializes the connector internally.
* Called at connector servlet {@link ConnectorServlet#init()
* initialization}.
*
* @param servletContext
* reference to the {@link ServletContext} in which the caller is
* running
* @throws Exception
* if the dispatcher initialization fails due to some reason
*/
Dispatcher(final ServletContext servletContext) throws Exception
{
connector = ConnectorHandler.getConnector();
connector.init(servletContext);
}
/**
* Called by the connector servlet to handle a {@code GET} request. In
* particular, it handles the {@link Command#GET_FOLDERS GetFolders},
* {@link Command#GET_FOLDERS_AND_FILES GetFoldersAndFiles} and
* {@link Command#CREATE_FOLDER CreateFolder} commands.
*
* @param request
* the current request instance
* @return the get response instance associated with this request
*/
GetResponse doGet(final HttpServletRequest request)
{
logger.debug("Entering Dispatcher#doGet");
Context context = ThreadLocalData.getContext();
context.logBaseParameters();
GetResponse getResponse = null;
// check parameters
if (!Command.isValidForGet(context.getCommandStr()))
getResponse = GetResponse.getInvalidCommandError();
else if (!ResourceType.isValidType(context.getTypeStr()))
getResponse = GetResponse.getInvalidResourceTypeError();
else if (!UtilsFile.isValidPath(context.getCurrentFolderStr()))
getResponse = GetResponse.getInvalidCurrentFolderError();
else
{
// in contrast to doPost the referrer has to send an explicit type
ResourceType type = context.getResourceType();
Command command = context.getCommand();
// check permissions for user action
if ((command.equals(Command.GET_FOLDERS) || command
.equals(Command.GET_FOLDERS_AND_FILES))
&& !RequestCycleHandler.isEnabledForFileBrowsing(request))
getResponse = GetResponse.getGetResourcesDisabledError();
else if (command.equals(Command.CREATE_FOLDER)
&& !RequestCycleHandler.isCreateFolderEnabled(request))
getResponse = GetResponse.getCreateFolderDisabledError();
else
{
// make the connector calls, catch its exceptions and generate
// the proper response object
try
{
if (command.equals(Command.CREATE_FOLDER))
{
String newFolderNameStr = request
.getParameter("NewFolderName");
// try
// {
// newFolderNameStr = new String(newFolderNameStr
// .getBytes("iso8859-1"), "UTF-8");
// }
// catch (UnsupportedEncodingException e)
// {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
logger.debug("Parameter NewFolderName: {}",
newFolderNameStr);
String sanitizedNewFolderNameStr = UtilsFile
.sanitizeFolderName(newFolderNameStr);
if (Utils.isEmpty(sanitizedNewFolderNameStr))
getResponse = GetResponse
.getInvalidNewFolderNameError();
else
{
logger.debug(
"Parameter NewFolderName (sanitized): {}",
sanitizedNewFolderNameStr);
connector.createFolder(type, context
.getCurrentFolderStr(),
sanitizedNewFolderNameStr);
getResponse = GetResponse.getOK();
}
}
else if (command.equals(Command.GET_FOLDERS)
|| command.equals(Command.GET_FOLDERS_AND_FILES))
{
String url = UtilsResponse.getUrl(RequestCycleHandler
.getUserFilesPath(request), type, context
.getCurrentFolderStr());
getResponse = getFoldersAndOrFiles(command, type,
context.getCurrentFolderStr(), url);
}
}
catch (InvalidCurrentFolderException e)
{
getResponse = GetResponse.getInvalidCurrentFolderError();
}
catch (InvalidNewFolderNameException e)
{
getResponse = GetResponse.getInvalidNewFolderNameError();
}
catch (FolderAlreadyExistsException e)
{
getResponse = GetResponse.getFolderAlreadyExistsError();
}
catch (WriteException e)
{
getResponse = GetResponse.getCreateFolderWriteError();
}
catch (ReadException e)
{
getResponse = GetResponse.getGetResourcesReadError();
}
}
}
logger.debug("Exiting Dispatcher#doGet");
return getResponse;
}
/**
* Returns get response for the {@code GetFolders*} commands. This is simply
* a helper method.
*
* @param command
* the current command, should be only GetFolders or
* GetFoldersAndFiles
* @param the
* current resource type
* @param currentFolder
* the current folder
* @param constructedUrl
* the final URL
* @return the get response instance associated with this request
* @t
没有合适的资源?快使用搜索试试~ 我知道了~
FCKeditor2.65最终修正版(解决中文乱码)
共493个文件
js:187个
gif:134个
html:53个
3星 · 超过75%的资源 需积分: 9 26 下载量 88 浏览量
2009-12-21
18:18:25
上传
评论
收藏 2.74MB RAR 举报
温馨提示
特点: 1.修改了文件上传命名方式。解决中文文件名上传与显示。 2.判断文件夹创建中的中文字符。禁止创建中文文件夹。 3.优化整个编辑器的风格。把不必要的功能去除。 4.调用简单。 <FCK:editor instanceName="content"> <jsp:attribute name="value"> </jsp:attribute> </FCK:editor>
资源推荐
资源详情
资源评论
收起资源包目录
FCKeditor2.65最终修正版(解决中文乱码) (493个子文件)
config.ascx 5KB
class_upload.asp 10KB
io.asp 8KB
commands.asp 6KB
config.asp 6KB
connector.asp 2KB
basexml.asp 2KB
upload.asp 2KB
util.asp 1KB
connector.aspx 1KB
upload.aspx 1KB
image.cfc 46KB
ImageObject.cfc 12KB
cf5_upload.cfm 12KB
cf5_connector.cfm 11KB
cf_io.cfm 10KB
cf_commands.cfm 8KB
config.cfm 7KB
spellchecker.cfm 5KB
cf_util.cfm 4KB
cf_basexml.cfm 3KB
cf_connector.cfm 3KB
cf_upload.cfm 2KB
connector.cfm 1005B
upload.cfm 993B
connector.cgi 3KB
upload.cgi 2KB
Dispatcher.class 9KB
ConnectorServlet.class 3KB
.classpath 962B
org.eclipse.wst.jsdt.ui.superType.container 49B
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_dialog.css 6KB
fck_dialog.css 6KB
fck_dialog.css 6KB
fck_internal.css 4KB
fck_editorarea.css 3KB
scayt_dialog.css 2KB
fck_dialog_common.css 2KB
fck_showtableborders_gecko.css 2KB
browser.css 2KB
spellerStyle.css 890B
fck_strip.gif 9KB
fck_strip.gif 5KB
fck_strip.gif 5KB
logo_fckeditor.gif 2KB
fck_plugin.gif 2KB
html.gif 1KB
htm.gif 1KB
rdp.gif 1KB
spellchecker_net.gif 1KB
ai.gif 1KB
embaressed_smile.gif 1KB
teeth_smile.gif 1KB
shades_smile.gif 1KB
tounge_smile.gif 1KB
wink_smile.gif 1KB
sad_smile.gif 1KB
regular_smile.gif 1KB
whatchutalkingabout_smile.gif 1KB
envelope.gif 1KB
heart.gif 1012B
thumbs_down.gif 992B
thumbs_up.gif 989B
kiss.gif 978B
sprites.gif 959B
sprites.gif 959B
sprites.gif 959B
fla.gif 946B
logo_fredck.gif 920B
toolbar.buttonbg.gif 829B
swf.gif 725B
swt.gif 724B
bmp.gif 709B
gif.gif 704B
html.gif 621B
htm.gif 621B
rdp.gif 606B
fck_flashlogo.gif 599B
pdf.gif 567B
cry_smile.gif 473B
png.gif 464B
jpg.gif 463B
mp3.gif 454B
avi.gif 454B
angry_smile.gif 453B
cake.gif 453B
angel_smile.gif 445B
devil_smile.gif 444B
broken_heart.gif 423B
template3.gif 422B
xml.gif 408B
ai.gif 403B
swf.gif 388B
swt.gif 388B
fla.gif 382B
template1.gif 375B
zip.gif 368B
共 493 条
- 1
- 2
- 3
- 4
- 5
资源评论
- lijing33332012-11-29只是解决中文文件名上传与显示,其他与asp共用乱码问题没有解决,比较失望
- kang86902012-10-13只是解决中文文件名上传与显示,其他与asp共用乱码问题没有解决。
- 石家庄热线2012-05-22只是解决中文文件名上传与显示,其他与asp共用乱码问题没有解决。
chinasb
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功