Skip to content

Commit 67fdc40

Browse files
committed
[FABCJ-259] Pagination Fix
Minor fix to pagination - arguments wrong Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
1 parent 1609425 commit 67fdc40

File tree

23 files changed

+142
-144
lines changed

23 files changed

+142
-144
lines changed

examples/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/SimpleAsset.java

Lines changed: 0 additions & 106 deletions
This file was deleted.

fabric-chaincode-integration-test/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependencies {
2121
}
2222
}
2323

24-
2524
task getLatestDockerImages{
2625
doLast {
2726
exec {
@@ -33,8 +32,5 @@ task getLatestDockerImages{
3332

3433
build.dependsOn project(':fabric-chaincode-docker').buildImage
3534

36-
37-
// compileJava.dependsOn project(':fabric-chaincode-docker').buildImage
38-
// compileJava.dependsOn project(':fabric-chaincode-example-sacc-jars').jar
3935
test.dependsOn project.getLatestDockerImages
4036

fabric-chaincode-integration-test/getDockerImages.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ echo "======== PULL DOCKER IMAGES ========"
77
# Pull and Tag the fabric and fabric-ca images from Nexus
88
##########################################################
99
echo "Fetching images from Nexus"
10-
NEXUS_URL=nexus3.hyperledger.org:10001
11-
ORG_NAME="hyperledger/fabric"
10+
# NEXUS_URL=nexus3.hyperledger.org:10001
11+
NEXUS_URL=hyperledger-fabric.jfrog.io
12+
ORG_NAME="fabric"
1213

1314
VERSION=2.0.0
1415
ARCH="amd64"

examples/fabric-chaincode-example-sacc/build.gradle renamed to fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ shadowJar {
2424
classifier = null
2525

2626
manifest {
27-
attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleAsset'
27+
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
2828
}
2929
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
package org.example;
5+
6+
import org.hyperledger.fabric.contract.Context;
7+
import org.hyperledger.fabric.contract.ContractInterface;
8+
import org.hyperledger.fabric.contract.annotation.*;
9+
10+
11+
import org.hyperledger.fabric.shim.ledger.*;
12+
import org.hyperledger.fabric.shim.*;
13+
import java.util.*;
14+
import static java.nio.charset.StandardCharsets.UTF_8;
15+
16+
@Contract(name = "AllAPI",
17+
info = @Info(title = "AllAPI contract",
18+
description = "Contract but using all the APIs",
19+
version = "0.0.1",
20+
license =
21+
@License(name = "SPDX-License-Identifier: Apache-2.0",
22+
url = ""),
23+
contact = @Contact(email = "fred@example.com",
24+
name = "fred",
25+
url = "http://fred.example.com")))
26+
@Default
27+
public class AllAPI implements ContractInterface {
28+
public AllAPI() {
29+
30+
}
31+
32+
@Transaction()
33+
public void putBulkStates(Context ctx){
34+
for (int x=100; x<200; x++){
35+
String key = "key"+x;
36+
String value = "value:"+x;
37+
38+
putState(ctx,key,value);
39+
}
40+
}
41+
42+
@Transaction()
43+
public void putState(Context ctx, String key, String payload){
44+
ChaincodeStub stub = ctx.getStub();
45+
stub.putState(key,payload.getBytes(UTF_8));
46+
}
47+
48+
@Transaction()
49+
public void putStateComposite(Context ctx, String key[], String payload){
50+
String composite = new CompositeKey("composite",key).toString();
51+
this.putState(ctx,composite,payload);
52+
}
53+
54+
@Transaction()
55+
public void getState(Context ctx, String key, String payload){
56+
ChaincodeStub stub = ctx.getStub();
57+
String result = stub.getStringState(key);
58+
if (!result.equals(payload)){
59+
String msg = "GetState::["+key+"] Expected "+payload+" got "+result;
60+
System.out.println(msg);
61+
throw new RuntimeException(msg);
62+
}
63+
}
64+
65+
@Transaction()
66+
public int getByRange(Context ctx, String start, String end){
67+
ChaincodeStub stub = ctx.getStub();
68+
System.out.println("getByRange>>");
69+
QueryResultsIterator<KeyValue> qri = stub.getStateByRange(start,end);
70+
int count=0;
71+
for (KeyValue kv : qri){
72+
kv.getKey();
73+
kv.getStringValue();
74+
count++;
75+
System.out.println("["+kv.getKey()+"] "+kv.getStringValue());
76+
}
77+
System.out.println("getByRange<<");
78+
return count;
79+
}
80+
81+
@Transaction()
82+
public String getByRangePaged(Context ctx, String start, String end, int pageSize, String bookmark){
83+
ChaincodeStub stub = ctx.getStub();
84+
System.out.println("getByRangePaged>>");
85+
QueryResultsIteratorWithMetadata<KeyValue> qri = stub.getStateByRangeWithPagination(start,end,pageSize,bookmark);
86+
for (KeyValue kv : qri){
87+
kv.getKey();
88+
kv.getStringValue();
89+
System.out.println("["+kv.getKey()+"] "+kv.getStringValue());
90+
}
91+
String newbookmark = qri.getMetadata().getBookmark();
92+
int records = qri.getMetadata().getFetchedRecordsCount();
93+
System.out.println(newbookmark+" @ "+records);
94+
95+
System.out.println("getByRangePaged<<");
96+
return newbookmark;
97+
}
98+
99+
}

0 commit comments

Comments
 (0)