01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.pluto.driver.services.container;
18:
19: import java.util.Iterator;
20: import java.util.Map;
21:
22: import javax.portlet.PortletMode;
23: import javax.portlet.WindowState;
24: import javax.portlet.PortletSecurityException;
25: import javax.servlet.http.HttpServletRequest;
26:
27: import org.apache.pluto.PortletWindow;
28: import org.apache.pluto.driver.url.PortalURLParameter;
29: import org.apache.pluto.driver.url.PortalURL;
30: import org.apache.pluto.driver.core.PortalRequestContext;
31: import org.apache.pluto.spi.PortletURLProvider;
32:
33: /**
34: *
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: PortalRequestContext ctx = (PortalRequestContext) request
44: .getAttribute(PortalRequestContext.REQUEST_KEY);
45: url = ctx.createPortalURL();
46:
47: this .window = internalPortletWindow.getId().getStringId();
48: }
49:
50: public void setPortletMode(PortletMode mode) {
51: url.setPortletMode(window, mode);
52: }
53:
54: public void setWindowState(WindowState state) {
55: url.setWindowState(window, state);
56: }
57:
58: public void setAction(boolean action) {
59: if (action) {
60: url.setActionWindow(window);
61: } else {
62: url.setActionWindow(null);
63: }
64: }
65:
66: public void setSecure() throws PortletSecurityException {
67: throw new PortletSecurityException("No Supported");
68: }
69:
70: public boolean isSecureSupported() {
71: return false;
72: }
73:
74: public void clearParameters() {
75: url.clearParameters(window);
76: }
77:
78: public void setParameters(Map parameters) {
79: Iterator it = parameters.entrySet().iterator();
80: while (it.hasNext()) {
81: Map.Entry entry = (Map.Entry) it.next();
82: PortalURLParameter param = new PortalURLParameter(window,
83: (String) entry.getKey(), (String[]) entry
84: .getValue());
85: url.addParameter(param);
86: }
87: }
88:
89: public String toString() {
90: return url.toString();
91: }
92:
93: }
|