diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77985350..04c9fd85 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,7 +54,7 @@ jobs: USERNAME_OR_ORG: "${{ github.repository_owner }}" - name: Release the SDK to GitHub run: | - mvn -B deploy -Dsdk + mvn -B jar:jar deploy:deploy -Dsdk env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - name: Increment the pom version diff --git a/pom.xml b/pom.xml index 80cb62f4..936db88c 100644 --- a/pom.xml +++ b/pom.xml @@ -43,12 +43,40 @@ fabric-chaincode-shim ${fabric-chaincode-java.version} compile + + + com.github.everit-org.json-schema + org.everit.json.schema + + + org.hyperledger.fabric-chaincode-java + fabric-chaincode-protos + + + javax.json + javax.json-api + + - com.owlike - genson - 1.5 - compile + org.hyperledger.fabric-chaincode-java + fabric-chaincode-protos + ${fabric-chaincode-java.version} + + + javax.annotation + javax.annotation-api + + + javax.json + javax.json-api + + + + + io.github.classgraph + classgraph + 4.8.139 org.springframework.boot @@ -157,12 +185,20 @@ org.hyperledger.fabric-sdk-java fabric-sdk-java - 2.2.12 + 2.2.25 org.apache.logging.log4j log4j-core + + javax.annotation + javax.annotation-api + + + javax.xml.bind + jaxb-api + @@ -181,6 +217,12 @@ org.springframework.boot spring-boot-starter-test test + + + org.skyscreamer + jsonassert + + org.mockito @@ -214,7 +256,12 @@ micrometer-registry-prometheus runtime - + + net.bytebuddy + byte-buddy + 1.14.11 + + diff --git a/src/main/java/hlf/java/rest/client/sdk/StandardCCEvent.java b/src/main/java/hlf/java/rest/client/sdk/StandardCCEvent.java index 4401b5af..c2467539 100644 --- a/src/main/java/hlf/java/rest/client/sdk/StandardCCEvent.java +++ b/src/main/java/hlf/java/rest/client/sdk/StandardCCEvent.java @@ -1,25 +1,24 @@ package hlf.java.rest.client.sdk; -import com.owlike.genson.annotation.JsonProperty; +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -import java.io.Serializable; - /** - * StandardCCEvent can be used by smart contract developers - * to send a commonly wrapped event that the hlf-connector - * decodes. The decoded event can be used to publish to Kafka. + * StandardCCEvent can be used by smart contract developers to send a commonly wrapped event that + * the hlf-connector decodes. The decoded event can be used to publish to Kafka. */ @Data @DataType public class StandardCCEvent implements Serializable { - @Property() - @JsonProperty("key") - private String key; + @Property() + @JsonProperty("key") + private String key; - @Property - @JsonProperty("event") - private String event; + @Property + @JsonProperty("event") + private String event; } diff --git a/src/main/java/hlf/java/rest/client/service/impl/ChannelServiceImpl.java b/src/main/java/hlf/java/rest/client/service/impl/ChannelServiceImpl.java index 72cdc419..738c4a55 100644 --- a/src/main/java/hlf/java/rest/client/service/impl/ChannelServiceImpl.java +++ b/src/main/java/hlf/java/rest/client/service/impl/ChannelServiceImpl.java @@ -249,7 +249,9 @@ private Common.Envelope getChannelCreationTransaction( */ private Configtx.ConfigUpdate newConfigUpdate(ChannelOperationRequest channelOperationRequest) { Map mspMap = new HashMap<>(); - channelOperationRequest.getPeers().forEach(p -> mspMap.putIfAbsent(p.getMspid(), p.getMspDTO())); + channelOperationRequest + .getPeers() + .forEach(p -> mspMap.putIfAbsent(p.getMspid(), p.getMspDTO())); return Configtx.ConfigUpdate.newBuilder() .setChannelId(channelOperationRequest.getChannelName()) .setReadSet(newChannelGroup(channelOperationRequest.getConsortiumName(), mspMap, false)) diff --git a/src/main/java/hlf/java/rest/client/service/impl/EventPublishServiceImpl.java b/src/main/java/hlf/java/rest/client/service/impl/EventPublishServiceImpl.java index 4ceb9701..ab52217b 100644 --- a/src/main/java/hlf/java/rest/client/service/impl/EventPublishServiceImpl.java +++ b/src/main/java/hlf/java/rest/client/service/impl/EventPublishServiceImpl.java @@ -10,7 +10,6 @@ import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.header.internals.RecordHeader; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.SendResult; @@ -39,7 +38,8 @@ public boolean sendMessage(String msg, String fabricTxId, String eventName, Stri try { ProducerRecord producerRecord = - new ProducerRecord(kafkaProperties.getEventListener().getTopic(), String.valueOf(msg.hashCode()), msg); + new ProducerRecord( + kafkaProperties.getEventListener().getTopic(), String.valueOf(msg.hashCode()), msg); producerRecord .headers() @@ -91,15 +91,16 @@ public boolean publishChaincodeEvents( boolean status = true; try { - String key = String.valueOf(payload.hashCode()); - if (fabricProperties.getEvents().isStandardCCEventEnabled()) { - // Fetch the key information for chaincode events, - // but only if the feature is enabled. - - // Parse the payload and use the key. - StandardCCEvent standardCCEvent = FabricEventParseUtil.parseString(payload, StandardCCEvent.class); - key = standardCCEvent.getKey(); - } + String key = String.valueOf(payload.hashCode()); + if (fabricProperties.getEvents().isStandardCCEventEnabled()) { + // Fetch the key information for chaincode events, + // but only if the feature is enabled. + + // Parse the payload and use the key. + StandardCCEvent standardCCEvent = + FabricEventParseUtil.parseString(payload, StandardCCEvent.class); + key = standardCCEvent.getKey(); + } ProducerRecord producerRecord = new ProducerRecord<>(kafkaProperties.getEventListener().getTopic(), key, payload); @@ -126,7 +127,9 @@ public boolean publishChaincodeEvents( FabricClientConstants.FABRIC_EVENT_TYPE, FabricClientConstants.FABRIC_EVENT_TYPE_CHAINCODE.getBytes())); - log.info("Publishing Chaincode event to outbound topic {}", kafkaProperties.getEventListener().getTopic()); + log.info( + "Publishing Chaincode event to outbound topic {}", + kafkaProperties.getEventListener().getTopic()); ListenableFuture> future = kafkaTemplate.send(producerRecord); @@ -170,7 +173,10 @@ public boolean publishBlockEvents( try { ProducerRecord producerRecord = - new ProducerRecord<>(kafkaProperties.getEventListener().getTopic(), String.valueOf(payload.hashCode()), payload); + new ProducerRecord<>( + kafkaProperties.getEventListener().getTopic(), + String.valueOf(payload.hashCode()), + payload); producerRecord .headers() @@ -205,7 +211,9 @@ public boolean publishBlockEvents( FabricClientConstants.IS_PRIVATE_DATA_PRESENT, isPrivateDataPresent.toString().getBytes())); - log.info("Publishing Block event to outbound topic {}", kafkaProperties.getEventListener().getTopic()); + log.info( + "Publishing Block event to outbound topic {}", + kafkaProperties.getEventListener().getTopic()); ListenableFuture> future = kafkaTemplate.send(producerRecord); diff --git a/src/test/java/hlf/java/rest/client/integration/ConfigHandlerControllerIntegrationTest.java b/src/test/java/hlf/java/rest/client/integration/ConfigHandlerControllerIntegrationTest.java index 49eff10a..dac61a3a 100644 --- a/src/test/java/hlf/java/rest/client/integration/ConfigHandlerControllerIntegrationTest.java +++ b/src/test/java/hlf/java/rest/client/integration/ConfigHandlerControllerIntegrationTest.java @@ -81,7 +81,7 @@ private static class TestConfiguration { static String FABRIC_PROPERTIES_CLIENT = "FabricProperties.Client(rest=FabricProperties.Client.Rest(apikey=expected-key))"; static String FABRIC_PROPERTIES_EVENTS = - "FabricProperties.Events(enable=true, chaincode=[chaincode12, chaincode2], block=[block111, block2], chaincodeDetails=null)"; + "FabricProperties.Events(enable=true, chaincode=[chaincode12, chaincode2], standardCCEventEnabled=false, block=[block111, block2], chaincodeDetails=null)"; static String KAFKA_PROPERTIES_PRODUCER = "Producer{brokerHost='localhost:8087', topic='hlf-offchain-topic1', saslJaasConfig='null'}"; static String KAFKA_CONSUMER_PROPERTIES = diff --git a/src/test/resources/integration/sample-application.yml b/src/test/resources/integration/sample-application.yml index 2535ba80..7544a1e5 100644 --- a/src/test/resources/integration/sample-application.yml +++ b/src/test/resources/integration/sample-application.yml @@ -36,6 +36,7 @@ fabric: apikey: expected-key events: enable: true + standardCCEventEnabled: false chaincode: chaincode12, chaincode2 block: block111, block2 kafka: @@ -69,6 +70,7 @@ fabric: filename: connection.yaml events: enable: false + standardCCEventEnabled: false chaincode: channel1 block: channel1 client: