1 | /* |
2 | * Copyright 2003,2004 The Apache Software Foundation. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | package org.apache.pluto.driver.services.container; |
17 | |
18 | import java.util.Iterator; |
19 | import java.util.Map; |
20 | |
21 | import javax.portlet.PortletMode; |
22 | import javax.portlet.WindowState; |
23 | import javax.servlet.http.HttpServletRequest; |
24 | |
25 | import org.apache.pluto.PortletWindow; |
26 | import org.apache.pluto.driver.url.PortalURL; |
27 | import org.apache.pluto.driver.url.PortalURLFactory; |
28 | import org.apache.pluto.driver.url.PortalURLParameter; |
29 | import org.apache.pluto.spi.PortletURLProvider; |
30 | |
31 | /** |
32 | * |
33 | * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a> |
34 | * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a> |
35 | */ |
36 | public class PortletURLProviderImpl implements PortletURLProvider { |
37 | |
38 | private PortalURL url; |
39 | private String window; |
40 | |
41 | public PortletURLProviderImpl(HttpServletRequest request, |
42 | PortletWindow internalPortletWindow) { |
43 | url = PortalURLFactory.getFactory().createPortalURL(request); |
44 | this.window = internalPortletWindow.getId().getStringId(); |
45 | } |
46 | |
47 | public void setPortletMode(PortletMode mode) { |
48 | url.setPortletMode(window, mode); |
49 | } |
50 | |
51 | public void setWindowState(WindowState state) { |
52 | url.setWindowState(window, state); |
53 | } |
54 | |
55 | public void setAction(boolean action) { |
56 | if (action) { |
57 | url.setActionWindow(window); |
58 | } else { |
59 | url.setActionWindow(null); |
60 | } |
61 | } |
62 | |
63 | public void setSecure() { |
64 | //url.setSecure(true); |
65 | } |
66 | |
67 | public void clearParameters() { |
68 | url.clearParameters(window); |
69 | } |
70 | |
71 | public void setParameters(Map parameters) { |
72 | Iterator it = parameters.entrySet().iterator(); |
73 | while (it.hasNext()) { |
74 | Map.Entry entry = (Map.Entry) it.next(); |
75 | PortalURLParameter param = new PortalURLParameter( |
76 | window, |
77 | (String) entry.getKey(), |
78 | (String[]) entry.getValue()); |
79 | url.addParameter(param); |
80 | } |
81 | } |
82 | |
83 | public String toString() { |
84 | return url.toString(); |
85 | } |
86 | |
87 | } |