我正在使用hyperledger composer製作業務模型,其中我有一個作爲參與者的銀行和一個作爲資產的客戶。該行定義如下:參與者沒有對資源的創建訪問權限
participant Bank identified by bankId {
o String bankId
o String name
o String code
}
和客戶看起來是這樣的:
asset Customer identified by aadhaarId {
o String aadhaarId
o String panId
o String firstName
o String lastName
o String contactNo
o String residence
o String accountNumber
o AccountType accountType
o String creationDate
--> Bank bank
}
我想,一個參與者(銀行)只能更新屬於它的客戶,我想創建一個交易要做到這一點。所以,我創建了以下交易:
transaction updateCustomer identified by transactionId {
o String transactionId
--> Customer customer
o Customer newDetails
}
,並在將.acl文件中定義的規則如下:
rule bankCanUpdateItsCutomersViaTransaction {
description: "Allow a participant to update it's own resources"
participant(p): "org.acme.sample.Bank"
operation: UPDATE
resource(r): "org.acme.sample.updateCustomer"
condition: (p.getIdentifier() == r.customer.bank.getIdentifier())
action: ALLOW
}
爲了測試這一點,我創建了一個參與者(除了已經提供的管理)和創建一個與該參與者相關聯的客戶。我有一個交易處理器功能,它只是更新客戶資產註冊表。 但是當我嘗試執行updateCustomer事務時,我收到一個錯誤,指出參與者沒有對資源的CREATE訪問權限。即使我將操作更改爲.acl文件中的CREATE,該問題仍然存在。我認爲問題在於條件部分,但我無法糾正它。
我有一個類似的交易,創造顧客如下:
transaction createCustomer identified by transactionId {
o String transactionId
o Customer newCustomer
}
,併爲它的規則如下:
rule bankCanCreateItsCutomersViaTransaction {
description: "Allow a participant to create it's own resources"
participant(p): "org.acme.sample.Bank"
operation: CREATE
resource(r): "org.acme.sample.createCustomer"
condition: (p.getIdentifier() == r.newCustomer.bank.getIdentifier())
action: ALLOW
}
有這個createCustomer交易背後的一個簡單的事務處理功能只是在客戶資產註冊表中添加newCustomer。這工作完全正常,但updateCustomer事務不起作用。 任何幫助將不勝感激。謝謝:)
您所說的實際上有意義,但createCustomer Transaction正常工作(我只是在問題中更新了它)。如果我將條件更改爲條件:(true),則更新客戶。所以我認爲問題在於我寫作條件的方式。我可以按照規則的方式從updateCustomer交易中訪問客戶嗎? –