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.state;
18  
19  import java.io.UnsupportedEncodingException;
20  import java.util.Iterator;
21  import java.util.Map;
22  
23  import javax.portlet.PortletMode;
24  import javax.portlet.WindowState;
25  
26  import org.apache.jetspeed.request.RequestContext;
27  import org.apache.pluto.om.window.PortletWindow;
28  
29  /***
30   * NavigationalState gives readonly access to the state of the Portal URL and all navigational state context
31   * as well as encoding a new State for usage in a Portal URL.
32   * <br>
33   * Note: Support for changing the PortletMode and/or WindowState of a PortletWindow, other than for encoding a new State
34   * is moved down to the {@link MutableNavigationState} interface to cleanly define the immutable contract of this 
35   * interface.
36   * 
37   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
38   * @version $Id: NavigationalState.java 554926 2007-07-10 13:12:26Z ate $
39   */
40  public interface NavigationalState 
41  {
42      public static final String NAVSTATE_SESSION_KEY = "org.apache.jetspeed.navstate";
43  
44      /*
45       * Decodes an encoded Navigational State as retrieved from a Portal URL.
46       * <br>
47       * Note: Initializing is done only once. Subsequent init requests are ignored.
48       * 
49       * @param encodedState encoded Navigational State as retrieved from a Portal URL.
50       * @param characterEncoding String containing the name of the chararacter encoding
51       */
52      void init(String encodedState, String characterEncoding) throws UnsupportedEncodingException;
53      
54      /***
55       * Synchronize the Navigational State with saved state (if used).
56       * <br>
57       * Should be called by the PortalURL impl right after calling {@link #init(String)}
58       *
59       * @param context The RequestContext for this Navigational State
60       */
61      void sync(RequestContext context);
62  
63      /***
64       * Gets the window state for given portlet window.
65       * 
66       * @param window
67       * @return
68       */
69      WindowState getState(PortletWindow window);    
70      
71      /***
72       * Gets the internal (portal) window state for given portlet window.
73       * 
74       * @param window
75       * @return
76       */
77      WindowState getMappedState(PortletWindow window);    
78      
79      /***
80       * Gets the window state for given portlet window id.
81       * 
82       * @param windowId
83       * @return
84       * @deprecated
85       */
86      WindowState getState(String windowId);    
87      
88      /***
89       * Gets the internal (portal) window state for given portlet window id.
90       * 
91       * @param windowId
92       * @return
93       */
94      WindowState getMappedState(String windowId);    
95      
96      /***
97       * Gets the portlet mode for the given portlet window.
98       * 
99       * @param window
100      * @return
101      */
102     PortletMode getMode(PortletWindow window);
103     
104     /***
105      * Gets the internal (portal) portlet mode for the given portlet window.
106      * 
107      * @param window
108      * @return
109      */
110     PortletMode getMappedMode(PortletWindow window);
111     
112     /***
113      * Gets the portlet mode for the given portlet window id.
114      * 
115      * @param windowId
116      * @return
117      * @deprecated
118      */
119     PortletMode getMode(String windowId);
120     
121     /***
122      * Gets the internal (portal) portlet mode for the given portlet window id.
123      * 
124      * @param windowId
125      * @return
126      */
127     PortletMode getMappedMode(String windowId);
128     
129     /***
130      * For the current request return the (first) maximized window or
131      * return null if no windows are maximized.
132      * 
133      * @return The maximized window or null
134      */
135     PortletWindow getMaximizedWindow();
136         
137     Iterator getParameterNames(PortletWindow window);
138     
139     String[] getParameterValues(PortletWindow window, String parameterName);
140 
141     PortletWindow getPortletWindowOfAction();
142     
143     PortletWindow getPortletWindowOfResource();
144     /***
145      * Returns an iterator of Portlet Window ids of all the Portlet Windows 
146      * within the NavigationalState.
147      * <br/>
148      * Note: for an ActionRequest, this will include the window id of
149      * the PortletWindowOfAction.
150      * @return iterator of portletWindow ids (String)
151      */
152     Iterator getWindowIdIterator();
153     
154     /***
155      * Encodes the Navigational State with overrides for a specific PortletWindow into a string to be embedded within a 
156      * PortalURL.
157      * 
158      * @param window the PortalWindow
159      * @param parameters the new request or action parameters for the PortalWindow
160      * @param mode the new PortletMode for the PortalWindow
161      * @param state the new WindowState for the PortalWindow
162      * @param action indicates if to be used in an actionURL or renderURL
163      * @return encoded new Navigational State
164      */
165     String encode(PortletWindow window, Map parameters, PortletMode mode, WindowState state, boolean action) throws UnsupportedEncodingException;
166 
167     /***
168      * Encodes the Navigational State with overrides for a specific PortletWindow while retaining its (request) 
169      * parameters into a string to be embedded within a renderURL.
170      * 
171      * @param window the PortalWindow
172      * @param mode the new PortletMode for the PortalWindow
173      * @param state the new WindowState for the PortalWindow
174      * @return encoded new Navigational State 
175      */
176     String encode(PortletWindow window, PortletMode mode, WindowState state) throws UnsupportedEncodingException;
177     
178     /***
179      * Encodes the current navigational State into a string to be embedded within a PortalURL.
180      * 
181      * @return encoded new Navigational State 
182      */
183     String encode() throws UnsupportedEncodingException;
184     
185     /***
186      * @return true if WindowStates and PortletModes will be saved in the Session
187      */
188     boolean isNavigationalParameterStateFull();
189 
190     /***
191      * @return true if render parameters will be saved in the Session
192      */
193     boolean isRenderParameterStateFull();
194 }