package Ġnet . cord a . bn . flows Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġnet . cord a . bn . contracts . Membership Contract Ċ import Ġnet . cord a . bn . states . BN Identity Ċ import Ġnet . cord a . core . contracts . Unique Identifier Ċ import Ġnet . cord a . core . flows . Flow Exception Ċ import Ġnet . cord a . core . flows . Flow Session Ċ import Ġnet . cord a . core . flows . Initi ated By Ċ import Ġnet . cord a . core . flows . Initi ating Flow Ċ import Ġnet . cord a . core . flows . Start able By RPC Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġnet . cord a . core . transactions . Transaction Builder Ċ Ċ /** Ċ Ġ* ĠThis Ġflow Ġis Ġinitiated Ġby Ġany Ġmember Ġauthor ised Ġto Ġmodify Ġmembership 's Ġbusiness Ġidentity . ĠQueries Ġfor Ġthe Ġmembership Ġwith Ċ Ġ* Ġ[ membership Id ] Ġlinear ĠID Ġand Ġover writes Ġ[ Membership State . identity . business Identity ] Ġfield Ġwith Ġ[ business Identity ] Ġvalue . ĠTransaction Ċ Ġ* Ġis Ġsigned Ġby Ġall Ġactive Ġmembers Ġauthor ised Ġto Ġmodify Ġmembership Ġand Ġstored Ġon Ġledger Ġof Ġall Ġstate 's Ġparticipants . Ċ Ġ* Ċ Ġ* Ġ@ property Ġmembership Id ĠID Ġof Ġthe Ġmembership Ġto Ġmodify Ġbusiness Ġidentity . Ċ Ġ* Ġ@ property Ġbusiness Identity ĠCustom Ġbusiness Ġidentity Ġto Ġbe Ġgiven Ġto Ġmembership . Ċ Ġ* Ġ@ property Ġnot ary ĠIdentity Ġof Ġthe Ġnot ary Ġto Ġbe Ġused Ġfor Ġtransactions Ġnot ar isation . ĠIf Ġnot Ġspecified , Ġfirst Ġone Ġfrom Ġthe Ġwhitelist Ġwill Ġbe Ġused . Ċ Ġ*/ Ċ @ Initi ating Flow Ċ @ Start able By RPC Ċ class ĠModify Business Identity Flow ( ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġmembership Id : ĠUnique Identifier , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġbusiness Identity : ĠBN Identity , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġnot ary : ĠParty ? Ġ= Ġnull Ċ ) Ġ: ĠMembers hip Management Flow < Signed Transaction >() Ġ{ ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĠĠĠĠĠĠĠ Ġaudit Logger . info ("$ our Identity Ġstarted ĠBusiness ĠIdentity Ġmodification Ġof Ġa Ġmember Ġwith Ġ$ membership Id Ġmembership ĠID Ġto Ġa Ġnew Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Business ĠIdentity Ġwith Ġ$ business Identity Ġvalue ") ĊĊĠĠĠĠĠĠĠ Ġval Ġbn Service Ġ= Ġservice Hub . cord a Service ( BN Service :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġmembership Ġ= Ġbn Service . get Membership ( membership Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠMembers hip NotFoundException (" Membership Ġstate Ġwith Ġ$ membership Id Ġlinear ĠID Ġdoesn 't Ġexist ") ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġwhether Ġparty Ġis Ġauthor ised Ġto Ġinitiate Ġflow ĊĠĠĠĠĠĠĠ Ġval Ġnetwork Id Ġ= Ġmembership . state . data . network Id ĊĠĠĠĠĠĠĠ Ġauthor ise ( network Id , Ġbn Service ) Ġ{ Ġit . can Modify Business Identity () Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// Ġfetch Ġsign ers ĊĠĠĠĠĠĠĠ Ġval Ġauthor ised Membership s Ġ= Ġbn Service . get Members Author ised To Modify Membership ( network Id ). toSet () ĊĠĠĠĠĠĠĠ Ġval Ġsign ers Ġ= Ġauthor ised Membership s . filter Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . state . data . isActive () ĊĠĠĠĠĠĠĠ Ġ}. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . state . data . identity . cord a Identity ĊĠĠĠĠĠĠĠ Ġ}. filter Not Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġremove Ġmodified Ġmember Ġfrom Ġsign ers Ġonly Ġif Ġit Ġis Ġnot Ġthe Ġflow Ġinit iator Ġ( since Ġinit iator Ġmust Ġsign Ġthe Ġtransaction ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit Ġ== Ġmembership . state . data . identity . cord a Identity Ġ&& Ġit Ġ!= Ġour Identity ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// Ġbuilding Ġtransaction ĊĠĠĠĠĠĠĠ Ġval Ġoutput Membership Ġ= Ġmembership . state . data . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcopy ( identity Ġ= Ġidentity . copy ( business Identity Ġ= Ġbusiness Identity ), Ġmodified Ġ= Ġservice Hub . clock . instant ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġrequired Sign ers Ġ= Ġsign ers . map Ġ{ Ġit . own ing Key Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( not ary Ġ?: Ġservice Hub . network Map Cache . not ary Id entities . first ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Input State ( membership ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output Membership ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Membership Contract . Commands . Modify Business Identity ( required Sign ers , Ġour Identity ), Ġrequired Sign ers ) ĊĠĠĠĠĠĠĠ Ġbuilder . verify ( service Hub ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcollect Ġsignatures Ġand Ġfinal ise Ġtransaction ĊĠĠĠĠĠĠĠ Ġval Ġobserver Sessions Ġ= Ġ( output Membership . participants Ġ- Ġour Identity ). map Ġ{ Ġinitiate Flow ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġfinal ised Transaction Ġ= Ġcollect Signatures And Final ise Transaction ( builder , Ġobserver Sessions , Ġsign ers ) ĊĊĠĠĠĠĠĠĠ Ġaudit Logger . info ("$ our Identity Ġsuccessfully Ġmodified ĠBusiness ĠIdentity Ġof Ġa Ġmember Ġwith Ġ$ membership Ġmembership ĠID Ġfrom Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"${ membership . state . data . identity . business Identity } Ġto Ġ$ business Identity ") ĊĊĠĠĠĠĠĠĠ Ġreturn Ġfinal ised Transaction ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Initi ated By ( Modify Business Identity Flow :: class ) Ċ class ĠModify Business Identity Responder Flow ( private Ġval Ġsession : ĠFlow Session ) Ġ: ĠMembers hip Management Flow < Unit >() Ġ{ ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall () Ġ{ ĊĠĠĠĠĠĠĠ Ġsign And Receive Final ised Transaction ( session ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . value Ġ! is ĠMembers hip Contract . Commands . Modify Business Identity ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠFlow Exception (" Only ĠModify Business Identity Ġcommand Ġis Ġallowed ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