1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.services.webpage;
1819// java.io20import java.io.IOException;
2122// javax.servlet23import javax.servlet.http.*;
2425// java.net26import java.net.URLConnection;
2728/***29 * Standard interface for all proxied sessions.30 * Handles the communication and session state between the webpage service and a single site31 *32 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>33 * @version $Id: SiteSession.java,v 1.3 2004/02/23 03:46:26 jford Exp $ 34 */35publicinterfaceSiteSession36 {
3738/***39 * Given a site URL, proxies the content of that site. 40 * The actual rules on rewriting the proxied resource are dependent on implementation 41 * and configuration parameters. For example, all HTTP hyperlinks(HREFs) could be42 * rewritten as proxied hyperlinks back to this Proxy.43 * Or all relative references to web resources (images, stylesheets, ...) could be44 * rewritten as absolute references, but are not proxied.45 *46 * @param site the proxied resource address.47 * @param data the request specific rundata.48 *49 * @exception IOException a servlet exception.50 */51publicvoid proxy(String site, ProxyRunData data)
52 throws IOException;
5354/***55 * Gets the HTML content from the URL Connection stream and returns it as a Stream56 *57 * @param con The URLConnection to read from.58 * @param data the request specific rundata.59 * @return The HTML Content from the stream.60 *61 * @deprecate62 * @exception IOException a servlet exception.63 */64public String getContentAsString(URLConnection con,
65ProxyRunData data,
66 String url)
67 throws IOException;
686970/***71 * Retrieves the content from the URL Connection stream and writes it to servlet response72 *73 * @param con The URLConnection to read from.74 *75 * @exception IOException a servlet exception.76 */77publicvoid drainContent(URLConnection con,
78 HttpServletResponse response) throws IOException;
7980/***81 * Given a cookie, it first checks to see if that cookie is already82 * managed in this session. If it is, it means that the session has83 * timed out and that the network element has now created a new session.84 * In that case, replace the cookie, and re-establish the session (logon)85 * If its a new cookie, we will still need to logon, and and the cookie to86 * the managed cookies collection for this session.87 *88 * @param cookie new cookie returned from target server.89 * @return true when a new cookie added, false when updated.90 *91 */92publicboolean addCookieToSession(Cookie cookie);
9394/***95 * Logs on to the target host96 *97 * @param data the request specific rundata. 98 *99 * @exception IOException a servlet exception.100 */101publicboolean logon(ProxyRunData data)
102 throws IOException;
103104105/***106 * Logs out of the target host107 *108 * @param data the request specific rundata. 109 *110 * @exception IOException a servlet exception.111 */112publicboolean logout(ProxyRunData data)
113 throws IOException;
114115116/***117 * Reads stream for proxied host, runs a rewriter against that stream,118 * rewriting relevant links, and writes the parsed stream back to the client.119 *120 * @param request Servlet request.121 * @param con the URLConnection with proxied host.122 * @param contentType the contentType of the request.123 *124 * @exception IOException a servlet exception.125 */126publicvoid rewriteContent(ProxyRunData data,
127 URLConnection con,
128int contentType,
129 String url) throws IOException;
130131/***132 * Gets the hitcount for this session.133 *134 * @return the hitcount for this session.135 */136publicint getHitCount();
137138/***139 * Increments the hitcount for this session.140 *141 */142publicvoid incHitCount();
143144/***145 * Gets the cache count for this session.146 *147 * @return the cache count for this session.148 */149publicint getCacheCount();
150151/***152 * Increments the hitcount for this session.153 *154 */155publicvoid incCacheCount();
156157 }
158