com.sun.portal.providers
Class ProfileProviderAdapter

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

public abstract class ProfileProviderAdapter
extends ProviderAdapter

This class adds convenience wrappers around some commonly used methods in the ProviderContext interface.

See Also:
Provider, ProviderAdapter, ProviderContext

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
ProfileProviderAdapter()
           
 
Method Summary
 boolean existsBooleanProperty(String name)
          Tests for the existence of a boolean property in the channel.
 boolean existsIntegerProperty(String name)
          Tests for the existence of an integer property in the channel.
 boolean existsListProperty(String name)
          Tests for the existence of a list property in the channel.
 boolean existsListProperty(String name, boolean localized)
          Tests for the existence of a listproperty in the channel.
 boolean existsStringProperty(String name)
          Tests for the existence of a string property in the channel.
 boolean existsStringProperty(String name, boolean localized)
          Tests for the existence of a string property in the channel.
 boolean getBooleanProperty(String key)
          Gets a boolean property for the channel.
 boolean getBooleanProperty(String key, boolean def)
          Gets a boolean property for the channel.
 String getClientProperty(String name)
          Gets the client property.
 int getIntegerProperty(String key)
          Gets an integer property for the channel.
 int getIntegerProperty(String key, int def)
          Gets an integer property for the channel.
 List getListProperty(String key)
          Gets a list property for the channel.
 List getListProperty(String key, List def)
          Gets a list property for the provider.
 Map getMapProperty(String key)
          Gets a map property for the channel.
 Map getMapProperty(String key, boolean localized)
          Gets the localized version of a map property for the channel.
 Map getMapProperty(String key, Map def)
          Gets a map property for the channel.
 Map getMapProperty(String key, Map def, boolean localized)
          Gets the localized version of a map property for the channel.
 String getStringAttribute(String name)
          Gets a string attribute.
 String getStringProperty(String key)
          Gets a string property for the channel.
 String getStringProperty(String key, boolean localized)
          Gets a localized string property for the channel.
 String getStringProperty(String key, String def)
          Gets a string property for the channel.
 String getStringProperty(String key, String def, boolean localized)
          Gets a localized string property for the channel.
 StringBuffer getTemplate(String file)
          Gets template for the provider.
 StringBuffer getTemplate(String file, Hashtable table)
          Gets template for the provider, and tag swap the results before returning.
 boolean isAllowed(String priv)
          Deprecated. use getBooleanProperty()
 boolean setBooleanProperty(String key, boolean val)
          Sets a boolean property for the channel.
 void setClientProperty(String name, String val)
          Sets a client property.
 int setIntegerProperty(String key, int val)
          Sets a integer property for the channel.
 List setListProperty(String key, List val)
          Sets a list property for the channel.
 Map setMapProperty(String key, Map val)
          Sets a map property for the channel.
 void setStringAttribute(String name, String val)
          Sets a string attribute.
 String setStringProperty(String key, String val)
          Sets a string property for the channel.
 
Methods inherited from class com.sun.portal.providers.ProviderAdapter
getContent, getContent, getDescription, getEdit, getEdit, getEditType, getHelp, getHelp, getName, getProviderContext, getRefreshTime, getResourceBundle, getResourceBundle, getTitle, getWidth, init, isEditable, isPresentable, processEdit, processEdit
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProfileProviderAdapter

public ProfileProviderAdapter()
Method Detail

getStringProperty

public String getStringProperty(String key)
                         throws ProviderException
Gets a string property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be returned.
Returns:
The string value corresponding to the key.

getStringProperty

public String getStringProperty(String key,
                                String def)
                         throws ProviderException
Gets a string property for the channel.

This method returns a default value if the property does not exist.

Parameters:
key - The key for the property to be returned.
def - The default value to be returned if the property does not exist.
Returns:
The string value corresponding to the key.

getStringProperty

public String getStringProperty(String key,
                                boolean localized)
                         throws ProviderException
Gets a localized string property for the channel.

If localized is true, then this method will attempt to find a localized version of the string named by the key. The locale for the user who this object is executing is read from the ProviderContext object associated with this provider object. Locale-based strings are searched for from more specific to less specific locales. For exmaple, if the user locale was "en_US_SW", the search order would be:



This lookup order is the same as defined by Java resource bundles.

If a locale version of this string is not found, and a non-locale version of this string is not found, then an java.lang.Error is thrown. Client of this call can catch the error and provide code to handle the error condition accordingly.

Parameters:
key - The key for the property to be returned.
localized - If true, first search for a localized string matching the given key.
Returns:
The string value corresponding to the key.

getStringProperty

public String getStringProperty(String key,
                                String def,
                                boolean localized)
                         throws ProviderException
Gets a localized string property for the channel.

