1
22
23 package com.liferay.portlet.quicknote.action;
24
25 import com.liferay.portal.kernel.util.ParamUtil;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.security.permission.ActionKeys;
28 import com.liferay.portal.service.permission.PortletPermissionUtil;
29 import com.liferay.portal.struts.JSONAction;
30 import com.liferay.portal.theme.ThemeDisplay;
31 import com.liferay.portal.util.WebKeys;
32 import com.liferay.portlet.PortletPreferencesFactoryUtil;
33
34 import javax.portlet.PortletPreferences;
35
36 import javax.servlet.http.HttpServletRequest;
37 import javax.servlet.http.HttpServletResponse;
38
39 import org.apache.struts.action.ActionForm;
40 import org.apache.struts.action.ActionMapping;
41
42
48 public class SaveAction extends JSONAction {
49
50 public String getJSON(
51 ActionMapping mapping, ActionForm form, HttpServletRequest request,
52 HttpServletResponse response)
53 throws Exception {
54
55 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
56 WebKeys.THEME_DISPLAY);
57
58 String portletId = ParamUtil.getString(request, "portletId");
59
60 PortletPermissionUtil.check(
61 themeDisplay.getPermissionChecker(), themeDisplay.getPlid(),
62 portletId, ActionKeys.CONFIGURATION);
63
64 PortletPreferences preferences =
65 PortletPreferencesFactoryUtil.getPortletSetup(request, portletId);
66
67 String color = ParamUtil.getString(request, "color");
68 String data = ParamUtil.getString(request, "data");
69
70 if (Validator.isNotNull(color)) {
71 preferences.setValue("color", color);
72 }
73
74 if (Validator.isNotNull(data)) {
75 preferences.setValue("data", data);
76 }
77
78 preferences.store();
79
80 return null;
81 }
82
83 }