wt.prefs
Class PreferenceHelperService

java.lang.Object
  extended bywt.prefs.PreferenceHelperService
All Implemented Interfaces:
RemoteAccess

public final class PreferenceHelperService
extends Object
implements RemoteAccess

The PreferenceHelperService is the server-side Helper for the Preferences Framework and is responsible for the maintaining of the Delegate Heirarchy and Delegate list in Windchill.

The public methods contained in this class should not be called directly, but instead should be called from the wt.prefs.PreferenceHelper class.

This class will on the server-side of any RMI calls where necessary, and will work properly only on the server environment due to server-side dependencies.

Supported API: false

See Also:
PreferenceHelper, WTPreferences, PreferenceDelegate, UserDelegate

Nested Class Summary
private static class PreferenceHelperService.PrefCacheKey
           
 
Field Summary
private static Cache cache
           
private static int cacheSize
           
private static List cvDelegateHeirarchy
          List of all DelegateStructures for initialized delegates
private static String cvDelegateList
          The most recently obtained heirarchy list from delegates.properties
private static Hashtable cvDelegates
          The hashtable of all Delegates
private static long cvLastUpdate
          Get the last update of the delegate orders
private static String DEF_CONTAINER_DEL
          Default container delegate class.
private static long TIME_OUT
          Timeout for properties refresh
private static boolean VERBOSE
           
 
Fields inherited from interface wt.method.RemoteAccess
versionID
 
Constructor Summary
PreferenceHelperService()
           
 
Method Summary
static String[] createContextMask(String division)
          This method will create a Context Mask for the current logged in user.
static String[] createContextMask(String aContainer, String division)
          This method will create a Context Mask for the current logged in user.
static String[] createContextMask(String aDivision, WTUser aUser)
          This method will create a Context Mask for the named user.
static String[] createContextMask(WTContainerRef aContainer, String aDivision, WTUser aUser)
          This method will create a Context Mask for the named user.
static String createEditMask()
          This method will attempt to create the Edit Mask for the current user.
static String createEditMask(String division, Boolean apolicy)
          This method will attempt to create the Edit Mask for the current user at a given division node in the Heirarchy.
static String createEditMask(String division, WTUser aUser, Boolean apolicy)
          This method will attempt to create the Edit Mask for a given user at a given division node in the Heirarchy.
static String createEditMask(WTContainerRef aContainer, WTUser aUser, Boolean apolicy)
          This method will attempt to create the Edit Mask for a given user at a given container level in the Heirarchy.
private static PreferenceDelegate getDelegate(String delegate_tag)
          This method will return a PreferenceDelegate that is assigned as the delegate for a specific delegate tag.
private static void getDelegateHeirarchy()
          This method will access the Preferences Framework and will create a heirarchial list of PreferenceDelegates as defined in the Property wt.prefs.delegates.DelegateOrder in the delegates.properties file.
static String getDisplayNameFromContext(String aContext, Locale aLocale)
          This method will access the delegate for the given context and return the localized string the represents that context within the delegate.
static String[] getDivisionsAsAdministrator()
          This method will return the divisions that the user can administer from the current sesssion context.
static String[] getDivisionsAsAdministrator(String aContainer)
          This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy.
static String[] getDivisionsAsAdministrator(WTContainerRef aContainer)
          This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy.
static String[] getDivisionsAsAdministrator(WTContainerRef aContainer, WTUser aUser)
          This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy.
static String[] getDivisionsAsAdministrator(WTUser user)
          This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy.
static Long getTimeOutInterval()
           
static void setTimeOutInterval(Long time)
           
static String transformContext(String context)
          Performs transformations on context Transforms WTPreferences.USER_CONTEXT to WTPreferences.USER_CONTEXT + identity

Supported API: false
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvDelegateHeirarchy

private static List cvDelegateHeirarchy
List of all DelegateStructures for initialized delegates


cvDelegates

private static Hashtable cvDelegates
The hashtable of all Delegates


cvDelegateList

private static String cvDelegateList
The most recently obtained heirarchy list from delegates.properties


