Class UserManagerResolver
java.lang.Object
org.nuxeo.ecm.core.schema.types.resolver.AbstractObjectResolver
org.nuxeo.ecm.platform.usermanager.UserManagerResolver
- All Implemented Interfaces:
Serializable
,ObjectResolver
This
ObjectResolver
allows to manage integrity for fields containing group or user references.
References should have a prefix. NuxeoPrincipal.PREFIX for users, NuxeoGroup.PREFIX for groups.
If only user or group are configured, the prefix is not needed but still supported. If noth user and group are configured, reference without prefix are resolved as user first.
To use it, put the following code in your schema XSD :
<!-- user or group resolver -->
<xs:simpleType name="userOrGroupReference">
<xs:restriction base="xs:string" ref:resolver="userManagerResolver" />
</xs:simpleType>
<!-- user resolver -->
<xs:simpleType name="userReference">
<xs:restriction base="xs:string" ref:resolver="userManagerResolver" ref:type="user" />
</xs:simpleType>
<!-- group resolver -->
<xs:simpleType name="groupReference">
<xs:restriction base="xs:string" ref:resolver="userManagerResolver" ref:type="group" />
</xs:simpleType>
- Since:
- 7.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.schema.types.resolver.ObjectResolver
ObjectResolver.Helper
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class org.nuxeo.ecm.core.schema.types.resolver.AbstractObjectResolver
parameters, validation
Fields inherited from interface org.nuxeo.ecm.core.schema.types.resolver.ObjectResolver
VALIDATION_PARAMETER_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Configure this resolver.<T> T
Provides the entity referenced by a value, return the entity as expected type.Provides the entity referenced by a value.getConstraintErrorMessage
(Object invalidValue, Locale locale) Provides an error message to display when some invalid value does not match existing entity.Returns the resolved object types.getName()
Provides this resolver name.getReference
(Object entity) Generates a reference to an entity.boolean
boolean
Methods inherited from class org.nuxeo.ecm.core.schema.types.resolver.AbstractObjectResolver
checkConfig, getParameters, validate, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.ecm.core.schema.types.resolver.ObjectResolver
fetch, getParameters, validate, validate
-
Field Details
-
INPUT_PARAM_FILTER
- See Also:
-
FILTER_GROUP
- See Also:
-
FILTER_USER
- See Also:
-
NAME
- See Also:
-
PARAM_INCLUDE_USERS
- See Also:
-
PARAM_INCLUDE_GROUPS
- See Also:
-
-
Constructor Details
-
UserManagerResolver
public UserManagerResolver()
-
-
Method Details
-
getUserManager
-
getManagedClasses
Description copied from interface:ObjectResolver
Returns the resolved object types.- Specified by:
getManagedClasses
in interfaceObjectResolver
-
configure
Description copied from interface:ObjectResolver
Configure this resolver.- Specified by:
configure
in interfaceObjectResolver
- Overrides:
configure
in classAbstractObjectResolver
- Parameters:
parameters
- A map of parameter whose keys are parameter names and map value are corresponding values.- Throws:
IllegalStateException
- If this resolver is already configured.
-
getName
Description copied from interface:ObjectResolver
Provides this resolver name.- Specified by:
getName
in interfaceObjectResolver
- Returns:
- The resolver name.
- Throws:
IllegalStateException
-
fetch
Description copied from interface:ObjectResolver
Provides the entity referenced by a value.- Specified by:
fetch
in interfaceObjectResolver
- Parameters:
value
- The reference.- Returns:
- The referenced entity, null if no entity matches the value.
- Throws:
IllegalStateException
- If this resolver has not been configured.
-
fetch
Description copied from interface:ObjectResolver
Provides the entity referenced by a value, return the entity as expected type.- Specified by:
fetch
in interfaceObjectResolver
value
- The reference.- Returns:
- The referenced entity, null if no entity matches the value or if this entity cannot be converted as type.
- Throws:
IllegalStateException
- If this resolver has not been configured.
-
getReference
Description copied from interface:ObjectResolver
Generates a reference to an entity.- Specified by:
getReference
in interfaceObjectResolver
- Parameters:
entity
- The entity.- Returns:
- A reference to the entity or null if its not a managed entity type.
- Throws:
IllegalStateException
- If this resolver has not been configured.
-
getConstraintErrorMessage
public String getConstraintErrorMessage(Object invalidValue, Locale locale) throws IllegalStateException Description copied from interface:ObjectResolver
Provides an error message to display when some invalid value does not match existing entity.- Specified by:
getConstraintErrorMessage
in interfaceObjectResolver
- Parameters:
invalidValue
- The invalid value that don't match any entity.locale
- The language in which the message should be generated.- Returns:
- A message in the specified language or
- Throws:
IllegalStateException
-
isIncludingUsers
- Throws:
IllegalStateException
-
isIncludingGroups
- Throws:
IllegalStateException
-