From 9f670a6fd401b5a4c34a215e14cecc9ec9bb9d87 Mon Sep 17 00:00:00 2001 From: Luis Sanchez Date: Tue, 30 May 2017 14:35:54 -0400 Subject: [PATCH] [FAB-4260] Update example_cc with FAB-3235 changes. Change-Id: I1c401143832885388d38917ad222ae0305a168b7 Signed-off-by: Luis Sanchez --- .../main/java/example/SimpleChaincode.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/test/fixture/sdkintegration/javacc/example_cc/src/main/java/example/SimpleChaincode.java b/src/test/fixture/sdkintegration/javacc/example_cc/src/main/java/example/SimpleChaincode.java index 17452f1e..7e97e268 100644 --- a/src/test/fixture/sdkintegration/javacc/example_cc/src/main/java/example/SimpleChaincode.java +++ b/src/test/fixture/sdkintegration/javacc/example_cc/src/main/java/example/SimpleChaincode.java @@ -17,9 +17,6 @@ package example; import static java.lang.String.format; -import static org.hyperledger.fabric.shim.ChaincodeHelper.newBadRequestResponse; -import static org.hyperledger.fabric.shim.ChaincodeHelper.newInternalServerErrorResponse; -import static org.hyperledger.fabric.shim.ChaincodeHelper.newSuccessResponse; import java.io.PrintWriter; import java.io.StringWriter; @@ -31,7 +28,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hyperledger.fabric.protos.peer.ProposalResponsePackage.Response; import org.hyperledger.fabric.shim.ChaincodeBase; import org.hyperledger.fabric.shim.ChaincodeStub; @@ -49,14 +45,14 @@ public Response init(ChaincodeStub stub) { case "init": return init(stub, args.stream().skip(0).toArray(String[]::new)); default: - return newBadRequestResponse(format("Unknown function: %s", args.get(0))); + return newErrorResponse(format("Unknown function: %s", args.get(0))); } } catch (NumberFormatException e) { - return newBadRequestResponse(e.toString()); + return newErrorResponse(e.toString()); } catch (IllegalArgumentException e) { - return newBadRequestResponse(e.getMessage()); + return newErrorResponse(e.getMessage()); } catch (Throwable e) { - return newInternalServerErrorResponse(e); + return newErrorResponse(e); } } @@ -86,15 +82,15 @@ public Response invoke(ChaincodeStub stub) { case "query": return query(stub, args); default: - return newBadRequestResponse(newErrorJson("Unknown function: %s", function)); + return newErrorResponse(newErrorJson("Unknown function: %s", function)); } } catch (NumberFormatException e) { - return newBadRequestResponse(e.toString()); + return newErrorResponse(e.toString()); } catch (IllegalArgumentException e) { - return newBadRequestResponse(e.getMessage()); + return newErrorResponse(e.getMessage()); } catch (Throwable e) { - return newInternalServerErrorResponse(e); + return newErrorResponse(e); } } @@ -114,7 +110,7 @@ private Response invoke(ChaincodeStub stub, String[] args) { stub.delState(arg); return newSuccessResponse(); default: - return newBadRequestResponse(newErrorJson("Unknown invoke sub-function: %s", subFunction)); + return newErrorResponse(newErrorJson("Unknown invoke sub-function: %s", subFunction)); } }