cvLastUpdate

private static long cvLastUpdate
Get the last update of the delegate orders


TIME_OUT

private static long TIME_OUT
Timeout for properties refresh


cacheSize

private static int cacheSize

VERBOSE

private static boolean VERBOSE

DEF_CONTAINER_DEL

private static final String DEF_CONTAINER_DEL
Default container delegate class.

See Also:
Constant Field Values

cache

private static Cache cache
Constructor Detail

PreferenceHelperService

public PreferenceHelperService()
Method Detail

getDisplayNameFromContext

public static String getDisplayNameFromContext(String aContext,
                                               Locale aLocale)
                                        throws WTException
This method will access the delegate for the given context and return the localized string the represents that context within the delegate.

NOTE: If the context is a WTPreferences.DIVISION_CONTEXT or WTPreferences.DIVISION_POLICY_CONTEXT, the Macro constant will be stripped before being sent to the delegate. Both a fully defined context (one that has a WTPreferences.DIVISION_CONTEXT) or a delegate context (just the name of the division) are valid parameters.



Supported API: false

Parameters:
aLocale - The locale of the current browser
aContext - The context name or Division to localize.
Returns:
String The display name or empty is no name was found.
Throws:
WTException

getTimeOutInterval

public static Long getTimeOutInterval()
                               throws WTException
Throws:
WTException

setTimeOutInterval

public static void setTimeOutInterval(Long time)
                               throws WTException
Throws:
WTException

getDelegateHeirarchy

private static final void getDelegateHeirarchy()
This method will access the Preferences Framework and will create a heirarchial list of PreferenceDelegates as defined in the Property wt.prefs.delegates.DelegateOrder in the delegates.properties file. This property lists the order from the top most context (mostly likely $DEFAULT - the system defaults) and through the delegates that are implemented followed by the $USER delegate. This property is comma separated and may contain trailing and leading spaces which are stripped off at read time. Any new delegates added to the system or removed should be reflected in this property. For example, if a customization creates an LDAPDelegate to read from their LDAP Heirarchy, and there will be a $DEFAULT and $USER level, the customizers should create a $DIVISION context in the property like and a corresponding $DIVISION preference. The property list might now read:

    $DEFAULT,$DIVISION,$USER


As mentioned above, another preference should be created, /wt/prefs/delegates/$DIVISION which contains the class that will be utilized to delegate the Division. (for example cust.prefs.LDAPDelegate)

If there are different delegates for handling different $DIVISION contexts, then they also must be listed in delegates.properties in proper order. For example,

    $DEFAULT,$DIVISION:Enterprise,$DIVISION:Plant,$DIVISION:Department,$DIVISION,$USER


In the above example, the Preference Heirarchy would be interpreted by the delegates using the $DEFAULT delegate first, followed by the $DIVISION:Enterprise delegate and so forth, using the $DIVISION to handle any other divisions below the ones listed explicitly.

This structure can best be described by looking at things from a tree model, where we have

    System Defaults
      -Windchill Enterprise
        -Cutsomer Tree Heirarchy (LDAP)
          -Individual User Preferences

By Default Windchill will ship with the following heirarchy, which may be customized on site.

    System Defaults
      - Windchill Enterprise
        - Individual User Preferences

Notes:

  1. The $DIVISION tag above is used by both $DIVISION and $DIVISION_POLICIES, since both are essentially the same division, except they have different ordering in the contextMasks.
  2. The usage of WTPreferences.xxxx_CONTEXT tags is meant only to separate the idea of System Default, User and 'other' levels.



Supported API: false


getDelegate

private static PreferenceDelegate getDelegate(String delegate_tag)
This method will return a PreferenceDelegate that is assigned as the delegate for a specific delegate tag. For example if the delegate tag is WTPreferences.DEFAULT_CONTEXT then the delegate for handling Windchill System Defaults should be returned. Likewise, WTPreferences.USER_CONTEXT will return the delegate for the User Preferences. All other context delegates are obtained in the following manner:

    If the context is WTPreferences.DIVISION_CONTEXT:some_division or WTPreferences.DIVISION_POLICY_CONTEXT:some_division an attempt is first made to find the Delegate for some_division. If this is not able to be located, then the Delegate for WTPreferenes.DIVISION_CONTEXT will be returned.


