Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 9f670a6

Browse files
Luis Sanchezcr22rc
authored andcommitted
[FAB-4260] Update example_cc with FAB-3235 changes.
Change-Id: I1c401143832885388d38917ad222ae0305a168b7 Signed-off-by: Luis Sanchez <sanchezl@us.ibm.com>
1 parent fd04683 commit 9f670a6

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/test/fixture/sdkintegration/javacc/example_cc/src/main/java/example/SimpleChaincode.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
package example;
1818

1919
import static java.lang.String.format;
20-
import static org.hyperledger.fabric.shim.ChaincodeHelper.newBadRequestResponse;
21-
import static org.hyperledger.fabric.shim.ChaincodeHelper.newInternalServerErrorResponse;
22-
import static org.hyperledger.fabric.shim.ChaincodeHelper.newSuccessResponse;
2320

2421
import java.io.PrintWriter;
2522
import java.io.StringWriter;
@@ -31,7 +28,6 @@
3128

3229
import org.apache.commons.logging.Log;
3330
import org.apache.commons.logging.LogFactory;
34-
import org.hyperledger.fabric.protos.peer.ProposalResponsePackage.Response;
3531
import org.hyperledger.fabric.shim.ChaincodeBase;
3632
import org.hyperledger.fabric.shim.ChaincodeStub;
3733

@@ -49,14 +45,14 @@ public Response init(ChaincodeStub stub) {
4945
case "init":
5046
return init(stub, args.stream().skip(0).toArray(String[]::new));
5147
default:
52-
return newBadRequestResponse(format("Unknown function: %s", args.get(0)));
48+
return newErrorResponse(format("Unknown function: %s", args.get(0)));
5349
}
5450
} catch (NumberFormatException e) {
55-
return newBadRequestResponse(e.toString());
51+
return newErrorResponse(e.toString());
5652
} catch (IllegalArgumentException e) {
57-
return newBadRequestResponse(e.getMessage());
53+
return newErrorResponse(e.getMessage());
5854
} catch (Throwable e) {
59-
return newInternalServerErrorResponse(e);
55+
return newErrorResponse(e);
6056
}
6157
}
6258

@@ -86,15 +82,15 @@ public Response invoke(ChaincodeStub stub) {
8682
case "query":
8783
return query(stub, args);
8884
default:
89-
return newBadRequestResponse(newErrorJson("Unknown function: %s", function));
85+
return newErrorResponse(newErrorJson("Unknown function: %s", function));
9086
}
9187

9288
} catch (NumberFormatException e) {
93-
return newBadRequestResponse(e.toString());
89+
return newErrorResponse(e.toString());
9490
} catch (IllegalArgumentException e) {
95-
return newBadRequestResponse(e.getMessage());
91+
return newErrorResponse(e.getMessage());
9692
} catch (Throwable e) {
97-
return newInternalServerErrorResponse(e);
93+
return newErrorResponse(e);
9894
}
9995

10096
}
@@ -114,7 +110,7 @@ private Response invoke(ChaincodeStub stub, String[] args) {
114110
stub.delState(arg);
115111
return newSuccessResponse();
116112
default:
117-
return newBadRequestResponse(newErrorJson("Unknown invoke sub-function: %s", subFunction));
113+
return newErrorResponse(newErrorJson("Unknown invoke sub-function: %s", subFunction));
118114
}
119115
}
120116

0 commit comments

Comments
 (0)