1
22
23
41
42 package com.liferay.portal.portletcontainer;
43
44 import com.liferay.portal.kernel.util.StringPool;
45 import com.liferay.portal.model.Portlet;
46 import com.liferay.portlet.PortletURLImpl;
47
48 import com.sun.portal.container.ChannelMode;
49 import com.sun.portal.container.ChannelState;
50 import com.sun.portal.container.ChannelURL;
51 import com.sun.portal.container.ChannelURLType;
52 import com.sun.portal.portletcontainer.appengine.PortletAppEngineUtils;
53
54 import java.io.Serializable;
55
56 import java.util.Collections;
57 import java.util.List;
58 import java.util.Map;
59
60 import javax.portlet.PortletModeException;
61 import javax.portlet.PortletRequest;
62 import javax.portlet.WindowStateException;
63
64 import javax.servlet.http.HttpServletRequest;
65
66 import org.apache.commons.logging.Log;
67 import org.apache.commons.logging.LogFactory;
68
69
76 public class PortletWindowURL implements ChannelURL, Serializable {
77
78 public PortletWindowURL(
79 HttpServletRequest request, Portlet portlet, ChannelState windowState,
80 ChannelMode portletMode, long plid) {
81
82 _portletURLImpl = new PortletURLImpl(
83 request, portlet.getPortletId(), plid, PortletRequest.RENDER_PHASE);
84
85 setWindowState(windowState);
86 setChannelMode(portletMode);
87 }
88
89 public void addProperty(String name, String value) {
90 if (name == null) {
91 return;
92 }
93
94 _portletURLImpl.addProperty(name, value);
95 }
96
97 public String getCacheLevel() {
98 return _portletURLImpl.getCacheability();
99 }
100
101 public ChannelMode getChannelMode() {
102 return PortletAppEngineUtils.getChannelMode(
103 _portletURLImpl.getPortletMode());
104 }
105
106 public Map<String, String[]> getParameters() {
107 return _portletURLImpl.getParameterMap();
108 }
109
110 public Map<String, List<String>> getProperties() {
111 return Collections.EMPTY_MAP;
112 }
113
114 public ChannelURLType getURLType() {
115 return _urlType;
116 }
117
118 public ChannelState getWindowState() {
119 return PortletAppEngineUtils.getChannelState(
120 _portletURLImpl.getWindowState());
121 }
122
123 public boolean isSecure() {
124 return _portletURLImpl.isSecure();
125 }
126
127 public void setCacheLevel(String cacheLevel) {
128 _portletURLImpl.setCacheability(cacheLevel);
129 }
130
131 public void setChannelMode(ChannelMode portletMode) {
132 try {
133 _portletURLImpl.setPortletMode(
134 PortletAppEngineUtils.getPortletMode(portletMode));
135 }
136 catch (PortletModeException pme) {
137 _log.error(pme);
138 }
139 }
140
141 public void setParameter(String name, String value) {
142 if (value == null) {
143 value = StringPool.NULL;
144 }
145
146 _portletURLImpl.setParameter(name, value);
147 }
148
149 public void setParameter(String name, String[] values) {
150 _portletURLImpl.setParameter(name, values);
151 }
152
153 public void setParameters(Map<String, String[]> parametersMap) {
154 _portletURLImpl.setParameters(parametersMap);
155 }
156
157 public void setProperty(String name, String value) {
158 if (name == null) {
159 return;
160 }
161
162 _portletURLImpl.setProperty(name, value);
163 }
164
165 public void setResourceID(String resourceID) {
166 _portletURLImpl.setResourceID(resourceID);
167 }
168
169 public void setSecure(boolean secure) {
170 _portletURLImpl.setSecure(secure);
171 }
172
173 public void setURLType(ChannelURLType urlType) {
174 _urlType = urlType;
175
176 _portletURLImpl.setLifecycle(getLifecycle());
177 _portletURLImpl.setURLType(getURLType());
178 }
179
180 public void setWindowState(ChannelState windowState) {
181 try {
182 _portletURLImpl.setWindowState(
183 PortletAppEngineUtils.getWindowState(windowState));
184 }
185 catch (WindowStateException wse) {
186 _log.error(wse);
187 }
188 }
189 public String toString() {
190 return _portletURLImpl.toString();
191 }
192
193 protected String getLifecycle() {
194 if (ChannelURLType.ACTION.equals(getURLType())) {
195 return PortletRequest.ACTION_PHASE;
196 }
197 else if (ChannelURLType.RENDER.equals(getURLType())) {
198
199
201 return PortletRequest.ACTION_PHASE;
202 }
203 else if (ChannelURLType.RESOURCE.equals(getURLType())) {
204 return PortletRequest.RESOURCE_PHASE;
205 }
206 else {
207 return PortletRequest.RENDER_PHASE;
208 }
209 }
210
211 private static Log _log = LogFactory.getLog(PortletWindowURL.class);
212
213 private PortletURLImpl _portletURLImpl;
214 private ChannelURLType _urlType;
215
216 }