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