Supported API: false

Parameters:
delegate_tag - The Context to determine the proper delegate for.
Returns:
The valid delegate or null if no delegate could be matched.

getDivisionsAsAdministrator

public static String[] getDivisionsAsAdministrator(WTUser user)
                                            throws WTException
This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy.

Supported API: false

Parameters:
user - The user which wants administration rights.
Returns:
String[] The array of Divisions which are administerable.
Throws:
WTException

getDivisionsAsAdministrator

public static String[] getDivisionsAsAdministrator(WTContainerRef aContainer,
                                                   WTUser aUser)
                                            throws WTException
This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy. For containers, aContainer and its ancestors are checked for administrative rights of the user.

Supported API: false

Parameters:
aContainer - The container to check administrative rights.
aUser - The user which wants administration rights.
Returns:
String[] The array of Divisions which are administerable.
Throws:
WTException

getDivisionsAsAdministrator

public static String[] getDivisionsAsAdministrator(WTContainerRef aContainer)
                                            throws WTException
This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy. For containers, aContainer and its ancestors are checked for administrative rights of the currently logged in user.

Supported API: false

Returns:
String[] Array of Divisions which are administerable.
Throws:
WTException

getDivisionsAsAdministrator

public static String[] getDivisionsAsAdministrator()
                                            throws WTException
This method will return the divisions that the user can administer from the current sesssion context.

Supported API: false

Returns:
String[] Array of Divisions which are administerable.
Throws:
WTException

getDivisionsAsAdministrator

public static String[] getDivisionsAsAdministrator(String aContainer)
                                            throws WTException
This method will return the divisions that the named user can administer from the list of all the delegates in the current heirarchy. For containers, aContainer and its ancestors are checked for administrative rights of the currently logged in user.

Supported API: false

Returns:
String[] Array of Divisions which are administerable.
Throws:
WTException

createEditMask

public static final String createEditMask()
                                   throws WTException
This method will attempt to create the Edit Mask for the current user. With this context, a call to

    WTPreferences.setEditContext( createEditMask( ) );

Will edit a preference at the user level upon a

    WTPreferences.put( aKey, aPreference );



Supported API: false

Returns:
String The correct Edit Mask
Throws:
WTException

createEditMask

public static String createEditMask(String division,
                                    Boolean apolicy)
                             throws WTException
This method will attempt to create the Edit Mask for the current user at a given division node in the Heirarchy. If the user can not administrate preferences at that division (ie. edit the value) then this method will return a null String. If the user is a valid user to edit at this level, then the correct context will be returned. With this context, a call to

    WTPreferences.setEditContext( createEditMask( division, policy ) );

Will edit a preference at this level upon a

    WTPreferences.put( aKey, aPreference );



Supported API: false

Parameters:
division - The division node in the heirarchy that is to be edited.
Returns:
String The correct Edit Mask or null if the user can not edit the value at this division node.
Throws:
WTException

createEditMask

public static String createEditMask(String division,
                                    WTUser aUser,
                                    Boolean apolicy)
                             throws WTException
This method will attempt to create the Edit Mask for a given user at a given division node in the Heirarchy. If the user can not administrate preferences at that division (ie. edit the value) then this method will return a null String. If the user is a valid user to edit at this level, then the correct context will be returned. With this context, a call to

    WTPreferences.setEditContext( createEditMask( division, aUseri, policy ) );

Will edit a preference at this level upon a

    WTPreferences.put( aKey, aPreference );



Supported API: false

Parameters:
division - The division node in the heirarchy that is to be edited.
aUser - The user requesting editing permissions.
Returns:
String The correct Edit Mask or null if the user can not edit the value at this division node.
Throws:
WTException

createEditMask

