Package org.ldaptive.ext
Class MergeOperation
java.lang.Object
org.ldaptive.ext.MergeOperation
The merge operation performs the LDAP operations necessary to synchronize the data in an
LdapEntry 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. Either MergeRequest.getIncludeAttributes() or MergeRequest.getExcludeAttributes() will be used, but not both.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AddOperationAdd operation used to add a new entry.private ConnectionFactoryConnection factory.private DeleteOperationDelete operation used to remove an entry.private final LoggerLogger for this class.private ModifyOperationModify operation used to update an entry.private SearchOperationSearch operation used to find the entry.private ResultPredicateFunction to test results. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.MergeOperation(ConnectionFactory factory) Creates a new merge operation. -
Method Summary
Modifier and TypeMethodDescriptionprotected Resultadd(MergeRequest request, LdapEntry entry) Executes anAddOperationfor the supplied entry.static MergeOperationcopy(MergeOperation operation) Returns a new merge operation with the same properties as the supplied operation.static MergeOperationcopy(MergeOperation operation, boolean deep) Returns a new merge operation with the same properties as the supplied operation.protected Resultdelete(MergeRequest request, LdapEntry entry) Executes aDeleteOperationfor the supplied entry.execute(MergeRequest request) Executes a merge request.protected Resultmodify(MergeRequest request, LdapEntry source, LdapEntry target) Retrieves the attribute modifications fromLdapEntry.computeModifications(LdapEntry, LdapEntry)and executes aModifyOperationwith those results.voidsetAddOperation(AddOperation operation) voidsetConnectionFactory(ConnectionFactory factory) voidsetDeleteOperation(DeleteOperation operation) voidsetModifyOperation(ModifyOperation operation) voidsetSearchOperation(SearchOperation operation) voidsetThrowCondition(ResultPredicate function)
-
Field Details
-
logger
Logger for this class. -
connectionFactory
Connection factory. -
searchOperation
Search operation used to find the entry. -
addOperation
Add operation used to add a new entry. -
modifyOperation
Modify operation used to update an entry. -
deleteOperation
Delete operation used to remove an entry. -
throwCondition
Function to test results.
-
-
Constructor Details
-
MergeOperation
public MergeOperation()Default constructor. -
MergeOperation
Creates a new merge operation.- Parameters:
factory- connection factory
-
-
Method Details
-
getConnectionFactory
-
setConnectionFactory
-
getSearchOperation
-
setSearchOperation
-
getAddOperation
-
setAddOperation
-
getModifyOperation
-
setModifyOperation
-
getDeleteOperation
-
setDeleteOperation
-
getThrowCondition
-
setThrowCondition
-
execute
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 aModifyOperationwith 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
Executes anAddOperationfor 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
Executes aDeleteOperationfor 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
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
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
-