001: /*
002: * Created on Jul 28, 2003
003: *
004: /*
005:
006: /*
007: Copyright (c) 2003 eInnovation Inc. All rights reserved
008:
009: This library is free software; you can redistribute it and/or modify it under the terms
010: of the GNU Lesser General Public License as published by the Free Software Foundation;
011: either version 2.1 of the License, or (at your option) any later version.
012:
013: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
014: without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
015: See the GNU Lesser General Public License for more details.
016: */
017: package com.openedit;
018:
019: import java.io.OutputStream;
020: import java.io.Writer;
021: import java.util.Map;
022:
023: import javax.servlet.http.HttpServletRequest;
024: import javax.servlet.http.HttpServletResponse;
025: import javax.servlet.http.HttpSession;
026:
027: import com.openedit.page.Page;
028: import com.openedit.page.PageAction;
029: import com.openedit.page.PageStreamer;
030: import com.openedit.users.User;
031:
032: /**
033: * @author Matt Avery, mavery@einnovation.com
034: */
035: public interface WebPageRequest {
036: HttpServletRequest getRequest();
037:
038: HttpServletResponse getResponse();
039:
040: HttpSession getSession();
041:
042: /**
043: * The redirect will send the browser to a new page
044: * This looses any parameters to the original page
045: * @param inInUrl can begin with http or be a path /index.html
046: */
047: void redirect(String inUrl);
048:
049: /**
050: * This is used to tell search engines to use the new links
051: * @param inPath
052: */
053: public void redirectPermanently(String inPath);
054:
055: /**
056: * This will simply render a new page instead of the page the user
057: * was expecting
058: *
059: * @param inInUrl should be a path such as /index.html
060: */
061: void forward(String inUrl) throws OpenEditException;
062:
063: /**
064: * Convenience methods for managing Velocity context objects.
065: */
066: Object getPageValue(String inKey);
067:
068: /**
069: * Looks in the action, page and parameter for a value
070: * @param inName
071: * @return
072: */
073: String findValue(String inName);
074:
075: String getPageProperty(String inKey);
076:
077: String getContentProperty(String inKey);
078:
079: void putPageValue(String inKey, Object inObject);
080:
081: /**
082: * <p>
083: * Add a protected page value to this page request. Protected values are
084: * reserved for use by OpenEdit itself and should not be overriden in
085: * general practice.
086: * </p>
087: * @param inKey
088: * @param inObject
089: */
090: void putProtectedPageValue(String inKey, Object inObject);
091:
092: void removePageValue(String inKey);
093:
094: Map getPageMap();
095:
096: /**
097: * Convenience methods for managing session objects.
098: */
099: Object getSessionValue(String inKey);
100:
101: void putSessionValue(String inKey, Object inObject);
102:
103: void removeSessionValue(String inKey);
104:
105: String getRequestParameter(String inKey);
106:
107: /**
108: * The returned values are escaped and suitable to show in a web browser
109: * @param inKey
110: * @return
111: */
112: public String getParam(String inKey);
113:
114: String[] getRequestParameters(String inKey);
115:
116: void setRequestParameter(String inKey, String inValue);
117:
118: void setRequestParameter(String inKey, String[] inValue);
119:
120: /**
121: *
122: * @return a mutable map of the request parameters
123: */
124: Map getParameterMap();
125:
126: // This may not be necessary
127: String getRequiredParameter(String inParameterName)
128: throws OpenEditException;
129:
130: User getUser();
131:
132: /**
133: * @param inObject
134: */
135: void setUser(User inUser);
136:
137: /**
138: * This is the path to the content
139: */
140: String getPath();
141:
142: /**
143: * This is the page that this context refers to in the getPath() method
144: * @return
145: */
146: Page getPage();
147:
148: /**
149: * Is the full path to the page you are on. This includes any arguments or parameters
150: * @return fullpath
151: */
152: String getPathUrl();
153:
154: String getPathUrlWithoutContext();
155:
156: OutputStream getOutputStream();
157:
158: Writer getWriter();
159:
160: PageStreamer getPageStreamer();
161:
162: void putPageStreamer(PageStreamer inStreamer);
163:
164: /**
165: * @return
166: */
167: boolean hasRedirected();
168:
169: boolean hasForwarded();
170:
171: void setHasRedirected(boolean inB);
172:
173: void setHasForwarded(boolean inB);
174:
175: boolean hasCancelActions();
176:
177: void setCancelActions(boolean inB);
178:
179: /**
180: * @return
181: */
182: Page getContentPage();
183:
184: /**
185: * Determine whether this page can be edited by the given user. The page is editable if:
186: *
187: * <ul>
188: * <li>
189: * the page's repository is not read-only;
190: * </li>
191: * <li>
192: * the "editable" property is not present or equal to "true"; and
193: * </li>
194: * <li>
195: * the edit filter is not present or passes the given user.
196: * </li>
197: * </ul>
198: *
199: *
200: * @param inUser The user to query
201: * @param inContext DOCME
202: *
203: * @return boolean <code>true</code> if the page is editable by the user, <code>false</code>
204: * if not
205: *
206: * @throws OpenEditException DOCME
207: */
208: public boolean isEditable();
209:
210: public void setEditable(boolean inEdi);
211:
212: public String[] getRequestActions();
213:
214: /**
215: * @return
216: */
217: WebPageRequest copy();
218:
219: /**
220: * @param inPage
221: * @return
222: */
223: WebPageRequest copy(Page inPage);
224:
225: /**
226: * @param inPage
227: */
228: void setPage(Page inPage);
229:
230: WebPageRequest getParent();
231:
232: /**
233: * @param inAction
234: */
235: void setCurrentAction(PageAction inAction);
236:
237: PageAction getCurrentAction();
238:
239: String getLocale();
240:
241: String getLanguage();
242:
243: String getUserName();
244:
245: }
|