Search in sources :

Example 1 with GraphDatabaseDependencies

use of org.neo4j.graphdb.facade.GraphDatabaseDependencies in project neo4j by neo4j.

the class AbstractInProcessNeo4jBuilder method build.

@Override
public InProcessNeo4j build() {
    Path userLogFile = serverFolder.resolve("neo4j.log");
    Path internalLogFile = serverFolder.resolve("debug.log");
    config.set(ServerSettings.third_party_packages, unmanagedExtentions.toList());
    config.set(GraphDatabaseSettings.store_internal_log_path, internalLogFile.toAbsolutePath());
    var certificates = serverFolder.resolve("certificates");
    if (disabledServer) {
        config.set(HttpConnector.enabled, false);
        config.set(HttpsConnector.enabled, false);
    }
    Config dbConfig = config.build();
    if (dbConfig.get(HttpsConnector.enabled) || dbConfig.get(BoltConnector.enabled) && dbConfig.get(BoltConnector.encryption_level) != BoltConnector.EncryptionLevel.DISABLED) {
        SelfSignedCertificateFactory.create(certificates);
        List<SslPolicyConfig> policies = List.of(SslPolicyConfig.forScope(HTTPS), SslPolicyConfig.forScope(BOLT));
        for (SslPolicyConfig policy : policies) {
            config.set(policy.enabled, Boolean.TRUE);
            config.set(policy.base_directory, certificates);
            config.set(policy.trust_all, true);
            config.set(policy.client_auth, ClientAuth.NONE);
        }
        dbConfig = config.build();
    }
    Neo4jLoggerContext loggerContext = LogConfig.createBuilder(new DefaultFileSystemAbstraction(), userLogFile, Level.INFO).withTimezone(dbConfig.get(db_timezone)).build();
    var userLogProvider = new Log4jLogProvider(loggerContext);
    GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(userLogProvider);
    dependencies = dependencies.extensions(buildExtensionList(dependencies));
    var managementService = createNeo(dbConfig, dependencies);
    InProcessNeo4j controls = new InProcessNeo4j(serverFolder, userLogFile, internalLogFile, managementService, dbConfig, userLogProvider);
    controls.start();
    try {
        fixtures.applyTo(controls);
    } catch (Exception e) {
        controls.close();
        throw e;
    }
    return controls;
}
Also used : Path(java.nio.file.Path) SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) Neo4jLoggerContext(org.neo4j.logging.log4j.Neo4jLoggerContext) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) Config(org.neo4j.configuration.Config) LogConfig(org.neo4j.logging.log4j.LogConfig) Log4jLogProvider(org.neo4j.logging.log4j.Log4jLogProvider) GraphDatabaseDependencies(org.neo4j.graphdb.facade.GraphDatabaseDependencies) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Config (org.neo4j.configuration.Config)1 SslPolicyConfig (org.neo4j.configuration.ssl.SslPolicyConfig)1 GraphDatabaseDependencies (org.neo4j.graphdb.facade.GraphDatabaseDependencies)1 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)1 Log4jLogProvider (org.neo4j.logging.log4j.Log4jLogProvider)1 LogConfig (org.neo4j.logging.log4j.LogConfig)1 Neo4jLoggerContext (org.neo4j.logging.log4j.Neo4jLoggerContext)1