diff --git a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapter.java b/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapter.java index 00cd4b0f2..f5f22a6e2 100644 --- a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapter.java +++ b/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapter.java @@ -77,7 +77,7 @@ /** * @author HiveMQ Adapter Generator */ -public class HttpProtocolAdapter implements PollingProtocolAdapter, WritingProtocolAdapter { +public class HttpProtocolAdapter implements PollingProtocolAdapter { private static final @NotNull Logger log = LoggerFactory.getLogger(HttpProtocolAdapter.class); @@ -303,7 +303,7 @@ public int getMaxPollingErrorsBeforeRemoval() { return adapterConfig.getHttpToMqttConfig().getMaxPollingErrorsBeforeRemoval(); } - @Override + //Deactivated for now public void write(final @NotNull WritingInput writingInput, final @NotNull WritingOutput writingOutput) { if (httpClient == null) { writingOutput.fail(new ProtocolAdapterException(), "No response was created, because the client is null."); @@ -373,11 +373,6 @@ public void createTagSchema( output.finish(JsonSchema.createJsonSchema()); } - @Override - public @NotNull Class getMqttPayloadClass() { - return HttpPayload.class; - } - private static boolean isSuccessStatusCode(final int statusCode) { return statusCode >= 200 && statusCode <= 299; } diff --git a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterInformation.java b/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterInformation.java index 6ce22441f..17427012e 100644 --- a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterInformation.java +++ b/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterInformation.java @@ -21,7 +21,6 @@ import com.hivemq.adapter.sdk.api.ProtocolAdapterTag; import com.hivemq.adapter.sdk.api.config.ProtocolSpecificAdapterConfig; import com.hivemq.adapter.sdk.api.tag.Tag; -import com.hivemq.edge.adapters.http.config.BidirectionalHttpSpecificAdapterConfig; import com.hivemq.edge.adapters.http.config.HttpSpecificAdapterConfig; import com.hivemq.edge.adapters.http.tag.HttpTag; import org.apache.commons.io.IOUtils; @@ -131,6 +130,6 @@ public List getTags() { @Override public @NotNull Class configurationClassNorthAndSouthbound() { - return BidirectionalHttpSpecificAdapterConfig.class; + return HttpSpecificAdapterConfig.class; } } diff --git a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/config/BidirectionalHttpSpecificAdapterConfig.java b/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/config/BidirectionalHttpSpecificAdapterConfig.java deleted file mode 100644 index c579c029b..000000000 --- a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/config/BidirectionalHttpSpecificAdapterConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2023-present HiveMQ GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.hivemq.edge.adapters.http.config; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.hivemq.adapter.sdk.api.annotations.ModuleConfigField; -import com.hivemq.edge.adapters.http.config.http2mqtt.HttpToMqttConfig; -import com.hivemq.edge.adapters.http.config.mqtt2http.MqttToHttpConfig; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Objects; - -public class BidirectionalHttpSpecificAdapterConfig extends HttpSpecificAdapterConfig { - - @JsonProperty(value = "mqttToHttp", access = JsonProperty.Access.WRITE_ONLY) - @ModuleConfigField(title = "MQTT to HTTP Config", - description = "The configuration for a data stream from MQTT to HTTP") - private final @NotNull MqttToHttpConfig mqttToHttpConfig; - - @JsonCreator - public BidirectionalHttpSpecificAdapterConfig( - @JsonProperty(value = "httpConnectTimeoutSeconds") final @Nullable Integer httpConnectTimeoutSeconds, - @JsonProperty(value = "httpToMqtt") final @Nullable HttpToMqttConfig httpToMqttConfig, - @JsonProperty(value = "mqttToHttp", - access = JsonProperty.Access.WRITE_ONLY) final @Nullable MqttToHttpConfig mqttToHttpConfig, - @JsonProperty(value = "allowUntrustedCertificates") final @Nullable Boolean allowUntrustedCertificates) { - super(httpConnectTimeoutSeconds, httpToMqttConfig, allowUntrustedCertificates); - this.mqttToHttpConfig = Objects.requireNonNullElseGet(mqttToHttpConfig, () -> new MqttToHttpConfig(List.of())); - } - - public @NotNull MqttToHttpConfig getMqttToHttpConfig() { - return mqttToHttpConfig; - } - -} diff --git a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/config/mqtt2http/MqttToHttpConfig.java b/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/config/mqtt2http/MqttToHttpConfig.java deleted file mode 100644 index d1b3b72ca..000000000 --- a/modules/hivemq-edge-module-http/src/main/java/com/hivemq/edge/adapters/http/config/mqtt2http/MqttToHttpConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hivemq.edge.adapters.http.config.mqtt2http; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.hivemq.adapter.sdk.api.annotations.ModuleConfigField; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Objects; - -public class MqttToHttpConfig { - - private final @NotNull List mappings; - - public MqttToHttpConfig(final @Nullable List mappings) { - this.mappings = Objects.requireNonNullElse(mappings, List.of()); - } - - public @NotNull List getMappings() { - return mappings; - } -} diff --git a/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/config/HttpProtocolAdapterConfigTest.java b/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/config/HttpProtocolAdapterConfigTest.java index eac56e2b1..8d3e0e1f5 100644 --- a/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/config/HttpProtocolAdapterConfigTest.java +++ b/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/config/HttpProtocolAdapterConfigTest.java @@ -25,10 +25,7 @@ import com.hivemq.configuration.reader.ConfigFileReaderWriter; import com.hivemq.configuration.reader.ConfigurationFile; import com.hivemq.edge.adapters.http.HttpProtocolAdapterFactory; -import com.hivemq.edge.adapters.http.config.HttpSpecificAdapterConfig.HttpHeader; import com.hivemq.edge.adapters.http.config.http2mqtt.HttpToMqttConfig; -import com.hivemq.edge.adapters.http.config.mqtt2http.MqttToHttpConfig; -import com.hivemq.edge.adapters.http.config.mqtt2http.MqttToHttpMapping; import com.hivemq.edge.adapters.http.tag.HttpTag; import com.hivemq.exceptions.UnrecoverableException; import com.hivemq.persistence.mappings.NorthboundMapping; @@ -93,8 +90,8 @@ public void convertConfigObject_defaults() throws Exception { final HttpProtocolAdapterFactory httpProtocolAdapterFactory = new HttpProtocolAdapterFactory(mockInput); - final BidirectionalHttpSpecificAdapterConfig config = - (BidirectionalHttpSpecificAdapterConfig)httpProtocolAdapterFactory.convertConfigObject(mapper, adapter.getConfig(), true); + final HttpSpecificAdapterConfig config = + (HttpSpecificAdapterConfig)httpProtocolAdapterFactory.convertConfigObject(mapper, adapter.getConfig(), true); final List> tagMaps = adapter.getTags().stream().map(tagEntity -> tagEntity.toMap()).collect(Collectors.toList()); @@ -153,7 +150,7 @@ public void convertConfigObject_emptyHeaders() throws Exception { assertThat(protocolAdapterConfig.missingTags()) .isEmpty(); - final BidirectionalHttpSpecificAdapterConfig config = (BidirectionalHttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig(); + final HttpSpecificAdapterConfig config = (HttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig(); assertThat(protocolAdapterConfig.getAdapterId()).isEqualTo("my-protocol-adapter"); assertThat(config.getHttpConnectTimeoutSeconds()).isEqualTo(50); @@ -182,7 +179,7 @@ public void convertConfigObject_full() throws Exception { assertThat(protocolAdapterConfig.missingTags()) .isEmpty(); - final BidirectionalHttpSpecificAdapterConfig config = (BidirectionalHttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig(); + final HttpSpecificAdapterConfig config = (HttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig(); assertThat(protocolAdapterConfig.getAdapterId()).isEqualTo("my-protocol-adapter"); assertThat(config.getHttpToMqttConfig().isHttpPublishSuccessStatusCodeOnly()).isTrue(); @@ -281,7 +278,7 @@ public void convertConfigObject_full() throws Exception { @Test public void unconvertConfigObject_full() throws Exception { - final BidirectionalHttpSpecificAdapterConfig httpAdapterConfig = new BidirectionalHttpSpecificAdapterConfig( + final HttpSpecificAdapterConfig httpAdapterConfig = new HttpSpecificAdapterConfig( 50, new HttpToMqttConfig( 1337, @@ -289,29 +286,6 @@ public void unconvertConfigObject_full() throws Exception { true, true ), - new MqttToHttpConfig(List.of( - new MqttToHttpMapping( - "tag3", - "my0/#", - 1, - POST, - 12, - List.of( - new HttpHeader("foo 1", "bar 1"), - new HttpHeader("foo 2", "bar 2") - ) - ), - new MqttToHttpMapping( - "tag4", - "my1/#", - 2, - POST, - 11, - List.of( - new HttpHeader("foo 1", "bar 1"), - new HttpHeader("foo 2", "bar 2") - ) - ))), true ); @@ -345,7 +319,7 @@ public void unconvertConfigObject_full() throws Exception { @Test public void unconvertConfigObject_defaults() { - final BidirectionalHttpSpecificAdapterConfig httpAdapterConfig = new BidirectionalHttpSpecificAdapterConfig( + final HttpSpecificAdapterConfig httpAdapterConfig = new HttpSpecificAdapterConfig( null, new HttpToMqttConfig( null, @@ -353,15 +327,6 @@ public void unconvertConfigObject_defaults() { null, null ), - new MqttToHttpConfig(List.of( - new MqttToHttpMapping( - "tag1", - "my/#", - null, - null, - null, - null - ))), null );