If localized is true, then this method will attempt to find a localized version of the string named by the key. The locale for the user who this object is executing is read from the ProviderContext object associated with this provider object. Locale-based strings are searched for from more specific to less specific locales. For exmaple, if the user locale was "en_US_SW", the search order would be:



This lookup order is the same as defined by Java resource bundles. If a locale version of this string is not found, and a non-locale version of this string is not found, then this method returns a default value.

Parameters:
key - The key for the property to be returned.
def - Default value.
localized - If true, first search for a localized string matching the given key.
Returns:
The string value corresponding to the key.

getListProperty

public List getListProperty(String key)
                     throws ProviderException
Gets a list property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be returned.
Returns:
The list value corresponding to the key.

getListProperty

public List getListProperty(String key,
                            List def)
                     throws ProviderException
Gets a list property for the provider.

This method will return the defaule list passed in if the property is undefined for the channel.

Parameters:
key - The key for the property to be returned.
def - The default list to be returned if the property does not exist.
Returns:
The list value corresponding to the key.

getMapProperty

public Map getMapProperty(String key)
                   throws ProviderException
Gets a map property for the channel.

This method assumes that the property is defined.

The Java Map object returned from this method fronts the persistent store for the property. Changes to this object are immediately reflected in the persistent store.

Because of this, it is not necessary to call setMapProperty() to persist changes made to a property returned from this method. However, if you are setting a new map value, you must call setMapProperty(). For example, it is not necessary to call setMapProperty() in the following example:

Map m = p.getMapProperty("foo");
m.put("a", "1");

This is because the Map m is returned from getMapProperty() and is therefore persistent. However, in the example below, you must call setMapProperty():

Map m = new HashMap();
m.put("a", "1");

Map m is not persistent because it was not returned from getMapProperty() method. The following line is required to persist the changes:

p.setMapProperty("foo", m);

Parameters:
key - The key for the property to be returned.
Returns:
The map value corresponding to the key.

getMapProperty

public Map getMapProperty(String key,
                          boolean localized)
                   throws ProviderException
Gets the localized version of a map property for the channel.

If localized is true, then this method will attempt to find a localized version of the map named by the key. The locale for the user who this object is executing is read from the ProviderContext object associated with this providero object. Locale-based maps are searched for from more specific to less specific locales. For exmaple, if the user locale was "en_US_SW", the search order would be:



This lookup order is the same as defined by Java resource bundles.

If a locale version of this map is not found, and a non-locale version of this map is not found, then an java.lang.Error is thrown. Client of this call can catch the error and provide code to handle the error condition accordingly.

Parameters:
key - The key for the property to be returned.
localized - If true, first search for a localized map matching the given key.
Returns:
The map value corresponding to the key.

getMapProperty

public Map getMapProperty(String key,
                          Map def)
                   throws ProviderException
Gets a map property for the channel.

This method returns a default value if the property does not exist.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be returned.
def - Default value.
Returns:
The map value corresponding to the key.

getMapProperty

public Map getMapProperty(String key,
                          Map def,
                          boolean localized)
                   throws ProviderException
Gets the localized version of a map property for the channel.

If localized is true, then this method will attempt to find a localized version of the map named by the key. The locale for the user who this object is executing is read from the ProviderContext object associated with this providero object. Locale-based maps are searched for from more specific to less specific locales. For exmaple, if the user locale was "en_US_SW", the search order would be:



This lookup order is the same as defined by Java resource bundles.

If a locale version of this map is not found, and a non-locale version of this string is not found, then this method returns a default value.

Parameters:
key - The key for the property to be returned.
def - Default value.
localized - If true, first search for a localized map matching the given key.
Returns:
The map value corresponding to the key.

getBooleanProperty

public boolean getBooleanProperty(String key)
                           throws ProviderException
Gets a boolean property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be returned.
Returns:
The boolean value corresponding to the key.

getBooleanProperty

public boolean getBooleanProperty(String key,
                                  boolean def)
                           throws ProviderException
Gets a boolean property for the channel.

This method returns a default value if the property does not exist.

Parameters:
key - The key for the property to be returned.
def - Default value.
Returns:
The boolean value corresponding to the key.

getIntegerProperty

public int getIntegerProperty(String key)
                       throws ProviderException
Gets an integer property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be returned.
Returns:
The integer value corresponding to the key.

getIntegerProperty

public int getIntegerProperty(String key,
                              int def)
                       throws ProviderException
Gets an integer property for the channel.

This method returns a default value if the property does not exist.

Parameters:
key - The key for the property to be returned.
def - Default value.
Returns:
The integer value corresponding to the key.

getStringAttribute

public String getStringAttribute(String name)
Gets a string attribute.

"Attributes" are settings that are not channel-specific. An example of an attribute might be the user's first and last name. Channel-specific settings are called "properties".

