mirror of
https://github.com/corda/corda.git
synced 2025-05-31 22:50:53 +00:00
Address comments
This commit is contained in:
parent
4e9d1f1924
commit
f884d112c3
@ -63,7 +63,7 @@ class InitialRegistration(val baseDirectory: Path, private val networkRootTrustS
|
|||||||
|
|
||||||
private val nodeRegistration = NodeRegistrationOption(networkRootTrustStorePath, networkRootTrustStorePassword)
|
private val nodeRegistration = NodeRegistrationOption(networkRootTrustStorePath, networkRootTrustStorePassword)
|
||||||
|
|
||||||
private val EXISTING_STATE_GENERIC_WARNING = "Please ensure there is no state from previous runs, before initiating registration of a node."
|
private val EXISTING_STATE_GENERIC_WARNING = "Initial registration can only be run on a new, clean node."
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
fun registerWithNetwork(conf: NodeConfiguration) {
|
fun registerWithNetwork(conf: NodeConfiguration) {
|
||||||
@ -96,17 +96,11 @@ class InitialRegistration(val baseDirectory: Path, private val networkRootTrustS
|
|||||||
val artemisDirectory = baseDirectory / "artemis"
|
val artemisDirectory = baseDirectory / "artemis"
|
||||||
check(!artemisDirectory.exists()) { "The node folder contains an artemis directory. $EXISTING_STATE_GENERIC_WARNING" }
|
check(!artemisDirectory.exists()) { "The node folder contains an artemis directory. $EXISTING_STATE_GENERIC_WARNING" }
|
||||||
val brokersDirectory = baseDirectory / "brokers"
|
val brokersDirectory = baseDirectory / "brokers"
|
||||||
check(!brokersDirectory.exists()) { "There node folder contains a brokers directory. $EXISTING_STATE_GENERIC_WARNING" }
|
check(!brokersDirectory.exists()) { "The node folder contains a brokers directory. $EXISTING_STATE_GENERIC_WARNING" }
|
||||||
|
|
||||||
val datasourceProps = conf.dataSourceProperties
|
|
||||||
if (datasourceProps.isEmpty) throw IllegalStateException("There must be a database configured.")
|
|
||||||
val datasourceUrl = datasourceProps.getProperty("dataSource.url")
|
|
||||||
val datasourceUser = datasourceProps.getProperty("dataSource.user")
|
|
||||||
val datasourcePassword = datasourceProps.getProperty("dataSource.password")
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val connection = DriverManager.getConnection(datasourceUrl, datasourceUser, datasourcePassword)
|
val datasource = DataSourceFactory.createDataSource(conf.dataSourceProperties, false)
|
||||||
val connectionMetadata = connection.metaData
|
val connectionMetadata = datasource.connection.metaData
|
||||||
// Accounting for different case-sensitivity behaviours (i.e. H2 creates tables in upper-case in some cases)
|
// Accounting for different case-sensitivity behaviours (i.e. H2 creates tables in upper-case in some cases)
|
||||||
val tablesLowerCaseResultSet = connectionMetadata.getTables(null, null, "$NODE_DATABASE_PREFIX%", null)
|
val tablesLowerCaseResultSet = connectionMetadata.getTables(null, null, "$NODE_DATABASE_PREFIX%", null)
|
||||||
val tablesUpperCaseResultSet = connectionMetadata.getTables(null, null, "${NODE_DATABASE_PREFIX.toUpperCase()}%", null)
|
val tablesUpperCaseResultSet = connectionMetadata.getTables(null, null, "${NODE_DATABASE_PREFIX.toUpperCase()}%", null)
|
||||||
@ -114,7 +108,7 @@ class InitialRegistration(val baseDirectory: Path, private val networkRootTrustS
|
|||||||
"The database contains Corda-specific tables, while it should be empty. $EXISTING_STATE_GENERIC_WARNING"
|
"The database contains Corda-specific tables, while it should be empty. $EXISTING_STATE_GENERIC_WARNING"
|
||||||
}
|
}
|
||||||
} catch (exception: SQLException) {
|
} catch (exception: SQLException) {
|
||||||
throw Exception("An error occurred whilst connecting to \"$datasourceUrl\". ", exception)
|
throw Exception("An error occurred whilst connecting to \"${conf.dataSourceProperties.getProperty("dataSource.url")}\". ", exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user