From ff8d083555a86cd8861a6f3961951d9f700141d2 Mon Sep 17 00:00:00 2001 From: Aniket Anerao Date: Wed, 24 Aug 2022 22:16:38 +0530 Subject: [PATCH] fixed bug --- .../samples/insfraudcheck/ClaimProcessing.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ins-fraud-check/chaincode-java/src/main/java/org/hyperledger/fabric/samples/insfraudcheck/ClaimProcessing.java b/ins-fraud-check/chaincode-java/src/main/java/org/hyperledger/fabric/samples/insfraudcheck/ClaimProcessing.java index 2ad31017..9d7dc24e 100644 --- a/ins-fraud-check/chaincode-java/src/main/java/org/hyperledger/fabric/samples/insfraudcheck/ClaimProcessing.java +++ b/ins-fraud-check/chaincode-java/src/main/java/org/hyperledger/fabric/samples/insfraudcheck/ClaimProcessing.java @@ -56,6 +56,21 @@ public final class ClaimProcessing implements ContractInterface { } + /** + * Checks the existence of the asset on the ledger + * + * @param ctx the transaction context + * @param assetID the ID of the asset + * @return boolean indicating the existence of the asset + */ + @Transaction(intent = Transaction.TYPE.EVALUATE) + public boolean ClaimExists(final Context ctx, final String claimID) { + ChaincodeStub stub = ctx.getStub(); + String claimJSON = stub.getStringState(claimID); + + return (claimJSON != null && !claimJSON.isEmpty()); + } + /** * Creates a new claim on the ledger. *