001    /**
002     * Copyright (c) 2000-2013 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.GetterUtil;
023    import com.liferay.portal.kernel.util.ParamUtil;
024    import com.liferay.portal.theme.ThemeDisplay;
025    import com.liferay.portal.util.WebKeys;
026    
027    import javax.servlet.http.HttpServletRequest;
028    import javax.servlet.http.HttpServletResponse;
029    
030    import org.apache.struts.action.Action;
031    import org.apache.struts.action.ActionForm;
032    import org.apache.struts.action.ActionForward;
033    import org.apache.struts.action.ActionMapping;
034    
035    /**
036     * @author Ivica Cardic
037     */
038    public class ConnectorAction extends Action {
039    
040            @Override
041            public ActionForward execute(
042                            ActionMapping actionMapping, ActionForm actionForm,
043                            HttpServletRequest request, HttpServletResponse response)
044                    throws Exception {
045    
046                    try {
047                            String command = request.getParameter("Command");
048                            String type = request.getParameter("Type");
049                            String sortType = request.getParameter("SortType");
050    
051                            String ascendingString = request.getParameter("Ascending");
052    
053                            boolean ascending = GetterUtil.getBoolean(ascendingString);
054    
055                            String currentFolder = request.getParameter("CurrentFolder");
056                            String newFolder = ParamUtil.getString(request, "NewFolderName");
057    
058                            if (_log.isDebugEnabled()) {
059                                    _log.debug("Command " + command);
060                                    _log.debug("Type " + type);
061                                    _log.debug("SortType " + sortType);
062                                    _log.debug("Ascending " + ascending);
063                                    _log.debug("Current folder " + currentFolder);
064                                    _log.debug("New folder " + newFolder);
065                            }
066    
067                            ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
068                                    WebKeys.THEME_DISPLAY);
069    
070                            CommandArgument commandArgument = new CommandArgument(
071                                    command, type, sortType, ascending, currentFolder, newFolder,
072                                    themeDisplay, request);
073    
074                            Command commandModel = CommandFactory.getCommand(command);
075    
076                            commandModel.execute(commandArgument, request, response);
077                    }
078                    catch (Exception e) {
079                            _log.error(e, e);
080                    }
081    
082                    return null;
083            }
084    
085            private static Log _log = LogFactoryUtil.getLog(ConnectorAction.class);
086    
087    }