com.sun.portal.providers
Class ProviderAdapter

java.lang.Object
  |
  +--com.sun.portal.providers.ProviderAdapter
All Implemented Interfaces:
Provider, ProviderEditTypes, ProviderWidths
Direct Known Subclasses:
ProfileProviderAdapter

public abstract class ProviderAdapter
extends Object
implements Provider, ProviderWidths, ProviderEditTypes

This class provides default implementations of methods in the Provider interface implemented using a ProviderContext object as the persistent store.

Developers who wish to implement a provider should extend this class or ProfileProviderAdapter.

The advantage of extending this class versus implementing the Provider interface directly is that you will maintain forward compatability as additions are made to the Provider API. Existing code will by default call the methods in this class. Eventually, code should be written to implement all of the methods in the Provider interface.

For method details, see the descriptions in the Provider interface.

See Also:
ProviderContext, Provider

Fields inherited from interface com.sun.portal.providers.ProviderWidths
WIDTH_FULL_BOTTOM, WIDTH_FULL_TOP, WIDTH_THICK, WIDTH_THIN
 
Fields inherited from interface com.sun.portal.providers.ProviderEditTypes
EDIT_COMPLETE, EDIT_SUBSET
 
Constructor Summary
ProviderAdapter()
           
 
Method Summary
 StringBuffer getContent(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Calls the getContent(Map) method in this object to provide backwards compatibility.
 StringBuffer getContent(Map m)
          Deprecated. Using this method has negative performance implications. Use getContent(HttpServletRequest, HttpServletResponse) instead.
 String getDescription()
          Gets the description for the channel.
 StringBuffer getEdit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Calls the getEdit(Map) method in this object to provide backwards compatibility.
 StringBuffer getEdit(Map m)
          Deprecated. Using this method has negative performance implications. Use getEdit(HttpServletRequest, HttpServletResponse) instead.
 int getEditType()
          Gets the edit type for the channel.
 URL getHelp(javax.servlet.http.HttpServletRequest req)
          Gets the default help URL for the channel that this object is providing an environment for.
 URL getHelp(javax.servlet.http.HttpServletRequest req, String key)
          Gets the named help URL for the channel that this object is providing an environment for.
 String getName()
          Gets the name of this provider.
 ProviderContext getProviderContext()
          Gets the ProviderContext for the provider.
 long getRefreshTime()
          Gets the refresh time for the channel.
 ResourceBundle getResourceBundle()
          Gets the well-knowned ResourceBundle for the provider based on User's locale.
 ResourceBundle getResourceBundle(String base)
          Gets a specified ResourceBundle file for the provider based on User's locale.
 String getTitle()
          Gets the title for the channel.
 int getWidth()
          Gets the width for the channel that this is providing an environment for.
 void init(String n, javax.servlet.http.HttpServletRequest req)
          Initializes the provider.
 boolean isEditable()
          Gets if the channel is editable.
 boolean isPresentable()
          Dictates whether the provider is presentable.
 URL processEdit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Calls the processEdit(Map) method in this object to provide backwards compatibility.
 URL processEdit(Map m)
          Deprecated. Using this method has negative performance implications. Use processEdit(HttpServletRequest, HttpServletResponse) instead.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProviderAdapter

public ProviderAdapter()
Method Detail

init

public void init(String n,
                 javax.servlet.http.HttpServletRequest req)
          throws ProviderException
Description copied from interface: Provider
Initializes the provider.

This method must be called by clients of the provider object when the provider object is created (after it is constructed, or before the object is used). This method should not be called more than once per object.

Specified by:
init in interface Provider
Following copied from interface: com.sun.portal.providers.Provider
Parameters:
name - Unique name identifying this provider. This value should always be returned from getName().
req - The HTTP request object corresponding to the HTTP request that caused this provider object to be created. This request may be used to extract session or user information that could be used to gain access to external resources.
Throws:
ProviderException - If there was an error initializing the provider. How this exception is handled is up to the client of the provider object.
See Also:
Provider.getName()

getContent

public StringBuffer getContent(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws ProviderException
Calls the getContent(Map) method in this object to provide backwards compatibility.

The implementation of this method provides backwards compatibility for providers that only implement the deprecated getContent(Map) method. It logs a warning informing the administrator that calling this method has performance implications, and that it should be re-implemented using the non-deprecated version of this method.

Each time this method is called, the HTTP parameter data in the request object must be converted to the Map form that is accepted by the getContent(Map) version of this method.

Specified by:
getContent in interface Provider
Following copied from interface: com.sun.portal.providers.Provider
Parameters:
request - An HttpServletRequest that contains information related to this request for content.
response - An HttpServletResponse that allows the provider to influence the overall response for the desktop page (besides generating the content).
Returns:
StringBuffer holding the content.
Throws:
ProviderException - If there was an error generating the content. How this exception is handled is up to the client of the provider object.
See Also:
ProviderException

getContent

public StringBuffer getContent(Map m)
                        throws ProviderException
Deprecated. Using this method has negative performance implications. Use getContent(HttpServletRequest, HttpServletResponse) instead.

This method has no effect.
Specified by:
getContent in interface Provider
Returns:
null, always.

getEdit

public StringBuffer getEdit(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response)
                     throws ProviderException
Calls the getEdit(Map) method in this object to provide backwards compatibility. The implementation of this method provides backwards compatibility for providers that only implement the deprecated getEdit(Map) method. It logs a warning informing the administrator that calling this method has performance implications, and that it should be re-implemented using the non-deprecated version of this method. Each time this method is called, the HTTP parameter data in the request object must be converted to the Map form that is accepted by the getEdit(Map) version of this method.
Specified by:
getEdit in interface Provider
Following copied from interface: com.sun.portal.providers.Provider
Parameters:
request - An HttpServletRequest that contains information related to this request for content.
response - An HttpServletResponse that allows the provider to influence the overall response for the desktop page (besides generating the content).
Returns:
StringBuffer holding the html edit form.
Throws:
ProviderException - If there was an error generating the edit form. How this exception is handled is up to the client of the provider object.
See Also:
Provider.getContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), Provider.isEditable(), Provider.processEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), Provider.getEditType(), DesktopServlet, ProviderException

getEdit

public StringBuffer getEdit(Map m)
                     throws ProviderException
Deprecated. Using this method has negative performance implications. Use getEdit(HttpServletRequest, HttpServletResponse) instead.

This method has no effect.
Specified by:
getEdit in interface Provider
Returns:
null, always.

getEditType

public int getEditType()
                throws UnknownEditTypeException
Gets the edit type for the channel. The edit type for a channel informs clients of the channel (such as a container channel) what sort of content to be returned for its edit view; either a fragment or a complete document.
Specified by:
getEditType in interface Provider
Returns:
The edit type; either EDIT_COMPLETE or EDIT_SUBSET.
Throws:
UnknownEditTypeException - if an error occurs when getting the edit type of the channel.
See Also:
ProviderEditTypes

processEdit

public URL processEdit(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response)
                throws ProviderException
Calls the processEdit(Map) method in this object to provide backwards compatibility.

The implementation of this method provides backwards compatibility for providers that only implement the deprecated processEdit(Map) method. It logs a warning informing the administrator that calling this method has performance implications, and that it should be re-implemented using the non-deprecated version of this method.

Each time this method is called, the HTTP parameter data in the request object must be converted to the Map form that is accepted by the processEdit(Map) version of this method.

Specified by:
processEdit in interface Provider
Following copied from interface: com.sun.portal.providers.Provider
Parameters:
request - An HttpServletRequest that contains information related to this request for content.
response - An HttpServletResponse that allows the provider to influence the overall response for the desktop page (besides generating the content).
Returns:
The URL that the iPS desktop will re-direct to. A value of null should indicate to the client that it should return to its default view.
Throws:
ProviderException - If there was an error processing the edit form. How this exception is handled is up to the client of the provider object.
See Also:
Provider.getEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), Provider.isEditable(), InvalidEditFormDataException, DesktopServlet

processEdit

public URL processEdit(Map m)
                throws ProviderException
Deprecated. Using this method has negative performance implications. Use processEdit(HttpServletRequest, HttpServletResponse) instead.

This method has no effect.
Specified by:
processEdit in interface Provider
Returns:
null, always

isEditable

public boolean isEditable()
                   throws ProviderException
Gets if the channel is editable. If a provider is editable, it is capable of providing an edit view to clients.
Specified by:
isEditable in interface Provider
Returns:
true if the channel is editable, otherwise false.
Throws:
ProviderException - if error occurs when getting if the channel is editable.

