Copyright© 2008-2018 SiteVision AB, all rights reserved.
@Requireable(value="UserDataUtil") public interface UserDataUtil
The portlet specification allows access of user-specific data via a read-only java.util.Map
that can be obtained as request attribute using the PortletRequest.USER_INFO
constant.
This utility is a convenience to get such user data, but it also extends it by allowing write operations
and access other user's data. Data written via this utility can be accesses via the Map exposed via the
PortletRequest.USER_INFO
constant and vice versa. Hence, with this utility there are no need to use
the portlet specification mechanism for accessing user data.
Mutating data operations (set/remove) on other users requires certain permissions, see individual method documentation.
Important note! The user data mechanism is closely tied to a specific user object and is intended to handle basic user information and user preferences. Adding "too much" (count) or "too large" (size) user data might cause persistence implications and performance implications.
An instance of the SiteVision class implementing this interface can be obtained via UserFactory.getUserDataUtil()
.
See UserFactory
for how to obtain an instance of the UserFactory
interface.
Modifier and Type | Method and Description |
---|---|
java.util.Set<String> |
getReadOnlyKeys()
The read-only keys.
|
java.io.Serializable |
getUserData(Node aUserNode,
String aUserDataKey)
Gets user data for a user.
|
java.io.Serializable |
getUserData(String aUserDataKey)
Gets user data for current user.
|
void |
removeUserData(Node aUserNode,
String aUserDataKey)
Removes user data for a user.
|
void |
removeUserData(String aUserDataKey)
Removes user data.
|
void |
setUserData(Node aUserNode,
String aUserDataKey,
java.io.Serializable aSerializableValue)
Sets user data for a user.
|
void |
setUserData(String aUserDataKey,
java.io.Serializable aSerializableValue)
Sets user data for current user.
|
java.util.Set<String> getReadOnlyKeys()
Mutating operations (set/remove) with any of these keys will be ignored.
Note that internal-only properties are not included in the returned set, but they will also be ignored in mutating operations.
java.io.Serializable getUserData(String aUserDataKey)
This read operation is equivalent to using the user info mechanism of the portlet specification.
aUserDataKey
- the data keyaUserDataKey
(typically a String
), or nulljava.io.Serializable getUserData(Node aUserNode, String aUserDataKey)
aUserNode
- the user node (typically a sv:user
or sv:simpleUser
)aUserDataKey
- the data keyaUserDataKey
(typically a String
), or nullvoid setUserData(String aUserDataKey, java.io.Serializable aSerializableValue)
This write operation is equivalent to using the SiteVision-specific user info mechanism of the portlet specification.
Important note! The set/write operation will be ignored if aUserDataKey
is null
, whitespace-only or
read-only (see getReadOnlyKeys()
). The set operation will also be ignored if aSerializableValue
is null
.
Use removeUserData(String)
to remove data instead.
aUserDataKey
- the data keyaSerializableValue
- the data value (typically a String
)void setUserData(Node aUserNode, String aUserDataKey, java.io.Serializable aSerializableValue)
Important note! The set/write operation will be ignored if aUserDataKey
is null
, whitespace-only or
read-only (see getReadOnlyKeys()
). The set operation will also be ignored if aSerializableValue
is null
.
Use removeUserData(String)
to remove data instead.
Permission note! Current user (as of PortletContextUtil.getCurrentUser()
) must have
PermissionUtil.Permission.WRITE
on current site
(as of ResourceLocatorUtil.getSite()
), otherwise the set/write operation will be ignored.
aUserNode
- the user node (typically a sv:user
or sv:simpleUser
)aUserDataKey
- the data keyaSerializableValue
- the data value (typically a String
)void removeUserData(String aUserDataKey)
Important note! The remove/delete operation will be ignored if aUserDataKey
is null
, whitespace-only or
read-only (see getReadOnlyKeys()
).
aUserDataKey
- the data keyvoid removeUserData(Node aUserNode, String aUserDataKey)
Important note! The remove/delete operation will be ignored if aUserDataKey
is null
, whitespace-only or
read-only (see getReadOnlyKeys()
).
Permission note! Current user (as of PortletContextUtil.getCurrentUser()
) must have
PermissionUtil.Permission.WRITE
on current site
(as of ResourceLocatorUtil.getSite()
), otherwise the remove/delete operation will be ignored.
aUserNode
- the user node (typically a sv:user
or sv:simpleUser
)aUserDataKey
- the data keySiteVision - Portal and Content Management Made Easy
SiteVision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2018 SiteVision AB, all rights reserved.