Skip to content

Commit

Permalink
fix: set empty neo4j settings to non empty default values so that the…
Browse files Browse the repository at this point in the history
…y appear in the setting view in local mode
  • Loading branch information
ClemDoum committed Jan 19, 2024
1 parent abf9078 commit 8962af2
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/main/java/org/icij/datashare/Neo4jResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,20 @@ public class Neo4jResource implements AutoCloseable {
"Name of the single project which will be able to user the extension when using neo4j"
+ " Community Edition"
),
List.of("neo4jHost", "neo4j", "Hostname of the neo4j DB."),
List.of("neo4jHost", "127.0.0.1", "Hostname of the neo4j DB."),
List.of("neo4jPort", 7687, "Port of the neo4j DB."),
List.of(
"neo4jUriScheme",
"",
"bolt",
"URI scheme used to connect to the neo4j DB (can be: bolt, neo4j, bolt+s, neo4j+s,"
+ " ....)"
),
List.of("neo4jUser", "", "User name used to connect to the neo4j DB"),
List.of("neo4jPassword", "", "Password used to connect to the neo4j DB"),
List.of("neo4jUser", "neo4j", "User name used to connect to the neo4j DB"),
List.of(
"neo4jPassword",
"please-change-this-password",
"Password used to connect to the neo4j DB"
),
List.of(
TASK_POLL_INTERVAL_S,
2,
Expand Down Expand Up @@ -226,10 +230,11 @@ protected void startServerProcess(boolean forceMigrations) {
logger.debug("Copying Datashare properties to temporary location {}",
lazy(propertiesFile::getAbsolutePath));

Properties setProperties = filterUnset(this.propertiesProvider.getProperties());

try {
this.propertiesProvider
.getProperties()
.store(Files.newOutputStream(propertiesFile.toPath().toAbsolutePath()), null);
setProperties.store(
Files.newOutputStream(propertiesFile.toPath().toAbsolutePath()), null);
} catch (IOException e) {
throw new RuntimeException("Failed to write properties in temporary location", e);
}
Expand Down Expand Up @@ -306,6 +311,7 @@ protected void startServerProcess(boolean forceMigrations) {
}
}


protected boolean supportsNeo4jEnterprise() {
checkNeo4jAppStarted();
synchronized (Neo4jResource.class) {
Expand Down Expand Up @@ -613,6 +619,16 @@ private long getDocumentNodesLimit() {
.orElse(NEO4J_DEFAULT_DUMPED_DOCUMENTS);
}

static Properties filterUnset(Properties properties) {
Properties filtered = new Properties(properties.size());
properties.forEach((key, value) -> {
if (!((String) value).isEmpty()) {
filtered.setProperty(key.toString(), value.toString());
}
});
return filtered;
}

@Override
public void close() throws Exception {
this.client.close();
Expand Down

0 comments on commit 8962af2

Please sign in to comment.