oracle.portal.provider.v1.http
Class URLRenderer

oracle.portal.provider.v1.http.URLRenderer
Direct Known Subclasses:
BasicURLRenderer

public class URLRenderer

URLRenderer is responsible for portletizing url contents specified through provider.xml. It opens an HTTPConnection to the url specified and reads the contents from it. The read contents are then written to the Portlet Renderer's output stream.

It uses sophisticated filters to massage the contents of url. There can be two types of filters depending on the requirement. HtmlFilter, a light weight filter can be used for basic filtering and XmlFilter for advanced operations.


Field Summary
static java.lang.String CHAR_ENCODING
          Constant key for getting character encoding from the HTTP Response.
static java.lang.String DEFAULT_CHARACTER_ENCODING
          The default character encoding for renderer output
 
Constructor Summary
URLRenderer()
           
 
Method Summary
 java.lang.String getCharSet()
          Gets the Default IANA character encoding to be used for this renderer's pages.
protected static URLPersonalizationObject getCustomizationData(oracle.portal.provider.v1.PortletRenderRequest pr)
          Convenience method to retrieve user customization data.
 java.lang.Object getFilter()
          Returns the Filter Class specified for a given rendering mode.
 java.lang.String getPageUrl()
          Returns the URL specified in the corresponding set method.
protected  java.lang.String getPageUrl(oracle.portal.provider.v1.PortletRenderRequest pr, int debugLevel)
          Method first tries to read inline rendering url value from the request.
 java.net.URL getParsedPageUrl()
          Returns URL object constructed out of string url, passed through provider.xml.
protected  java.io.InputStream getURLStream(oracle.portal.provider.v1.PortletRenderRequest pr, java.net.URL contentURL)
           Method which connects to the given content url and returns the corresponding input stream.
 java.lang.String getUseInvalidationCaching()
          Returns flag which indicates renderer to use invalidation based caching or not.
protected  java.lang.String makeNVPair(java.lang.String name, java.lang.String value, java.lang.String encoding)
           
 boolean prepareResponse(oracle.portal.provider.v1.PortletRenderRequest pr)
          Overriding super class's prepareResponse method for implementing Invalidation Based Caching.
 void renderBody(oracle.portal.provider.v1.PortletRenderRequest pr)
           Method responsible for rendering Portlet's are responsible for ensuring the request's user has sufficient rights to receive this rendering.
 void renderContents(oracle.portal.provider.v1.PortletRenderRequest pr, java.lang.String urlContent, int debugLevel, int type)
          renderContents is a private helper method, which renders the portlet with the specified url content.
 void setCharSet(java.lang.String encoding)
          Sets the Default IANA character encoding to be used for this renderer's pages.
 void setFilter(java.lang.Object filter)
          Sets the filter class for this rendering mode.
 void setFilterType(java.lang.String type)
          Sets the type of filter.This variable is not used from now on.
 void setPageUrl(java.lang.String pageUrl)
          Specifies the URL for fetching content for a given rendering mode.
 void setUseInvalidationCaching(java.lang.String useInCache)
          Sets flag which indicates renderer to use invalidation based caching or not.
 

Field Detail

DEFAULT_CHARACTER_ENCODING

public static final java.lang.String DEFAULT_CHARACTER_ENCODING
The default character encoding for renderer output

CHAR_ENCODING

public static final java.lang.String CHAR_ENCODING
Constant key for getting character encoding from the HTTP Response. Usage - pr.getAttribute(URLRenderer.CHAR_ENCODING);
Constructor Detail

URLRenderer

public URLRenderer()
Method Detail

renderBody

public void renderBody(oracle.portal.provider.v1.PortletRenderRequest pr)
                throws oracle.portal.provider.v1.PortletException,
                       oracle.portal.provider.v1.AccessControlException

Method responsible for rendering Portlet's are responsible for ensuring the request's user has sufficient rights to receive this rendering.

Parameters:
pr - ProviderRequest for this rendering.
Throws:
PortletException,AccessControlException -  
See Also:
(@link oracle.portal.provider.v1.PortletException), (@link oracle.portal.provider.v1.AccessControlException)

getURLStream

