Skip to content

fix: resolve Java CouchDB index deployment and add ledger-queries Java implementation#1406

Open
SurbhiAgarwal1 wants to merge 6 commits intohyperledger:mainfrom
SurbhiAgarwal1:fix-1148-java-couchdb-index
Open

fix: resolve Java CouchDB index deployment and add ledger-queries Java implementation#1406
SurbhiAgarwal1 wants to merge 6 commits intohyperledger:mainfrom
SurbhiAgarwal1:fix-1148-java-couchdb-index

Conversation

@SurbhiAgarwal1
Copy link
Copy Markdown

Summary

This Pull Request addresses several critical issues in the test-network scripts and completes the asset-transfer-ledger-queries sample by adding the missing Java implementation.

Key Improvements

1. Fix for Issue #1148 (CouchDB Index Deployment)
Previously, Java chaincode failed to deploy CouchDB indexes because the packageCC.sh script did not include the META-INF directory in the package.

  • Change: Updated packageCC.sh to explicitly copy META-INF from the source resources into the distribution directory before packaging.

2. Resolved Package ID Logic Error
The packageCC.sh script failed to calculate the PACKAGE_ID when the --package-only (-cco) flag was enabled.

  • Change: Added conditional logic to calculatepackageid to look in the correct versioned subdirectory (packagedChaincode/) when the package-only flag is set.

3. New Java Smart Contract for Ledger Queries
Added a full, Gradle-based Java implementation for the asset-transfer-ledger-queries sample.

  • Parity: Achieves full feature parity with the existing Go and Node.js versions, including rich query support and history tracking.
  • Metadata: Professionally structured with correct Apache-2.0 headers and contract metadata.

4. Script Robustness

  • Added build verification (verifyResult) after Java and TypeScript compilation to prevent the creation of broken packages when a build fails.
  • Updated root README.md to officially list the new language support.

##How to Test

  1. Run ./network.sh packageCC -ccn ledger -ccp ../asset-transfer-ledger-queries/chaincode-java -ccl java -cco true.
  2. Verify the package is created in packagedChaincode/ and the Package ID is correctly displayed.
  3. Deploy the chaincode using standard methods and verify that rich queries now work against CouchDB.

##Mentorship Highlights

  • Ensured full parity with official samples.
  • Strict adherence to ContractInterface naming conventions.
  • Zero-pollution pull request (added .gitignore to keep the branch clean).

…ncode

Signed-off-by: SurbhiAgarwal1 <agarwalsurbhi1807@gmail.com>
…code

- Update packageCC.sh to correctly copy META-INF to the distribution directory.
- Port asset-transfer-ledger-queries to Java to provide a sample with rich query support.
- Ensure all Java chaincodes use src/main/resources/META-INF for standard index placement.

Signed-off-by: SurbhiAgarwal1 <agarwalsurbhi1807@gmail.com>
- Add TransferAssetByColor using composite keys.
- Add range query methods (GetAssetsByRange, GetAssetsByRangeWithPagination).
- Ensure composite key management in Create/Update/Delete methods.

Signed-off-by: SurbhiAgarwal1 <agarwalsurbhi1807@gmail.com>
@SurbhiAgarwal1 SurbhiAgarwal1 requested a review from a team as a code owner April 17, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant