Class UserManagerResolver
- java.lang.Object
-
- org.nuxeo.ecm.core.schema.types.resolver.AbstractObjectResolver
-
- org.nuxeo.ecm.platform.usermanager.UserManagerResolver
-
- All Implemented Interfaces:
Serializable,ObjectResolver
public class UserManagerResolver extends AbstractObjectResolver implements ObjectResolver
ThisObjectResolverallows 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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.schema.types.resolver.ObjectResolver
ObjectResolver.Helper
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILTER_GROUPstatic StringFILTER_USERstatic StringINPUT_PARAM_FILTERstatic StringNAMEstatic StringPARAM_INCLUDE_GROUPSstatic StringPARAM_INCLUDE_USERS-
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
Constructors Constructor Description UserManagerResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Map<String,String> parameters)Configure this resolver.<T> Tfetch(Class<T> type, Object value)Provides the entity referenced by a value, return the entity as expected type.Objectfetch(Object value)Provides the entity referenced by a value.StringgetConstraintErrorMessage(Object invalidValue, Locale locale)Provides an error message to display when some invalid value does not match existing entity.List<Class<?>>getManagedClasses()Returns the resolved object types.StringgetName()Provides this resolver name.SerializablegetReference(Object entity)Generates a reference to an entity.UserManagergetUserManager()booleanisIncludingGroups()booleanisIncludingUsers()-
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 Detail
-
INPUT_PARAM_FILTER
public static final String INPUT_PARAM_FILTER
- See Also:
- Constant Field Values
-
FILTER_GROUP
public static final String FILTER_GROUP
- See Also:
- Constant Field Values
-
FILTER_USER
public static final String FILTER_USER
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
PARAM_INCLUDE_USERS
public static final String PARAM_INCLUDE_USERS
- See Also:
- Constant Field Values
-
PARAM_INCLUDE_GROUPS
public static final String PARAM_INCLUDE_GROUPS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getUserManager
public UserManager getUserManager()
-
getManagedClasses
public List<Class<?>> getManagedClasses()
Description copied from interface:ObjectResolverReturns the resolved object types.- Specified by:
getManagedClassesin interfaceObjectResolver
-
configure
public void configure(Map<String,String> parameters) throws IllegalStateException
Description copied from interface:ObjectResolverConfigure this resolver.- Specified by:
configurein interfaceObjectResolver- Overrides:
configurein 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
public String getName() throws IllegalStateException
Description copied from interface:ObjectResolverProvides this resolver name.- Specified by:
getNamein interfaceObjectResolver- Returns:
- The resolver name.
- Throws:
IllegalStateException
-
fetch
public Object fetch(Object value) throws IllegalStateException
Description copied from interface:ObjectResolverProvides the entity referenced by a value.- Specified by:
fetchin 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
public <T> T fetch(Class<T> type, Object value) throws IllegalStateException
Description copied from interface:ObjectResolverProvides the entity referenced by a value, return the entity as expected type.- Specified by:
fetchin interfaceObjectResolvervalue- 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
public Serializable getReference(Object entity) throws IllegalStateException
Description copied from interface:ObjectResolverGenerates a reference to an entity.- Specified by:
getReferencein 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:ObjectResolverProvides an error message to display when some invalid value does not match existing entity.- Specified by:
getConstraintErrorMessagein 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
public boolean isIncludingUsers() throws IllegalStateException- Throws:
IllegalStateException
-
isIncludingGroups
public boolean isIncludingGroups() throws IllegalStateException- Throws:
IllegalStateException
-
-