001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.editor.fckeditor;
016    
017    import com.liferay.portal.editor.fckeditor.command.Command;
018    import com.liferay.portal.editor.fckeditor.command.CommandArgument;
019    import com.liferay.portal.editor.fckeditor.command.CommandFactory;
020    import com.liferay.portal.kernel.log.Log;
021    import com.liferay.portal.kernel.log.LogFactoryUtil;
022    import com.liferay.portal.kernel.util.ParamUtil;
023    import com.liferay.portal.theme.ThemeDisplay;
024    import com.liferay.portal.util.WebKeys;
025    
026    import javax.servlet.http.HttpServletRequest;
027    import javax.servlet.http.HttpServletResponse;
028    
029    import org.apache.struts.action.Action;
030    import org.apache.struts.action.ActionForm;
031    import org.apache.struts.action.ActionForward;
032    import org.apache.struts.action.ActionMapping;
033    
034    /**
035     * @author Ivica Cardic
036     */
037    public class ConnectorAction extends Action {
038    
039            public ActionForward execute(
040                            ActionMapping mapping, ActionForm form, HttpServletRequest request,
041                            HttpServletResponse response)
042                    throws Exception {
043    
044                    try {
045                            String command = request.getParameter("Command");
046                            String type = request.getParameter("Type");
047                            String currentFolder = request.getParameter("CurrentFolder");
048                            String newFolder = ParamUtil.getString(request, "NewFolderName");
049    
050                            if (_log.isDebugEnabled()) {
051                                    _log.debug("Command " + command);
052                                    _log.debug("Type " + type);
053                                    _log.debug("Current folder " + currentFolder);
054                                    _log.debug("New folder " + newFolder);
055                            }
056    
057                            ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
058                                    WebKeys.THEME_DISPLAY);
059    
060                            CommandArgument argument = new CommandArgument(
061                                    command, type, currentFolder, newFolder, themeDisplay, request);
062    
063                            Command commandObj = CommandFactory.getCommand(command);
064    
065                            commandObj.execute(argument, request, response);
066                    }
067                    catch (Exception e) {
068                            _log.error(e, e);
069                    }
070    
071                    return null;
072            }
073    
074            private static Log _log = LogFactoryUtil.getLog(ConnectorAction.class);
075    
076    }