Interface UserProperties
-
@ProviderType public interface UserProperties
UserProperties is a general interface used to represent user preferences and profiles. It provides convenience methods to retrieve properties in various formats.
The properties are either read from a single node or are composed from an list of nodes. Such a composite can be retrieved via
UserPropertiesManager.getUserProperties(String, String, Comparator)
. The comparator will define the order in which a given property is read from the composite in case it is present in more than one of the enclosedUserProperties
.In addition this interface allows to access the underlying JCR Node used to write or modify this
UserProperties
, version or lock it as well as to register observation event listeners. In case of a singularUserProperties
object this is the node the information is read from. In case of composite the it's the node representing the relative root path specified inUserPropertiesManager.getUserProperties(String, String, Comparator)
.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ABOUT_ME
Constant for the property containing a description of an authorizable.static java.lang.String
DISPLAY_NAME
Constant for the display name (or nick name) property of a given user or group.static java.lang.String
EMAIL
Constant for the email property of an authorizable.static java.lang.String
FAMILY_NAME
Constant for the family name of a given user.static java.lang.String
GIVEN_NAME
Constant for the given name of a given user or group.static java.lang.String
MIDDLE_NAME
Constant for the middle name property of a user.static java.lang.String
PHOTOS
Constant for the user property storing images of a user.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull java.util.List<UserProperties>
getAggregatedUserProperties()
Returns a list ofUserProperties
enclosed within this instance or an empty list if this instance doesn't represent an aggregation ofUserProperties
.@NotNull java.lang.String
getAuthorizableID()
Returns the ID of the authorizable this user properties belong to.@NotNull java.lang.String
getAuthorizablePath()
Returns the authorizables path@NotNull java.lang.String
getDisplayName()
Calculate a display name from thisUserProperties
instance.@NotNull java.lang.String
getDisplayName(@Nullable java.lang.String nameDisplayOrder)
Calculate a display name from thisUserProperties
instance.@Nullable javax.jcr.Node
getNode()
Returns the JCRnode
associated with this user properties instance.@NotNull java.lang.String
getPrincipalName()
Returns the principal name of the authorizable.@Nullable java.lang.String
getProperty(@NotNull java.lang.String relativePath)
Returns the string value of the property identified by the specifiedrelativePath
.<T> T
getProperty(@NotNull java.lang.String relativePath, T defaultValue, @NotNull java.lang.Class<T> type)
Same asgetProperty(String)
.@NotNull java.lang.String[]
getPropertyNames()
Retrieves all first-level property names found on the underlyingNode
or on all enclosed user properties in case this instance is the result of aggregation.@NotNull java.lang.String[]
getPropertyNames(@Nullable java.lang.String relPath)
Retrieves all property names available at the specified relative path on the underlyingNode
or on the enclosedUserProperties
in case this instance is the result of aggregation.@Nullable Resource
getResource(@NotNull java.lang.String relativePath)
Retrieve the resource at the specified path relative to this instance.@NotNull java.lang.String
getResourcePath(@NotNull java.lang.String relativePath, @Nullable java.lang.String suffix, @NotNull java.lang.String defaultPath)
Calculates the resource path for the property located the specifiedrelativePath
using the givensuffix
.@Nullable java.util.Iterator<Resource>
getResources(@NotNull java.lang.String relativePath)
Retrieve the resources at the specified path relative to this instance.boolean
isGroupProperties()
Checks if the authorizable of this properties is a group.
-
-
-
Field Detail
-
ABOUT_ME
static final java.lang.String ABOUT_ME
Constant for the property containing a description of an authorizable.- See Also:
- Constant Field Values
-
EMAIL
static final java.lang.String EMAIL
Constant for the email property of an authorizable.- See Also:
- Constant Field Values
-
FAMILY_NAME
static final java.lang.String FAMILY_NAME
Constant for the family name of a given user.- See Also:
- Constant Field Values
-
GIVEN_NAME
static final java.lang.String GIVEN_NAME
Constant for the given name of a given user or group.- See Also:
- Constant Field Values
-
MIDDLE_NAME
static final java.lang.String MIDDLE_NAME
Constant for the middle name property of a user.- See Also:
- Constant Field Values
-
DISPLAY_NAME
static final java.lang.String DISPLAY_NAME
Constant for the display name (or nick name) property of a given user or group. See alsogetDisplayName()
for a implementation specific calculation of a display name that may rely on or fallback to various name related properties.- See Also:
- Constant Field Values
-
PHOTOS
static final java.lang.String PHOTOS
Constant for the user property storing images of a user.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAuthorizableID
@NotNull @NotNull java.lang.String getAuthorizableID()
Returns the ID of the authorizable this user properties belong to.- Returns:
- the ID of the authorizable this user properties belong to.
-
getAuthorizablePath
@NotNull @NotNull java.lang.String getAuthorizablePath()
Returns the authorizables path- Returns:
- the path of the authorizable.
-
getPrincipalName
@NotNull @NotNull java.lang.String getPrincipalName()
Returns the principal name of the authorizable.- Returns:
- The principal name.
-
getNode
@Nullable @Nullable javax.jcr.Node getNode()
Returns the JCRnode
associated with this user properties instance. The node may then be used to write properties or execute other JCR specific operations on this user properties that are not covered by convenience methods defined by this interface. If this instance is composed of multiple enclosedUserProperties
, this method will return theNode
representing the relative root path as specified withUserPropertiesManager.getUserProperties(String, String, Comparator)
. If that node is not accessible to the editing session, this method will returnnull
.- Returns:
- the
node
associated with this user properties instance ornull
if the node is not accessible.
-
getPropertyNames
@NotNull @NotNull java.lang.String[] getPropertyNames() throws javax.jcr.RepositoryException
Retrieves all first-level property names found on the underlyingNode
or on all enclosed user properties in case this instance is the result of aggregation. This is the same asgetPropertyNames(String)
where the relative path isnull
.- Returns:
- An array of property names.
- Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getPropertyNames
@NotNull @NotNull java.lang.String[] getPropertyNames(@Nullable @Nullable java.lang.String relPath) throws javax.jcr.RepositoryException
Retrieves all property names available at the specified relative path on the underlyingNode
or on the enclosedUserProperties
in case this instance is the result of aggregation. IfrelPath
isnull
, the names are obtained from thenode
directly (and not from a subtree).- Parameters:
relPath
- A relative path to the sub tree where to retrieve the property names.- Returns:
- An array of property names.
- Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getProperty
@Nullable @Nullable java.lang.String getProperty(@NotNull @NotNull java.lang.String relativePath) throws javax.jcr.RepositoryException
Returns the string value of the property identified by the specified
relativePath
. This may be a simple property name in case ofgetPropertyNames()
or the relative path to the property in case ofgetPropertyNames(String)
.Note that this method is a simplified variant of
In case of aggregation the referenced property may be found on multiple enclosedgetProperty(String, Object, Class)
where the default value isnull
and the desired typeString
.UserProperties
. In this case the order of the underlyingUserProperties
will determine, which property value will be exposed. The order of the user properties is governed by explicitly specifying the order inUserPropertiesManager.getUserProperties(String, String, Comparator)
.- Parameters:
relativePath
- Relative path referring to the property to be retrieved.- Returns:
- The string value of the specified property or
null
. - Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getProperty
@Nullable <T> T getProperty(@NotNull @NotNull java.lang.String relativePath, @Nullable T defaultValue, @NotNull @NotNull java.lang.Class<T> type) throws javax.jcr.RepositoryException
Same asgetProperty(String)
. Additionally the expected format of the property value is specified by the type parameter. If no property exists atrelativePath
the specifieddefaultValue
is returned.- Type Parameters:
T
- specifies the expected format of the property- Parameters:
relativePath
- Relative path referring to the property to be retrieved.defaultValue
- The default value to be used if the property at relativePath does not exist.type
- The expected value type. The property value may need to be converted.- Returns:
- The value of the specified property converted to the specified
type
or thedefaultValue
if the property does not exist or cannot be converted to the specified type. - Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getResource
@Nullable @Nullable Resource getResource(@NotNull @NotNull java.lang.String relativePath) throws javax.jcr.RepositoryException
Retrieve the resource at the specified path relative to this instance.- Parameters:
relativePath
- Relative path to the resource to be retrieved.- Returns:
- The resource at the specified relative path or
null
if the the path cannot be resolved to a resource. - Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getResources
@Nullable @Nullable java.util.Iterator<Resource> getResources(@NotNull @NotNull java.lang.String relativePath) throws javax.jcr.RepositoryException
Retrieve the resources at the specified path relative to this instance.- Parameters:
relativePath
- Relative path to the resources to be retrieved.- Returns:
- The resources at the specified relative path or
null
if the the path cannot be resolved to resources. - Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getResourcePath
@NotNull @NotNull java.lang.String getResourcePath(@NotNull @NotNull java.lang.String relativePath, @Nullable @Nullable java.lang.String suffix, @NotNull @NotNull java.lang.String defaultPath) throws javax.jcr.RepositoryException
Calculates the resource path for the property located the specifiedrelativePath
using the givensuffix
. If the property does not exist the specifieddefaultPath
is returned.- Parameters:
relativePath
- Relative path to the property for which the resource path will be calculated.suffix
- An optional suffix to be appended to the resource path.defaultPath
- An optional default path in case the requested property does not exist (or is not accessible).- Returns:
- The resource path for the requested property or the default path.
- Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getDisplayName
@NotNull @NotNull java.lang.String getDisplayName() throws javax.jcr.RepositoryException
Calculate a display name from thisUserProperties
instance.- Returns:
- Implementation specific display name as stored in this user properties instance or some implementation specific default.
- Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
getDisplayName
@NotNull @NotNull java.lang.String getDisplayName(@Nullable @Nullable java.lang.String nameDisplayOrder) throws javax.jcr.RepositoryException
Calculate a display name from thisUserProperties
instance.- Parameters:
nameDisplayOrder
- Order of given, middle and family names. Western name order should be "givenName middleName familyName", Eastern name order should be "familyName givenName middleName".- Returns:
- Implementation specific display name as stored in this user properties instance or some implementation specific default.
- Throws:
javax.jcr.RepositoryException
- If an error occurs.
-
isGroupProperties
boolean isGroupProperties()
Checks if the authorizable of this properties is a group.- Returns:
true
if this properties belongs to a group.
-
getAggregatedUserProperties
@NotNull @NotNull java.util.List<UserProperties> getAggregatedUserProperties()
Returns a list ofUserProperties
enclosed within this instance or an empty list if this instance doesn't represent an aggregation ofUserProperties
.- Returns:
- The collection of aggregated user properties or an empty collection if there are no aggregated properties.
-
-