mirror of
https://github.com/corda/corda.git
synced 2025-05-30 14:14:29 +00:00
Fixes from code review.
This commit is contained in:
parent
a2bf7d4d84
commit
396fc43f11
@ -43,11 +43,11 @@ class ProfileController : Controller() {
|
|||||||
// dialogue has already confirmed that this is OK.
|
// dialogue has already confirmed that this is OK.
|
||||||
target.delete()
|
target.delete()
|
||||||
|
|
||||||
FileSystems.newFileSystem(URI.create("jar:" + target.toURI()), mapOf("create" to "true")).use {
|
FileSystems.newFileSystem(URI.create("jar:" + target.toURI()), mapOf("create" to "true")).use { fs ->
|
||||||
fs -> configs.forEach { it ->
|
configs.forEach { config ->
|
||||||
val nodeDir = Files.createDirectories(fs.getPath(it.key))
|
val nodeDir = Files.createDirectories(fs.getPath(config.key))
|
||||||
val conf = Files.write(nodeDir.resolve("node.conf"), it.toText().toByteArray(UTF_8))
|
val file = Files.write(nodeDir.resolve("node.conf"), config.toText().toByteArray(UTF_8))
|
||||||
log.info("Wrote: $conf")
|
log.info("Wrote: $file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,17 +64,17 @@ class ProfileController : Controller() {
|
|||||||
|
|
||||||
val configs = LinkedList<NodeConfig>()
|
val configs = LinkedList<NodeConfig>()
|
||||||
|
|
||||||
FileSystems.newFileSystem(chosen.toPath(), null).use {
|
FileSystems.newFileSystem(chosen.toPath(), null).use { fs ->
|
||||||
fs -> fs.rootDirectories.forEach {
|
fs.rootDirectories.forEach { root ->
|
||||||
root -> Files.find(root, 2, ConfigAcceptor).forEach {
|
Files.find(root, 2, ConfigAcceptor).forEach { file ->
|
||||||
try {
|
try {
|
||||||
// Java seems to "walk" through the ZIP file backwards.
|
// Java seems to "walk" through the ZIP file backwards.
|
||||||
// So add new config to the front of the list, so that
|
// So add new config to the front of the list, so that
|
||||||
// our final list is ordered to match the file.
|
// our final list is ordered to match the file.
|
||||||
configs.addFirst(toNodeConfig(parse(it)))
|
configs.addFirst(toNodeConfig(parse(file)))
|
||||||
log.info("Loaded: $it")
|
log.info("Loaded: $file")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.severe("Failed to parse '$it': ${e.message}")
|
log.severe("Failed to parse '$file': ${e.message}")
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,22 +118,17 @@ class ProfileController : Controller() {
|
|||||||
private fun Config.parsePort(path: String): Int {
|
private fun Config.parsePort(path: String): Int {
|
||||||
val address = this.getString(path)
|
val address = this.getString(path)
|
||||||
val port = HostAndPort.fromString(address).port
|
val port = HostAndPort.fromString(address).port
|
||||||
if (!nodeController.isPortValid(port)) {
|
require(nodeController.isPortValid(port), { "Invalid port $port from '$path'." })
|
||||||
throw IllegalArgumentException("Invalid port $port from '$path'.")
|
|
||||||
}
|
|
||||||
return port
|
return port
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Config.parseExtraServices(path: String): List<String> {
|
private fun Config.parseExtraServices(path: String): List<String> {
|
||||||
val services = serviceController.services.toSortedSet()
|
val services = serviceController.services.toSortedSet()
|
||||||
return this.getString(path).split(",").filter {
|
return this.getString(path).split(",")
|
||||||
!it.isNullOrEmpty()
|
.filter { svc -> !svc.isNullOrEmpty() }
|
||||||
}.map {
|
.map { svc ->
|
||||||
if (!services.contains(it)) {
|
require(svc in services, { "Unknown service '$svc'." } )
|
||||||
throw IllegalArgumentException("Unknown service '$it'.")
|
svc
|
||||||
} else {
|
}.toList()
|
||||||
it
|
|
||||||
}
|
|
||||||
}.toList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class R3Pty(val name: String, settings: SettingsProvider, dimension: Dimension,
|
|||||||
|
|
||||||
val environment = HashMap<String, String>(envs)
|
val environment = HashMap<String, String>(envs)
|
||||||
if (!UIUtil.isWindows) {
|
if (!UIUtil.isWindows) {
|
||||||
environment.put("TERM", "xterm")
|
environment["TERM"] = "xterm"
|
||||||
}
|
}
|
||||||
|
|
||||||
val connector = createTtyConnector(args, environment, workingDir)
|
val connector = createTtyConnector(args, environment, workingDir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user