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.state;
018:
019: import java.io.UnsupportedEncodingException;
020: import java.util.Iterator;
021: import java.util.Map;
022:
023: import javax.portlet.PortletMode;
024: import javax.portlet.WindowState;
025:
026: import org.apache.jetspeed.request.RequestContext;
027: import org.apache.pluto.om.window.PortletWindow;
028:
029: /**
030: * NavigationalState gives readonly access to the state of the Portal URL and all navigational state context
031: * as well as encoding a new State for usage in a Portal URL.
032: * <br>
033: * Note: Support for changing the PortletMode and/or WindowState of a PortletWindow, other than for encoding a new State
034: * is moved down to the {@link MutableNavigationState} interface to cleanly define the immutable contract of this
035: * interface.
036: *
037: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
038: * @version $Id: NavigationalState.java 554926 2007-07-10 13:12:26Z ate $
039: */
040: public interface NavigationalState {
041: public static final String NAVSTATE_SESSION_KEY = "org.apache.jetspeed.navstate";
042:
043: /*
044: * Decodes an encoded Navigational State as retrieved from a Portal URL.
045: * <br>
046: * Note: Initializing is done only once. Subsequent init requests are ignored.
047: *
048: * @param encodedState encoded Navigational State as retrieved from a Portal URL.
049: * @param characterEncoding String containing the name of the chararacter encoding
050: */
051: void init(String encodedState, String characterEncoding)
052: throws UnsupportedEncodingException;
053:
054: /**
055: * Synchronize the Navigational State with saved state (if used).
056: * <br>
057: * Should be called by the PortalURL impl right after calling {@link #init(String)}
058: *
059: * @param context The RequestContext for this Navigational State
060: */
061: void sync(RequestContext context);
062:
063: /**
064: * Gets the window state for given portlet window.
065: *
066: * @param window
067: * @return
068: */
069: WindowState getState(PortletWindow window);
070:
071: /**
072: * Gets the internal (portal) window state for given portlet window.
073: *
074: * @param window
075: * @return
076: */
077: WindowState getMappedState(PortletWindow window);
078:
079: /**
080: * Gets the window state for given portlet window id.
081: *
082: * @param windowId
083: * @return
084: * @deprecated
085: */
086: WindowState getState(String windowId);
087:
088: /**
089: * Gets the internal (portal) window state for given portlet window id.
090: *
091: * @param windowId
092: * @return
093: */
094: WindowState getMappedState(String windowId);
095:
096: /**
097: * Gets the portlet mode for the given portlet window.
098: *
099: * @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,
140: String parameterName);
141:
142: PortletWindow getPortletWindowOfAction();
143:
144: PortletWindow getPortletWindowOfResource();
145:
146: /**
147: * Returns an iterator of Portlet Window ids of all the Portlet Windows
148: * within the NavigationalState.
149: * <br/>
150: * Note: for an ActionRequest, this will include the window id of
151: * the PortletWindowOfAction.
152: * @return iterator of portletWindow ids (String)
153: */
154: Iterator getWindowIdIterator();
155:
156: /**
157: * Encodes the Navigational State with overrides for a specific PortletWindow into a string to be embedded within a
158: * PortalURL.
159: *
160: * @param window the PortalWindow
161: * @param parameters the new request or action parameters for the PortalWindow
162: * @param mode the new PortletMode for the PortalWindow
163: * @param state the new WindowState for the PortalWindow
164: * @param action indicates if to be used in an actionURL or renderURL
165: * @return encoded new Navigational State
166: */
167: String encode(PortletWindow window, Map parameters,
168: PortletMode mode, WindowState state, boolean action)
169: throws UnsupportedEncodingException;
170:
171: /**
172: * Encodes the Navigational State with overrides for a specific PortletWindow while retaining its (request)
173: * parameters into a string to be embedded within a renderURL.
174: *
175: * @param window the PortalWindow
176: * @param mode the new PortletMode for the PortalWindow
177: * @param state the new WindowState for the PortalWindow
178: * @return encoded new Navigational State
179: */
180: String encode(PortletWindow window, PortletMode mode,
181: WindowState state) throws UnsupportedEncodingException;
182:
183: /**
184: * Encodes the current navigational State into a string to be embedded within a PortalURL.
185: *
186: * @return encoded new Navigational State
187: */
188: String encode() throws UnsupportedEncodingException;
189:
190: /**
191: * @return true if WindowStates and PortletModes will be saved in the Session
192: */
193: boolean isNavigationalParameterStateFull();
194:
195: /**
196: * @return true if render parameters will be saved in the Session
197: */
198: boolean isRenderParameterStateFull();
199: }
|