From a84cd567d8b2bd67153a1de7c933b1d0985e5d29 Mon Sep 17 00:00:00 2001 From: mkit Date: Tue, 29 Aug 2017 13:41:17 +0100 Subject: [PATCH] Removing Kt suffixed Java class (#1344) --- .../corda/client/jfx/NodeMonitorModelTest.kt | 2 +- .../client/rpc/CordaRPCJavaClientTest.java | 2 +- .../corda/client/rpc/CordaRPCClientTest.kt | 2 +- .../core/flows/ContractUpgradeFlowTest.kt | 2 +- .../corda/docs/IntegrationTestingTutorial.kt | 2 +- .../net/corda/docs/ClientRpcTutorial.kt | 2 +- .../kotlin/net/corda/node/BootTests.kt | 2 +- .../corda/node/CordappScanningDriverTest.kt | 2 +- .../net/corda/node/NodePerformanceTests.kt | 2 +- .../node/services/AdvertisedServiceTests.kt | 1 + .../node/services/DistributedServiceTests.kt | 1 + .../corda/node/internal/CordaRPCOpsImpl.kt | 2 +- .../net/corda/node/services/RPCUserService.kt | 36 +++++++++++++++++-- .../net/corda/node/CordaRPCOpsImplTest.kt | 2 +- .../attachmentdemo/AttachmentDemoTest.kt | 2 +- .../corda/bank/BankOfCordaRPCClientTest.kt | 2 +- .../net/corda/bank/BankOfCordaDriver.kt | 2 +- .../corda/notarydemo/SingleNotaryCordform.kt | 2 +- .../net/corda/traderdemo/TraderDemoTest.kt | 2 +- .../test/kotlin/net/corda/traderdemo/Main.kt | 2 +- .../corda/testing/FlowStackSnapshotTest.kt | 2 +- .../net/corda/explorer/ExplorerSimulation.kt | 2 +- 22 files changed, 54 insertions(+), 22 deletions(-) diff --git a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt index 88f09effcb..83453feddd 100644 --- a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt +++ b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt @@ -26,7 +26,7 @@ import net.corda.finance.flows.CashExitFlow import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashPaymentFlow import net.corda.node.services.network.NetworkMapService -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import net.corda.testing.* diff --git a/client/rpc/src/integration-test/java/net/corda/client/rpc/CordaRPCJavaClientTest.java b/client/rpc/src/integration-test/java/net/corda/client/rpc/CordaRPCJavaClientTest.java index cc55200301..5fd5ec83b3 100644 --- a/client/rpc/src/integration-test/java/net/corda/client/rpc/CordaRPCJavaClientTest.java +++ b/client/rpc/src/integration-test/java/net/corda/client/rpc/CordaRPCJavaClientTest.java @@ -29,7 +29,7 @@ import static kotlin.test.AssertionsKt.assertEquals; import static net.corda.client.rpc.CordaRPCClientConfiguration.getDefault; import static net.corda.finance.CurrencyUtils.DOLLARS; import static net.corda.finance.contracts.GetBalances.getCashBalance; -import static net.corda.node.services.RPCUserServiceKt.startFlowPermission; +import static net.corda.node.services.FlowPermissions.startFlowPermission; import static net.corda.testing.TestConstants.getALICE; public class CordaRPCJavaClientTest extends NodeBasedTest { diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt index 1d11f377fc..6c8a7d7a8c 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt @@ -14,7 +14,7 @@ import net.corda.finance.flows.CashException import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashPaymentFlow import net.corda.node.internal.Node -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.nodeapi.User import net.corda.testing.ALICE diff --git a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt b/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt index 5562d068f3..951f28b9e3 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt +++ b/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt @@ -17,7 +17,7 @@ import net.corda.finance.`issued by` import net.corda.finance.contracts.asset.Cash import net.corda.finance.flows.CashIssueFlow import net.corda.node.internal.CordaRPCOpsImpl -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.nodeapi.User import net.corda.testing.RPCDriverExposedDSLInterface import net.corda.testing.contracts.DummyContract diff --git a/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt b/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt index 629ec3a6ee..288c0015e0 100644 --- a/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt +++ b/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt @@ -11,7 +11,7 @@ import net.corda.finance.DOLLARS import net.corda.finance.contracts.asset.Cash import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashPaymentFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.nodeapi.User import net.corda.testing.* diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt index 25f5653da0..6f6c080322 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt @@ -15,7 +15,7 @@ import net.corda.finance.contracts.asset.Cash import net.corda.finance.flows.CashExitFlow import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashPaymentFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.nodeapi.User import net.corda.testing.ALICE diff --git a/node/src/integration-test/kotlin/net/corda/node/BootTests.kt b/node/src/integration-test/kotlin/net/corda/node/BootTests.kt index 00a64b0926..f1bb21c2d0 100644 --- a/node/src/integration-test/kotlin/net/corda/node/BootTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/BootTests.kt @@ -10,7 +10,7 @@ import net.corda.core.node.services.ServiceType import net.corda.core.utilities.getOrThrow import net.corda.testing.ALICE import net.corda.node.internal.NodeStartup -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.nodeapi.User import net.corda.testing.driver.ListenProcessDeathException import net.corda.testing.driver.NetworkMapStartStrategy diff --git a/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt b/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt index 258c18cfae..2417f1d329 100644 --- a/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt @@ -12,7 +12,7 @@ import net.corda.core.utilities.getOrThrow import net.corda.testing.ALICE import net.corda.testing.BOB import net.corda.core.utilities.unwrap -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.nodeapi.User import net.corda.testing.driver.driver import org.assertj.core.api.Assertions.assertThat diff --git a/node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt b/node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt index e046f83fcc..d1f0a5e480 100644 --- a/node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt @@ -12,7 +12,7 @@ import net.corda.core.utilities.minutes import net.corda.finance.DOLLARS import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashPaymentFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import net.corda.testing.driver.NodeHandle diff --git a/node/src/integration-test/kotlin/net/corda/node/services/AdvertisedServiceTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/AdvertisedServiceTests.kt index 9f422f7e16..204058c519 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/AdvertisedServiceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/AdvertisedServiceTests.kt @@ -6,6 +6,7 @@ import net.corda.core.flows.StartableByRPC import net.corda.core.messaging.startFlow import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceType +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.nodeapi.User import net.corda.testing.driver.driver import org.bouncycastle.asn1.x500.X500Name diff --git a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt index f27972b55a..26442c108c 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt @@ -22,6 +22,7 @@ import org.junit.Test import rx.Observable import java.util.* import kotlin.test.assertEquals +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission class DistributedServiceTests : DriverBasedTest() { lateinit var alice: NodeHandle diff --git a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt index 8b604c0940..79ca9d2f22 100644 --- a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt +++ b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt @@ -21,7 +21,7 @@ import net.corda.core.transactions.SignedTransaction import net.corda.node.services.api.ServiceHubInternal import net.corda.node.services.messaging.getRpcContext import net.corda.node.services.messaging.requirePermission -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.statemachine.FlowStateMachineImpl import net.corda.node.services.statemachine.StateMachineManager import net.corda.node.utilities.CordaPersistence diff --git a/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt b/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt index d1a260a581..2c4ed57754 100644 --- a/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt +++ b/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt @@ -9,6 +9,7 @@ import net.corda.nodeapi.User * to. These permissions are represented as [String]s to allow RPC implementations to add their own permissioning. */ interface RPCUserService { + fun getUser(username: String): User? val users: List } @@ -20,6 +21,35 @@ class RPCUserServiceImpl(override val users: List) : RPCUserService { override fun getUser(username: String): User? = users.find { it.username == username } } -fun startFlowPermission(className: String) = "StartFlow.$className" -fun

> startFlowPermission(clazz: Class

) = startFlowPermission(clazz.name) -inline fun > startFlowPermission(): String = startFlowPermission(P::class.java) +/** + * Helper class for creating flow class permissions. + */ +class FlowPermissions { + companion object { + + /** + * Creates the flow permission string of the format "StartFlow.{ClassName}". + * + * @param className a flow class name for which permission is created. + */ + @JvmStatic + fun startFlowPermission(className: String) = "StartFlow.$className" + + /** + * An overload for the [startFlowPermission] + * + * @param clazz a class for which permission is created. + * + */ + @JvmStatic + fun

> startFlowPermission(clazz: Class

) = startFlowPermission(clazz.name) + + /** + * An overload for the [startFlowPermission]. + * + * @param P a class for which permission is created. + */ + @JvmStatic + inline fun > startFlowPermission(): String = startFlowPermission(P::class.java) + } +} diff --git a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt index cfbcdca61e..158a8ce8b3 100644 --- a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt +++ b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt @@ -25,7 +25,7 @@ import net.corda.node.internal.CordaRPCOpsImpl import net.corda.node.services.messaging.CURRENT_RPC_CONTEXT import net.corda.node.services.messaging.RpcContext import net.corda.node.services.network.NetworkMapService -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.PermissionException import net.corda.nodeapi.User diff --git a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt index b1bea3b8ab..a8e2787c3a 100644 --- a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt +++ b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt @@ -7,7 +7,7 @@ import net.corda.testing.DUMMY_BANK_A import net.corda.testing.DUMMY_BANK_B import net.corda.testing.DUMMY_NOTARY import net.corda.testing.driver.driver -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import org.junit.Test diff --git a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt index c488f9fd32..4df2768692 100644 --- a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt +++ b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt @@ -9,7 +9,7 @@ import net.corda.core.utilities.getOrThrow import net.corda.finance.DOLLARS import net.corda.finance.contracts.asset.Cash import net.corda.finance.flows.CashIssueAndPaymentFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import net.corda.testing.* diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt index a870368417..0f61b602e0 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt @@ -9,7 +9,7 @@ import net.corda.core.utilities.NetworkHostAndPort import net.corda.finance.flows.CashExitFlow import net.corda.finance.flows.CashIssueAndPaymentFlow import net.corda.finance.flows.CashPaymentFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import net.corda.testing.BOC diff --git a/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/SingleNotaryCordform.kt b/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/SingleNotaryCordform.kt index 567bfe03f5..46d1bf0ae6 100644 --- a/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/SingleNotaryCordform.kt +++ b/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/SingleNotaryCordform.kt @@ -6,7 +6,7 @@ import net.corda.testing.ALICE import net.corda.testing.BOB import net.corda.testing.DUMMY_NOTARY import net.corda.demorun.runNodes -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.nodeapi.User import net.corda.notarydemo.flows.DummyIssueAndMove diff --git a/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt b/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt index 0325bc1d5d..7db63b4f77 100644 --- a/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt +++ b/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt @@ -8,7 +8,7 @@ import net.corda.core.utilities.millis import net.corda.finance.DOLLARS import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashPaymentFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import net.corda.testing.BOC diff --git a/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/Main.kt b/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/Main.kt index a6d6d1a5b7..1661b70ad7 100644 --- a/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/Main.kt +++ b/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/Main.kt @@ -3,7 +3,7 @@ package net.corda.traderdemo import net.corda.core.internal.div import net.corda.core.node.services.ServiceInfo import net.corda.finance.flows.CashIssueFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import net.corda.testing.BOC diff --git a/test-utils/src/integration-test/kotlin/net/corda/testing/FlowStackSnapshotTest.kt b/test-utils/src/integration-test/kotlin/net/corda/testing/FlowStackSnapshotTest.kt index 6625b3fa35..b1a1dba4fc 100644 --- a/test-utils/src/integration-test/kotlin/net/corda/testing/FlowStackSnapshotTest.kt +++ b/test-utils/src/integration-test/kotlin/net/corda/testing/FlowStackSnapshotTest.kt @@ -11,7 +11,7 @@ import net.corda.core.internal.read import net.corda.core.messaging.startFlow import net.corda.core.serialization.CordaSerializable import net.corda.jackson.JacksonSupport -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.nodeapi.User import net.corda.testing.driver.driver import org.junit.Ignore diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt index 761af30b0e..3eda29511e 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt @@ -25,7 +25,7 @@ import net.corda.finance.flows.CashExitFlow.ExitRequest import net.corda.finance.flows.CashIssueAndPaymentFlow import net.corda.finance.flows.CashIssueAndPaymentFlow.IssueAndPaymentRequest import net.corda.finance.flows.CashPaymentFlow -import net.corda.node.services.startFlowPermission +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.nodeapi.User import net.corda.testing.ALICE