Package org.archive.modules.fetcher
Class AbstractCookieStore
java.lang.Object
org.archive.modules.fetcher.AbstractCookieStore
- All Implemented Interfaces:
org.apache.http.client.CookieStore
,org.archive.checkpointing.Checkpointable
,FetchHTTPCookieStore
,org.springframework.context.Lifecycle
- Direct Known Subclasses:
BdbCookieStore
,SimpleCookieStore
public abstract class AbstractCookieStore extends Object implements org.springframework.context.Lifecycle, org.archive.checkpointing.Checkpointable, org.apache.http.client.CookieStore, FetchHTTPCookieStore
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractCookieStore.LimitedCookieStoreFacade
-
Field Summary
Fields Modifier and Type Field Description protected static Comparator<org.apache.http.cookie.Cookie>
cookieComparator
protected org.archive.spring.ConfigFile
cookiesLoadFile
protected org.archive.spring.ConfigPath
cookiesSaveFile
protected boolean
isRunning
protected Logger
logger
static int
MAX_COOKIES_FOR_DOMAIN
-
Constructor Summary
Constructors Constructor Description AbstractCookieStore()
-
Method Summary
Modifier and Type Method Description void
addCookie(org.apache.http.cookie.Cookie cookie)
protected abstract void
addCookieImpl(org.apache.http.cookie.Cookie cookie)
abstract void
clear()
org.apache.http.client.CookieStore
cookieStoreFor(CrawlURI curi)
Returns aCookieStore
whoseCookieStore.getCookies()
returns all the cookies that could possibly applycuri
.abstract boolean
expireCookie(org.apache.http.cookie.Cookie cookie, Date date)
org.archive.spring.ConfigFile
getCookiesLoadFile()
org.archive.spring.ConfigPath
getCookiesSaveFile()
boolean
isCookieCountMaxedForDomain(String domain)
boolean
isRunning()
protected void
loadCookies(Reader reader)
protected void
loadCookies(org.archive.spring.ConfigFile file)
protected String
normalizeHost(String host)
protected abstract void
prepare()
protected Collection<org.apache.http.cookie.Cookie>
readCookies(Reader reader)
Load cookies.void
saveCookies()
void
saveCookies(String saveCookiesFile)
void
setCookiesLoadFile(org.archive.spring.ConfigFile cookiesLoadFile)
void
setCookiesSaveFile(org.archive.spring.ConfigPath cookiesSaveFile)
protected String
sortableKey(org.apache.http.cookie.Cookie cookie)
Returns a string that uniquely identifies the cookie, The format The format of the key is"normalizedDomain;name;path"
.void
start()
void
stop()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.archive.checkpointing.Checkpointable
doCheckpoint, finishCheckpoint, setRecoveryCheckpoint, startCheckpoint
Methods inherited from interface org.apache.http.client.CookieStore
clearExpired, getCookies
Methods inherited from interface org.archive.modules.fetcher.FetchHTTPCookieStore
cookieStoreFor
-
Field Details
-
MAX_COOKIES_FOR_DOMAIN
public static final int MAX_COOKIES_FOR_DOMAIN- See Also:
- Constant Field Values
-
logger
-
cookieComparator
-
cookiesLoadFile
protected org.archive.spring.ConfigFile cookiesLoadFile -
cookiesSaveFile
protected org.archive.spring.ConfigPath cookiesSaveFile -
isRunning
protected boolean isRunning
-
-
Constructor Details
-
AbstractCookieStore
public AbstractCookieStore()
-
-
Method Details
-
getCookiesLoadFile
public org.archive.spring.ConfigFile getCookiesLoadFile() -
setCookiesLoadFile
public void setCookiesLoadFile(org.archive.spring.ConfigFile cookiesLoadFile) -
getCookiesSaveFile
public org.archive.spring.ConfigPath getCookiesSaveFile() -
setCookiesSaveFile
public void setCookiesSaveFile(org.archive.spring.ConfigPath cookiesSaveFile) -
start
public void start()- Specified by:
start
in interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()- Specified by:
stop
in interfaceorg.springframework.context.Lifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceorg.springframework.context.Lifecycle
-
saveCookies
public void saveCookies() -
loadCookies
protected void loadCookies(org.archive.spring.ConfigFile file) -
loadCookies
-
saveCookies
-
readCookies
Load cookies. The input is text in the Netscape's 'cookies.txt' file format. Example entry of cookies.txt file:www.archive.org FALSE / FALSE 1311699995 details-visit texts-cralond
Each line has 7 tab-separated fields:
- DOMAIN: The domain that created and have access to the cookie value.
- FLAG: A TRUE or FALSE value indicating if hosts within the given domain can access the cookie value.
- PATH: The path within the domain that the cookie value is valid for.
- SECURE: A TRUE or FALSE value indicating if to use a secure connection to access the cookie value.
- EXPIRATION: The expiration time of the cookie value, or -1 for no expiration
- NAME: The name of the cookie value
- VALUE: The cookie value
- Parameters:
reader
- input in the Netscape's 'cookies.txt' format.
-
sortableKey
Returns a string that uniquely identifies the cookie, The format The format of the key is"normalizedDomain;name;path"
. Adapted fromCookieIdentityComparator.compare(Cookie, Cookie)
. -
normalizeHost
-
cookieStoreFor
public org.apache.http.client.CookieStore cookieStoreFor(CrawlURI curi) throws org.apache.commons.httpclient.URIExceptionDescription copied from interface:FetchHTTPCookieStore
Returns aCookieStore
whoseCookieStore.getCookies()
returns all the cookies that could possibly applycuri
.- Specified by:
cookieStoreFor
in interfaceFetchHTTPCookieStore
- Throws:
org.apache.commons.httpclient.URIException
-
isCookieCountMaxedForDomain
-
addCookie
public void addCookie(org.apache.http.cookie.Cookie cookie)- Specified by:
addCookie
in interfaceorg.apache.http.client.CookieStore
-
expireCookie
-
addCookieImpl
protected abstract void addCookieImpl(org.apache.http.cookie.Cookie cookie) -
clear
public abstract void clear()- Specified by:
clear
in interfaceorg.apache.http.client.CookieStore
-
prepare
protected abstract void prepare()
-