Search in sources :

Example 1 with PersistenceOperationService

use of org.gluu.persist.operation.PersistenceOperationService in project oxTrust by GluuFederation.

the class LdifService method importLdifFileInLdap.

public ResultCode importLdifFileInLdap(Class<?> entryClass, InputStream is) throws LDAPException {
    if (dataSourceTypeService.isLDAP(attributeService.getDnForAttribute(null))) {
        ResultCode result = ResultCode.UNAVAILABLE;
        PersistenceOperationService persistenceOperationService = persistenceManager.getOperationService();
        LdapOperationService ldapOperationService = (LdapOperationService) persistenceOperationService;
        LDAPConnection connection = ldapOperationService.getConnection();
        try {
            LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
            LDIFReader importLdifReader = new LDIFReader(is);
            result = ldifDataUtility.importLdifFile(connection, importLdifReader);
            importLdifReader.close();
        } catch (Exception ex) {
            log.error("Failed to import ldif file: ", ex);
        } finally {
            ldapOperationService.releaseConnection(connection);
        }
        return result;
    } else {
        performImport(entryClass, is);
        return ResultCode.SUCCESS;
    }
}
Also used : LdapOperationService(org.gluu.persist.ldap.operation.LdapOperationService) LDIFReader(com.unboundid.ldif.LDIFReader) PersistenceOperationService(org.gluu.persist.operation.PersistenceOperationService) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) LdifDataUtility(org.gluu.persist.ldap.impl.LdifDataUtility) ResultCode(com.unboundid.ldap.sdk.ResultCode) IOException(java.io.IOException) LDAPException(com.unboundid.ldap.sdk.LDAPException)

Example 2 with PersistenceOperationService

use of org.gluu.persist.operation.PersistenceOperationService in project oxAuth by GluuFederation.

the class LdapStatusTimer method logConnectionProviderStatistic.

public void logConnectionProviderStatistic(PersistenceEntryManager ldapEntryManager, String connectionProviderName, String bindConnectionProviderName) {
    PersistenceOperationService persistenceOperationService = ldapEntryManager.getOperationService();
    if (!(persistenceOperationService instanceof LdapOperationService)) {
        return;
    }
    LdapConnectionProvider ldapConnectionProvider = ((LdapOperationService) persistenceOperationService).getConnectionProvider();
    LdapConnectionProvider bindLdapConnectionProvider = ((LdapOperationService) persistenceOperationService).getBindConnectionProvider();
    if (ldapConnectionProvider == null) {
        log.error("{} is empty", connectionProviderName);
    } else {
        if (ldapConnectionProvider.getConnectionPool() == null) {
            log.error("{} is empty", connectionProviderName);
        } else {
            log.info("{} statistics: {}", connectionProviderName, ldapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
        }
    }
    if (bindLdapConnectionProvider == null) {
        log.error("{} is empty", bindConnectionProviderName);
    } else {
        if (bindLdapConnectionProvider.getConnectionPool() == null) {
            log.error("{} is empty", bindConnectionProviderName);
        } else {
            log.info("{} statistics: {}", bindConnectionProviderName, bindLdapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
        }
    }
}
Also used : LdapOperationService(org.gluu.persist.ldap.operation.LdapOperationService) LdapConnectionProvider(org.gluu.persist.ldap.operation.impl.LdapConnectionProvider) PersistenceOperationService(org.gluu.persist.operation.PersistenceOperationService)

Example 3 with PersistenceOperationService

use of org.gluu.persist.operation.PersistenceOperationService in project oxTrust by GluuFederation.

the class CacheRefreshTimer method toLdapProperties.

private Properties toLdapProperties(PersistenceEntryManagerFactory ldapEntryManagerFactory, GluuLdapConfiguration ldapConfiguration) {
    String persistenceType = ldapEntryManagerFactory.getPersistenceType();
    Properties ldapProperties = new Properties();
    ldapProperties.put(persistenceType + "#servers", PropertyUtil.simplePropertiesToCommaSeparatedList(ldapConfiguration.getServers()));
    ldapProperties.put(persistenceType + "#maxconnections", Integer.toString(ldapConfiguration.getMaxConnections()));
    ldapProperties.put(persistenceType + "#useSSL", Boolean.toString(ldapConfiguration.isUseSSL()));
    ldapProperties.put(persistenceType + "#bindDN", ldapConfiguration.getBindDN());
    ldapProperties.put(persistenceType + "#bindPassword", ldapConfiguration.getBindPassword());
    // Copy binary attributes list from main LDAP connection
    PersistenceOperationService persistenceOperationService = ldapEntryManager.getOperationService();
    if (persistenceOperationService instanceof LdapOperationService) {
        ldapProperties.put(persistenceType + "#binaryAttributes", PropertyUtil.stringsToCommaSeparatedList(((LdapOperationService) persistenceOperationService).getConnectionProvider().getBinaryAttributes()));
    }
    return ldapProperties;
}
Also used : LdapOperationService(org.gluu.persist.ldap.operation.LdapOperationService) PersistenceOperationService(org.gluu.persist.operation.PersistenceOperationService) Properties(java.util.Properties)

Example 4 with PersistenceOperationService

use of org.gluu.persist.operation.PersistenceOperationService in project oxTrust by GluuFederation.

the class PersistanceStatusTimer method logConnectionProviderStatistic.

public void logConnectionProviderStatistic(PersistenceEntryManager ldapEntryManager, String connectionProviderName) {
    PersistenceOperationService persistenceOperationService = ldapEntryManager.getOperationService();
    if (!(persistenceOperationService instanceof LdapEntryManager)) {
        return;
    }
    LdapConnectionProvider ldapConnectionProvider = (LdapConnectionProvider) persistenceOperationService;
    if (ldapConnectionProvider == null) {
        log.error("{} is empty", connectionProviderName);
    } else {
        if (ldapConnectionProvider.getConnectionPool() == null) {
            log.error("{} is empty", connectionProviderName);
        } else {
            log.debug("{} statistics: {}", connectionProviderName, ldapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
        }
    }
}
Also used : LdapEntryManager(org.gluu.persist.ldap.impl.LdapEntryManager) LdapConnectionProvider(org.gluu.persist.ldap.operation.impl.LdapConnectionProvider) PersistenceOperationService(org.gluu.persist.operation.PersistenceOperationService)

Aggregations

PersistenceOperationService (org.gluu.persist.operation.PersistenceOperationService)4 LdapOperationService (org.gluu.persist.ldap.operation.LdapOperationService)3 LdapConnectionProvider (org.gluu.persist.ldap.operation.impl.LdapConnectionProvider)2 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 ResultCode (com.unboundid.ldap.sdk.ResultCode)1 LDIFReader (com.unboundid.ldif.LDIFReader)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 LdapEntryManager (org.gluu.persist.ldap.impl.LdapEntryManager)1 LdifDataUtility (org.gluu.persist.ldap.impl.LdifDataUtility)1