com.bowstreet.profiles
Class ProfileSetStorageManager

java.lang.Object
  extended by com.bowstreet.profiles.ProfileSetStorageManager

public class ProfileSetStorageManager
extends java.lang.Object

Class to manage getting and setting ProfileSet objects from the IProfileStorageHandler implementation. The IProfileStorageHandler is specified in the bowstreet.properties file by the "bowstreet.profiles.storage.handler" property.

See Also:
ProfileSetDescription, ProfileSet

Field Summary
static java.lang.String STORAGE_HANDLER_PROPERTY_NAME
           
 
Constructor Summary
ProfileSetStorageManager()
          Constructs a ProfileSetStorageManager using the storage handler specified by the property "bowstreet.profiles.storage.handler".
ProfileSetStorageManager(java.lang.String strUserName)
          Constructs a ProfileSetStorageManager using the storage handler specified by the property "bowstreet.profiles.storage.handler".
ProfileSetStorageManager(java.lang.String strUserName, java.lang.String strStorageHandlerPropertyName)
          Constructs a ProfileSetStorageManager using the storage handler specified by the property passed in.
 
Method Summary
 void clearChildValues(java.lang.String strProfileSetId, java.lang.String strParentProfile, java.lang.String strValueName, boolean forceChangeOvewrite)
          This will clear the values of the specified children profiles.
 boolean doesProfileSetExist(java.lang.String strName)
          Looks for a ProfileSet for the specified Profile Set ID.
 java.util.Iterator getChildProfiles(java.lang.String profileSetName, java.lang.String parentProfile, boolean onlyContainers)
          Gets an Iterator of ProfileDescription objects for the children of the specified parent Profile.
 long getLastModified(java.lang.String profileSetName, java.lang.String profileName)
          Returns the last time the specified Profile was modified.
 java.util.Iterator getProfilesBySegment(java.lang.String profileSetName, java.util.Iterator segments)
          Gets an Iterator of ProfileDescription objects for Profiles that match one of the specified segments.
 ProfileSet getProfileSet(java.lang.String profileSetName)
          Gets a ProfileSet for the specified ProfileSet Name.
 ProfileSet getProfileSet(java.lang.String profileSetName, java.util.Iterator profileNames)
          Gets a ProfileSet that is populated with the specified Profiles from the Iterator of Profile names.
 ProfileSet getProfileSet(java.lang.String profileSetName, java.lang.String profileName)
          Gets a ProfileSet that is populated with the specified Profile.
 ProfileSetDescription getProfileSetDescription(java.lang.String strId)
          Gets a specified ProfileSet's, ProfileSetDescription.
 java.util.List getProfileSetDescriptions()
          Gets a list of all of the ProfileSetDescription's for the entire system.
 java.util.List getProfileSetDescriptions(long time)
          Gets a list of all of the ProfileSetDescription's who's last modified time stamp is greater that the specified.
 java.util.List getSegmentsInUse(java.lang.String profileSetName)
          Gets an List of segment names used by the specified ProfileSet.
 long lastModified(java.lang.String strName)
          Gets the last modified time of a specified profile.
 boolean removeProfileSet(java.lang.String strName)
          Removes an existing ProfileSet with the specified name.
 void renameProfile(java.lang.String profileSetName, java.lang.String profileName, java.lang.String newName)
          Renames an existing Profile and fix up any parent/child dependencies.
 void saveProfileData(ProfileSet profileSet, ProfileSet originalProfileSet, boolean forceChangeOvewrite)
          Adds or modifies only the Profiles of specified ProfileSet.
 void saveProfileSet(ProfileSet profileSet, boolean forceChangeOvewrite)
          Adds or modifies the entire specified ProfileSet.
 void saveProfileSet(ProfileSet profileSet, ProfileSet originalProfileSet, boolean forceChangeOvewrite)
          Adds or modifies the ProfilesDef, Profiles, strProfileSelectionClass and strValueClass of the specified ProfileSet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STORAGE_HANDLER_PROPERTY_NAME

public static final java.lang.String STORAGE_HANDLER_PROPERTY_NAME
See Also:
Constant Field Values
Constructor Detail

ProfileSetStorageManager

public ProfileSetStorageManager()
Constructs a ProfileSetStorageManager using the storage handler specified by the property "bowstreet.profiles.storage.handler".

See Also:
IProfileSetStorage

ProfileSetStorageManager

public ProfileSetStorageManager(java.lang.String strUserName)
Constructs a ProfileSetStorageManager using the storage handler specified by the property "bowstreet.profiles.storage.handler".

Parameters:
strUserName - The name of the current user. Used to trace who has modified the ProfileSet.
See Also:
IProfileSetStorage

ProfileSetStorageManager

public ProfileSetStorageManager(java.lang.String strUserName,
                                java.lang.String strStorageHandlerPropertyName)
Constructs a ProfileSetStorageManager using the storage handler specified by the property passed in. This will lookup the class name from the specified property name. Use this to override the default property for specifying the storage handler class name.

Parameters:
strUserName - The name of the current user. Used to trace who has modified the ProfileSet.
strStorageHandlerPropertyName - The name of the property that contains the class name for the storage handler.
See Also:
IProfileSetStorage
Method Detail

clearChildValues

public void clearChildValues(java.lang.String strProfileSetId,
                             java.lang.String strParentProfile,
                             java.lang.String strValueName,
                             boolean forceChangeOvewrite)
                      throws ProfileException,
                             com.bowstreet.profiles.ProfileSetChangedException
This will clear the values of the specified children profiles. Doing this will force the specified value to be inherited from the parent. *Note - Because it is possible for children Profiles to not all be in memory this method will save all of the effect Profiles and therefore after calling this method you should re-fetch the ProfileSet in order to pickup any changes.

Parameters:
strProfileSetId - The unique ID of the ProfileSet to operate on.
strParentProfile - The unique ID of the parent profile who's children will be effected.
strValueName - The name of the value to clear.
forceChangeOvewrite - If set to false and the ProfileSet already exists with a lastmodified time is greater than the specified ProfileSet and exception will be thrown. If true the ProfileSet will be overwritten.
Throws:
ProfileException - On error.
ProfileSetChangedException - if ProfileSet has been modified since the specified ProfileSet was read.
See Also:
updateProfilesChanged

doesProfileSetExist

public boolean doesProfileSetExist(java.lang.String strName)
Looks for a ProfileSet for the specified Profile Set ID.

Parameters:
strName - The unique ID of the requested Profile Set.
Returns:
true if the profile set is found, else false
See Also:
ProfileSet

getChildProfiles

public java.util.Iterator getChildProfiles(java.lang.String profileSetName,
                                           java.lang.String parentProfile,
                                           boolean onlyContainers)
                                    throws ProfileException
Gets an Iterator of ProfileDescription objects for the children of the specified parent Profile.

Parameters:
profileSetName - The name of the ProfileSet to operate on.
parentProfile - The name of the parent Profile within the ProfileSet.
onlyContainers - If true then only container Profiles will be included in the results, if false then all children will be included.
Returns:
An Iterator of ProfileDescription for the children of the specified parent Profile.
Throws:
ProfileException - On error.
See Also:
ProfileDescription
Example:
// Gets all of the root level container profiles
 Iterator iterator = profileSetStorageManager.getChildProfiles("myProfileSet", "Default", true);

 // Gets all of the child profiles of "Acme.HR"
 Iterator iterator = profileSetStorageManager.getChildProfiles("myProfileSet", "Acme.HR", false);

getLastModified

public long getLastModified(java.lang.String profileSetName,
                            java.lang.String profileName)
                     throws ProfileException
Returns the last time the specified Profile was modified.

Parameters:
profileSetName - The name of the ProfileSet that contains the Profile.
profileName - The name of the Profile to get last modified time of.
Returns:
The last time modified in milliseconds since January 1, 1970, 00:00:00 GMT.
Throws:
ProfileException - On error.

getProfilesBySegment

public java.util.Iterator getProfilesBySegment(java.lang.String profileSetName,
                                               java.util.Iterator segments)
                                        throws ProfileException
Gets an Iterator of ProfileDescription objects for Profiles that match one of the specified segments.

Parameters:
profileSetName - The ProfileSet to find the matching profile on.
segments - An Iterator of segment names that the user is in.
Returns:
An Iterator of ProfileDescription of the matching Profiles.
Throws:
ProfileException

getProfileSet

public ProfileSet getProfileSet(java.lang.String profileSetName)
                         throws ProfileException
Gets a ProfileSet for the specified ProfileSet Name.

Parameters:
profileSetName - The unique name of the requested ProfileSet.
Returns:
The requested ProfileSet object. This will throw a ProfileException if the Profile Set does not exist.
Throws:
ProfileException - On error
See Also:
ProfileSet

getProfileSet

public ProfileSet getProfileSet(java.lang.String profileSetName,
                                java.util.Iterator profileNames)
                         throws ProfileException
Gets a ProfileSet that is populated with the specified Profiles from the Iterator of Profile names.

Note - This will also bring in all of the parents of the specified profiles.

Parameters:
profileSetName - The name of the ProfileSet to retrieve.
profileNames - The names of the Profiles to populate the ProfileSet with.
Returns:
A ProfileSet populated with the Profiles specified by the profileNames Iterator and their parent Profiles.
Throws:
ProfileException - On error.

getProfileSet

public ProfileSet getProfileSet(java.lang.String profileSetName,
                                java.lang.String profileName)
                         throws ProfileException
Gets a ProfileSet that is populated with the specified Profile.

Note - This will also bring in all of the parents of the specified profile.

Parameters:
profileSetName - The name of the ProfileSet to retrieve.
profileName - The name of the Profile to populate the ProfileSet with.
Returns:
A ProfileSet populated with the Profile specified by the profileName parameter.
Throws:
ProfileException - On error.

getProfileSetDescription

public ProfileSetDescription getProfileSetDescription(java.lang.String strId)
                                               throws ProfileException
Gets a specified ProfileSet's, ProfileSetDescription.

Parameters:
strId - The unique ID of the requested ProfileSet, ProfileSetDescription.
Returns:
The requested ProfileSetDescription object. This will throw a ProfileException if the Profile Set does not exist.
Throws:
ProfileException - On error
See Also:
ProfileSetDescription, ProfileSet

getProfileSetDescriptions

public java.util.List getProfileSetDescriptions()
                                         throws ProfileException
Gets a list of all of the ProfileSetDescription's for the entire system.

Returns:
A List of ProfileSetDescription objects.
Throws:
ProfileException - On error
See Also:
ProfileSetDescription, ProfileSet

getProfileSetDescriptions

public java.util.List getProfileSetDescriptions(long time)
                                         throws ProfileException
Gets a list of all of the ProfileSetDescription's who's last modified time stamp is greater that the specified.

Parameters:
time - The time in milliseconds to compare against.
Returns:
A List of ProfileSetDescription objects.
Throws:
ProfileException - On error
See Also:
ProfileSetDescription, ProfileSet

getSegmentsInUse

public java.util.List getSegmentsInUse(java.lang.String profileSetName)
                                throws ProfileException
Gets an List of segment names used by the specified ProfileSet.

Parameters:
profileSetName - The name of the ProfileSet to get all the segment names used.
Returns:
A List of segment names(String) that are used in the specified ProfileSet.
Throws:
ProfileException - On error.

lastModified

public long lastModified(java.lang.String strName)
                  throws ProfileException
Gets the last modified time of a specified profile.

Parameters:
strName - The name of the ProfileSet to get the last modified time for.
Returns:
the last time modified in milliseconds since January 1, 1970, 00:00:00 GMT.
Throws:
ProfileException - On error.

removeProfileSet

public boolean removeProfileSet(java.lang.String strName)
                         throws ProfileException
Removes an existing ProfileSet with the specified name.

Parameters:
strName - The name of the ProfileSet to remove.
Returns:
boolean true if successful, else false
Throws:
ProfileException - On error.
See Also:
ProfileSet

renameProfile

public void renameProfile(java.lang.String profileSetName,
                          java.lang.String profileName,
                          java.lang.String newName)
                   throws ProfileException
Renames an existing Profile and fix up any parent/child dependencies.

Parameters:
profileSetName - The name of the ProfileSet to operate on.
profileName - The existing profile to be renamed. This must be the fully qualified profile name (e.g. "Acme.HR").
newName - The new profile name (e.g. "Sales").
Throws:
ProfileException - On error.

saveProfileData

public void saveProfileData(ProfileSet profileSet,
                            ProfileSet originalProfileSet,
                            boolean forceChangeOvewrite)
                     throws ProfileException,
                            com.bowstreet.profiles.ProfileSetChangedException
Adds or modifies only the Profiles of specified ProfileSet. If a ProfileSet exists with the same ID all of the changed Profiles will be modified, else a new ProfileSet will be added. If the specified ProfileSet has been modified since this ProfileSet was read then you must set forceChangeOvewrite=true or an exception will be thrown. This should only be used by a customizer. After saving the ProfileSet you should re-read it.

Parameters:
profileSet - The ProfileSet to modify.
originalProfileSet - The original ProfileSet to compare against or null if there was no original.
forceChangeOvewrite - If set to false and the ProfileSet already exists with a lastmodified time is greater than the specified ProfileSet and exception will be thrown. If true the ProfileSet will be overwritten.
Throws:
ProfileException - On error.
ProfileSetChangedException - if ProfileSet has been modified since the specified ProfileSet was read.
See Also:
updateProfilesChanged

saveProfileSet

public void saveProfileSet(ProfileSet profileSet,
                           boolean forceChangeOvewrite)
                    throws ProfileException,
                           com.bowstreet.profiles.ProfileSetChangedException
Adds or modifies the entire specified ProfileSet. If a ProfileSet exists with the same ID it will be overwritten, else a new ProfileSet will be added. If the specified ProfileSet has been modified since this ProfileSet was read then you must set forceChangeOvewrite=true or an exception will be thrown. After saving the ProfileSet you should re-read it.

Parameters:
profileSet - The ProfileSet to add or modify.
forceChangeOvewrite - If set to false and the ProfileSet already exists with a lastmodified time is greater than the specified ProfileSet and exception will be thrown. If true the ProfileSet will be overwritten.
Throws:
ProfileException - On error.
ProfileSetChangedException - if ProfileSet has been modified since the specified ProfileSet was read.
See Also:
ProfileSet

saveProfileSet

public void saveProfileSet(ProfileSet profileSet,
                           ProfileSet originalProfileSet,
                           boolean forceChangeOvewrite)
                    throws ProfileException,
                           com.bowstreet.profiles.ProfileSetChangedException
Adds or modifies the ProfilesDef, Profiles, strProfileSelectionClass and strValueClass of the specified ProfileSet. If a ProfileSet exists with the same ID all of the Def, strProfileSelectionClass and strValueClass, data will be modified and the Profiles will be merged. If the ProfileSet does not exist it will be added. If the specified ProfileSet has been modified since this ProfileSet was read then you must set forceChangeOvewrite=true or an exception will be thrown. After saving the ProfileSet you should re-read it.

Parameters:
profileSet - The ProfileSet to modify.
originalProfileSet - The original ProfileSet to compare against or null if there was no original.
forceChangeOvewrite - If set to false and the ProfileSet already exists with a lastmodified time is greater than the specified ProfileSet and exception will be thrown. If true the ProfileSet will be overwritten.
Throws:
ProfileException - On error.
ProfileSetChangedException - if ProfileSet has been modified since the specified ProfileSet was read.
See Also:
updateProfilesChanged


Copyright © 2009 IBM. All Rights Reserved.