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 @Override
044 public String getJSON(
045 ActionMapping actionMapping, ActionForm actionForm,
046 HttpServletRequest request, HttpServletResponse response)
047 throws Exception {
048
049 HttpSession session = request.getSession();
050
051 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
052 WebKeys.THEME_DISPLAY);
053
054 Layout layout = themeDisplay.getLayout();
055
056 PermissionChecker permissionChecker =
057 themeDisplay.getPermissionChecker();
058
059 String portletId = ParamUtil.getString(request, "portletId");
060
061 if (!PortletPermissionUtil.contains(
062 permissionChecker, layout, portletId,
063 ActionKeys.CONFIGURATION)) {
064
065 return null;
066 }
067
068 String languageId = LanguageUtil.getLanguageId(request);
069 String title = ParamUtil.getString(request, "title");
070
071 PortletPreferences portletSetup =
072 PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(
073 layout, portletId);
074
075 portletSetup.setValue("portletSetupTitle_" + languageId, title);
076 portletSetup.setValue("portletSetupUseCustomTitle", "true");
077
078 portletSetup.store();
079
080 InvokerPortletImpl.clearResponse(
081 session, layout.getPrimaryKey(), portletId,
082 LanguageUtil.getLanguageId(request));
083
084 return null;
085 }
086
087 }