Package org.nuxeo.ecm.directory.ldap
Class LDAPReference
- java.lang.Object
-
- org.nuxeo.ecm.directory.AbstractReference
-
- org.nuxeo.ecm.directory.ldap.LDAPReference
-
public class LDAPReference extends AbstractReference implements Cloneable
Implementation of the directory Reference interface that leverage two common ways of storing relationships in LDAP directories:- the static attribute strategy where a multi-valued attribute store the exhaustive list of distinguished names of the refereed entries (eg. the uniqueMember attribute of the groupOfUniqueNames objectclass)
- the dynamic attribute strategy where a potentially multi-valued attribute stores a ldap urls intensively describing the refereed LDAP entries (eg. the memberURLs attribute of the groupOfURLs objectclass)
Please note that both static and dynamic references are resolved in read mode whereas only the static attribute strategy is used when creating new references or when deleting existing ones (write / update mode).
Some design considerations behind the implementation of such reference can be found at: http://jira.nuxeo.org/browse/NXP-1506
- Author:
- Olivier Grisel
-
-
Field Summary
Fields Modifier and Type Field Description protected StringdynamicAttributeIdbooleanforceDnConsistencyCheckprotected StringstaticAttributeIdprotected LDAPDirectoryDescriptortargetDirectoryDescriptor-
Fields inherited from class org.nuxeo.ecm.directory.AbstractReference
fieldName, sourceDirectory, sourceDirectoryName, targetDirectory, targetDirectoryName
-
-
Constructor Summary
Constructors Constructor Description LDAPReference()LDAPReference(ReferenceDescriptor referenceDescriptor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLinks(String sourceId, List<String> targetIds)Store new links using the LDAP staticAttributeId strategy.voidaddLinks(String sourceId, List<String> targetIds, Session session)Adds the links between the source id and the target idsvoidaddLinks(List<String> sourceIds, String targetId)Store new links using the LDAP staticAttributeId strategy.voidaddLinks(List<String> sourceIds, String targetId, Session session)Adds the links between the source ids and the target idLDAPReferenceclone()StringgetDynamicAttributeId()List<LDAPDynamicReferenceDescriptor>getDynamicAttributes()protected StringgetIdForDn(LDAPSession session, String dn)List<String>getLdapTargetIds(Attributes attributes)Optimized method to spare a LDAP request when the caller is a LDAPSession object that has already fetched the LDAP Attribute instances.DirectorygetSourceDirectory()List<String>getSourceIdsForTarget(String targetId)Fetch both statically and dynamically defined references and merge the results.protected LDAPDirectorygetSourceLDAPDirectory()StringgetStaticAttributeId()StringgetStaticAttributeId(DirectoryFieldMapper sourceFM)DirectorygetTargetDirectory()protected LDAPDirectoryDescriptorgetTargetDirectoryDescriptor()List<String>getTargetIdsForSource(String sourceId)Fetches both statically and dynamically defined references and merges the results.protected LDAPDirectorygetTargetLDAPDirectory()booleanisDynamic()booleanisStatic()protected static StringpseudoNormalizeDn(String dn)Simple helper that replaces ", " by "," in the provided dn and returns the lower case version of the result for comparison purpose.voidremoveLinksForSource(String sourceId)Remove existing statically defined links for the given source id (dynamic references remain unaltered)voidremoveLinksForSource(String sourceId, Session session)Removes all the links for a given source idvoidremoveLinksForTarget(String targetId)Remove existing statically defined links for the given target id (dynamic references remain unaltered)voidremoveLinksForTarget(String targetId, Session session)Removes all the links for a given target idvoidsetFieldName(String fieldName)voidsetSourceIdsForTarget(String targetId, List<String> sourceIds)Edit the list of statically defined references for a given target (dynamic references remain unaltered)voidsetSourceIdsForTarget(String targetId, List<String> sourceIds, Session session)Sets all source ids to be associated to the given target idvoidsetTargetDirectoryName(String targetDirectoryName)voidsetTargetIdsForSource(String sourceId, List<String> targetIds)Set the list of statically defined references for a given source (dynamic references remain unaltered)voidsetTargetIdsForSource(String sourceId, List<String> targetIds, Session session)Sets all target ids to be associated to the given source idStringtoString()-
Methods inherited from class org.nuxeo.ecm.directory.AbstractReference
getFieldName, setSourceDirectoryName
-
-
-
-
Field Detail
-
forceDnConsistencyCheck
public boolean forceDnConsistencyCheck
-
targetDirectoryDescriptor
protected LDAPDirectoryDescriptor targetDirectoryDescriptor
-
staticAttributeId
protected String staticAttributeId
-
dynamicAttributeId
protected String dynamicAttributeId
-
-
Constructor Detail
-
LDAPReference
public LDAPReference()
-
LDAPReference
public LDAPReference(ReferenceDescriptor referenceDescriptor)
-
-
Method Detail
-
setFieldName
public void setFieldName(String fieldName)
-
isStatic
public boolean isStatic()
- Returns:
- true if the reference should resolve statically refereed entries (identified by dn-valued attribute)
-
getStaticAttributeId
public String getStaticAttributeId()
-
getStaticAttributeId
public String getStaticAttributeId(DirectoryFieldMapper sourceFM)
-
getDynamicAttributes
public List<LDAPDynamicReferenceDescriptor> getDynamicAttributes()
-
getDynamicAttributeId
public String getDynamicAttributeId()
-
isDynamic
public boolean isDynamic()
- Returns:
- true if the reference should resolve dynamically refereed entries (identified by a LDAP url-valued attribute)
-
setTargetDirectoryName
public void setTargetDirectoryName(String targetDirectoryName)
- Specified by:
setTargetDirectoryNamein interfaceReference- Overrides:
setTargetDirectoryNamein classAbstractReference
-
getSourceDirectory
public Directory getSourceDirectory()
- Specified by:
getSourceDirectoryin interfaceReference- Overrides:
getSourceDirectoryin classAbstractReference
-
getTargetDirectory
public Directory getTargetDirectory()
- Specified by:
getTargetDirectoryin interfaceReference- Overrides:
getTargetDirectoryin classAbstractReference
-
getTargetLDAPDirectory
protected LDAPDirectory getTargetLDAPDirectory()
-
getSourceLDAPDirectory
protected LDAPDirectory getSourceLDAPDirectory()
-
getTargetDirectoryDescriptor
protected LDAPDirectoryDescriptor getTargetDirectoryDescriptor()
-
addLinks
public void addLinks(String sourceId, List<String> targetIds)
Store new links using the LDAP staticAttributeId strategy.- Specified by:
addLinksin interfaceReference- See Also:
Reference.addLinks(String, List)
-
addLinks
public void addLinks(List<String> sourceIds, String targetId)
Store new links using the LDAP staticAttributeId strategy.- Specified by:
addLinksin interfaceReference- See Also:
Reference.addLinks(List, String)
-
getSourceIdsForTarget
public List<String> getSourceIdsForTarget(String targetId)
Fetch both statically and dynamically defined references and merge the results.- Specified by:
getSourceIdsForTargetin interfaceReference- See Also:
Reference.getSourceIdsForTarget(String)
-
getTargetIdsForSource
public List<String> getTargetIdsForSource(String sourceId)
Fetches both statically and dynamically defined references and merges the results.- Specified by:
getTargetIdsForSourcein interfaceReference- See Also:
Reference.getSourceIdsForTarget(String)
-
pseudoNormalizeDn
protected static String pseudoNormalizeDn(String dn) throws InvalidNameException
Simple helper that replaces ", " by "," in the provided dn and returns the lower case version of the result for comparison purpose.- Parameters:
dn- the raw unnormalized dn- Returns:
- lowercase version without whitespace after commas
- Throws:
InvalidNameException
-
getLdapTargetIds
public List<String> getLdapTargetIds(Attributes attributes)
Optimized method to spare a LDAP request when the caller is a LDAPSession object that has already fetched the LDAP Attribute instances.This method should return the same results as the sister method: org.nuxeo .ecm.directory.Reference#getTargetIdsForSource(java.lang.String)
- Returns:
- target reference ids
-
getIdForDn
protected String getIdForDn(LDAPSession session, String dn)
-
removeLinksForSource
public void removeLinksForSource(String sourceId)
Remove existing statically defined links for the given source id (dynamic references remain unaltered)- Specified by:
removeLinksForSourcein interfaceReference- See Also:
Reference.removeLinksForSource(String)
-
removeLinksForTarget
public void removeLinksForTarget(String targetId)
Remove existing statically defined links for the given target id (dynamic references remain unaltered)- Specified by:
removeLinksForTargetin interfaceReference- See Also:
Reference.removeLinksForTarget(String)
-
setSourceIdsForTarget
public void setSourceIdsForTarget(String targetId, List<String> sourceIds)
Edit the list of statically defined references for a given target (dynamic references remain unaltered)- Specified by:
setSourceIdsForTargetin interfaceReference- See Also:
Reference.setSourceIdsForTarget(String, List)
-
setSourceIdsForTarget
public void setSourceIdsForTarget(String targetId, List<String> sourceIds, Session session)
Description copied from interface:ReferenceSets all source ids to be associated to the given target id- Specified by:
setSourceIdsForTargetin interfaceReference- Parameters:
targetId- the target idsourceIds- the source idssession- the session
-
setTargetIdsForSource
public void setTargetIdsForSource(String sourceId, List<String> targetIds)
Set the list of statically defined references for a given source (dynamic references remain unaltered)- Specified by:
setTargetIdsForSourcein interfaceReference- See Also:
Reference.setTargetIdsForSource(String, List)
-
setTargetIdsForSource
public void setTargetIdsForSource(String sourceId, List<String> targetIds, Session session)
Description copied from interface:ReferenceSets all target ids to be associated to the given source id- Specified by:
setTargetIdsForSourcein interfaceReference- Parameters:
sourceId- the source idtargetIds- the target idssession- the session
-
removeLinksForTarget
public void removeLinksForTarget(String targetId, Session session)
Description copied from interface:ReferenceRemoves all the links for a given target id- Specified by:
removeLinksForTargetin interfaceReference- Parameters:
targetId- the target idsession- the session
-
removeLinksForSource
public void removeLinksForSource(String sourceId, Session session)
Description copied from interface:ReferenceRemoves all the links for a given source id- Specified by:
removeLinksForSourcein interfaceReference- Parameters:
sourceId- the source idsession- the session
-
clone
public LDAPReference clone()
-
addLinks
public void addLinks(String sourceId, List<String> targetIds, Session session)
Description copied from interface:ReferenceAdds the links between the source id and the target ids
-
-