001
014
015 package com.liferay.portlet.portletconfiguration.action;
016
017 import com.liferay.portal.kernel.language.LanguageUtil;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.model.Layout;
020 import com.liferay.portal.security.permission.ActionKeys;
021 import com.liferay.portal.security.permission.PermissionChecker;
022 import com.liferay.portal.service.permission.PortletPermissionUtil;
023 import com.liferay.portal.struts.JSONAction;
024 import com.liferay.portal.theme.ThemeDisplay;
025 import com.liferay.portal.util.WebKeys;
026 import com.liferay.portlet.InvokerPortletImpl;
027 import com.liferay.portlet.PortletPreferencesFactoryUtil;
028
029 import javax.portlet.PortletPreferences;
030
031 import javax.servlet.http.HttpServletRequest;
032 import javax.servlet.http.HttpServletResponse;
033 import javax.servlet.http.HttpSession;
034
035 import org.apache.struts.action.ActionForm;
036 import org.apache.struts.action.ActionMapping;
037
038
041 public class UpdateTitleAction extends JSONAction {
042
043 public String getJSON(
044 ActionMapping mapping, ActionForm form, HttpServletRequest request,
045 HttpServletResponse response)
046 throws Exception {
047
048 HttpSession session = request.getSession();
049
050 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
051 WebKeys.THEME_DISPLAY);
052
053 Layout layout = themeDisplay.getLayout();
054
055 PermissionChecker permissionChecker =
056 themeDisplay.getPermissionChecker();
057
058 String portletId = ParamUtil.getString(request, "portletId");
059
060 if (!PortletPermissionUtil.contains(
061 permissionChecker, themeDisplay.getPlid(), portletId,
062 ActionKeys.CONFIGURATION)) {
063
064 return null;
065 }
066
067 String languageId = LanguageUtil.getLanguageId(request);
068 String title = ParamUtil.getString(request, "title");
069
070 PortletPreferences portletSetup =
071 PortletPreferencesFactoryUtil.getLayoutPortletSetup(
072 layout, portletId);
073
074 portletSetup.setValue("portlet-setup-title-" + languageId, title);
075 portletSetup.setValue("portlet-setup-use-custom-title", "true");
076
077 portletSetup.store();
078
079 InvokerPortletImpl.clearResponse(
080 session, layout.getPrimaryKey(), portletId,
081 LanguageUtil.getLanguageId(request));
082
083 return null;
084 }
085
086 }