public class DirectoryEntryResolver extends Object implements ObjectResolver
ObjectResolver allows to manage integrity for fields containing references to directory's entry.
References contains the directory entry id.
To use it, put the following code in your schema XSD (don't forget the directory name):
{@code
For hierarchical directories, which entries reference other entries. You can manage a specific reference containing the full entry path. You have to specify the parent field and the separator used to encode the reference.
{@code
It's not necessary to define parentField and separator for directory using schema ending by xvocabulary. The feature is automatically enable.
ObjectResolver.Helper| Modifier and Type | Field and Description |
|---|---|
static String |
NAME |
static String |
PARAM_DIRECTORY |
static String |
PARAM_PARENT_FIELD |
static String |
PARAM_SEPARATOR |
| Constructor and Description |
|---|
DirectoryEntryResolver() |
| 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.
|
Directory |
getDirectory() |
DirectoryService |
getDirectoryService() |
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.
|
void |
setDirectory(Directory directory) |
boolean |
validate(Object value)
Validates some value references an existing entity.
|
public static final String NAME
public static final String PARAM_DIRECTORY
public static final String PARAM_PARENT_FIELD
public static final String PARAM_SEPARATOR
public DirectoryEntryResolver()
public void configure(Map<String,String> parameters) throws IllegalArgumentException, IllegalStateException
ObjectResolverconfigure in interface ObjectResolverparameters - A map of parameter whose keys are parameter names and map value are corresponding values.IllegalArgumentException - If some parameter are not compatible with this resolver.IllegalStateException - If this resolver is already configured.public List<Class<?>> getManagedClasses()
ObjectResolvergetManagedClasses in interface ObjectResolverpublic DirectoryService getDirectoryService()
public Directory getDirectory()
public void setDirectory(Directory directory)
public String getName()
ObjectResolvergetName in interface ObjectResolverpublic Map<String,Serializable> getParameters()
ObjectResolvergetParameters in interface ObjectResolverpublic boolean validate(Object value) throws IllegalStateException
ObjectResolvervalidate in interface ObjectResolvervalue - The reference.IllegalStateException - If this resolver has not been configured.public Object fetch(Object value) throws IllegalStateException
ObjectResolverfetch in interface ObjectResolvervalue - The reference.IllegalStateException - If this resolver has not been configured.public <T> T fetch(Class<T> type, Object value) throws IllegalStateException
ObjectResolverfetch in interface ObjectResolvervalue - The reference.IllegalStateException - If this resolver has not been configured.public Serializable getReference(Object entity) throws IllegalStateException
ObjectResolvergetReference in interface ObjectResolverentity - The entity.IllegalStateException - If this resolver has not been configured.public String getConstraintErrorMessage(Object invalidValue, Locale locale)
ObjectResolvergetConstraintErrorMessage in interface ObjectResolverinvalidValue - The invalid value that don't match any entity.locale - The language in which the message should be generated.Copyright © 2016 Nuxeo SA. All rights reserved.