Search in sources :

Example 1 with ConfigurationException

use of io.jans.orm.exception.operation.ConfigurationException in project jans by JanssenProject.

the class CouchbaseEntryManagerFactory method createEntryManager.

@Override
public CouchbaseEntryManager createEntryManager(Properties conf) {
    Properties entryManagerConf = PropertiesHelper.filterProperties(conf, "#");
    // Allow proper initialization
    if (this.couchbaseConnectionProperties == null) {
        this.couchbaseConnectionProperties = entryManagerConf;
    }
    init();
    if (!isInitialized()) {
        throw new ConfigurationException("Failed to create Couchbase environment!");
    }
    CouchbaseConnectionProvider connectionProvider = new CouchbaseConnectionProvider(entryManagerConf, couchbaseEnvironment);
    connectionProvider.create();
    if (!connectionProvider.isCreated()) {
        throw new ConfigurationException(String.format("Failed to create Couchbase connection pool! Result code: '%s'", connectionProvider.getCreationResultCode()));
    }
    LOG.debug("Created connectionProvider '{}' with code '{}'", connectionProvider, connectionProvider.getCreationResultCode());
    CouchbaseEntryManager couchbaseEntryManager = new CouchbaseEntryManager(new CouchbaseOperationServiceImpl(entryManagerConf, connectionProvider));
    LOG.info("Created CouchbaseEntryManager: {}", couchbaseEntryManager.getOperationService());
    return couchbaseEntryManager;
}
Also used : ConfigurationException(io.jans.orm.exception.operation.ConfigurationException) CouchbaseConnectionProvider(io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider) Properties(java.util.Properties) CouchbaseOperationServiceImpl(io.jans.orm.couchbase.operation.impl.CouchbaseOperationServiceImpl)

Example 2 with ConfigurationException

use of io.jans.orm.exception.operation.ConfigurationException in project jans by JanssenProject.

the class StandalonePersistanceFactoryService method createPersistenceEntryManagerFactoryImpl.

private PersistenceEntryManagerFactory createPersistenceEntryManagerFactoryImpl(Class<? extends PersistenceEntryManagerFactory> persistenceEntryManagerFactoryClass) {
    PersistenceEntryManagerFactory persistenceEntryManagerFactory;
    try {
        persistenceEntryManagerFactory = ReflectHelper.createObjectByDefaultConstructor(persistenceEntryManagerFactoryClass);
        persistenceEntryManagerFactory.initStandalone(this);
    } catch (PropertyNotFoundException | IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
        throw new ConfigurationException(String.format("Failed to create PersistenceEntryManagerFactory by type '%s'!", persistenceEntryManagerFactoryClass));
    }
    return persistenceEntryManagerFactory;
}
Also used : PropertyNotFoundException(io.jans.orm.exception.PropertyNotFoundException) ConfigurationException(io.jans.orm.exception.operation.ConfigurationException) PersistenceEntryManagerFactory(io.jans.orm.PersistenceEntryManagerFactory) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with ConfigurationException

use of io.jans.orm.exception.operation.ConfigurationException in project jans by JanssenProject.

the class SqlEntryManagerFactory method createEntryManager.

@Override
public SqlEntryManager createEntryManager(Properties conf) {
    Properties entryManagerConf = PropertiesHelper.filterProperties(conf, "#");
    SqlConnectionProvider connectionProvider = new SqlConnectionProvider(entryManagerConf);
    connectionProvider.create();
    if (!connectionProvider.isCreated()) {
        throw new ConfigurationException(String.format("Failed to create SQL connection pool! Result code: '%s'", connectionProvider.getCreationResultCode()));
    }
    LOG.debug("Created connectionProvider '{}' with code '{}'", connectionProvider, connectionProvider.getCreationResultCode());
    SqlEntryManager sqlEntryManager = new SqlEntryManager(new SqlOperationServiceImpl(entryManagerConf, connectionProvider));
    LOG.info("Created SqlEntryManager: {}", sqlEntryManager.getOperationService());
    return sqlEntryManager;
}
Also used : SqlConnectionProvider(io.jans.orm.sql.operation.impl.SqlConnectionProvider) ConfigurationException(io.jans.orm.exception.operation.ConfigurationException) SqlOperationServiceImpl(io.jans.orm.sql.operation.impl.SqlOperationServiceImpl) Properties(java.util.Properties)

Example 4 with ConfigurationException

use of io.jans.orm.exception.operation.ConfigurationException in project jans by JanssenProject.

the class LdapEntryManagerFactory method createEntryManager.

