0

I am getting bellow error while playing around Hyperledger Composer.

{
  "$class": "org.property.registration.purchaseProperty",
  "propertyListing":
  "resource:org.property.registration.PropertyListing#PL001"
}

Error: attempt to get property owner on an InvalidRelationship is not allowed. InvalidRelationship created due to Object with ID '1003' in collection with ID 'Asset:org.property.registration.Property' does not exist; [cause=Participant 'org.property.registration.User#0001' does not have 'READ' access to resource 'org.property.registration.Property#1003']

I am trying to access Asset property which is a part of another asset propertyListing.

asset Property identified by PID {
  o String PID
  o Integer marketPrice
  o DateTime regDate
  o String propertyType
  o String location
  o String status default= "Registered"
  --> User owner
} 
asset PropertyListing identified by PLID {
  o String PLID
  --> Property property
}

I am trying to access PropertyListing asset and change status of property asset inside it. (I want to purchase the property from the propertyListing posted by some other user)

const registry = await getAssetRegistry(tx.propertyListing.property.getFullyQualifiedType());
    await registry.update(tx.propertyListing.property);
 // Remove the property from propertyListing()
    const registry2 =  await getAssetRegistry(tx.propertyListing.getFullyQualifiedType());
    await registry2.remove(tx.propertyListing); 

I hope and as per the error message it seems like some permission issue which is blocking me to purchase the property post by other user.

// User can see all properties listed for sale
rule UserAccessAllSaleProperties {
    description: "Allow Users to access all properties listed for sale"
    participant: "org.property.registration.User"
    operation: ALL
    resource: "org.property.registration.PropertyListing"
    action: ALLOW
}

Here i want to access the property which is part of PropertyListing. I am trying to find what short of ACL i can use. Still trying.

Guys your suggestions are welcome!!!

1 Answers1

0

Try,

rule UserAccessAllSaleProperties {
    description: "Allow Users to access all properties listed for sale"
    participant: "org.property.registration.**"
    operation: READ
    resource: "org.property.registration.PropertyListing"
    action: ALLOW
}

This will allow all participants to only "READ" the PropertyListing Asset which will be better suited to your application. It will be beneficial if you introduce any future participants. (Assuming User is defined as a participant and not an asset).

I would also recommend separating your participant and Asset files since you have a big application. like

org.property.registration.Property (-> Will only contain Assets)
org.property.registration.Participants (-> Will only contain Participants)

And import them into each other.

so your rule will be like

rule UserAccessAllSaleProperties {
    description: "Allow Users to access all properties listed for sale"
    participant: "org.property.registration.Participants.**"
    operation: READ
    resource: "org.property.registration.PropertyListing"
    action: ALLOW
}
Chromeium
  • 264
  • 1
  • 11