isPresentable

public boolean isPresentable()

Dictates whether the provider is presentable.

Searches for the key genericHTML with the value true on the client data for the session's client type and returns true.

If there is no such key, method will return true if the session's client type is named genericHTML.

In both cases, the content-type for the session's client type must equal text/html in order for the method to return true.

Specified by:
isPresentable in interface Provider
Returns:
A boolean value dictating presentability
See Also:
Provider.isPresentable()

getTitle

public String getTitle()
                throws ProviderException
Gets the title for the channel.
Specified by:
getTitle in interface Provider
Returns:
A string title.
Throws:
ProviderException - if error occurs when getting the title for the channel.

getName

public String getName()
Description copied from interface: Provider
Gets the name of this provider.

The name returned from this method must match the name of the provider that it was initialized with.

Specified by:
getName in interface Provider
Returns:
The name of the provider, as it was passed in to the init() method.

getDescription

public String getDescription()
                      throws ProviderException
Gets the description for the channel.
Specified by:
getDescription in interface Provider
Returns:
A string description.
Throws:
ProviderException - if error occurs when getting the description of the channel.

getWidth

public int getWidth()
             throws ProviderException
Gets the width for the channel that this is providing an environment for. The channel width is used as a suggestion to the container of the channel as to how much screen real estate it requires.
Specified by:
getWidth in interface Provider
Returns:
The width; either WIDTH_THIN, WIDTH_THICK, WIDTH_FULL_TOP, or WIDTH_FULL_BOTTOM.
Throws:
ProviderException - If there was an error getting the width of the channel.
See Also:
ProviderWidths

getHelp

public URL getHelp(javax.servlet.http.HttpServletRequest req,
                   String key)
            throws ProviderException
Gets the named help URL for the channel that this object is providing an environment for. The request object parameter is included to facilitate implementations. It can be used to get the server name, port, and protocol. These can be used to transform a relative URL to absolute. It is not required that the request object be used as such. If the named help page is not supported, then the default help URL is returned (see getHelp(HttpServletRequest)).
Parameters:
key - Key name that maps to a help URL.
req - Request object containing information for building the URL.
Returns:
A URL object.
Throws:
ProviderException - If there was an error constructing the URL.

getHelp

public URL getHelp(javax.servlet.http.HttpServletRequest req)
            throws ProviderException
Gets the default help URL for the channel that this object is providing an environment for. This method must return an absolute URL. The request object parameter is included to facilitate implementations. It can be used to get the server name, port, and protocol. These can be used to transform a relative URL to absolute. It is not required that the request object be used as such.
Specified by:
getHelp in interface Provider
Parameters:
req - Request object containing information for building the URL.
Returns:
URL object that points to the channel's help page.
Throws:
ProviderException - If there was an error constructing the URL.
See Also:
getHelp(HttpServletRequest)

getRefreshTime

public long getRefreshTime()
                    throws ProviderException
Gets the refresh time for the channel. The refresh time for a channel is used to allow containers to implement caching of content for their contained channels. This value is used to indicate the validity of the cached content.
Specified by:
getRefreshTime in interface Provider
Returns:
>0, refresh time in number of seconds that a container should wait before expiring a content cache. 0, container should never cache channel's content. -1, container may cache channel's content indefinitely.
Throws:
ProviderException - If there was an error getting the refresh time for the channel.

getProviderContext

public ProviderContext getProviderContext()
Gets the ProviderContext for the provider.
Returns:
ProviderContext.
See Also:
ProviderContext

getResourceBundle

public ResourceBundle getResourceBundle(String base)
                                 throws ProviderException
Gets a specified ResourceBundle file for the provider based on User's locale.

A provider can specify on-screen strings to be localized in a resource bundle file, as described in the Java ResourceBundle class.

Parameters:
base - a specified ResourceBundle name.
Returns:
ResourceBundle.
See Also:
java.util.ResourceBundle.

getResourceBundle

public ResourceBundle getResourceBundle()
                                 throws ProviderException
Gets the well-knowned ResourceBundle for the provider based on User's locale.

A provider can specify on-screen strings to be localized in a resource bundle file, as described in the Java ResourceBundle class.

The well-knowned name is the provider name.

Returns:
ResourceBundle.