com.sapportals.portal.pb.contentservice
Interface IContentFetchingService
- All Superinterfaces:
- com.sapportals.portal.prt.service.IService
- public interface IContentFetchingService
- extends com.sapportals.portal.prt.service.IService
The main interface of the Application cache. Used to create cache entries and write response to the browser.
The application cache service is used to request content from a backend system and cache it in the Portal. It provides
"smart caching" mechanism which on demand parses the response HTML from the backend system and search it for elements (IMG,
IFRAME or FRAME) that should also be cached by the Portal. These elements are marked by the backend syste, with the special
attribute "portal_bridge" which defines by the backend which elements should be cached by the Portal.
The response fethced by the service is written directly to the browser and not returned to the calling Portal component.
A sample usage might be:
IContentFetchingService contentService = (IContentFetchingService)PortalRuntime.getRuntimeResources().getService(IContentFetchingService.KEY );
IPackageInformation packInfo = contentService.createIPackgeInformation(request);
packInfo.collectCookies( request );
packInfo.setURL("GET", URL); // The URL to request
packInfo.setSimpleAuthenticationMode( AuthenticationMode.URL_PARAMS , "", "");
packInfo.setCachingLevel(cachingLevel); // the required caching level
packInfo.setEnableClientSideCaching( true);
packInfo.setCacheExpirationTimeout( 300000 ); // Validity period of the cached content
packInfo.setConnectionTimeout( 300000 );
String key = contentService.createCacheEntry ( packInfo );
if( request.getNode().getNodeMode() == NodeMode.REFRESH_MODE )
{
contentService.removeCacheEntry( key );
}
contentService.fetchCacheEntry( request, key);
The IHTTPRequest defines a set of methods for wrapping an object which opens HTTP
connections to some site and returns the response.
|
Field Summary |
static java.lang.String |
KEY
|
|
Method Summary |
java.lang.String |
createCacheEntry(IPackageInformation packageInformation)
Use this method to create a cache entry in the service based on the IPackageInformation. |
IHTTPRequest |
createIHTTPRequest(IPackageInformation packageInformation)
A factory for creating IHTTPRequest objects, that can be used for requesting data from URLs. |
IPackageInformation |
createIPackgeInformation(com.sapportals.portal.prt.component.IPortalComponentRequest request)
Provides a factory for an IPackageInformation object which is initialized according with some settings from the request.
|
void |
fetchCacheEntry(com.sapportals.portal.prt.component.IPortalComponentRequest request,
java.lang.String cacheKey)
Requests the content from the backend system or the cache. |
ICacheResponse |
getIPackageInformation(java.lang.String cacheKey)
Get the com.sapportals.portal.pb.contentservice.cachehandler.CacheResponse object containing the com.sapportals.portal.pb.contentservice.PackageInformation
corresponding to the cache key provided. |
void |
removeCacheEntry(java.lang.String cacheKey)
Use to force invalidation of specific cache entry and its nested content. |
| Methods inherited from interface com.sapportals.portal.prt.service.IService |
afterInit, configure, destroy, getContext, getKey, init, release |
KEY
public static final java.lang.String KEY
fetchCacheEntry
public void fetchCacheEntry(com.sapportals.portal.prt.component.IPortalComponentRequest request,
java.lang.String cacheKey)
- Requests the content from the backend system or the cache. This method can be called only after a cache key was already
created for this request.
This method over-takes the control over the response, and writes the content to the browser.
- Parameters:
request - the current requestcacheKey - the key of the cached content to display
removeCacheEntry
public void removeCacheEntry(java.lang.String cacheKey)
- Use to force invalidation of specific cache entry and its nested content. Use only on the root element.
- Parameters:
cacheKey - of the root element to be removed
createIPackgeInformation
public IPackageInformation createIPackgeInformation(com.sapportals.portal.prt.component.IPortalComponentRequest request)
- Provides a factory for an IPackageInformation object which is initialized according with some settings from the request.
It extracts the locale and the user agent from the request.
- Returns:
- a new IPackageInformation object to set in all of the request parameters
createCacheEntry
public java.lang.String createCacheEntry(IPackageInformation packageInformation)
- Use this method to create a cache entry in the service based on the IPackageInformation. This method should be used even
if the content should not be cached. The service uses this method to map a unique key to the IPackageInformation object with the
connection information. The returned key could be used for fetching the actual content from the back end.
- Parameters:
packageInformation - a IPackageInformation object containing all of the request parameters need to connect and cache the content- Returns:
- the cache key for this request from the backend system
createIHTTPRequest
public IHTTPRequest createIHTTPRequest(IPackageInformation packageInformation)
- A factory for creating IHTTPRequest objects, that can be used for requesting data from URLs. Uses the information
stored in the IPackageInformation object to connect to the server. The returned object wraps the
com.sapportals.portal.ivs.http.HttpClient
object which uses the URLConnection object for requesting content from URLs
- Parameters:
packageInformation - which stores the connection information- Returns:
- IHTTPRequest object that represents the connection
getIPackageInformation
public ICacheResponse getIPackageInformation(java.lang.String cacheKey)
- Get the
com.sapportals.portal.pb.contentservice.cachehandler.CacheResponse object containing the com.sapportals.portal.pb.contentservice.PackageInformation
corresponding to the cache key provided. If the returned object is null, there is no object with this key in the cache (or the object is not valid anymore).
This method should be called only from core components.
- Parameters:
cacheKey - of the required PackageInformation object- Returns:
com.sapportals.portal.pb.contentservice.cachehandler.CacheResponse object as received from the cache