|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lumis.portal.page.cache.PageCacheManager
public class PageCacheManager
Manager for page cache information.
Nested Class Summary | |
---|---|
protected static class |
PageCacheManager.HttpAccessResult
Structure used to hold the result of doHttpAccess(URL, String) . |
Nested classes/interfaces inherited from interface lumis.portal.page.cache.IPageCacheManager |
---|
IPageCacheManager.GenerationOutcome |
Field Summary | |
---|---|
static String |
PAGE_CACHE_MANAGER_LANGUAGE_FILENAME_PREFIX
|
Fields inherited from interface lumis.portal.page.cache.IPageCacheManager |
---|
CLEAR_CACHE_CHANGE_TYPE_DELETE, CLEAR_CACHE_CHANGE_TYPE_UPDATE, PAGE_CACHE_GEN_STATE_DISABLED, PAGE_CACHE_GEN_STATE_ENABLED |
Constructor Summary | |
---|---|
PageCacheManager()
|
Method Summary | |
---|---|
String |
add(SessionConfig sessionConfig,
PageCacheConfig pageCacheConfig,
ITransaction transaction)
Adds a Page Cache Config object. |
void |
addOrUpdate(SessionConfig sessionConfig,
PageCacheConfig pageCacheConfig,
ITransaction transaction)
If the Page Cache Config exists, it is updated, else it is added. |
void |
clearAllHTMLCache(ITransaction transaction)
Clears all page HTML cache. |
void |
clearCacheByChannelIds(SessionConfig sessionConfig,
Collection<String> channelIds,
Parameters parameters,
int changeType,
boolean clearImmediately,
ITransaction transaction)
Clear the cache of the pages within the specified channels recursively. |
void |
clearCacheByPagesIds(SessionConfig sessionConfig,
Collection<String> pagesIds,
Parameters parameters,
int changeType,
boolean clearImmediately,
ITransaction transaction)
Deprecated. |
void |
clearCacheByPagesIds(SessionConfig sessionConfig,
Collection<String> pagesIds,
Parameters parameters,
int changeType,
ITransaction transaction)
Deprecated. |
void |
clearCacheByPagesIds(SessionConfig sessionConfig,
Collection<String> pagesIds,
Parameters parameters,
Locale locale,
int changeType,
boolean clearImmediately,
ITransaction transaction)
Clear the cache of the specified pages. |
void |
clearCacheByServiceInterfaceInstances(SessionConfig sessionConfig,
Collection<ServiceInterfaceInstanceConfig> serviceInterfaceInstances,
Parameters parameters,
int changeType,
ITransaction transaction)
Deprecated. |
void |
clearCacheByServiceInterfaceInstancesIds(SessionConfig sessionConfig,
Collection<String> serviceInterfaceInstanceIds,
Parameters parameters,
int changeType,
ITransaction transaction)
Deprecated. |
String |
convertMainUrl(SessionConfig sessionConfig,
String mainUrl,
ITransaction transaction)
Converts a url to main.jsp to a url to the cached page html url. |
void |
delete(SessionConfig sessionConfig,
String pageCacheId,
ITransaction transaction)
Delete a page cache. |
protected PageCacheManager.HttpAccessResult |
doHttpAccess(URL url,
String cookies)
|
PageCacheConfig |
generateNextPage(boolean forImmediateUseOnly)
Generates next outdated page cache, according to its priority. |
protected void |
generatePage(PageCacheConfig pageCacheConfig)
|
PageCacheConfig |
generatePage(String pageCacheId)
Generates a page cache. |
PageCacheConfig |
get(SessionConfig sessionConfig,
String pageCacheId,
ITransaction transaction)
Returns a page cache config given its id. |
PageCacheConfig |
getByCachedPageProperties(SessionConfig sessionConfig,
PageCacheConfig cachedPageProperties,
ITransaction transaction)
Given the url and language, this method returns the appropriate page cache config. |
String |
getCachedPageId(SessionConfig sessionConfig,
PageCacheConfig pageCacheConfig)
Get the Id of the Page's cache. |
protected PageCacheConfig |
getGenerationLock(String pageCacheId)
Gets a lock for generating a cached page. |
protected PageCacheConfig |
getNextPageForGeneration(boolean forImmediateUseOnly)
Returns the next page cache to be generated. |
int |
getPageCacheGenerationState(SessionConfig sessionConfig,
ITransaction transaction)
Returns whether page cache generation is enabled or not |
String |
getPageCacheRelativePath(PageConfig pageConfig,
String cachedPageId)
Returns the path, relative to the web application root, where a page cached HTML is stored. |
String |
getPageCacheRelativePath(String pageCacheId,
ITransaction transaction)
Returns the path, relative to the web application root, where a page cached HTML is stored. |
String |
getPageUrl(PageCacheConfig pageCacheConfig,
ITransaction transaction)
Get the Page's URL. |
void |
pageCacheMissed(String pageCacheId,
boolean forImmediateUse)
Indicates a miss in the page cache occurred. |
String |
parseHTMLContent(SessionConfig sessionConfig,
String htmlContent,
String cachedPageId,
int cacheType,
ITransaction transaction)
Processes the HTML content correcting relative paths. |
String |
processHtmlReferencesToCachedPages(SessionConfig sessionConfig,
String html,
ITransaction transaction)
Finds in the given html dynamic references to cached pages, adding PageCacheConfig when a proper one does not already exist. |
protected void |
releaseGenerationLock(PageCacheConfig pageCacheConfig,
IPageCacheManager.GenerationOutcome outcome)
Releases the generation lock for a cached page. |
void |
setPageCacheGenerationState(SessionConfig sessionConfig,
int state,
ITransaction transaction)
Sets the page cache generation state. |
void |
update(SessionConfig sessionConfig,
PageCacheConfig pageCacheConfig,
ITransaction transaction)
Updates a Page Cache Config Object. |
void |
updateCachedFilesLastModifiedDate(SessionConfig sessionConfig,
PageConfig pageConfig,
Locale locale,
Date lastModifiedDate,
ITransaction transaction)
Updates the last modified date of the cached files that match the given pageId and locale. |
String |
waitForGeneration(String pageCacheId,
long timeout)
Waits for the generation of a page cache. |
void |
waitForPagesReadyToGenerate(long timeout,
boolean forImmediateUseOnly)
Waits for new pages to be ready to be generated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PAGE_CACHE_MANAGER_LANGUAGE_FILENAME_PREFIX
Constructor Detail |
---|
public PageCacheManager()
Method Detail |
---|
public String waitForGeneration(String pageCacheId, long timeout) throws PortalException, InterruptedException
IPageCacheManager
waitForGeneration
in interface IPageCacheManager
pageCacheId
- the page cache identifier.timeout
- maximum time to wait.
InterruptedException
- if the thread was interrupted.
PortalException
public void waitForPagesReadyToGenerate(long timeout, boolean forImmediateUseOnly) throws InterruptedException
IPageCacheManager
waitForPagesReadyToGenerate
in interface IPageCacheManager
timeout
- maximum time to wait.forImmediateUseOnly
- if true, wait until a page for
immediate use is ready to generate. If false, wait until any page is
ready to generate.
InterruptedException
- if the thread was interrupted.protected PageCacheManager.HttpAccessResult doHttpAccess(URL url, String cookies) throws UnsupportedEncodingException, IOException
UnsupportedEncodingException
IOException
protected void generatePage(PageCacheConfig pageCacheConfig) throws ManagerException, PortalException
ManagerException
PortalException
public PageCacheConfig generateNextPage(boolean forImmediateUseOnly) throws PortalException
IPageCacheManager
generateNextPage
in interface IPageCacheManager
forImmediateUseOnly
- if true, only pages whose priority is higher
than PageCacheConfig.MAX_INITIAL_PRIORITY
are taken in account.
PortalException
public PageCacheConfig generatePage(String pageCacheId) throws PortalException
IPageCacheManager
generatePage
in interface IPageCacheManager
pageCacheId
- the page cache identifier.
PortalException
public String getPageCacheRelativePath(PageConfig pageConfig, String cachedPageId)
IPageCacheManager
getPageCacheRelativePath
in interface IPageCacheManager
pageConfig
- the page that is cached.
public String getPageUrl(PageCacheConfig pageCacheConfig, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
getPageUrl
in interface IPageCacheManager
ManagerException
PortalException
public String getCachedPageId(SessionConfig sessionConfig, PageCacheConfig pageCacheConfig) throws ManagerException, PortalException
IPageCacheManager
getCachedPageId
in interface IPageCacheManager
sessionConfig
- TODO
ManagerException
PortalException
public void addOrUpdate(SessionConfig sessionConfig, PageCacheConfig pageCacheConfig, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
addOrUpdate
in interface IPageCacheManager
ManagerException
PortalException
public void delete(SessionConfig sessionConfig, String pageCacheId, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
delete
in interface IPageCacheManager
ManagerException
PortalException
public String add(SessionConfig sessionConfig, PageCacheConfig pageCacheConfig, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
add
in interface IPageCacheManager
ManagerException
PortalException
public void update(SessionConfig sessionConfig, PageCacheConfig pageCacheConfig, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
update
in interface IPageCacheManager
ManagerException
PortalException
public PageCacheConfig get(SessionConfig sessionConfig, String pageCacheId, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
get
in interface IPageCacheManager
ManagerException
PortalException
public PageCacheConfig getByCachedPageProperties(SessionConfig sessionConfig, PageCacheConfig cachedPageProperties, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
If no config is found, a PortalObjectNotFound exception is thrown.
getByCachedPageProperties
in interface IPageCacheManager
ManagerException
PortalException
public String parseHTMLContent(SessionConfig sessionConfig, String htmlContent, String cachedPageId, int cacheType, ITransaction transaction) throws PortalException
IPageCacheManager
parseHTMLContent
in interface IPageCacheManager
ManagerException
PortalException
@Deprecated public void clearCacheByServiceInterfaceInstancesIds(SessionConfig sessionConfig, Collection<String> serviceInterfaceInstanceIds, Parameters parameters, int changeType, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
clearCacheByServiceInterfaceInstancesIds
in interface IPageCacheManager
ManagerException
PortalException
@Deprecated public void clearCacheByServiceInterfaceInstances(SessionConfig sessionConfig, Collection<ServiceInterfaceInstanceConfig> serviceInterfaceInstances, Parameters parameters, int changeType, ITransaction transaction) throws ManagerException, PortalException
IPageCacheManager
clearCacheByServiceInterfaceInstances
in interface IPageCacheManager
ManagerException
PortalException
@Deprecated public void clearCacheByPagesIds(SessionConfig sessionConfig, Collection<String> pagesIds, Parameters parameters, int changeType, ITransaction transaction) throws PortalException
IPageCacheManager
clearCacheByPagesIds
in interface IPageCacheManager
ManagerException
PortalException
@Deprecated public void clearCacheByPagesIds(SessionConfig sessionConfig, Collection<String> pagesIds, Parameters parameters, int changeType, boolean clearImmediately, ITransaction transaction) throws PortalException
IPageCacheManager
clearImmediately
is set to true
,
it will also clear the specified pages cache immediately, synchronously.
clearCacheByPagesIds
in interface IPageCacheManager
sessionConfig
- the user session information.pagesIds
- a collection of the pages identifiers.parameters
- the page parameters.changeType
- the cause of the cache clear. Must be one of the
CLEAR_CACHE_CHANGE_TYPE_* constants.clearImmediately
- if the cache clearing is also to be executed
immediately.transaction
- the transaction for persistence access.
PortalException
public void clearCacheByPagesIds(SessionConfig sessionConfig, Collection<String> pagesIds, Parameters parameters, Locale locale, int changeType, boolean clearImmediately, ITransaction transaction) throws PortalException
IPageCacheManager
clearImmediately
is set to true
,
it will also clear the specified pages cache immediately, synchronously.
clearCacheByPagesIds
in interface IPageCacheManager
sessionConfig
- the user session information.pagesIds
- a collection of the pages identifiers.parameters
- the page parameters.locale
- specifies the locale to which the cache clearing is to
be applied. May be null to indicate any locale.changeType
- the cause of the cache clear. Must be one of the
CLEAR_CACHE_CHANGE_TYPE_* constants.clearImmediately
- if the cache clearing is also to be executed
immediately.transaction
- the transaction for persistence access.
PortalException
public void clearCacheByChannelIds(SessionConfig sessionConfig, Collection<String> channelIds, Parameters parameters, int changeType, boolean clearImmediately, ITransaction transaction) throws PortalException
IPageCacheManager
clearImmediately
is set to true
,
it will also clear the specified pages cache immediately, synchronously.
clearCacheByChannelIds
in interface IPageCacheManager
sessionConfig
- the user session information.parameters
- the page parameters.changeType
- the cause of the cache clear. Must be one of the
CLEAR_CACHE_CHANGE_TYPE_* constants.clearImmediately
- if the cache clearing is also to be executed
immediately.transaction
- the transaction for persistence access.
PortalException
public int getPageCacheGenerationState(SessionConfig sessionConfig, ITransaction transaction) throws PortalException
getPageCacheGenerationState
in interface IPageCacheManager
sessionConfig
- transaction
-
PortalException
public void setPageCacheGenerationState(SessionConfig sessionConfig, int state, ITransaction transaction) throws PortalException
The session provided must have MANAGE_CACHE permission at the portal level in order to execute this method successfully.
setPageCacheGenerationState
in interface IPageCacheManager
sessionConfig
- state
- transaction
-
PortalException
protected PageCacheConfig getGenerationLock(String pageCacheId) throws PortalException
To get a lock successfully, the page cache status must be PageCacheConfig.STATUS_OUTDATED
.
If successful, the page cache status will be changed to PageCacheConfig.STATUS_GENERATING
.
pageCacheId
- the page cache identifier.
PortalException
protected void releaseGenerationLock(PageCacheConfig pageCacheConfig, IPageCacheManager.GenerationOutcome outcome) throws PortalException
According to the outcome argument, the following happens:
GenerationOutcome#SUCCESS
: If the current status is
generating
, it is changed to
updated
, else it is changed to
outdated
. The
number of errors
is reset
to zero.GenerationOutcome#CANCEL
: The status is changed to
outdated
.GenerationOutcome#ERROR
: The
number of errors
is incremented, and the status is changed to
outdated
or
outdated with error
,
depending on whether the number of errors reached
max error count
.
pageCacheConfig
- the page cache.outcome
- the generation outcome.newStatus
- the new status if the current status is generating.
PortalException
public void updateCachedFilesLastModifiedDate(SessionConfig sessionConfig, PageConfig pageConfig, Locale locale, Date lastModifiedDate, ITransaction transaction) throws PortalException
IPageCacheManager
updateCachedFilesLastModifiedDate
in interface IPageCacheManager
sessionConfig
- the user session information.pageConfig
- the portal page.locale
- locale for which the cached files needs to be modified.lastModifiedDate
- date to which the matched files must be modified to.transaction
- the transaction for persistence access.
PortalException
public void pageCacheMissed(String pageCacheId, boolean forImmediateUse) throws PortalException
IPageCacheManager
pageCacheMissed
in interface IPageCacheManager
pageCacheId
- the page cache identifier.forImmediateUse
- if true, indicates that the missed page cache
is required for immediate use. This will greater boost the priority to
generate the corresponding page cache.
PortalException
protected PageCacheConfig getNextPageForGeneration(boolean forImmediateUseOnly) throws PortalException
forImmediateUseOnly
- if true, only pages whose priority is higher
than PageCacheConfig.MAX_INITIAL_PRIORITY
are taken in account.
PortalException
#getGenerationLock(PageCacheConfig)
,
#releaseGenerationLock(PageCacheConfig, int)
public String getPageCacheRelativePath(String pageCacheId, ITransaction transaction) throws PortalException
IPageCacheManager
This method may access the database. Consider using
IPageCacheManager.getPageCacheRelativePath(PageConfig, String)
for better performance if the corresponding PageConfig
is already available.
getPageCacheRelativePath
in interface IPageCacheManager
pageCacheId
- the page cache identifier.transaction
- the transaction for persistence access.
PortalException
public String processHtmlReferencesToCachedPages(SessionConfig sessionConfig, String html, ITransaction transaction) throws PortalException
IPageCacheManager
PageCacheConfig
when a proper one does not already exist. The
dynamic references are replaced by static references.
processHtmlReferencesToCachedPages
in interface IPageCacheManager
sessionConfig
- user session information.html
- the html.transaction
- transaction for persistence access.
PortalException
public String convertMainUrl(SessionConfig sessionConfig, String mainUrl, ITransaction transaction) throws PortalException
PageCacheConfig
if necessary and appropriated.
convertMainUrl
in interface IPageCacheManager
sessionConfig
- the user session information.mainUrl
- the url to main.jsp. Must start with main.jsp.transaction
- the transaction for persistence access.
PortalException
public void clearAllHTMLCache(ITransaction transaction) throws PortalException
IPageCacheManager
clearAllHTMLCache
in interface IPageCacheManager
transaction
- the transaction for persistence access.
PortalException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |