de.uplanet.lucy.server.profile
Class UserProfile

java.lang.Object
  extended by de.uplanet.lucy.server.profile.UserProfile

@Scriptable
public final class UserProfile
extends java.lang.Object

User profile class.

Used to store properties of an users's profile. The values may be of any Object-derived class such as strings, date values, integer or floating point values, hash maps and so on.

Users MUST call done() when finished using the user profile to ensure that all resources such as SQL statements are properly closed and freed.

Users are encouraged to use URN-like property names, e.g.
    urn:schemas-intrexx-de:profile:my-property,
to make their applications namespace aware.


The class operates on the LCPROFILE table:

CREATE TABLE LCPROFILE
(
    GUIDUSER   VARCHAR(40) NOT NULL,
    STRNAME    VARCHAR(255) NOT NULL,
    INTTYPEID  INTEGER NOT NULL,
    INTVERSION INTEGER NOT NULL,
    TXTVALUE   TEXT
)

ALTER TABLE LCPROFILE WITH NOCHECK ADD CONSTRAINT PK_LCPROFILE
    PRIMARY KEY CLUSTERED (GUIDUSER, STRNAME)

If USE_CACHE is used, read properties are buffered. So subsequent gets will not result in database read operations. For this reason changes in the database that are made from different instances may not be visible if the own instance read the property before the foreign change occurred.

Version:
$Revision: 65386 $

Field Summary
static java.lang.String DEFAULT_USER_ID
          Default-user ID (0000000000000000000000000000000000000000).
static java.lang.Object ERR_RET_VAL
          Default return value for error conditions (null).
static int NO_CACHE
          Don't use the internal cache.
static java.lang.Object NO_PROP_RET_VAL
          Default return value if a property does not exist (empty String).
static int USE_CACHE
          Enable the internal cache.
static int VERSION
          Version identifier for serializing mechanism, currently 100.
 
Method Summary
static UserProfile createInstance(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strUserId, int p_iCacheUsage)
          Factory method to create a user profile.
static void delete(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strNamePrefix)
          Delete all profile properties whose names start with the specified prefix.
static void delete(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strNamePrefix, java.lang.String p_strUserGuid)
          Delete all profile properties whose names start with the specified prefix.
 void done()
          This method does nothing.
 java.lang.Object get(java.lang.String p_strName)
          Get a user profile property.
<T> T
get(java.lang.String p_strName, T p_objDefault)
          Get a user profile property.
 java.lang.Object getDefault(java.lang.String p_strName)
          Get a default profile property.
<T> T
getDefault(java.lang.String p_strName, T p_objDefault)
          Get a default profile property.
 void put(java.lang.String p_strName, java.lang.Object p_objValue)
          Set a user profile property.
 void putDefault(java.lang.String p_strName, java.lang.Object p_objValue)
          Set a default profile property.
 boolean userOverridesProperty(java.lang.String p_strName)
          Check if the current user overrides the given property.
 boolean userOverridesProperty(java.lang.String p_strName, java.lang.String p_strUserId)
          Check if a given user overrides the given property.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_RET_VAL

public static final java.lang.Object ERR_RET_VAL
Default return value for error conditions (null).


NO_PROP_RET_VAL

public static final java.lang.Object NO_PROP_RET_VAL
Default return value if a property does not exist (empty String).


DEFAULT_USER_ID

public static final java.lang.String DEFAULT_USER_ID
Default-user ID (0000000000000000000000000000000000000000).

It has the lowest sorting precedence of all user IDs.

See Also:
IcPortletConstants.DEFAULT_USER_ID, Constant Field Values

VERSION

public static final int VERSION
Version identifier for serializing mechanism, currently 100.

See Also:
IcPortletConstants.VERSION, Constant Field Values

NO_CACHE

public static final int NO_CACHE
Don't use the internal cache.

See Also:
Constant Field Values

USE_CACHE

public static final int USE_CACHE
Enable the internal cache.

See Also:
Constant Field Values
Method Detail

createInstance

public static UserProfile createInstance(de.uplanet.jdbc.JdbcConnection p_conn,
                                         java.lang.String p_strUserId,
                                         int p_iCacheUsage)
Factory method to create a user profile.

Parameters:
p_conn - An open database connection.
p_strUserId - The ID of the user for whom the profile should be created.
p_iCacheUsage - NO_CACHE or USE_CACHE.
Returns:
A newly created user profile.
Throws:
java.lang.UnsupportedOperationException - If an invalid cache flag is supplied.

get

public java.lang.Object get(java.lang.String p_strName)
Get a user profile property.

Parameters:
p_strName - The name of the property to be retrieved.
Returns:
The property or NO_PROP_RET_VAL if the property does not exist or ERR_RET_VAL if an error occurred.

get

public <T> T get(java.lang.String p_strName,
                 T p_objDefault)
Get a user profile property.

If the specified property does not exist or any error occurs while retrieving the property, the specified fallback object is returned.

Parameters:
p_strName - The name of the property to be retrieved.
p_objDefault - The property to be returned in error conditions.
Returns:
The property or p_objDefault if the property does not exist or if an error occurred.

getDefault

public java.lang.Object getDefault(java.lang.String p_strName)
Get a default profile property.

Parameters:
p_strName - The name of the property to be retrieved.
Returns:
The property or NO_PROP_RET_VAL if the property does not exist or ERR_RET_VAL if an error occurred.

getDefault

public <T> T getDefault(java.lang.String p_strName,
                        T p_objDefault)
Get a default profile property.

If the specified property does not exist or any error occurs while retrieving the property, the specified fallback object is returned.

Parameters:
p_strName - The name of the property to be retrieved.
p_objDefault - The property to be returned in error conditions.
Returns:
The property or p_objDefault if the property does not exist or if an error occurred.

put

public void put(java.lang.String p_strName,
                java.lang.Object p_objValue)
Set a user profile property.

Parameters:
p_strName - The name of the property.
p_objValue - The value of the property.

putDefault

public void putDefault(java.lang.String p_strName,
                       java.lang.Object p_objValue)
Set a default profile property.

Parameters:
p_strName - The name of the property.
p_objValue - The value of the property.

userOverridesProperty

public boolean userOverridesProperty(java.lang.String p_strName)
Check if the current user overrides the given property.

Parameters:
p_strName - The name of the property.
Returns:
true if the current user overrides the property, or false otherwise.

userOverridesProperty

public boolean userOverridesProperty(java.lang.String p_strName,
                                     java.lang.String p_strUserId)
Check if a given user overrides the given property.

Parameters:
p_strName - The name of the property.
p_strUserId - The ID of a specific user.
Returns:
true if the given user overrides the property, or false otherwise.

delete

public static void delete(de.uplanet.jdbc.JdbcConnection p_conn,
                          java.lang.String p_strNamePrefix)
Delete all profile properties whose names start with the specified prefix.

Parameters:
p_conn - The database connection to be used.
p_strNamePrefix - The propery name prefix.

delete

public static void delete(de.uplanet.jdbc.JdbcConnection p_conn,
                          java.lang.String p_strNamePrefix,
                          java.lang.String p_strUserGuid)
Delete all profile properties whose names start with the specified prefix.

Parameters:
p_conn - The database connection to be used.
p_strNamePrefix - The propery name prefix.
p_strUserGuid - The guid of the user

done

public void done()
This method does nothing.



Last updated: 2011-01-27
Copyright 2000-2010 United Planet. All Rights Reserved.