View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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.jetspeed.container.url;
18  
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.jetspeed.container.state.NavigationalState;
26  import org.apache.pluto.om.window.PortletWindow;
27  
28  /***
29   * <p>
30   * PortalURL defines the interface for manipulating Jetspeed Portal URLs.
31   * These URLs are used internally by the portal and are not available to
32   * Portlet Applications.
33   * </p>
34   * 
35   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
36   * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
37   * @version $Id: PortalURL.java 605989 2007-12-20 18:26:54Z ate $
38   *
39   */
40  public interface PortalURL
41  {
42      /*** HTTP protocol. */
43      public static final String HTTP = "http";
44  
45      /*** HTTPS protocol. */
46      public static final String HTTPS = "https";
47      
48      /***
49       * @return true if only relative urls should be generated (without scheme, servername, port)
50       */
51      boolean isRelativeOnly();
52      
53      /***
54       * Gets the Base URL for this portal.
55       * 
56       * @return The Base URL of the portal.
57       */
58      String getBaseURL();   
59  
60      /***
61       * Gets a secure version of the Base URL for this portal.
62       * 
63       * @return The secure Base URL of the portal.
64       */
65      String getBaseURL(boolean secure);
66  
67      /***
68       * Gets the global navigational path of the current request.
69       * <br>
70       * The path does not contain the NavigationalState parameter
71       * 
72       * @return The the global navigational path of the current request.
73       */
74      String getPath();
75      
76      /***
77       * Returns the current Portal base path. 
78       * <br>
79       * This path can be used as base for root relative pages and resources which don't need
80       * the NavigationalState.
81       * @return the current Portal base path without NavigationalState
82       */
83      String getBasePath();
84  
85      /***
86       * Returns the current Portal Page base path without possible encoded
87       * NavigationalState parameter.
88       * <br>
89       * This path can be used as base for page relative resources which don't need
90       * the NavigationalState.
91       * @return the current Portal Page base path without NavigationalState
92       */
93      String getPageBasePath();
94  
95      /***
96       * @return true if the current request is secure
97       */
98      boolean isSecure();
99  
100     /***
101      * Gets the NavigationalState for access to the current request portal control parameters
102      * @return the NavigationalState of the PortalURL
103      */
104     NavigationalState getNavigationalState();    
105 
106     /***
107      * Create a new PortletURL for a PortletWindow including request or action parameters.
108      * <br>
109      * The Portal Navigational State is encoded within the URL
110      * 
111      * @param window the PortalWindow
112      * @param parameters the new request or action parameters for the PortalWindow
113      * @param mode the new PortletMode for the PortalWindow
114      * @param state the new WindowState for the PortalWindow
115      * @param action indicates if an actionURL or renderURL is created
116      * @param secure indicates if a secure url is required 
117      * @return a new actionURL or renderURL as String
118      */
119     String createPortletURL(PortletWindow window, Map parameters, PortletMode mode, WindowState state, boolean action, boolean secure);
120 
121     /***
122      * Create a new PortletURL for a PortletWindow retaining its (request) parameters.
123      * <br>
124      * The Portal Navigational State is encoded within the URL
125      * 
126      * @param window the PortalWindow
127      * @param mode the new PortletMode for the PortalWindow
128      * @param state the new WindowState for the PortalWindow
129      * @param secure
130      * @param secure indicates if a secure url is required 
131      * @return a new renderURL as String
132      */
133     String createPortletURL(PortletWindow window, PortletMode mode, WindowState state, boolean secure);
134     
135     /***
136      * Sets the @link{javax.servlet.http.HttpServletRequest} that will be used 
137      * to generate urls.
138      * @param request
139      */
140     void setRequest(HttpServletRequest request);
141     
142     void setCharacterEncoding(String characterEncoding);
143     
144     /***
145      * Creates the navigational encoding for a given window
146      * Similiar to createPortletURL above
147      * 
148      * @param window the PortalWindow
149      * @param parameters the new request or action parameters for the PortalWindow
150      * @param mode the new PortletMode for the PortalWindow
151      * @param state the new WindowState for the PortalWindow
152      * @param action indicates if an actionURL or renderURL is created
153      * @param secure indicates if a secure url is required 
154      * @return a new navigational state as String
155      */
156     String createNavigationalEncoding(PortletWindow window, Map parameters, PortletMode mode, WindowState state, boolean action);
157     
158     /***
159      * Creates the navigational encoding for a given window
160      * Similiar to createPortletURL above
161      * 
162      * @param window the PortalWindow
163      * @param mode the new PortletMode for the PortalWindow
164      * @param state the new WindowState for the PortalWindow
165      * @param secure
166      * @param secure indicates if a secure url is required 
167      * @return a new renderURL as String
168      */    
169     String createNavigationalEncoding(PortletWindow window, PortletMode mode, WindowState state);
170 
171     /***
172      * @return a Portal URL with encoded current navigational state
173      */
174     String getPortalURL();
175     
176     /***
177      * @return true if navigational state was provided on the url
178      */
179     boolean hasEncodedNavState();
180     
181     /***
182      * @return true if navigational state is encoded as pathInfo
183      */
184     boolean isPathInfoEncodingNavState();
185     
186 
187 }