Skip to content

Commit

Permalink
Update mvn dependency for json-schema
Browse files Browse the repository at this point in the history
Dependency updates for package version

Signed-off-by: S m, Aruna <aruna.mohan@walmart.com>
  • Loading branch information
arsulegai committed Jan 4, 2024
1 parent a877df8 commit e2af5ef
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 34 deletions.
59 changes: 53 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,40 @@
<artifactId>fabric-chaincode-shim</artifactId>
<version>${fabric-chaincode-java.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.github.everit-org.json-schema</groupId>
<artifactId>org.everit.json.schema</artifactId>
</exclusion>
<exclusion>
<groupId>org.hyperledger.fabric-chaincode-java</groupId>
<artifactId>fabric-chaincode-protos</artifactId>
</exclusion>
<exclusion>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.owlike</groupId>
<artifactId>genson</artifactId>
<version>1.5</version>
<scope>compile</scope>
<groupId>org.hyperledger.fabric-chaincode-java</groupId>
<artifactId>fabric-chaincode-protos</artifactId>
<version>${fabric-chaincode-java.version}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.139</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -157,12 +185,20 @@
<dependency>
<groupId>org.hyperledger.fabric-sdk-java</groupId>
<artifactId>fabric-sdk-java</artifactId>
<version>2.2.12</version>
<version>2.2.25</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Logging -->
Expand All @@ -181,6 +217,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down Expand Up @@ -214,7 +256,12 @@
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.11</version>
</dependency>
</dependencies>

<distributionManagement>
<repository>
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/hlf/java/rest/client/sdk/StandardCCEvent.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ private Common.Envelope getChannelCreationTransaction(
*/
private Configtx.ConfigUpdate newConfigUpdate(ChannelOperationRequest channelOperationRequest) {
Map<String, MSPDTO> 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,7 +38,8 @@ public boolean sendMessage(String msg, String fabricTxId, String eventName, Stri
try {

ProducerRecord<String, String> producerRecord =
new ProducerRecord<String, String>(kafkaProperties.getEventListener().getTopic(), String.valueOf(msg.hashCode()), msg);
new ProducerRecord<String, String>(
kafkaProperties.getEventListener().getTopic(), String.valueOf(msg.hashCode()), msg);

producerRecord
.headers()
Expand Down Expand Up @@ -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<String, String> producerRecord =
new ProducerRecord<>(kafkaProperties.getEventListener().getTopic(), key, payload);

Expand All @@ -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<SendResult<String, String>> future = kafkaTemplate.send(producerRecord);

Expand Down Expand Up @@ -170,7 +173,10 @@ public boolean publishBlockEvents(
try {

ProducerRecord<String, String> producerRecord =
new ProducerRecord<>(kafkaProperties.getEventListener().getTopic(), String.valueOf(payload.hashCode()), payload);
new ProducerRecord<>(
kafkaProperties.getEventListener().getTopic(),
String.valueOf(payload.hashCode()),
payload);

producerRecord
.headers()
Expand Down Expand Up @@ -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<SendResult<String, String>> future = kafkaTemplate.send(producerRecord);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/integration/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fabric:
apikey: expected-key
events:
enable: true
standardCCEventEnabled: false
chaincode: chaincode12, chaincode2
block: block111, block2
kafka:
Expand Down Expand Up @@ -69,6 +70,7 @@ fabric:
filename: connection.yaml
events:
enable: false
standardCCEventEnabled: false
chaincode: channel1
block: channel1
client:
Expand Down

0 comments on commit e2af5ef

Please sign in to comment.