1
14
15 package com.liferay.portlet.portletconfiguration.action;
16
17 import com.liferay.portal.kernel.language.LanguageUtil;
18 import com.liferay.portal.kernel.util.ParamUtil;
19 import com.liferay.portal.model.Layout;
20 import com.liferay.portal.security.permission.ActionKeys;
21 import com.liferay.portal.security.permission.PermissionChecker;
22 import com.liferay.portal.service.permission.PortletPermissionUtil;
23 import com.liferay.portal.struts.JSONAction;
24 import com.liferay.portal.theme.ThemeDisplay;
25 import com.liferay.portal.util.WebKeys;
26 import com.liferay.portlet.InvokerPortletImpl;
27 import com.liferay.portlet.PortletPreferencesFactoryUtil;
28
29 import javax.portlet.PortletPreferences;
30
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import javax.servlet.http.HttpSession;
34
35 import org.apache.struts.action.ActionForm;
36 import org.apache.struts.action.ActionMapping;
37
38
43 public class UpdateTitleAction extends JSONAction {
44
45 public String getJSON(
46 ActionMapping mapping, ActionForm form, HttpServletRequest request,
47 HttpServletResponse response)
48 throws Exception {
49
50 HttpSession session = request.getSession();
51
52 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
53 WebKeys.THEME_DISPLAY);
54
55 Layout layout = themeDisplay.getLayout();
56
57 PermissionChecker permissionChecker =
58 themeDisplay.getPermissionChecker();
59
60 String portletId = ParamUtil.getString(request, "portletId");
61
62 if (!PortletPermissionUtil.contains(
63 permissionChecker, themeDisplay.getPlid(), portletId,
64 ActionKeys.CONFIGURATION)) {
65
66 return null;
67 }
68
69 String languageId = LanguageUtil.getLanguageId(request);
70 String title = ParamUtil.getString(request, "title");
71
72 PortletPreferences portletSetup =
73 PortletPreferencesFactoryUtil.getLayoutPortletSetup(
74 layout, portletId);
75
76 portletSetup.setValue("portlet-setup-title-" + languageId, title);
77 portletSetup.setValue("portlet-setup-use-custom-title", "true");
78
79 portletSetup.store();
80
81 InvokerPortletImpl.clearResponse(
82 session, layout.getPrimaryKey(), portletId,
83 LanguageUtil.getLanguageId(request));
84
85 return null;
86 }
87
88 }