public static String createEditMask(WTContainerRef aContainer,
                                    WTUser aUser,
                                    Boolean apolicy)
                             throws WTException
This method will attempt to create the Edit Mask for a given user at a given container level in the Heirarchy. If the user is a valid user to edit at this level, then the correct context will be returned. Else the value will be that of USER_CONTEXT. With this context, a call to

    WTPreferences.setEditContext( createEditMask( aContainer, aUser, policy ) );

Will edit a preference at this level upon a

    WTPreferences.put( aKey, aPreference );



Supported API: false

Parameters:
aContainer - The container in the heirarchy that is to be edited.
aUser - The user requesting editing permissions.
Returns:
String The correct Edit Mask or null if the user can not edit the value at this division node.
Throws:
WTException

createContextMask

public static String[] createContextMask(String division)
                                  throws WTException
This method will create a Context Mask for the current logged in user. The mask that is created with the named division being taken in precedence over the normal ordering of the context mask. For example, if the normal order was:

    { Policy.1, Policy2, User, Division.1....}

and Division.1 was passed in as the division parameter then the new order would be

    { Policy.1, Policy.2, Division.1, User, .... }

Please see Context Mask Format for details on the proper format of the context mask.

Supported API: false

Parameters:
division - The division to take higher priority
Returns:
String[] array of contexts in the order above.
Throws:
WTException

createContextMask

public static String[] createContextMask(String aContainer,
                                         String division)
                                  throws WTException
This method will create a Context Mask for the current logged in user. The mask that is created with the named division being taken in precedence over the normal ordering of the context mask. For example, if the normal order was:

    { Policy.1, Policy2, User, Division.1....}

and Division.1 was passed in as the division parameter then the new order would be

    { Policy.1, Policy.2, Division.1, User, .... }

Please see Context Mask Format for details on the proper format of the context mask.

Supported API: false

Parameters:
aContainer - The container to create the hierarchy for
division - The division to take higher priority
Returns:
String[] array of contexts in the order above.
Throws:
WTException

createContextMask

public static String[] createContextMask(String aDivision,
                                         WTUser aUser)
                                  throws WTException
This method will create a Context Mask for the named user. The mask that is created, if a fully expanded context mask (except for the WTPreferences.USER_CONTEXT which is expanded during Preferences calls). The mask will have a proper heirarchy list for a given user.

The mask that is created with the named division being taken in precedence over the normal ordering of the context mask. For example, if the normal order was:

    { Policy.1, Policy2, User, Division.1....}

and Division.1 was passed in as the division parameter then the new order would be

    { Policy.1, Policy.2, Division.1, User, .... }

Please see Context Mask Format for details on the proper format of the context mask.

Supported API: false

@param aUser The user to create the mask for.

Parameters:
aDivision - The division to create the Context Mask with.
Returns:
String[] array of contexts in the order above.
Throws:
WTException

createContextMask

public static String[] createContextMask(WTContainerRef aContainer,
                                         String aDivision,
                                         WTUser aUser)
                                  throws WTException
This method will create a Context Mask for the named user. The mask that is created, is a fully expanded context mask (except for the WTPreferences.USER_CONTEXT which is expanded during Preferences calls). The mask will have a proper heirarchy list for a given user.

The mask that is created with the named division being taken in precedence over the normal ordering of the context mask. For example, if the normal order was:

    { Policy.1, Policy2, User, Division.1....}

and Division.1 was passed in as the division parameter then the new order would be

    { Policy.1, Policy.2, Division.1, User, .... }

Please see Context Mask Format for details on the proper format of the context mask.

Supported API: false

@param aUser The user to create the mask for.

Parameters:
aDivision - The division to create the Context Mask with.
Returns:
String[] array of contexts in the order above.
Throws:
WTException

transformContext

public static String transformContext(String context)
                               throws WTException
Performs transformations on context Transforms WTPreferences.USER_CONTEXT to WTPreferences.USER_CONTEXT + identity

Supported API: false

Parameters:
context - context to be transformed
Throws:
WTException