Properties can be retrieved by calling the get*Property() methods. Whether a particular value is considered a property or an attribute depends on the underlying implementation of ProviderContext.

Parameters:
name - Attribute name.
Returns:
Attribute value as a string. If attribute is not not found, null is returned.

getClientProperty

public String getClientProperty(String name)
Gets the client property.
Parameters:
name - Property name.
Returns:
Property value. If the property is not not found, then null is returned.

isAllowed

public boolean isAllowed(String priv)
                  throws ProviderException
Deprecated. use getBooleanProperty()

Checks for access to the named privilege.

This method is provided for backwards compatibility. There is no longer a concept of a privilege in the Provider API. Instead, use boolean properties.

This method simply calls getBooleanProperty() to determine its return value.

Parameters:
priv - The privilege to check.
Returns:
A boolean value. true if the user is granted access by the named privilege, otherwise false.

setStringProperty

public String setStringProperty(String key,
                                String val)
                         throws ProviderException
Sets a string property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be set.
val - The value for the propery to be set.
Returns:
The previous value.

setListProperty

public List setListProperty(String key,
                            List val)
                     throws ProviderException
Sets a list property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be set.
val - The value for the propery to be set.
Returns:
The previous value.

setMapProperty

public Map setMapProperty(String key,
                          Map val)
                   throws ProviderException
Sets a map property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be set.
val - The value for the propery to be set.
Returns:
The previous value.

setBooleanProperty

public boolean setBooleanProperty(String key,
                                  boolean val)
                           throws ProviderException
Sets a boolean property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be set.
val - The value for the propery to be set.
Returns:
The previous value.

setIntegerProperty

public int setIntegerProperty(String key,
                              int val)
                       throws ProviderException
Sets a integer property for the channel.

This method assumes that the property is defined.

Parameters:
key - The key for the property to be set.
val - The value for the propery to be set.
Returns:
The previous value.

setStringAttribute

public void setStringAttribute(String name,
                               String val)
Sets a string attribute.

"Attributes" are settings that are not channel-specific. An example of an attribute might be the user's first and last name. Channel-specific settings are called "properties".

Properties can be set by calling the set*Property() methods. Whether a particular value is considered a property or an attribute depends on the underlying implementation of ProviderContext.

Parameters:
name - Attribute name.
name - Attribute value.

setClientProperty

public void setClientProperty(String name,
                              String val)
Sets a client property.
Parameters:
name - The property name.
value - The property value.

existsStringProperty

public boolean existsStringProperty(String name)
                             throws ProviderException
Tests for the existence of a string property in the channel.
Parameters:
name - A String, the property name.
Returns:
A boolean, true if the property exists, otherwise false.

existsStringProperty

public boolean existsStringProperty(String name,
                                    boolean localized)
                             throws ProviderException
Tests for the existence of a string property in the channel.

This method will also check for the existence of the localized version of the property.

Parameters:
name - A String, the property name.
localized - A boolean, whether to check the existence of localized properties.
Returns:
A boolean, true if the property exists, otherwise false.

existsBooleanProperty

public boolean existsBooleanProperty(String name)
                              throws ProviderException
Tests for the existence of a boolean property in the channel.
Parameters:
name - A String, the property name.
Returns:
A boolean, true if the property exists, otherwise false.

existsIntegerProperty

public boolean existsIntegerProperty(String name)
                              throws ProviderException
Tests for the existence of an integer property in the channel.
Parameters:
name - A String, the property name.
Returns:
A boolean, true if the property exists, otherwise false.

existsListProperty

public boolean existsListProperty(String name)
                           throws ProviderException
Tests for the existence of a list property in the channel.
Parameters:
name - A String, the property name.
Returns:
A boolean, true if the property exists, otherwise false.

existsListProperty

public boolean existsListProperty(String name,
                                  boolean localized)
                           throws ProviderException
Tests for the existence of a listproperty in the channel.

This method will also check for the existence of the localized version of the property.

Parameters:
name - A String, the property name.
localized - A boolean, whether to check the existence of localized properties.
Returns:
A boolean, true if the property exists, otherwise false.

getTemplate

public StringBuffer getTemplate(String file)
                         throws ProviderException

Gets template for the provider.

The directory search order of the template file is as follows:

Where

  1. <type> is the value of the desktop template type property
  2. <locale> is the user's locale
  3. <component> is the component name (or channel name)
  4. <clientPath> is an optional file-path containing client-specific templates

If there is no <clientPath> specified, then the directory search order is as follows:



Parameters:
file - The template file name
Returns:
template A StringBuffer represents the template

getTemplate

public StringBuffer getTemplate(String file,
                                Hashtable table)
                         throws ProviderException

Gets template for the provider, and tag swap the results before returning.

See Also:
getTemplate(String)