1
22
23 package com.liferay.portlet.wsrp.action;
24
25 import com.liferay.portal.kernel.util.ParamUtil;
26 import com.liferay.portal.struts.PortletAction;
27 import com.liferay.portal.util.WebKeys;
28 import com.liferay.util.servlet.SessionMessages;
29
30 import javax.portlet.ActionRequest;
31 import javax.portlet.ActionResponse;
32 import javax.portlet.PortletConfig;
33 import javax.portlet.PortletPreferences;
34 import javax.portlet.PortletSession;
35 import javax.portlet.RenderRequest;
36 import javax.portlet.RenderResponse;
37
38 import org.apache.struts.action.ActionForm;
39 import org.apache.struts.action.ActionForward;
40 import org.apache.struts.action.ActionMapping;
41
42
48 public class EditLocalPreferencesAction extends PortletAction {
49
50 public void processAction(
51 ActionMapping mapping, ActionForm form, PortletConfig config,
52 ActionRequest req, ActionResponse res)
53 throws Exception {
54
55 PortletPreferences prefs = req.getPreferences();
56
57 String wsrpServiceUrl = ParamUtil.getString(req, "wsrp_service_url");
58 String markupEndpoint = ParamUtil.getString(req, "markup_endpoint");
59 String serviceDescriptionEndpoint = ParamUtil.getString(req,
60 "service_description_endpoint");
61 String registrationEndpoint = ParamUtil.getString(req,
62 "registration_endpoint");
63 String portletManagementEndpoint = ParamUtil.getString(req,
64 "portlet_management_endpoint");
65 String portletHandle = ParamUtil.getString(req, "portlet_handle");
66
67 prefs.setValue("wsrp-service-url", wsrpServiceUrl);
68 prefs.setValue("markup-endpoint", markupEndpoint);
69 prefs.setValue("service-description-endpoint",
70 serviceDescriptionEndpoint);
71 prefs.setValue("registration-endpoint", registrationEndpoint);
72 prefs.setValue("portlet-management-endpoint",
73 portletManagementEndpoint);
74
75 String oldPortletHandle = prefs.getValue("portlet-handle", "");
76 if (!portletHandle.equals(oldPortletHandle)) {
77 prefs.reset("parent-handle");
78 }
79 prefs.setValue("portlet-handle", portletHandle);
80
81 PortletSession ses = req.getPortletSession();
83 ses.setAttribute(WebKeys.WSRP_NEW_SESSION, "true");
84
85 prefs.store();
86
87 SessionMessages.add(req, config.getPortletName() + ".doEdit");
88
89 setForward(req, "portlet.wsrp.edit");
90 }
91
92 public ActionForward render(
93 ActionMapping mapping, ActionForm form, PortletConfig config,
94 RenderRequest req, RenderResponse res)
95 throws Exception {
96
97 return mapping.findForward(
98 getForward(req, "portlet.wsrp.edit_local_preferences"));
99 }
100
101 }