001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.container.url;
018:
019: import java.util.Map;
020:
021: import javax.portlet.PortletMode;
022: import javax.portlet.WindowState;
023: import javax.servlet.http.HttpServletRequest;
024:
025: import org.apache.jetspeed.container.state.NavigationalState;
026: import org.apache.pluto.om.window.PortletWindow;
027:
028: /**
029: * <p>
030: * PortalURL defines the interface for manipulating Jetspeed Portal URLs.
031: * These URLs are used internally by the portal and are not available to
032: * Portlet Applications.
033: * </p>
034: *
035: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
036: * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
037: * @version $Id: PortalURL.java 605989 2007-12-20 18:26:54Z ate $
038: *
039: */
040: public interface PortalURL {
041: /** HTTP protocol. */
042: public static final String HTTP = "http";
043:
044: /** HTTPS protocol. */
045: public static final String HTTPS = "https";
046:
047: /**
048: * @return true if only relative urls should be generated (without scheme, servername, port)
049: */
050: boolean isRelativeOnly();
051:
052: /**
053: * Gets the Base URL for this portal.
054: *
055: * @return The Base URL of the portal.
056: */
057: String getBaseURL();
058:
059: /**
060: * Gets a secure version of the Base URL for this portal.
061: *
062: * @return The secure Base URL of the portal.
063: */
064: String getBaseURL(boolean secure);
065:
066: /**
067: * Gets the global navigational path of the current request.
068: * <br>
069: * The path does not contain the NavigationalState parameter
070: *
071: * @return The the global navigational path of the current request.
072: */
073: String getPath();
074:
075: /**
076: * Returns the current Portal base path.
077: * <br>
078: * This path can be used as base for root relative pages and resources which don't need
079: * the NavigationalState.
080: * @return the current Portal base path without NavigationalState
081: */
082: String getBasePath();
083:
084: /**
085: * Returns the current Portal Page base path without possible encoded
086: * NavigationalState parameter.
087: * <br>
088: * This path can be used as base for page relative resources which don't need
089: * the NavigationalState.
090: * @return the current Portal Page base path without NavigationalState
091: */
092: String getPageBasePath();
093:
094: /**
095: * @return true if the current request is secure
096: */
097: boolean isSecure();
098:
099: /**
100: * Gets the NavigationalState for access to the current request portal control parameters
101: * @return the NavigationalState of the PortalURL
102: */
103: NavigationalState getNavigationalState();
104:
105: /**
106: * Create a new PortletURL for a PortletWindow including request or action parameters.
107: * <br>
108: * The Portal Navigational State is encoded within the URL
109: *
110: * @param window the PortalWindow
111: * @param parameters the new request or action parameters for the PortalWindow
112: * @param mode the new PortletMode for the PortalWindow
113: * @param state the new WindowState for the PortalWindow
114: * @param action indicates if an actionURL or renderURL is created
115: * @param secure indicates if a secure url is required
116: * @return a new actionURL or renderURL as String
117: */
118: String createPortletURL(PortletWindow window, Map parameters,
119: PortletMode mode, WindowState state, boolean action,
120: boolean secure);
121:
122: /**
123: * Create a new PortletURL for a PortletWindow retaining its (request) parameters.
124: * <br>
125: * The Portal Navigational State is encoded within the URL
126: *
127: * @param window the PortalWindow
128: * @param mode the new PortletMode for the PortalWindow
129: * @param state the new WindowState for the PortalWindow
130: * @param secure
131: * @param secure indicates if a secure url is required
132: * @return a new renderURL as String
133: */
134: String createPortletURL(PortletWindow window, PortletMode mode,
135: WindowState state, boolean secure);
136:
137: /**
138: * Sets the @link{javax.servlet.http.HttpServletRequest} that will be used
139: * to generate urls.
140: * @param request
141: */
142: void setRequest(HttpServletRequest request);
143:
144: void setCharacterEncoding(String characterEncoding);
145:
146: /**
147: * Creates the navigational encoding for a given window
148: * Similiar to createPortletURL above
149: *
150: * @param window the PortalWindow
151: * @param parameters the new request or action parameters for the PortalWindow
152: * @param mode the new PortletMode for the PortalWindow
153: * @param state the new WindowState for the PortalWindow
154: * @param action indicates if an actionURL or renderURL is created
155: * @param secure indicates if a secure url is required
156: * @return a new navigational state as String
157: */
158: String createNavigationalEncoding(PortletWindow window,
159: Map parameters, PortletMode mode, WindowState state,
160: boolean action);
161:
162: /**
163: * Creates the navigational encoding for a given window
164: * Similiar to createPortletURL above
165: *
166: * @param window the PortalWindow
167: * @param mode the new PortletMode for the PortalWindow
168: * @param state the new WindowState for the PortalWindow
169: * @param secure
170: * @param secure indicates if a secure url is required
171: * @return a new renderURL as String
172: */
173: String createNavigationalEncoding(PortletWindow window,
174: PortletMode mode, WindowState state);
175:
176: /**
177: * @return a Portal URL with encoded current navigational state
178: */
179: String getPortalURL();
180:
181: /**
182: * @return true if navigational state was provided on the url
183: */
184: boolean hasEncodedNavState();
185:
186: /**
187: * @return true if navigational state is encoded as pathInfo
188: */
189: boolean isPathInfoEncodingNavState();
190:
191: }
|