Skip to content

Commit

Permalink
Merge pull request #103 from SoftwareAG/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
switschel authored May 8, 2024
2 parents 34a2083 + b02359b commit d4e2cd0
Show file tree
Hide file tree
Showing 170 changed files with 16,987 additions and 34,864 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ jobs:
- name: deploy
uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 18.x
- run: npm i
working-directory: ./dynamic-mapping-ui
- run: npm install -g @angular/cli > /dev/null
working-directory: ./dynamic-mapping-ui
- run: npm run build --if-present
working-directory: ./dynamic-mapping-ui
- name: Zip Frontend
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
cd dynamic-mapping-ui/dist/apps/sag-ps-pkg-dynamic-mapping
zip -r -q ../../../dynamic-mapping-ui.zip *
cd dynamic-mapping-ui/dist/dynamic-mapping-ui
zip -r -q ../../dynamic-mapping-ui.zip *
- name: Create Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
id: create_release
Expand All @@ -52,7 +54,7 @@ jobs:
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
draft: true
prerelease: false
- name: Upload Release Asset Frontend
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ target/
logs/
bin/
attic/*
dist/


.factorypath
set.sh
dynamic-mapping-ui/.env

**/.flattened-pom.xml
.flattened-pom.xml
dist
node_modules
.angular
dynamic-mapping-ui/cypress.env.js
dynamic-mapping-ui/cypress/videos
dynamic-mapping-ui/cypress/screenshots
dynamic-mapping-ui/cypress/fixtures/mqttConnectionPostRequest.json
dynamic-mapping-service/src/main/configuration/dynamic-mapping-service-logging.xml
JSONata4Java/dependency-reduced-pom.xml
130 changes: 73 additions & 57 deletions README.md

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions dynamic-mapping-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>
<!-- <dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<scope>test</scope>
</dependency> -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<groupId>com.hivemq</groupId>
<artifactId>hivemq-mqtt-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import dynamic.mapping.processor.model.RepairStrategy;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.stereotype.Component;

import javax.ws.rs.ProcessingException;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,68 +21,81 @@

package dynamic.mapping;

import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import java.util.Date;

import com.hivemq.client.mqtt.datatypes.MqttQos;
import com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClient;
import com.hivemq.client.mqtt.mqtt3.Mqtt3BlockingClient;
import com.hivemq.client.mqtt.mqtt3.Mqtt3Client;
import com.hivemq.client.mqtt.mqtt3.message.auth.Mqtt3SimpleAuth;
import com.hivemq.client.mqtt.mqtt3.message.connect.connack.Mqtt3ConnAck;
import com.hivemq.client.mqtt.mqtt3.message.connect.connack.Mqtt3ConnAckReturnCode;

import dynamic.mapping.processor.extension.external.CustomEventOuter;
import dynamic.mapping.processor.extension.external.CustomEventOuter.CustomEvent;


