Package org.ldaptive.ext
Class MergeOperation
- java.lang.Object
-
- org.ldaptive.ext.MergeOperation
-
public class MergeOperation extends java.lang.ObjectThe merge operation performs the LDAP operations necessary to synchronize the data in anLdapEntrywith it's corresponding entry in the LDAP. The following logic is executed:- if the entry does not exist in the LDAP, execute an add
- if the request is for a delete, execute a delete
- if the entry exists in the LDAP, execute a modify
LdapEntry.computeModifications(LdapEntry, LdapEntry)is used to determine the list of attribute modifications that are necessary to perform the merge. EitherMergeRequest.getIncludeAttributes()orMergeRequest.getExcludeAttributes()will be used, but not both.- Author:
- Middleware Services
-
-
Constructor Summary
Constructors Constructor Description MergeOperation()Default constructor.MergeOperation(ConnectionFactory factory)Creates a new merge operation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Resultadd(Connection conn, MergeRequest request, LdapEntry entry)Executes anAddOperationfor the supplied entry.protected Resultdelete(Connection conn, MergeRequest request, LdapEntry entry)Executes aDeleteOperationfor the supplied entry.Resultexecute(MergeRequest request)Executes a merge request.ConnectionFactorygetConnectionFactory()ResultPredicategetThrowCondition()protected Resultmodify(Connection conn, MergeRequest request, LdapEntry source, LdapEntry target)Retrieves the attribute modifications fromLdapEntry.computeModifications(LdapEntry, LdapEntry)and executes aModifyOperationwith those results.voidsetConnectionFactory(ConnectionFactory factory)voidsetThrowCondition(ResultPredicate function)
-
-
-
Constructor Detail
-
MergeOperation
public MergeOperation()
Default constructor.
-
MergeOperation
public MergeOperation(ConnectionFactory factory)
Creates a new merge operation.- Parameters:
factory- connection factory
-
-
Method Detail
-
getConnectionFactory
public ConnectionFactory getConnectionFactory()
-
setConnectionFactory
public void setConnectionFactory(ConnectionFactory factory)
-
getThrowCondition
public ResultPredicate getThrowCondition()
-
setThrowCondition
public void setThrowCondition(ResultPredicate function)
-
execute
public Result execute(MergeRequest request) throws LdapException
Executes a merge request. SeeOperationHandle.execute().- Parameters:
request- merge request- Returns:
- merge result
- Throws:
LdapException- if the connection cannot be opened
-
modify
protected Result modify(Connection conn, MergeRequest request, LdapEntry source, LdapEntry target) throws LdapException
Retrieves the attribute modifications fromLdapEntry.computeModifications(LdapEntry, LdapEntry)and executes aModifyOperationwith those results. If no modifications are necessary, no operation is performed.- Parameters:
conn- connection to perform operation onrequest- merge requestsource- ldap entry to merge into the LDAPtarget- ldap entry that exists in the LDAP- Returns:
- response of the modify operation or an empty response if no operation is performed
- Throws:
LdapException- if an error occurs executing the modify operation
-
add
protected Result add(Connection conn, MergeRequest request, LdapEntry entry) throws LdapException
Executes anAddOperationfor the supplied entry.- Parameters:
conn- connection to perform operation onrequest- merge requestentry- to add to the LDAP- Returns:
- response of the add operation
- Throws:
LdapException- if an error occurs executing the add operation
-
delete
protected Result delete(Connection conn, MergeRequest request, LdapEntry entry) throws LdapException
Executes aDeleteOperationfor the supplied entry.- Parameters:
conn- connection to perform operation onrequest- merge requestentry- to delete from the LDAP- Returns:
- response of the delete operation
- Throws:
LdapException- if an error occurs executing the deleting operation
-
-