Package org.ldaptive.ext
Class MergeOperation
- java.lang.Object
-
- org.ldaptive.ext.MergeOperation
-
public class MergeOperation extends Object
The merge operation performs the LDAP operations necessary to synchronize the data in anLdapEntry
with its 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.
-
-
Field Summary
Fields Modifier and Type Field Description private AddOperation
addOperation
Add operation used to add a new entry.private ConnectionFactory
connectionFactory
Connection factory.private DeleteOperation
deleteOperation
Delete operation used to remove an entry.private Logger
logger
Logger for this class.private ModifyOperation
modifyOperation
Modify operation used to update an entry.private SearchOperation
searchOperation
Search operation used to find the entry.private ResultPredicate
throwCondition
Function to test results.
-
Constructor Summary
Constructors Constructor Description MergeOperation()
Default constructor.MergeOperation(ConnectionFactory factory)
Creates a new merge operation.
-
Method Summary
-
-
-
Field Detail
-
logger
private final Logger logger
Logger for this class.
-
connectionFactory
private ConnectionFactory connectionFactory
Connection factory.
-
searchOperation
private SearchOperation searchOperation
Search operation used to find the entry.
-
addOperation
private AddOperation addOperation
Add operation used to add a new entry.
-
modifyOperation
private ModifyOperation modifyOperation
Modify operation used to update an entry.
-
deleteOperation
private DeleteOperation deleteOperation
Delete operation used to remove an entry.
-
throwCondition
private ResultPredicate throwCondition
Function to test results.
-
-
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)
-
getSearchOperation
public SearchOperation getSearchOperation()
-
setSearchOperation
public void setSearchOperation(SearchOperation operation)
-
getAddOperation
public AddOperation getAddOperation()
-
setAddOperation
public void setAddOperation(AddOperation operation)
-
getModifyOperation
public ModifyOperation getModifyOperation()
-
setModifyOperation
public void setModifyOperation(ModifyOperation operation)
-
getDeleteOperation
public DeleteOperation getDeleteOperation()
-
setDeleteOperation
public void setDeleteOperation(DeleteOperation operation)
-
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(MergeRequest request, LdapEntry source, LdapEntry target) throws LdapException
Retrieves the attribute modifications fromLdapEntry.computeModifications(LdapEntry, LdapEntry)
and executes aModifyOperation
with those results. If no modifications are necessary, no operation is performed.- Parameters:
request
- merge requestsource
- ldap entry to merge into the LDAPtarget
- ldap entry that exists in the LDAP- Returns:
- response of the modify operation or a null response if no operation is performed. If batching is enabled in the request, returns the response of the last operation performed
- Throws:
LdapException
- if an error occurs executing the modify operation
-
add
protected Result add(MergeRequest request, LdapEntry entry) throws LdapException
Executes anAddOperation
for the supplied entry.- Parameters:
request
- 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(MergeRequest request, LdapEntry entry) throws LdapException
Executes aDeleteOperation
for the supplied entry.- Parameters:
request
- merge requestentry
- to delete from the LDAP- Returns:
- response of the delete operation
- Throws:
LdapException
- if an error occurs executing the deleting operation
-
copy
public static MergeOperation copy(MergeOperation operation)
Returns a new merge operation with the same properties as the supplied operation.- Parameters:
operation
- to copy- Returns:
- copy of the supplied merge operation
-
copy
public static MergeOperation copy(MergeOperation operation, boolean deep)
Returns a new merge operation with the same properties as the supplied operation.- Parameters:
operation
- to copydeep
- whether to make a deep copy- Returns:
- copy of the supplied merge operation
-
-