| ActionResponseImpl.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
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 }