@Override
public LdapEntryManager createEntryManager(Properties conf) {
    Properties entryManagerConf = PropertiesHelper.filterProperties(conf, "#");
    LdapConnectionProvider connectionProvider = new LdapConnectionProvider(entryManagerConf);
    connectionProvider.create();
    if (!connectionProvider.isCreated()) {
        throw new ConfigurationException(String.format("Failed to create LDAP connection pool! Result code: '%s'", connectionProvider.getCreationResultCode()));
    }
    LOG.debug("Created connectionProvider '{}' with code '{}'", connectionProvider, connectionProvider.getCreationResultCode());
    LdapConnectionProvider bindConnectionProvider = new LdapAuthConnectionProvider(entryManagerConf);
    connectionProvider.create();
    if (!bindConnectionProvider.isCreated()) {
        throw new ConfigurationException(String.format("Failed to create LDAP bind connection pool! Result code: '%s'", bindConnectionProvider.getCreationResultCode()));
    }
    LOG.debug("Created bindConnectionProvider '{}' with code '{}'", bindConnectionProvider, bindConnectionProvider.getCreationResultCode());
    LdapEntryManager ldapEntryManager = new LdapEntryManager(new LdapOperationServiceImpl(connectionProvider, bindConnectionProvider));
    LOG.info("Created LdapEntryManager: {}", ldapEntryManager.getOperationService());
    return ldapEntryManager;
}
Also used : ConfigurationException(io.jans.orm.exception.operation.ConfigurationException) LdapConnectionProvider(io.jans.orm.ldap.operation.impl.LdapConnectionProvider) LdapAuthConnectionProvider(io.jans.orm.ldap.operation.impl.LdapAuthConnectionProvider) LdapOperationServiceImpl(io.jans.orm.ldap.operation.impl.LdapOperationServiceImpl) Properties(java.util.Properties)

Example 5 with ConfigurationException

use of io.jans.orm.exception.operation.ConfigurationException in project jans by JanssenProject.

the class HybridEntryManagerFactory method createEntryManager.

@Override
public HybridEntryManager createEntryManager(Properties conf) {
    HashMap<String, PersistenceEntryManager> persistenceEntryManagers = new HashMap<String, PersistenceEntryManager>();
    List<PersistenceOperationService> operationServices = new ArrayList<PersistenceOperationService>();
    if (persistenceTypes == null) {
        Properties hybridProperties = PropertiesHelper.findProperties(conf, PERSISTENCE_TYPE, "#");
        hybridProperties = PropertiesHelper.filterProperties(hybridProperties, "#");
        String storagesList = hybridProperties.getProperty("storages", null);
        if (StringHelper.isEmpty(storagesList)) {
            throw new ConfigurationException("'storages' key not exists or value is empty!");
        }
        this.persistenceTypes = StringHelper.split(storagesList, ",");
    }
    for (String persistenceType : persistenceTypes) {
        PersistenceEntryManagerFactory persistenceEntryManagerFactory = persistanceFactoryService.getPersistenceEntryManagerFactory(persistenceType);
        if (persistenceEntryManagerFactory == null) {
            throw new ConfigurationException(String.format("Unable to get Persistence Entry Manager Factory by type '%s'", persistenceType));
        }
        Properties entryManagerConf = PropertiesHelper.findProperties(conf, persistenceType, "#");
        PersistenceEntryManager persistenceEntryManager = persistenceEntryManagerFactory.createEntryManager(entryManagerConf);
        persistenceEntryManagers.put(persistenceType, persistenceEntryManager);
        operationServices.add(persistenceEntryManager.getOperationService());
    }
    this.hybridMappingProperties = PropertiesHelper.filterProperties(conf, "#");
    HybridPersistenceOperationService hybridOperationService = new HybridPersistenceOperationService(operationServices);
    HybridEntryManager hybridEntryManager = new HybridEntryManager(hybridMappingProperties, persistenceEntryManagers, hybridOperationService);
    LOG.info("Created HybridEntryManager: {}", hybridOperationService);
    return hybridEntryManager;
}
Also used : PersistenceEntryManager(io.jans.orm.PersistenceEntryManager) HashMap(java.util.HashMap) ConfigurationException(io.jans.orm.exception.operation.ConfigurationException) ArrayList(java.util.ArrayList) PersistenceEntryManagerFactory(io.jans.orm.PersistenceEntryManagerFactory) PersistenceOperationService(io.jans.orm.operation.PersistenceOperationService) Properties(java.util.Properties)

Aggregations

ConfigurationException (io.jans.orm.exception.operation.ConfigurationException)10 Properties (java.util.Properties)7 PersistenceEntryManagerFactory (io.jans.orm.PersistenceEntryManagerFactory)3 HashMap (java.util.HashMap)2 BindRequest (com.unboundid.ldap.sdk.BindRequest)1 FailoverServerSet (com.unboundid.ldap.sdk.FailoverServerSet)1 GetEntryLDAPConnectionPoolHealthCheck (com.unboundid.ldap.sdk.GetEntryLDAPConnectionPoolHealthCheck)1 LDAPConnectionOptions (com.unboundid.ldap.sdk.LDAPConnectionOptions)1 SimpleBindRequest (com.unboundid.ldap.sdk.SimpleBindRequest)1 SSLUtil (com.unboundid.util.ssl.SSLUtil)1 TrustAllTrustManager (com.unboundid.util.ssl.TrustAllTrustManager)1 TrustStoreTrustManager (com.unboundid.util.ssl.TrustStoreTrustManager)1 PersistenceEntryManager (io.jans.orm.PersistenceEntryManager)1 SpannerConnectionProvider (io.jans.orm.cloud.spanner.operation.impl.SpannerConnectionProvider)1 SpannerOperationServiceImpl (io.jans.orm.cloud.spanner.operation.impl.SpannerOperationServiceImpl)1 CouchbaseConnectionProvider (io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider)1 CouchbaseOperationServiceImpl (io.jans.orm.couchbase.operation.impl.CouchbaseOperationServiceImpl)1 KeyConversionException (io.jans.orm.exception.KeyConversionException)1 PropertyNotFoundException (io.jans.orm.exception.PropertyNotFoundException)1 ConnectionException (io.jans.orm.exception.operation.ConnectionException)1