@Override public boolean activate(final Connection c) { boolean success = false; if (c != null) { try { c.open(); success = true; } catch (Exception e) { logger.error("unable to connect to the ldap", e); } } return success; } }
@Override public boolean activate(final Connection c) { boolean success = false; if (c != null) { try { c.open(); success = true; } catch (Exception e) { logger.error("unable to connect to the ldap", e); } } return success; } }
@Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
@Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
@Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
@Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
@Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
@Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
@Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
/** * Create and open a connection to ldap * via the given config and provider. * * @return the connection * @throws LdapException the ldap exception */ protected Connection createConnection() throws LdapException { logger.debug("Establishing a connection..."); final Connection connection = this.connectionFactory.getConnection(); connection.open(); return connection; }
/** * Retrieve a connection that is ready for use. * * @return connection * * @throws LdapException if an error occurs opening the connection */ @Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
/** * Retrieve a connection that is ready for use. * * @return connection * * @throws LdapException if an error occurs opening the connection */ @Override protected Connection getConnection() throws LdapException { final Connection conn = factory.getConnection(); conn.open(); return conn; }
@Override public Response<S> call() throws LdapException { try { conn.open(); return operation.execute(request); } finally { conn.close(); } } };
@Override public Response<S> call() throws LdapException { try { conn.open(); return operation.execute(request); } finally { conn.close(); } } };
@Override public Collection<Response<S>> call() throws LdapException { try { conn.open(); return worker.executeToCompletion(requests); } finally { conn.close(); } } };
/** * Gets connection from the factory. * Opens the connection if needed. * * @param connectionFactory the connection factory * @return the connection * @throws LdapException the ldap exception */ public static Connection createConnection(final ConnectionFactory connectionFactory) throws LdapException { final Connection c = connectionFactory.getConnection(); if (!c.isOpen()) { c.open(); } return c; }
@Override public Response<Void> delete(final T object) throws LdapException { final String dn = getLdapEntryMapper().mapDn(object); final DeleteRequest request = new DeleteRequest(dn); try (Connection conn = getConnectionFactory().getConnection()) { conn.open(); final DeleteOperation delete = new DeleteOperation(conn); return delete.execute(request); } } }
@Override protected void deleteById(final String id) { Connection connection = null; try { connection = connectionFactory.getConnection(); connection.open(); final DeleteOperation delete = new DeleteOperation(connection); delete.execute(new DeleteRequest(getIdAttribute() + "=" + id + "," + usersDn)); } catch (final LdapException e) { throw new TechnicalException(e); } finally { if (connection != null) { connection.close(); } } }
@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); } }
@Override public Response<Void> add(final T object) throws LdapException { final LdapEntry entry = new LdapEntry(); getLdapEntryMapper().map(object, entry); final AddRequest request = new AddRequest(entry.getDn(), entry.getAttributes()); try (Connection conn = getConnectionFactory().getConnection()) { conn.open(); final AddOperation add = new AddOperation(conn); return add.execute(request); } }