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