/** * Creates a new merge request. * * @param entry to merge into the LDAP */ public MergeRequest(final LdapEntry entry) { setEntry(entry); }
/** * Creates a new merge request. * * @param entry to merge into the LDAP * @param delete whether the supplied entry should be deleted */ public MergeRequest(final LdapEntry entry, final boolean delete) { setEntry(entry); setDeleteEntry(delete); }
/** * Executes a {@link MergeOperation} with the supplied entry. * * @param entry to merge * * @return response for the merge operation * * @throws LdapException if the operation fails */ @Nonnull private Response<Void> merge(@Nonnull final LdapEntry entry) throws LdapException { Connection conn = null; try { conn = connectionFactory.getConnection(); final MergeOperation merge = new MergeOperation(conn); final MergeRequest request = new MergeRequest(entry); request.setIncludeAttributes(entry.getAttributeNames()); return merge.execute(request); } finally { conn.close(); } }
throws LdapException final LdapEntry sourceEntry = request.getEntry(); Response<Void> response; final SearchOperation search = new SearchOperation(getConnection()); searchResponse = search.execute( SearchRequest.newObjectScopeSearchRequest(sourceEntry.getDn(), request.getSearchAttributes())); } catch (LdapException e) { if (e.getResultCode() != ResultCode.NO_SUCH_OBJECT) { if (request.getDeleteEntry()) { logger.info("target entry does not exist, no delete performed for request {}", request); response = new Response<>(null, null); } else { response = add(request, sourceEntry); } else if (request.getDeleteEntry()) { response = delete(request, sourceEntry); } else { response = modify(request, sourceEntry, searchResponse.getResult().getEntry());
@Override public String toString() { return String.format( "[%s@%d::ldapEntry=%s, deleteEntry=%s, searchAttributes=%s, " + "includeAttributes=%s, excludeAttributes=%s, controls=%s, " + "referralHandler=%s, intermediateResponseHandlers=%s]", getClass().getName(), hashCode(), ldapEntry, deleteEntry, Arrays.toString(searchAttrs), Arrays.toString(includeAttrs), Arrays.toString(excludeAttrs), Arrays.toString(getControls()), getReferralHandler(), Arrays.toString(getIntermediateResponseHandlers())); } }
@Override public Response<Void> merge(final T object) throws LdapException { final LdapEntry entry = new LdapEntry(); getLdapEntryMapper().map(object, entry); final MergeRequest request = new MergeRequest(entry); try (Connection conn = getConnectionFactory().getConnection()) { conn.open(); final MergeOperation merge = new MergeOperation(conn); return merge.execute(request); } }
/** * Executes a {@link DeleteOperation} for the supplied entry. * * @param request merge request * @param entry to delete from the LDAP * * @return response of the delete operation * * @throws LdapException if an error occurs executing the deleting operation */ protected Response<Void> delete(final MergeRequest request, final LdapEntry entry) throws LdapException { Response<Void> response; final DeleteOperation delete = new DeleteOperation(getConnection()); response = delete.execute(new DeleteRequest(entry.getDn())); logger.info("delete entry {} for request {}", entry, request); return response; } }
throws LdapException final LdapEntry sourceEntry = request.getEntry(); final Response<Void> response; final SearchOperation search = new SearchOperation(getConnection()); searchResponse = search.execute( SearchRequest.newObjectScopeSearchRequest(sourceEntry.getDn(), request.getSearchAttributes())); } catch (LdapException e) { if (e.getResultCode() != ResultCode.NO_SUCH_OBJECT) { if (request.getDeleteEntry()) { logger.info("target entry does not exist, no delete performed for request {}", request); response = new Response<>(null, null); } else { response = add(request, sourceEntry); } else if (request.getDeleteEntry()) { response = delete(request, sourceEntry); } else { response = modify(request, sourceEntry, searchResponse.getResult().getEntry());
@Override public String toString() { return String.format( "[%s@%d::ldapEntry=%s, deleteEntry=%s, searchAttributes=%s, " + "includeAttributes=%s, excludeAttributes=%s, controls=%s, " + "referralHandler=%s, intermediateResponseHandlers=%s]", getClass().getName(), hashCode(), ldapEntry, deleteEntry, Arrays.toString(searchAttrs), Arrays.toString(includeAttrs), Arrays.toString(excludeAttrs), Arrays.toString(getControls()), getReferralHandler(), Arrays.toString(getIntermediateResponseHandlers())); } }
/** * Creates a new merge request. * * @param entry to merge into the LDAP * @param delete whether the supplied entry should be deleted */ public MergeRequest(final LdapEntry entry, final boolean delete) { setEntry(entry); setDeleteEntry(delete); }
/** * Executes a {@link DeleteOperation} for the supplied entry. * * @param request merge request * @param entry to delete from the LDAP * * @return response of the delete operation * * @throws LdapException if an error occurs executing the deleting operation */ protected Response<Void> delete(final MergeRequest request, final LdapEntry entry) throws LdapException { final Response<Void> response; final DeleteOperation delete = new DeleteOperation(getConnection()); response = delete.execute(new DeleteRequest(entry.getDn())); logger.info("delete entry {} for request {}", entry, request); return response; } }
/** * Creates a new merge request. * * @param entry to merge into the LDAP */ public MergeRequest(final LdapEntry entry) { setEntry(entry); }
throws LdapException final LdapEntry sourceEntry = request.getEntry(); final Response<Void> response; final SearchOperation search = new SearchOperation(getConnection()); searchResponse = search.execute( SearchRequest.newObjectScopeSearchRequest(sourceEntry.getDn(), request.getSearchAttributes())); } catch (LdapException e) { if (e.getResultCode() != ResultCode.NO_SUCH_OBJECT) { if (request.getDeleteEntry()) { logger.info("target entry does not exist, no delete performed for request {}", request); response = new Response<>(null, null); } else { response = add(request, sourceEntry); } else if (request.getDeleteEntry()) { response = delete(request, sourceEntry); } else { response = modify(request, sourceEntry, searchResponse.getResult().getEntry());
@Override public String toString() { return String.format( "[%s@%d::ldapEntry=%s, deleteEntry=%s, searchAttributes=%s, " + "includeAttributes=%s, excludeAttributes=%s, controls=%s, " + "referralHandler=%s, intermediateResponseHandlers=%s]", getClass().getName(), hashCode(), ldapEntry, deleteEntry, Arrays.toString(searchAttrs), Arrays.toString(includeAttrs), Arrays.toString(excludeAttrs), Arrays.toString(getControls()), getReferralHandler(), Arrays.toString(getIntermediateResponseHandlers())); } }
/** * Creates a new merge request. * * @param entry to merge into the LDAP * @param delete whether the supplied entry should be deleted */ public MergeRequest(final LdapEntry entry, final boolean delete) { setEntry(entry); setDeleteEntry(delete); }
/** * Executes a {@link DeleteOperation} for the supplied entry. * * @param request merge request * @param entry to delete from the LDAP * * @return response of the delete operation * * @throws LdapException if an error occurs executing the deleting operation */ protected Response<Void> delete(final MergeRequest request, final LdapEntry entry) throws LdapException { final Response<Void> response; final DeleteOperation delete = new DeleteOperation(getConnection()); response = delete.execute(new DeleteRequest(entry.getDn())); logger.info("delete entry {} for request {}", entry, request); return response; } }
/** * Creates a new merge request. * * @param entry to merge into the LDAP */ public MergeRequest(final LdapEntry entry) { setEntry(entry); }
/** * Executes an {@link AddOperation} for the supplied entry. * * @param request merge request * @param entry to add to the LDAP * * @return response of the add operation * * @throws LdapException if an error occurs executing the add operation */ protected Response<Void> add(final MergeRequest request, final LdapEntry entry) throws LdapException { final Response<Void> response; final AddOperation add = new AddOperation(getConnection()); response = add.execute(new AddRequest(entry.getDn(), entry.getAttributes())); logger.info("added entry {} for request {}", entry, request); return response; }
/** * Executes an {@link AddOperation} for the supplied entry. * * @param request merge request * @param entry to add to the LDAP * * @return response of the add operation * * @throws LdapException if an error occurs executing the add operation */ protected Response<Void> add(final MergeRequest request, final LdapEntry entry) throws LdapException { Response<Void> response; final AddOperation add = new AddOperation(getConnection()); response = add.execute(new AddRequest(entry.getDn(), entry.getAttributes())); logger.info("added entry {} for request {}", entry, request); return response; }
/** * Executes an {@link AddOperation} for the supplied entry. * * @param request merge request * @param entry to add to the LDAP * * @return response of the add operation * * @throws LdapException if an error occurs executing the add operation */ protected Response<Void> add(final MergeRequest request, final LdapEntry entry) throws LdapException { final Response<Void> response; final AddOperation add = new AddOperation(getConnection()); response = add.execute(new AddRequest(entry.getDn(), entry.getAttributes())); logger.info("added entry {} for request {}", entry, request); return response; }