public class UserManagerResolver extends Object implements ObjectResolver
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>
ObjectResolver.Helper
Modifier and Type | Field and Description |
---|---|
static String |
FILTER_GROUP |
static String |
FILTER_USER |
static String |
INPUT_PARAM_FILTER |
static String |
NAME |
static String |
PARAM_INCLUDE_GROUPS |
static String |
PARAM_INCLUDE_USERS |
Constructor and Description |
---|
UserManagerResolver() |
Modifier and Type | Method and Description |
---|---|
void |
configure(Map<String,String> parameters)
Configure this resolver.
|
<T> T |
fetch(Class<T> type,
Object value)
Provides the entity referenced by a value, return the entity as expected type.
|
Object |
fetch(Object value)
Provides the entity referenced by a value.
|
String |
getConstraintErrorMessage(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.
|
String |
getName()
Provides this resolver name.
|
Map<String,Serializable> |
getParameters()
Provides this resolver parameters.
|
Serializable |
getReference(Object entity)
Generates a reference to an entity.
|
UserManager |
getUserManager() |
boolean |
isIncludingGroups() |
boolean |
isIncludingUsers() |
boolean |
validate(Object value)
Validates some value references an existing entity.
|
public static final String INPUT_PARAM_FILTER
public static final String FILTER_GROUP
public static final String FILTER_USER
public static final String NAME
public static final String PARAM_INCLUDE_USERS
public static final String PARAM_INCLUDE_GROUPS
public UserManager getUserManager()
public List<Class<?>> getManagedClasses()
ObjectResolver
getManagedClasses
in interface ObjectResolver
public void configure(Map<String,String> parameters) throws IllegalStateException
ObjectResolver
configure
in interface ObjectResolver
parameters
- A map of parameter whose keys are parameter names and map value are corresponding values.IllegalStateException
- If this resolver is already configured.public String getName() throws IllegalStateException
ObjectResolver
getName
in interface ObjectResolver
IllegalStateException
public Map<String,Serializable> getParameters() throws IllegalStateException
ObjectResolver
getParameters
in interface ObjectResolver
IllegalStateException
public boolean validate(Object value) throws IllegalStateException
ObjectResolver
validate
in interface ObjectResolver
value
- The reference.IllegalStateException
- If this resolver has not been configured.public Object fetch(Object value) throws IllegalStateException
ObjectResolver
fetch
in interface ObjectResolver
value
- The reference.IllegalStateException
- If this resolver has not been configured.public <T> T fetch(Class<T> type, Object value) throws IllegalStateException
ObjectResolver
fetch
in interface ObjectResolver
value
- The reference.IllegalStateException
- If this resolver has not been configured.public Serializable getReference(Object entity) throws IllegalStateException
ObjectResolver
getReference
in interface ObjectResolver
entity
- The entity.IllegalStateException
- If this resolver has not been configured.public String getConstraintErrorMessage(Object invalidValue, Locale locale) throws IllegalStateException
ObjectResolver
getConstraintErrorMessage
in interface ObjectResolver
invalidValue
- The invalid value that don't match any entity.locale
- The language in which the message should be generated.IllegalStateException
public boolean isIncludingUsers() throws IllegalStateException
IllegalStateException
public boolean isIncludingGroups() throws IllegalStateException
IllegalStateException
Copyright © 2015 Nuxeo SA. All rights reserved.