Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ transfer an asset in a more realistic transfer scenario.
| **Smart Contract** | **Description** | **Tutorial** | **Smart contract languages** | **Application languages** |
| -----------|------------------------------|----------|---------|---------|
| [Basic](asset-transfer-basic) | The Basic sample smart contract that allows you to create and transfer an asset by putting data on the ledger and retrieving it. This sample is recommended for new Fabric users. | [Writing your first application](https://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html) | Go, JavaScript, TypeScript, Java | Go, TypeScript, Java |
| [Ledger queries](asset-transfer-ledger-queries) | The ledger queries sample demonstrates range queries and transaction updates using range queries (applicable for both LevelDB and CouchDB state databases), and how to deploy an index with your chaincode to support JSON queries (applicable for CouchDB state database only). | [Using CouchDB](https://hyperledger-fabric.readthedocs.io/en/latest/couchdb_tutorial.html) | Go, JavaScript | Java, JavaScript |
| [Ledger queries](asset-transfer-ledger-queries) | The ledger queries sample demonstrates range queries and transaction updates using range queries (applicable for both LevelDB and CouchDB state databases), and how to deploy an index with your chaincode to support JSON queries (applicable for CouchDB state database only). | [Using CouchDB](https://hyperledger-fabric.readthedocs.io/en/latest/couchdb_tutorial.html) | Go, JavaScript, Java, TypeScript | Java, JavaScript |
| [Private data](asset-transfer-private-data) | This sample demonstrates the use of private data collections, how to manage private data collections with the chaincode lifecycle, and how the private data hash can be used to verify private data on the ledger. It also demonstrates how to control asset updates and transfers using client-based ownership and access control. | [Using Private Data](https://hyperledger-fabric.readthedocs.io/en/latest/private_data_tutorial.html) | Go, TypeScript, Java | TypeScript |
| [State-Based Endorsement](asset-transfer-sbe) | This sample demonstrates how to override the chaincode-level endorsement policy to set endorsement policies at the key-level (data/asset level). | [Using State-based endorsement](https://github.com/hyperledger/fabric-samples/tree/main/asset-transfer-sbe) | Java, TypeScript | JavaScript |
| [Secured agreement](asset-transfer-secured-agreement) | Smart contract that uses implicit private data collections, state-based endorsement, and organization-based ownership and access control to keep data private and securely transfer an asset with the consent of both the current owner and buyer. | [Secured asset transfer](https://hyperledger-fabric.readthedocs.io/en/latest/secured_asset_transfer/secured_private_asset_transfer_tutorial.html) | Go | TypeScript |
Expand Down
6 changes: 6 additions & 0 deletions asset-transfer-ledger-queries/chaincode-java/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

4 changes: 4 additions & 0 deletions asset-transfer-ledger-queries/chaincode-java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/
.gradle/
build/
bin/
31 changes: 31 additions & 0 deletions asset-transfer-ledger-queries/chaincode-java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# the first stage
FROM gradle:9-jdk25 AS gradle_build

# copy the build.gradle and src code to the container
COPY src/ src/
COPY build.gradle ./

# Build and package our code
RUN gradle --no-daemon build shadowJar -x checkstyleMain -x checkstyleTest


# the second stage of our build just needs the compiled files
FROM eclipse-temurin:25-jre
ARG CC_SERVER_PORT=9999

# Setup tini to work better handle signals
ENV TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

RUN addgroup --system javauser && useradd -g javauser javauser

# copy only the artifacts we need from the first stage and discard the rest
COPY --chown=javauser:javauser --from=gradle_build /home/gradle/build/libs/chaincode.jar /chaincode.jar
COPY --chown=javauser:javauser docker/docker-entrypoint.sh /docker-entrypoint.sh

ENV PORT=$CC_SERVER_PORT
EXPOSE $CC_SERVER_PORT

USER javauser
ENTRYPOINT [ "/tini", "--", "/docker-entrypoint.sh" ]
91 changes: 91 additions & 0 deletions asset-transfer-ledger-queries/chaincode-java/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/

plugins {
id 'com.gradleup.shadow' version '9.2.2'
id 'application'
id 'checkstyle'
id 'jacoco'
}

group 'org.hyperledger.fabric.samples'
version '1.0-SNAPSHOT'

dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.+'
implementation 'org.json:json:+'
implementation 'com.owlike:genson:1.6'
testImplementation platform('org.junit:junit-bom:5.14.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.27.6'
testImplementation 'org.mockito:mockito-core:5.20.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

repositories {
mavenCentral()
maven {
url 'https://jitpack.io'
}
}

compileJava {
options.release = 11
}

application {
mainClass = 'org.hyperledger.fabric.contract.ContractRouter'
}

checkstyle {
toolVersion '8.21'
configFile file("config/checkstyle/checkstyle.xml")
}

checkstyleMain {
source ='src/main/java'
}

checkstyleTest {
source ='src/test/java'
}

jacocoTestReport {
dependsOn test
}

jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.9
}
}
}

finalizedBy jacocoTestReport
}

test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}

shadowJar {
archiveBaseName = 'chaincode'
archiveVersion = ''
archiveClassifier = ''

duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()

manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
}
}

check.dependsOn jacocoTestCoverageVerification
installDist.dependsOn check
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading