001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.wsrp.action;
022:
023: import com.liferay.portal.kernel.util.ParamUtil;
024: import com.liferay.portal.struts.PortletAction;
025: import com.liferay.portal.util.WebKeys;
026: import com.liferay.util.servlet.SessionMessages;
027:
028: import javax.portlet.ActionRequest;
029: import javax.portlet.ActionResponse;
030: import javax.portlet.PortletConfig;
031: import javax.portlet.PortletPreferences;
032: import javax.portlet.PortletSession;
033: import javax.portlet.RenderRequest;
034: import javax.portlet.RenderResponse;
035:
036: import org.apache.struts.action.ActionForm;
037: import org.apache.struts.action.ActionForward;
038: import org.apache.struts.action.ActionMapping;
039:
040: /**
041: * <a href="EditLocalPreferencesAction.java.html"><b><i>View Source</i></b></a>
042: *
043: * @author Michael Young
044: *
045: */
046: public class EditLocalPreferencesAction extends PortletAction {
047:
048: public void processAction(ActionMapping mapping, ActionForm form,
049: PortletConfig config, ActionRequest req, ActionResponse res)
050: throws Exception {
051:
052: PortletPreferences prefs = req.getPreferences();
053:
054: String wsrpServiceUrl = ParamUtil.getString(req,
055: "wsrp_service_url");
056: String markupEndpoint = ParamUtil.getString(req,
057: "markup_endpoint");
058: String serviceDescriptionEndpoint = ParamUtil.getString(req,
059: "service_description_endpoint");
060: String registrationEndpoint = ParamUtil.getString(req,
061: "registration_endpoint");
062: String portletManagementEndpoint = ParamUtil.getString(req,
063: "portlet_management_endpoint");
064: String portletHandle = ParamUtil.getString(req,
065: "portlet_handle");
066:
067: prefs.setValue("wsrp-service-url", wsrpServiceUrl);
068: prefs.setValue("markup-endpoint", markupEndpoint);
069: prefs.setValue("service-description-endpoint",
070: serviceDescriptionEndpoint);
071: prefs.setValue("registration-endpoint", registrationEndpoint);
072: prefs.setValue("portlet-management-endpoint",
073: portletManagementEndpoint);
074:
075: String oldPortletHandle = prefs.getValue("portlet-handle", "");
076: if (!portletHandle.equals(oldPortletHandle)) {
077: prefs.reset("parent-handle");
078: }
079: prefs.setValue("portlet-handle", portletHandle);
080:
081: // start a new wsrp session on next render
082: PortletSession ses = req.getPortletSession();
083: ses.setAttribute(WebKeys.WSRP_NEW_SESSION, "true");
084:
085: prefs.store();
086:
087: SessionMessages.add(req, config.getPortletName() + ".doEdit");
088:
089: setForward(req, "portlet.wsrp.edit");
090: }
091:
092: public ActionForward render(ActionMapping mapping, ActionForm form,
093: PortletConfig config, RenderRequest req, RenderResponse res)
094: throws Exception {
095:
096: return mapping.findForward(getForward(req,
097: "portlet.wsrp.edit_local_preferences"));
098: }
099:
100: }
|