From 21cb1bf6f31ef3ac83ed69b03cb94a17318d2d28 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Fri, 22 Sep 2017 16:03:24 +0100 Subject: [PATCH] Moved the RPC classes in node-api that are needed in client-rpc. (#1610) Everything that now remains in node-api isn't needed as public API for app developers so we can mark this module as non-public and subject to change. --- .../corda/client/rpc/PermissionException.kt | 10 +++++++++ .../net/corda/client/rpc/RPCException.kt | 11 ++++++++++ .../net/corda/client/rpc/RPCSinceVersion.kt | 6 +++++ .../corda/client/rpc/internal/RPCClient.kt | 2 +- .../rpc/internal/RPCClientProxyHandler.kt | 2 ++ .../rpc/ClientRPCInfrastructureTests.kt | 1 - .../corda/client/rpc/RPCPermissionsTests.kt | 1 - docs/source/changelog.rst | 2 ++ .../kotlin/net/corda/nodeapi/RPCStructures.kt | 22 ------------------- .../amqp/SerializationOutputTests.kt | 2 +- .../node/services/messaging/RPCServer.kt | 1 + .../services/messaging/RPCServerStructures.kt | 2 +- .../net/corda/node/CordaRPCOpsImplTest.kt | 2 +- 13 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 client/rpc/src/main/kotlin/net/corda/client/rpc/PermissionException.kt create mode 100644 client/rpc/src/main/kotlin/net/corda/client/rpc/RPCException.kt create mode 100644 client/rpc/src/main/kotlin/net/corda/client/rpc/RPCSinceVersion.kt diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/PermissionException.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/PermissionException.kt new file mode 100644 index 0000000000..0498801989 --- /dev/null +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/PermissionException.kt @@ -0,0 +1,10 @@ +package net.corda.client.rpc + +import net.corda.core.serialization.CordaSerializable + +/** + * Thrown to indicate that the calling user does not have permission for something they have requested (for example + * calling a method). + */ +@CordaSerializable +class PermissionException(msg: String) : RuntimeException(msg) diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/RPCException.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/RPCException.kt new file mode 100644 index 0000000000..32ea9928be --- /dev/null +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/RPCException.kt @@ -0,0 +1,11 @@ +package net.corda.client.rpc + +import net.corda.core.CordaRuntimeException + +/** + * Thrown to indicate a fatal error in the RPC system itself, as opposed to an error generated by the invoked + * method. + */ +open class RPCException(message: String?, cause: Throwable?) : CordaRuntimeException(message, cause) { + constructor(msg: String) : this(msg, null) +} diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/RPCSinceVersion.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/RPCSinceVersion.kt new file mode 100644 index 0000000000..262d009427 --- /dev/null +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/RPCSinceVersion.kt @@ -0,0 +1,6 @@ +package net.corda.client.rpc + +/** Records the protocol version in which this RPC was added. */ +@Target(AnnotationTarget.FUNCTION) +@MustBeDocumented +annotation class RPCSinceVersion(val version: Int) diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt index cca836d858..f0fc941668 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt @@ -1,5 +1,6 @@ package net.corda.client.rpc.internal +import net.corda.client.rpc.RPCException import net.corda.core.crypto.random63BitValue import net.corda.core.internal.logElapsedTime import net.corda.core.messaging.RPCOps @@ -12,7 +13,6 @@ import net.corda.core.utilities.seconds import net.corda.nodeapi.ArtemisTcpTransport.Companion.tcpTransport import net.corda.nodeapi.ConnectionDirection import net.corda.nodeapi.RPCApi -import net.corda.nodeapi.RPCException import net.corda.nodeapi.config.SSLConfiguration import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.api.core.TransportConfiguration diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt index e0a0c21ca0..10e901eb70 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt @@ -10,6 +10,8 @@ import com.google.common.cache.RemovalCause import com.google.common.cache.RemovalListener import com.google.common.util.concurrent.SettableFuture import com.google.common.util.concurrent.ThreadFactoryBuilder +import net.corda.client.rpc.RPCException +import net.corda.client.rpc.RPCSinceVersion import net.corda.core.crypto.random63BitValue import net.corda.core.internal.LazyPool import net.corda.core.internal.LazyStickyPool diff --git a/client/rpc/src/test/kotlin/net/corda/client/rpc/ClientRPCInfrastructureTests.kt b/client/rpc/src/test/kotlin/net/corda/client/rpc/ClientRPCInfrastructureTests.kt index e798438fa7..3502145ae0 100644 --- a/client/rpc/src/test/kotlin/net/corda/client/rpc/ClientRPCInfrastructureTests.kt +++ b/client/rpc/src/test/kotlin/net/corda/client/rpc/ClientRPCInfrastructureTests.kt @@ -7,7 +7,6 @@ import net.corda.core.internal.concurrent.thenMatch import net.corda.core.messaging.RPCOps import net.corda.core.utilities.getOrThrow import net.corda.node.services.messaging.getRpcContext -import net.corda.nodeapi.RPCSinceVersion import net.corda.testing.RPCDriverExposedDSLInterface import net.corda.testing.rpcDriver import net.corda.testing.rpcTestUser diff --git a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPermissionsTests.kt b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPermissionsTests.kt index f31469bcb4..4411bbfd07 100644 --- a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPermissionsTests.kt +++ b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPermissionsTests.kt @@ -3,7 +3,6 @@ package net.corda.client.rpc import net.corda.core.messaging.RPCOps import net.corda.node.services.messaging.getRpcContext import net.corda.node.services.messaging.requirePermission -import net.corda.nodeapi.PermissionException import net.corda.nodeapi.User import net.corda.testing.RPCDriverExposedDSLInterface import net.corda.testing.rpcDriver diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index dccfbcc459..69de13333b 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -209,6 +209,8 @@ UNRELEASED * ``ContractUpgradeFlow.Initiator`` has been renamed to ``ContractUpgradeFlow.Initiate`` +* ``@RPCSinceVersion``, ``RPCException`` and ``PermissionException`` have moved to ``net.corda.client.rpc``. + Milestone 14 ------------ diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/RPCStructures.kt b/node-api/src/main/kotlin/net/corda/nodeapi/RPCStructures.kt index 3911943969..01f56973b5 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/RPCStructures.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/RPCStructures.kt @@ -5,8 +5,6 @@ package net.corda.nodeapi import com.esotericsoftware.kryo.Registration import com.esotericsoftware.kryo.Serializer import net.corda.core.concurrent.CordaFuture -import net.corda.core.CordaRuntimeException -import net.corda.core.serialization.CordaSerializable import net.corda.core.serialization.SerializationContext import net.corda.core.toFuture import net.corda.core.toObservable @@ -28,26 +26,6 @@ data class User( ) } -/** Records the protocol version in which this RPC was added. */ -@Target(AnnotationTarget.FUNCTION) -@MustBeDocumented -annotation class RPCSinceVersion(val version: Int) - -/** - * Thrown to indicate a fatal error in the RPC system itself, as opposed to an error generated by the invoked - * method. - */ -open class RPCException(message: String?, cause: Throwable?) : CordaRuntimeException(message, cause) { - constructor(msg: String) : this(msg, null) -} - -/** - * Thrown to indicate that the calling user does not have permission for something they have requested (for example - * calling a method). - */ -@CordaSerializable -class PermissionException(msg: String) : RuntimeException(msg) - /** * The Kryo used for the RPC wire protocol. */ diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt index e30e63c3c4..05cd84c934 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt @@ -12,7 +12,7 @@ import net.corda.core.internal.toX509CertHolder import net.corda.core.serialization.CordaSerializable import net.corda.core.serialization.SerializationFactory import net.corda.core.transactions.LedgerTransaction -import net.corda.nodeapi.RPCException +import net.corda.client.rpc.RPCException import net.corda.nodeapi.internal.serialization.AbstractAMQPSerializationScheme import net.corda.nodeapi.internal.serialization.AllWhitelist import net.corda.nodeapi.internal.serialization.EmptyWhitelist diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt index 10b4373716..b4c61c2574 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt @@ -11,6 +11,7 @@ import com.google.common.collect.HashMultimap import com.google.common.collect.Multimaps import com.google.common.collect.SetMultimap import com.google.common.util.concurrent.ThreadFactoryBuilder +import net.corda.client.rpc.RPCException import net.corda.core.crypto.random63BitValue import net.corda.core.identity.CordaX500Name import net.corda.core.internal.LazyStickyPool diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt index ab546ea4d9..e8e91d793f 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt @@ -2,8 +2,8 @@ package net.corda.node.services.messaging +import net.corda.client.rpc.PermissionException import net.corda.nodeapi.ArtemisMessagingComponent -import net.corda.nodeapi.PermissionException /** Helper method which checks that the current RPC user is entitled for the given permission. Throws a [PermissionException] otherwise. */ fun RpcContext.requirePermission(permission: String) { diff --git a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt index 0f2a33aec5..eb05bac499 100644 --- a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt +++ b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt @@ -30,7 +30,7 @@ import net.corda.node.services.network.NetworkMapService import net.corda.node.services.FlowPermissions.Companion.startFlowPermission import net.corda.nodeapi.internal.ServiceInfo import net.corda.node.services.transactions.SimpleNotaryService -import net.corda.nodeapi.PermissionException +import net.corda.client.rpc.PermissionException import net.corda.nodeapi.User import net.corda.testing.chooseIdentity import net.corda.testing.expect