001
014
015 package com.liferay.portlet.portletconfiguration.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.model.Layout;
019 import com.liferay.portal.security.permission.ActionKeys;
020 import com.liferay.portal.security.permission.PermissionChecker;
021 import com.liferay.portal.service.permission.PortletPermissionUtil;
022 import com.liferay.portal.struts.JSONAction;
023 import com.liferay.portal.theme.ThemeDisplay;
024 import com.liferay.portal.util.WebKeys;
025 import com.liferay.portlet.PortletPreferencesFactoryUtil;
026 import com.liferay.portlet.PortletSetupUtil;
027
028 import javax.portlet.PortletPreferences;
029
030 import javax.servlet.http.HttpServletRequest;
031 import javax.servlet.http.HttpServletResponse;
032
033 import org.apache.struts.action.ActionForm;
034 import org.apache.struts.action.ActionMapping;
035
036
039 public class GetLookAndFeelAction extends JSONAction {
040
041 public String getJSON(
042 ActionMapping mapping, ActionForm form, HttpServletRequest request,
043 HttpServletResponse response)
044 throws Exception {
045
046 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
047 WebKeys.THEME_DISPLAY);
048
049 Layout layout = themeDisplay.getLayout();
050
051 PermissionChecker permissionChecker =
052 themeDisplay.getPermissionChecker();
053
054 String portletId = ParamUtil.getString(request, "portletId");
055
056 if (!PortletPermissionUtil.contains(
057 permissionChecker, themeDisplay.getPlid(), portletId,
058 ActionKeys.CONFIGURATION)) {
059
060 return null;
061 }
062
063 PortletPreferences portletSetup =
064 PortletPreferencesFactoryUtil.getLayoutPortletSetup(
065 layout, portletId);
066
067 return PortletSetupUtil.cssToString(portletSetup);
068 }
069
070 }