protected java.io.InputStream getURLStream(oracle.portal.provider.v1.PortletRenderRequest pr,
                                           java.net.URL contentURL)
                                    throws oracle.portal.provider.v1.PortletException

Method which connects to the given content url and returns the corresponding input stream. Care has been taken for two types of authentication.

In case of form based authentication, cookies stored in this user context, through provider will be submitted to the connection and then input stream is fetched.

In case of basic authentication, authorization information is already specified in the provider's initSession. As we are operating under the same context of HTTPClient from Renderer also, this authentication information still holds good.

Parameters:

- pr PortletRenderRequest Object needed for getting Session object as well as cookies.

URL - content URL from which input stream is to be read.
Returns:
InputStream Inputstream to the specified URL

setPageUrl

public void setPageUrl(java.lang.String pageUrl)
                throws oracle.portal.provider.v1.PortletException
Specifies the URL for fetching content for a given rendering mode.
Parameters:
pageUrl - value of URL for getting content

getPageUrl

public java.lang.String getPageUrl()
Returns the URL specified in the corresponding set method.

setFilterType

public void setFilterType(java.lang.String type)
Sets the type of filter.This variable is not used from now on. Still kept just to ensure provider.xml backward compatibility.

setFilter

public void setFilter(java.lang.Object filter)
               throws oracle.portal.provider.v1.PortletException
Sets the filter class for this rendering mode.
Parameters:
filter - PortletFilter object.

getFilter

public java.lang.Object getFilter()
Returns the Filter Class specified for a given rendering mode.
Returns:
Object Specified PortletFilter object.

makeNVPair

protected java.lang.String makeNVPair(java.lang.String name,
                                      java.lang.String value,
                                      java.lang.String encoding)
                               throws oracle.portal.provider.v1.PortletException

setCharSet

public void setCharSet(java.lang.String encoding)
Sets the Default IANA character encoding to be used for this renderer's pages.
Parameters:
charSet - IANA character encoding to be used for this renderer's pages

getCharSet

public java.lang.String getCharSet()
Gets the Default IANA character encoding to be used for this renderer's pages. If a character encoding hasn't been set explicitly on this URLRenderer, then by default ISO-8859-1 will be used.
Returns:
IANA character encoding to be used for this renderer's pages

prepareResponse

public boolean prepareResponse(oracle.portal.provider.v1.PortletRenderRequest pr)
                        throws oracle.portal.provider.v1.PortletException

Overriding super class's prepareResponse method for implementing Invalidation Based Caching.

Parameters:
pr - PortletRenderRequest to determine if the portlet has been customized.

getCustomizationData

protected static URLPersonalizationObject getCustomizationData(oracle.portal.provider.v1.PortletRenderRequest pr)
                                                        throws oracle.portal.provider.v1.AccessControlException
Convenience method to retrieve user customization data. If not found, creates a new instance with default values and returns it.

getUseInvalidationCaching

public java.lang.String getUseInvalidationCaching()
Returns flag which indicates renderer to use invalidation based caching or not.
Returns:
boolean Enable caching or not (true/false)

setUseInvalidationCaching

public void setUseInvalidationCaching(java.lang.String useInCache)
Sets flag which indicates renderer to use invalidation based caching or not.
Parameters:
useInCache - Enable caching or not (true/false)

renderContents

public void renderContents(oracle.portal.provider.v1.PortletRenderRequest pr,
                           java.lang.String urlContent,
                           int debugLevel,
                           int type)
                    throws oracle.portal.provider.v1.PortletException
renderContents is a private helper method, which renders the portlet with the specified url content.

getParsedPageUrl

public java.net.URL getParsedPageUrl()
Returns URL object constructed out of string url, passed through provider.xml. This eliminates the need to frequently parse the string to get URL object.
Returns:
URL object constructed out of string specified in provider.xml

getPageUrl

protected java.lang.String getPageUrl(oracle.portal.provider.v1.PortletRenderRequest pr,
                                      int debugLevel)
                               throws oracle.portal.provider.v1.PortletException
Method first tries to read inline rendering url value from the request. Returns null if none present. Sub classes can override this method to provide their own Urls.
Parameters:
pr - PortletRendererRequest
debugLevel - Debug level