1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.editor.fckeditor;
16  
17  import com.liferay.portal.editor.fckeditor.command.Command;
18  import com.liferay.portal.editor.fckeditor.command.CommandArgument;
19  import com.liferay.portal.editor.fckeditor.command.CommandFactory;
20  import com.liferay.portal.kernel.log.Log;
21  import com.liferay.portal.kernel.log.LogFactoryUtil;
22  import com.liferay.portal.kernel.util.ParamUtil;
23  import com.liferay.portal.theme.ThemeDisplay;
24  import com.liferay.portal.util.WebKeys;
25  
26  import javax.servlet.http.HttpServletRequest;
27  import javax.servlet.http.HttpServletResponse;
28  
29  import org.apache.struts.action.Action;
30  import org.apache.struts.action.ActionForm;
31  import org.apache.struts.action.ActionForward;
32  import org.apache.struts.action.ActionMapping;
33  
34  /**
35   * <a href="ConnectorAction.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Ivica Cardic
38   */
39  public class ConnectorAction extends Action {
40  
41      public ActionForward execute(
42              ActionMapping mapping, ActionForm form, HttpServletRequest request,
43              HttpServletResponse response)
44          throws Exception {
45  
46          try {
47              String command = request.getParameter("Command");
48              String type = request.getParameter("Type");
49              String currentFolder = request.getParameter("CurrentFolder");
50              String newFolder = ParamUtil.getString(request, "NewFolderName");
51  
52              if (_log.isDebugEnabled()) {
53                  _log.debug("Command " + command);
54                  _log.debug("Type " + type);
55                  _log.debug("Current folder " + currentFolder);
56                  _log.debug("New folder " + newFolder);
57              }
58  
59              ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
60                  WebKeys.THEME_DISPLAY);
61  
62              CommandArgument argument = new CommandArgument(
63                  command, type, currentFolder, newFolder, themeDisplay, request);
64  
65              Command commandObj = CommandFactory.getCommand(command);
66  
67              commandObj.execute(argument, request, response);
68          }
69          catch (Exception e) {
70              _log.error(e, e);
71          }
72  
73          return null;
74      }
75  
76      private static Log _log = LogFactoryUtil.getLog(ConnectorAction.class);
77  
78  }