org.apache.jetspeed.services.webpage
Class AbstractSiteSession

java.lang.Object
  extended byorg.apache.jetspeed.services.webpage.AbstractSiteSession
All Implemented Interfaces:
SiteSession
Direct Known Subclasses:
JetspeedSiteSession

public abstract class AbstractSiteSession
extends java.lang.Object
implements SiteSession


Field Summary
protected  int cacheCount
           
protected  java.util.HashMap cookies
           
protected  int hitCount
           
protected  java.lang.String proxyBase
           
protected  java.lang.String targetBase
           
 
Constructor Summary
AbstractSiteSession(java.lang.String targetBase, java.lang.String proxyBase)
          Create a NetElementSession, which maintains sessions with one network element.
 
Method Summary
 boolean addCookieToSession(javax.servlet.http.Cookie cookie)
          Given a cookie, it first checks to see if that cookie is already managed in this session.
 void dispatch(java.lang.String url, ProxyRunData data)
          Given a URL, returns the content from that URL in a string.
 void getBinaryContent(java.net.URLConnection con, javax.servlet.http.HttpServletResponse response)
          Gets the HTML content from the URL Connection stream and writes it to respones
 int getCacheCount()
          Gets the cache count for this session.
 int getHitCount()
          Gets the hitcount for this session.
 java.lang.String getHTMLContent(java.net.URLConnection con, ProxyRunData data, java.lang.String resource)
          Gets the HTML content from the URL Connection stream and returns it in a string
 void incCacheCount()
          Increments the hitcount for this session.
 void incHitCount()
          Increments the hitcount for this session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jetspeed.services.webpage.SiteSession
drainContent, getContentAsString, logon, logout, proxy, rewriteContent
 

Field Detail

targetBase

protected java.lang.String targetBase

proxyBase

protected java.lang.String proxyBase

cookies

protected java.util.HashMap cookies

hitCount

protected int hitCount

cacheCount

protected int cacheCount
Constructor Detail

AbstractSiteSession

public AbstractSiteSession(java.lang.String targetBase,
                           java.lang.String proxyBase)
Create a NetElementSession, which maintains sessions with one network element.

Parameters:
targetBase - the target host's base URL
proxyBase - the proxy server host URL base address.
Method Detail

dispatch

public void dispatch(java.lang.String url,
                     ProxyRunData data)
              throws java.io.IOException
Given a URL, returns the content from that URL in a string. All HTTP hyperlinks(HREFs) are rewritten as proxied-referenced hyperlinks. All relative references to web resources (images, stylesheets, ...) are rewritten as absolute references, but are not proxied. Determines if we are logged on to the target site. If not, calls logon(), which is a implementation specific 'POST' exchange

Parameters:
url - the proxied resource address.
data - the rundata
Throws:
java.io.IOException - a servlet exception.
See Also:
logon(String, HttpServletRequest, HttpServletResponse)

getHTMLContent

public java.lang.String getHTMLContent(java.net.URLConnection con,
                                       ProxyRunData data,
                                       java.lang.String resource)
                                throws java.io.IOException
Gets the HTML content from the URL Connection stream and returns it in a string

Parameters:
con - The URLConnection to read from.
resource - The full URL of the resource.
Returns:
The HTML Content from the stream.
Throws:
java.io.IOException - a servlet exception.

getBinaryContent

public void getBinaryContent(java.net.URLConnection con,
                             javax.servlet.http.HttpServletResponse response)
                      throws java.io.IOException
Gets the HTML content from the URL Connection stream and writes it to respones

Parameters:
con - The URLConnection to read from.
Throws:
java.io.IOException - a servlet exception.

addCookieToSession

public boolean addCookieToSession(javax.servlet.http.Cookie cookie)
Given a cookie, it first checks to see if that cookie is already managed in this session. If it is, it means that the session has timed out and that the network element has now created a new session. In that case, replace the cookie, and re-establish the session (logon) If its a new cookie, we will still need to logon, and and the cookie to the managed cookies collection for this session.

Specified by:
addCookieToSession in interface SiteSession
Parameters:
cookie - new cookie returned from target server.
Returns:
true when a new cookie added, false when updated.

getHitCount

public int getHitCount()
Description copied from interface: SiteSession
Gets the hitcount for this session.

Specified by:
getHitCount in interface SiteSession
Returns:
the hitcount for this session.

incHitCount

public void incHitCount()
Description copied from interface: SiteSession
Increments the hitcount for this session.

Specified by:
incHitCount in interface SiteSession

getCacheCount

public int getCacheCount()
Description copied from interface: SiteSession
Gets the cache count for this session.

Specified by:
getCacheCount in interface SiteSession
Returns:
the cache count for this session.

incCacheCount

public void incCacheCount()
Description copied from interface: SiteSession
Increments the hitcount for this session.

Specified by:
incCacheCount in interface SiteSession


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.