Skip to content

Commit 5ca5575

Browse files
committed
update notary selection BM
1 parent c517576 commit 5ca5575

File tree

7 files changed

+29
-11
lines changed

7 files changed

+29
-11
lines changed

BusinessNetworks/insurancebusinessnetwork/workflows/src/main/java/net/corda/samples/businessmembership/flows/IssuePolicy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import net.corda.core.contracts.*;
1111
import net.corda.core.crypto.SecureHash;
1212
import net.corda.core.flows.*;
13+
import net.corda.core.identity.CordaX500Name;
1314
import net.corda.core.identity.Party;
1415
import net.corda.core.transactions.SignedTransaction;
1516
import net.corda.core.transactions.TransactionBuilder;
@@ -45,7 +46,9 @@ public IssuePolicyInitiator(String networkId, Party careProvider, String insuree
4546
@Override
4647
@Suspendable
4748
public SignedTransaction call() throws FlowException {
48-
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
49+
// Obtain a reference to a notary we wish to use.
50+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
51+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
4952
businessNetworkFullVerification(this.networkId, getOurIdentity(), this.careProvider);
5053
InsuranceState outputState = new InsuranceState(getOurIdentity(), this.insuree, this.careProvider, networkId, "Initiating Policy");
5154
BNService bnService = getServiceHub().cordaService(BNService.class);

BusinessNetworks/insurancebusinessnetwork/workflows/src/main/java/net/corda/samples/businessmembership/flows/membershipFlows/ActiveMembers.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.corda.core.flows.FlowException;
77
import net.corda.core.flows.FlowLogic;
88
import net.corda.core.flows.StartableByRPC;
9+
import net.corda.core.identity.CordaX500Name;
910
import net.corda.core.identity.Party;
1011

1112
@StartableByRPC
@@ -20,7 +21,9 @@ public ActiveMembers(UniqueIdentifier membershipId) {
2021
@Override
2122
@Suspendable
2223
public String call() throws FlowException {
23-
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
24+
// Obtain a reference to a notary we wish to use.
25+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
26+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
2427
subFlow(new ActivateMembershipFlow(this.membershipId,notary));
2528
return "\nMember("+ this.membershipId.toString()+")'s network membership has been activated.";
2629
}

BusinessNetworks/insurancebusinessnetwork/workflows/src/main/java/net/corda/samples/businessmembership/flows/membershipFlows/AssignBNIdentity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.corda.core.flows.FlowException;
77
import net.corda.core.flows.FlowLogic;
88
import net.corda.core.flows.StartableByRPC;
9+
import net.corda.core.identity.CordaX500Name;
910
import net.corda.core.identity.Party;
1011
import net.corda.samples.businessmembership.states.CareProviderIdentity;
1112
import net.corda.samples.businessmembership.states.InsurerIdentity;
@@ -26,7 +27,9 @@ public AssignBNIdentity(String firmType, UniqueIdentifier membershipId, String b
2627
@Override
2728
@Suspendable
2829
public String call() throws FlowException {
29-
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
30+
// Obtain a reference to a notary we wish to use.
31+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
32+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
3033
if(this.firmType.equals("InsuranceFirm")){
3134
InsurerIdentity insuranceIdty = new InsurerIdentity(bnIdentity);
3235
if(!insuranceIdty.isValid()){

BusinessNetworks/insurancebusinessnetwork/workflows/src/main/java/net/corda/samples/businessmembership/flows/membershipFlows/AssignOrthodonticsRole.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.corda.core.flows.FlowException;
1010
import net.corda.core.flows.FlowLogic;
1111
import net.corda.core.flows.StartableByRPC;
12+
import net.corda.core.identity.CordaX500Name;
1213
import net.corda.core.identity.Party;
1314
import net.corda.core.transactions.SignedTransaction;
1415
import net.corda.samples.businessmembership.states.CareProviderIdentity;
@@ -31,7 +32,9 @@ public AssignOrthodonticsRole(UniqueIdentifier membershipId, String networkId) {
3132
@Suspendable
3233
public SignedTransaction call() throws FlowException {
3334

34-
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
35+
// Obtain a reference to a notary we wish to use.
36+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
37+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
3538
BNService bnService = getServiceHub().cordaService(BNService.class);
3639
MembershipState membershipState = bnService.getMembership(membershipId).getState().getData();
3740
Set<BNRole> roles = new HashSet<>();

BusinessNetworks/insurancebusinessnetwork/workflows/src/main/java/net/corda/samples/businessmembership/flows/membershipFlows/AssignPolicyIssuerRole.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.corda.core.flows.FlowException;
1010
import net.corda.core.flows.FlowLogic;
1111
import net.corda.core.flows.StartableByRPC;
12+
import net.corda.core.identity.CordaX500Name;
1213
import net.corda.core.identity.Party;
1314
import net.corda.core.transactions.SignedTransaction;
1415
import net.corda.samples.businessmembership.states.InsurerIdentity;
@@ -30,7 +31,9 @@ public AssignPolicyIssuerRole(UniqueIdentifier membershipId, String networkId) {
3031
@Override
3132
@Suspendable
3233
public SignedTransaction call() throws FlowException {
33-
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
34+
// Obtain a reference to a notary we wish to use.
35+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
36+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
3437
BNService bnService = getServiceHub().cordaService(BNService.class);
3538
MembershipState membershipState = bnService.getMembership(this.membershipId).getState().getData();
3639
Set<BNRole> roles = new HashSet<>();

BusinessNetworks/insurancebusinessnetwork/workflows/src/main/java/net/corda/samples/businessmembership/flows/membershipFlows/CreateNetworkSubGroup.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.corda.core.flows.FlowException;
77
import net.corda.core.flows.FlowLogic;
88
import net.corda.core.flows.StartableByRPC;
9+
import net.corda.core.identity.CordaX500Name;
910
import net.corda.core.identity.Party;
1011

1112
import java.util.Set;
@@ -26,7 +27,9 @@ public CreateNetworkSubGroup(String networkId, String groupName, Set<UniqueIdent
2627
@Override
2728
@Suspendable
2829
public String call() throws FlowException {
29-
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
30+
// Obtain a reference to a notary we wish to use.
31+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
32+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
3033
UniqueIdentifier groupId = new UniqueIdentifier();
3134
subFlow(new CreateGroupFlow(this.networkId,groupId,this.groupName,this.groupParticipants,notary));
3235
String result = "\n "+ this.groupName+ " has created under BN network ("+this.networkId+")"+

BusinessNetworks/insurancebusinessnetwork/workflows/src/test/java/net/corda/samples/businessmembership/FlowTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
import com.google.common.collect.ImmutableList;
44
import net.corda.bn.states.MembershipState;
55
import net.corda.core.contracts.StateAndRef;
6+
import net.corda.core.identity.CordaX500Name;
67
import net.corda.core.node.services.Vault;
78
import net.corda.core.node.services.vault.QueryCriteria;
89
import net.corda.samples.businessmembership.flows.membershipFlows.CreateNetwork;
9-
import net.corda.testing.node.MockNetwork;
10-
import net.corda.testing.node.MockNetworkParameters;
11-
import net.corda.testing.node.StartedMockNode;
12-
import net.corda.testing.node.TestCordapp;
10+
import net.corda.testing.node.*;
1311
import org.junit.After;
1412
import org.junit.Before;
1513
import org.junit.Test;
@@ -29,7 +27,9 @@ public void setup() {
2927
TestCordapp.findCordapp("net.corda.samples.businessmembership.contracts"),
3028
TestCordapp.findCordapp("net.corda.samples.businessmembership.flows"),
3129
TestCordapp.findCordapp("net.corda.bn.flows"),
32-
TestCordapp.findCordapp("net.corda.bn.states"))));
30+
TestCordapp.findCordapp("net.corda.bn.states")))
31+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB"))))
32+
);
3333
a = network.createPartyNode(null);
3434
b = network.createPartyNode(null);
3535
network.runNetwork();

0 commit comments

Comments
 (0)