Skip to content

Commit

Permalink
updated datahub version to 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian-Limpoeck committed Aug 6, 2024
1 parent ee9ae1f commit 89e5a53
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion hivemq-edge/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jaxb = "2.3.9"
jctools = "4.0.5"
jersey = "2.43"
jose4j = "0.9.4"
jsonSchemaValidator = "1.0.88"
jsonSchemaValidator = "1.5.0"
junit-jupiter = "5.10.3"
junit = "4.13.2"
logback = "1.5.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

public class TimestampToDateConverter {

public static final @NotNull ZoneId ZONE_ID_UTC = ZoneId.of("UTC");
public static final DateTimeFormatter DATE_FORMAT_OUTBOUND =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.US);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.hivemq.configuration.service.RestrictionsConfigurationService;
import com.hivemq.configuration.service.entity.Listener;
import com.hivemq.extension.sdk.api.annotations.NotNull;
import com.hivemq.extension.sdk.api.annotations.Nullable;
import com.hivemq.mqtt.handler.connect.MessageBarrier;
import com.hivemq.mqtt.handler.publish.PublishFlushHandler;
import com.hivemq.security.exception.SslException;
Expand Down Expand Up @@ -109,7 +108,7 @@ protected void initChannel(final @NotNull T ch) throws Exception {
ch.pipeline()
.addLast(MQTT_MESSAGE_BARRIER, new MessageBarrier(channelDependencies.getMqttServerDisconnector()));

final @Nullable HandlerPackage handlerPackage = channelDependencies.getHandlerProvider().get();
final HandlerPackage handlerPackage = channelDependencies.getHandlerProvider().get();
if (handlerPackage != null) {
ch.pipeline().addLast(handlerPackage.getHandlerName(), handlerPackage.getHandler());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.networknt.schema.SpecVersion;
import com.networknt.schema.ValidationMessage;

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -47,8 +46,8 @@ public class ProtocolAdapterSchemaManager {
private @Nullable JsonSchema schema;

public ProtocolAdapterSchemaManager(
@NotNull final ObjectMapper objectMapper,
@NotNull final Class<? extends ProtocolAdapterConfig> configBean) {
final @NotNull ObjectMapper objectMapper,
final @NotNull Class<? extends ProtocolAdapterConfig> configBean) {
this.objectMapper = objectMapper;
this.configBean = configBean;
this.customConfigSchemaGenerator = new CustomConfigSchemaGenerator();
Expand All @@ -63,27 +62,16 @@ public ProtocolAdapterSchemaManager(

public synchronized @NotNull JsonSchema generateSchema() {
if (schema == null) {
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012);
final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012);
schema = factory.getSchema(generateSchemaNode());
schema.initializeValidators();
}
return schema;
}

public @NotNull List<ProtocolAdapterValidationFailure> validateJsonDocument(final byte @NotNull [] jsonDocument)
throws IOException {
JsonSchema schema = generateSchema();
Preconditions.checkNotNull(jsonDocument);
JsonNode node = objectMapper.readTree(jsonDocument);
return schema.validate(node)
.stream()
.map(ProtocolAdapterSchemaManager::convertMessage)
.collect(Collectors.toList());
}

public @NotNull List<ProtocolAdapterValidationFailure> validateObject(@NotNull final Object o) {
public @NotNull List<ProtocolAdapterValidationFailure> validateObject(final @NotNull Object o) {
Preconditions.checkNotNull(o);
JsonNode node;
final JsonNode node;
if (o instanceof JsonNode) {
node = (JsonNode) o;
} else {
Expand All @@ -96,9 +84,9 @@ public ProtocolAdapterSchemaManager(
}


static ProtocolAdapterValidationFailure convertMessage(ValidationMessage validationMessage) {
static ProtocolAdapterValidationFailure convertMessage(final @NotNull ValidationMessage validationMessage) {
return new ProtocolAdapterValidationFailureImpl(validationMessage.getMessage(),
validationMessage.getPath(),
validationMessage.getEvaluationPath().toString(),
validationMessage.getClass());
}

Expand Down

0 comments on commit 89e5a53

Please sign in to comment.