public class ProtobufPahoClient {

static MemoryPersistence persistence = new MemoryPersistence();
Mqtt3BlockingClient testClient;
static String broker_host = System.getenv("broker_host");
static Integer broker_port = Integer.valueOf(System.getenv("broker_port"));
static String client_id = System.getenv("client_id");
static String broker_username = System.getenv("broker_username");
static String broker_password = System.getenv("broker_password");

public ProtobufPahoClient(Mqtt3BlockingClient sampleClient) {
testClient = sampleClient;
}

public static void main(String[] args) {

ProtobufPahoClient client = new ProtobufPahoClient();
Mqtt3SimpleAuth simpleAuth = Mqtt3SimpleAuth.builder().username(broker_username)
.password(broker_password.getBytes()).build();
Mqtt3BlockingClient sampleClient = Mqtt3Client.builder()
.serverHost(broker_host)
.serverPort(broker_port)
.identifier(client_id)
.simpleAuth(simpleAuth)
.sslWithDefaultConfig()
.buildBlocking();
ProtobufPahoClient client = new ProtobufPahoClient(sampleClient);
client.testSendEvent();
}

private void testSendEvent() {
int qos = 0;
String broker = System.getenv("broker");
String client_id = System.getenv("client_id");
String broker_username = System.getenv("broker_username");
String broker_password = System.getenv("broker_password");
String topic2 = "protobuf/event";

try {
MqttClient sampleClient = new MqttClient(broker, client_id, persistence);
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setUserName(broker_username);
connOpts.setPassword(broker_password.toCharArray());
connOpts.setCleanSession(true);

System.out.println("Connecting to broker: " + broker);

sampleClient.connect(connOpts);

System.out.println("Publishing message: :::");
String topic = "protobuf/event";

System.out.println("Connecting to broker: ssl://" + broker_host + ":" + broker_port);

// testClient.connect();
Mqtt3ConnAck ack = testClient.connectWith()
.cleanSession(true)
.keepAlive(60)
.send();
if (!ack.getReturnCode().equals(Mqtt3ConnAckReturnCode.SUCCESS)) {
// throw new ConnectorException("Tenant " + tenant + " - Error connecting to
// broker:"
// + mqttClient.getConfig().getServerHost() + ". Errorcode: "
// + ack.getReturnCode().name());
System.out.println("Error connecting to broker:"
+ broker_host + ". Errorcode: "
+ ack.getReturnCode().name());
}

CustomEventOuter.CustomEvent proto = CustomEvent.newBuilder()
.setExternalIdType("c8y_Serial")
.setExternalId("berlin_01")
.setTxt("Dummy Text")
.setEventType("c8y_ProtobufEventType")
.setTimestamp(System.currentTimeMillis())
.build();
System.out.println("Publishing message on topic" + topic);

MqttMessage message = new MqttMessage(proto.toByteArray());
message.setQos(qos);
sampleClient.publish(topic2, message);
CustomEventOuter.CustomEvent proto = CustomEvent.newBuilder()
.setExternalIdType("c8y_Serial")
.setExternalId("berlin_01")
.setTxt("Stop at petrol station: " + (new Date().toString()))
.setEventType("c8y_ProtobufEventType")
.setTimestamp(System.currentTimeMillis())
.build();

System.out.println("Message published");
sampleClient.disconnect();
System.out.println("Disconnected");
//System.exit(0);
Mqtt3AsyncClient sampleClientAsync = testClient.toAsync();
sampleClientAsync.publishWith().topic(topic).qos(MqttQos.AT_LEAST_ONCE).payload(proto.toByteArray()).send();

} catch (MqttException me) {
System.out.println("Exception:" + me.getMessage());
me.printStackTrace();
}
System.out.println("Message published");
testClient.disconnect();
System.out.println("Disconnected");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void testDeserializeCustomEvent() {
.build();

ProcessorExtensionInboundCustomEvent extension = new ProcessorExtensionInboundCustomEvent();
ProcessingContext context = new ProcessingContext();
ProcessingContext<byte[]> context = new ProcessingContext<>();
context.setPayload(proto.toByteArray());
Mapping m1 = new Mapping();
m1.setTargetAPI(API.EVENT);
Expand Down
18 changes: 15 additions & 3 deletions dynamic-mapping-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
<dependency>
<groupId>com.hivemq</groupId>
<artifactId>hivemq-mqtt-client</artifactId>
</dependency>
<dependency>
<groupId>com.ibm.jsonata4java</groupId>
<artifactId>JSONata4Java</artifactId>
Expand Down Expand Up @@ -78,7 +82,15 @@
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>com.github.loki4j</groupId>
<artifactId>loki-logback-appender</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>../dynamic-mapping-service/src/main/java</sourceDirectory>
<plugins>
Expand Down
59 changes: 48 additions & 11 deletions dynamic-mapping-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,25 @@
<c8y-artefact-name>dynamic-mapping-service</c8y-artefact-name>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.ibm.jsonata4java</groupId>
<artifactId>JSONata4Java</artifactId>
<version>2.4.9</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
Expand All @@ -65,12 +78,8 @@
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
</dependency>
<dependency>
<groupId>com.ibm.jsonata4java</groupId>
<artifactId>JSONata4Java</artifactId>
<groupId>com.hivemq</groupId>
<artifactId>hivemq-mqtt-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -89,9 +98,37 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.ibm.jsonata4java</groupId>
<artifactId>JSONata4JavaFIX</artifactId>
<version>2.4.8-fix</version>
</dependency>
<!-- <dependency>
<groupId>com.ibm.jsonata4java</groupId>
<artifactId>JSONata4Java</artifactId>
</dependency> -->
</dependencies>

<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"ROLE_NOTIFICATION_2_ADMIN",
"ROLE_USER_MANAGEMENT_READ",
"ROLE_USER_MANAGEMENT_CREATE",
"ROLE_USER_MANAGEMENT_ADMIN"
"ROLE_USER_MANAGEMENT_ADMIN",
"ROLE_MQTT_SERVICE_ADMIN"
],
"roles":[
"ROLE_MAPPING_ADMIN",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />

<logger name="com.cumulocity.microservice.security.filter.provider.SpringSecurityContextProvider" level="ERROR" />

<appender name="OpenTelemetry"
class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="OpenTelemetry"/>
</root>
</configuration>
Loading

0 comments on commit d4e2cd0

Please sign in to comment.