| ActionResponseImpl.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
14
15 package com.liferay.portlet;
16
17 import javax.portlet.ActionResponse;
18 import javax.portlet.PortletRequest;
19
20 /**
21 * <a href="ActionResponseImpl.java.html"><b><i>View Source</i></b></a>
22 *
23 * @author Brian Wing Shun Chan
24 */
25 public class ActionResponseImpl
26 extends StateAwareResponseImpl implements ActionResponse {
27
28 public String getLifecycle() {
29 return PortletRequest.ACTION_PHASE;
30 }
31
32 public void sendRedirect(String location) {
33 if ((location == null) ||
34 (!location.startsWith("/") && (location.indexOf("://") == -1) &&
35 (!location.startsWith("wsrp_rewrite?")))) {
36
37 throw new IllegalArgumentException(
38 location + " is not a valid redirect");
39 }
40
41 // This is needed because app servers will try to prepend a host if
42 // they see an invalid URL
43
44 if (location.startsWith("wsrp_rewrite?")) {
45 location = "http://wsrp-rewrite-holder?" + location;
46 }
47
48 if (isCalledSetRenderParameter()) {
49 throw new IllegalStateException(
50 "Set render parameter has already been called");
51 }
52
53 setRedirectLocation(location);
54 }
55
56 public void sendRedirect(String location, String renderUrlParamName) {
57 }
58
59 }