@Scriptable
public final class UserProfile
extends java.lang.Object
implements de.uplanet.lucy.server.profile.IUserProfile
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:
IUserProfile.USE_CACHE
is used, read properties are buffered. So subsequent get
s
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.Modifier and Type | Method and Description |
---|---|
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.
|
static void |
deleteExceptForDefaultUser(de.uplanet.jdbc.JdbcConnection p_conn,
java.lang.String p_strNamePrefix)
Delete all profile properties that do not belong to the default user and 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.
|
java.lang.Object |
getUserDefined(java.lang.String p_strName) |
<T> T |
getUserDefined(java.lang.String p_strName,
T p_objDefault) |
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.
|
public static UserProfile createInstance(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strUserId, int p_iCacheUsage)
p_conn
- An open database connection.p_strUserId
- The ID of the user for whom the profile should be created.p_iCacheUsage
- IUserProfile.NO_CACHE
or IUserProfile.USE_CACHE
.java.lang.UnsupportedOperationException
- If an invalid cache flag is supplied.public java.lang.Object getUserDefined(java.lang.String p_strName)
getUserDefined
in interface de.uplanet.lucy.server.profile.IUserProfile
public <T> T getUserDefined(java.lang.String p_strName, T p_objDefault)
getUserDefined
in interface de.uplanet.lucy.server.profile.IUserProfile
public java.lang.Object get(java.lang.String p_strName)
get
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property to be retrieved.IUserProfile.NO_PROP_RET_VAL
if the property does
not exist or IUserProfile.ERR_RET_VAL
if an error occurred.public <T> T get(java.lang.String p_strName, T p_objDefault)
If the specified property does not exist or any error occurs while retrieving the property, the specified fallback object is returned.
get
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property to be retrieved.p_objDefault
- The property to be returned in error conditions.p_objDefault
if the
property does not exist or if an error occurred.public java.lang.Object getDefault(java.lang.String p_strName)
getDefault
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property to be retrieved.IUserProfile.NO_PROP_RET_VAL
if the property does
not exist or IUserProfile.ERR_RET_VAL
if an error occurred.public <T> T getDefault(java.lang.String p_strName, T p_objDefault)
If the specified property does not exist or any error occurs while retrieving the property, the specified fallback object is returned.
getDefault
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property to be retrieved.p_objDefault
- The property to be returned in error conditions.p_objDefault
if the
property does not exist or if an error occurred.public void put(java.lang.String p_strName, java.lang.Object p_objValue)
put
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property.p_objValue
- The value of the property.public void putDefault(java.lang.String p_strName, java.lang.Object p_objValue)
putDefault
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property.p_objValue
- The value of the property.public boolean userOverridesProperty(java.lang.String p_strName)
userOverridesProperty
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property.true
if the current user overrides the
property, or false
otherwise.public boolean userOverridesProperty(java.lang.String p_strName, java.lang.String p_strUserId)
userOverridesProperty
in interface de.uplanet.lucy.server.profile.IUserProfile
p_strName
- The name of the property.p_strUserId
- The ID of a specific user.true
if the given user overrides the
property, or false
otherwise.public static void delete(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strNamePrefix)
p_conn
- The database connection to be used.p_strNamePrefix
- The property name prefix.public static void delete(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strNamePrefix, java.lang.String p_strUserGuid)
p_conn
- The database connection to be used.p_strNamePrefix
- The property name prefix.p_strUserGuid
- The guid of the userpublic static void deleteExceptForDefaultUser(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strNamePrefix)
p_conn
- The database connection to be used.p_strNamePrefix
- The property name prefix.public void done()
done
in interface de.uplanet.lucy.server.profile.IUserProfile