Package org.nuxeo.ecm.directory
Class DirectoryEntryResolver
java.lang.Object
org.nuxeo.ecm.core.schema.types.resolver.AbstractObjectResolver
org.nuxeo.ecm.directory.DirectoryEntryResolver
- All Implemented Interfaces:
Serializable,ObjectResolver
This
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):
<xs:element name="carBrand">
<xs:simpleType>
<xs:restriction base="xs:string" ref:resolver="directoryResolver" ref:directory="carBrandsDirectory" />
</xs:simpleType>
</xs:element>
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.
<xs:element name="coverage">
<xs:simpleType>
<xs:restriction base="xs:string" ref:resolver="directoryResolver" ref:directory="l10ncoverage" ref:parentField="parent" ref:separator="/" />
</xs:simpleType>
</xs:element>
It's not necessary to define parentField and separator for directory using schema ending by xvocabulary. The feature is automatically enable.
- 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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.nuxeo.ecm.core.schema.types.resolver.AbstractObjectResolver
parameters, validationFields inherited from interface org.nuxeo.ecm.core.schema.types.resolver.ObjectResolver
VALIDATION_PARAMETER_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure this resolver.<T> TProvides 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.protected StringReturns the resolved object types.getName()Provides this resolver name.getReference(Object entity) Generates a reference to an entity.Methods inherited from class org.nuxeo.ecm.core.schema.types.resolver.AbstractObjectResolver
checkConfig, getParameters, validate, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.core.schema.types.resolver.ObjectResolver
fetch, getParameters, validate, validate
-
Field Details
-
NAME
- See Also:
-
PARAM_DIRECTORY
- See Also:
-
PARAM_PARENT_FIELD
- See Also:
-
PARAM_SEPARATOR
- See Also:
-
-
Constructor Details
-
DirectoryEntryResolver
public DirectoryEntryResolver()
-
-
Method Details
-
configure
public void configure(Map<String, String> parameters) throws IllegalArgumentException, IllegalStateExceptionDescription 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:
IllegalArgumentException- If some parameter are not compatible with this resolver.IllegalStateException- If this resolver is already configured.
-
getManagedClasses
Description copied from interface:ObjectResolverReturns the resolved object types.- Specified by:
getManagedClassesin interfaceObjectResolver
-
getDirectory
-
getName
Description copied from interface:ObjectResolverProvides this resolver name.- Specified by:
getNamein interfaceObjectResolver- Returns:
- The resolver name.
-
fetch
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
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
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.
-
getHierarchicalReference
-
getConstraintErrorMessage
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
-