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. *