You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2023/02/15 06:44:55 UTC

[streampipes] 01/02: [hotfix] Remove set adapters from extensions

This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch remove-set-adapters
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 2f9d615657b9c932cb7d010d542503d7bd5c9de8
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Wed Feb 15 07:33:49 2023 +0100

    [hotfix] Remove set adapters from extensions
---
 .../connect/iiot/ConnectAdapterIiotInit.java       |   4 -
 .../connect/iiot/protocol/set/FileProtocol.java    | 140 -------------------
 .../connect/iiot/protocol/set/HttpProtocol.java    | 148 ---------------------
 .../documentation.md                               |  32 -----
 .../icon.png                                       | Bin 12881 -> 0 bytes
 .../strings.en                                     |  28 ----
 .../documentation.md                               |  32 -----
 .../icon.png                                       | Bin 17467 -> 0 bytes
 .../strings.en                                     |  25 ----
 9 files changed, 409 deletions(-)

diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/ConnectAdapterIiotInit.java b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/ConnectAdapterIiotInit.java
index fab0dde2e..318a02c1b 100644
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/ConnectAdapterIiotInit.java
+++ b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/ConnectAdapterIiotInit.java
@@ -23,8 +23,6 @@ import org.apache.streampipes.connect.iiot.adapters.plc4x.modbus.Plc4xModbusAdap
 import org.apache.streampipes.connect.iiot.adapters.plc4x.s7.Plc4xS7Adapter;
 import org.apache.streampipes.connect.iiot.adapters.ros.RosBridgeAdapter;
 import org.apache.streampipes.connect.iiot.adapters.simulator.machine.MachineDataStreamAdapter;
-import org.apache.streampipes.connect.iiot.protocol.set.FileProtocol;
-import org.apache.streampipes.connect.iiot.protocol.set.HttpProtocol;
 import org.apache.streampipes.connect.iiot.protocol.stream.FileStreamProtocol;
 import org.apache.streampipes.connect.iiot.protocol.stream.HttpServerProtocol;
 import org.apache.streampipes.connect.iiot.protocol.stream.HttpStreamProtocol;
@@ -54,8 +52,6 @@ public class ConnectAdapterIiotInit extends ExtensionsModelSubmitter {
         .registerAdapter(new OpcUaAdapter())
         .registerAdapter(new Plc4xS7Adapter())
         .registerAdapter(new Plc4xModbusAdapter())
-        .registerAdapter(new FileProtocol())
-        .registerAdapter(new HttpProtocol())
         .registerAdapter(new FileStreamProtocol())
         .registerAdapter(new KafkaProtocol())
         .registerAdapter(new MqttProtocol())
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/protocol/set/FileProtocol.java b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/protocol/set/FileProtocol.java
deleted file mode 100644
index 347826e12..000000000
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/protocol/set/FileProtocol.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.streampipes.connect.iiot.protocol.set;
-
-
-import org.apache.streampipes.connect.iiot.utils.FileProtocolUtils;
-import org.apache.streampipes.extensions.api.connect.IAdapterPipeline;
-import org.apache.streampipes.extensions.api.connect.IFormat;
-import org.apache.streampipes.extensions.api.connect.IParser;
-import org.apache.streampipes.extensions.api.connect.exception.ParseException;
-import org.apache.streampipes.extensions.management.connect.SendToPipeline;
-import org.apache.streampipes.extensions.management.connect.adapter.guess.SchemaGuesser;
-import org.apache.streampipes.extensions.management.connect.adapter.model.generic.Protocol;
-import org.apache.streampipes.model.AdapterType;
-import org.apache.streampipes.model.connect.grounding.ProtocolDescription;
-import org.apache.streampipes.model.connect.guess.GuessSchema;
-import org.apache.streampipes.model.schema.EventSchema;
-import org.apache.streampipes.sdk.builder.adapter.ProtocolDescriptionBuilder;
-import org.apache.streampipes.sdk.extractor.StaticPropertyExtractor;
-import org.apache.streampipes.sdk.helpers.AdapterSourceType;
-import org.apache.streampipes.sdk.helpers.Filetypes;
-import org.apache.streampipes.sdk.helpers.Labels;
-import org.apache.streampipes.sdk.helpers.Locales;
-import org.apache.streampipes.sdk.utils.Assets;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.InputStream;
-import java.util.List;
-
-public class FileProtocol extends Protocol {
-
-  private static Logger logger = LoggerFactory.getLogger(FileProtocol.class);
-
-  public static final String ID = "org.apache.streampipes.connect.iiot.protocol.set.file";
-
-  private String selectedFilename;
-
-  public FileProtocol() {
-  }
-
-  public FileProtocol(IParser parser,
-                      IFormat format,
-                      String selectedFilename) {
-    super(parser, format);
-    this.selectedFilename = selectedFilename;
-  }
-
-  @Override
-  public ProtocolDescription declareModel() {
-    return ProtocolDescriptionBuilder.create(ID)
-        .withAssets(Assets.DOCUMENTATION, Assets.ICON)
-        .withLocales(Locales.EN)
-        .sourceType(AdapterSourceType.SET)
-        .category(AdapterType.Generic)
-        .requiredFile(Labels.withId("filePath"), Filetypes.XML, Filetypes.JSON, Filetypes.CSV)
-        .build();
-  }
-
-  @Override
-  public Protocol getInstance(ProtocolDescription protocolDescription, IParser parser, IFormat format) {
-    StaticPropertyExtractor extractor = StaticPropertyExtractor.from(protocolDescription.getConfig());
-    String selectedFilename = extractor.selectedFilename("filePath");
-    return new FileProtocol(parser, format, selectedFilename);
-  }
-
-  @Override
-  public void run(IAdapterPipeline adapterPipeline) {
-    FileReader fr = null;
-
-    // TODO fix this. Currently needed because it must be wait till the whole pipeline is up and running
-    try {
-      Thread.sleep(7000);
-    } catch (InterruptedException e) {
-      e.printStackTrace();
-    }
-    SendToPipeline stk = new SendToPipeline(format, adapterPipeline);
-    try {
-      InputStream dataInputStream = FileProtocolUtils.getFileInputStream(this.selectedFilename);
-      if (dataInputStream != null) {
-        parser.parse(dataInputStream, stk);
-      } else {
-        logger.warn("Could not read data from file.");
-      }
-    } catch (ParseException e) {
-      logger.error("Error while parsing: " + e.getMessage());
-    } catch (FileNotFoundException e) {
-      logger.error("Error reading file: " + e.getMessage());
-    }
-  }
-
-  @Override
-  public void stop() {
-
-  }
-
-  @Override
-  public GuessSchema getGuessSchema() throws ParseException {
-
-    try {
-      InputStream targetStream = FileProtocolUtils.getFileInputStream(this.selectedFilename);
-      List<byte[]> dataByte = parser.parseNEvents(targetStream, 20);
-
-      if (parser.supportsPreview()) {
-        return SchemaGuesser.guessSchema(parser.getSchemaAndSample(dataByte));
-      } else {
-        EventSchema eventSchema = parser.getEventSchema(dataByte);
-        return SchemaGuesser.guessSchema(eventSchema);
-      }
-    } catch (FileNotFoundException e) {
-      throw new ParseException("Could not read local file");
-    }
-  }
-
-
-  @Override
-  public String getId() {
-    return ID;
-  }
-
-}
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/protocol/set/HttpProtocol.java b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/protocol/set/HttpProtocol.java
deleted file mode 100644
index d72001c11..000000000
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/protocol/set/HttpProtocol.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.streampipes.connect.iiot.protocol.set;
-
-import org.apache.streampipes.extensions.api.connect.IAdapterPipeline;
-import org.apache.streampipes.extensions.api.connect.IFormat;
-import org.apache.streampipes.extensions.api.connect.IParser;
-import org.apache.streampipes.extensions.api.connect.exception.ParseException;
-import org.apache.streampipes.extensions.management.connect.SendToPipeline;
-import org.apache.streampipes.extensions.management.connect.adapter.guess.SchemaGuesser;
-import org.apache.streampipes.extensions.management.connect.adapter.model.generic.Protocol;
-import org.apache.streampipes.extensions.management.connect.adapter.sdk.ParameterExtractor;
-import org.apache.streampipes.model.AdapterType;
-import org.apache.streampipes.model.connect.grounding.ProtocolDescription;
-import org.apache.streampipes.model.connect.guess.GuessSchema;
-import org.apache.streampipes.model.schema.EventSchema;
-import org.apache.streampipes.sdk.builder.adapter.ProtocolDescriptionBuilder;
-import org.apache.streampipes.sdk.helpers.AdapterSourceType;
-import org.apache.streampipes.sdk.helpers.Labels;
-import org.apache.streampipes.sdk.helpers.Locales;
-import org.apache.streampipes.sdk.utils.Assets;
-
-import org.apache.http.client.fluent.Request;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-public class HttpProtocol extends Protocol {
-
-  Logger logger = LoggerFactory.getLogger(Protocol.class);
-
-  public static final String ID = "org.apache.streampipes.connect.iiot.protocol.set.http";
-
-  private String url;
-
-  public HttpProtocol() {
-  }
-
-  public HttpProtocol(IParser parser, IFormat format, String url) {
-    super(parser, format);
-    this.url = url;
-  }
-
-  @Override
-  public ProtocolDescription declareModel() {
-    return ProtocolDescriptionBuilder.create(ID)
-        .withAssets(Assets.DOCUMENTATION, Assets.ICON)
-        .withLocales(Locales.EN)
-        .category(AdapterType.Generic)
-        .sourceType(AdapterSourceType.SET)
-        .requiredTextParameter(Labels.withId("url"))
-        .build();
-  }
-
-  @Override
-  public Protocol getInstance(ProtocolDescription protocolDescription, IParser parser, IFormat format) {
-    ParameterExtractor extractor = new ParameterExtractor(protocolDescription.getConfig());
-    String url = extractor.singleValue("url");
-
-    return new HttpProtocol(parser, format, url);
-  }
-
-  @Override
-  public void run(IAdapterPipeline adapterPipeline) {
-
-    // TODO fix this. Currently needed because it must be wait till the whole pipeline is up and running
-    try {
-      Thread.sleep(7000);
-    } catch (InterruptedException e) {
-      e.printStackTrace();
-    }
-
-    SendToPipeline stk = new SendToPipeline(format, adapterPipeline);
-
-    InputStream data = getDataFromEndpoint();
-    try {
-      parser.parse(data, stk);
-
-    } catch (ParseException e) {
-      logger.error("Error while parsing: " + e.getMessage());
-    }
-  }
-
-  @Override
-  public void stop() {
-
-  }
-
-
-  @Override
-  public GuessSchema getGuessSchema() throws ParseException {
-
-    InputStream dataInputStream = getDataFromEndpoint();
-
-    List<byte[]> dataByte = parser.parseNEvents(dataInputStream, 2);
-
-    EventSchema eventSchema = parser.getEventSchema(dataByte);
-
-    GuessSchema result = SchemaGuesser.guessSchema(eventSchema);
-
-    return result;
-  }
-
-
-  public InputStream getDataFromEndpoint() throws ParseException {
-    InputStream result = null;
-
-    try {
-      result = Request.Get(url)
-          .connectTimeout(1000)
-          .socketTimeout(100000)
-          .execute().returnContent().asStream();
-
-    } catch (IOException e) {
-      throw new ParseException("Could not receive Data from: " + url);
-    }
-
-    if (result == null) {
-      throw new ParseException("Could not receive Data from: " + url);
-    }
-
-    return result;
-  }
-
-  @Override
-  public String getId() {
-    return ID;
-  }
-}
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/documentation.md b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/documentation.md
deleted file mode 100644
index 4fb4f06af..000000000
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/documentation.md
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You 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.
-  ~
-  -->
-
-## File (Set)
-
-<p align="center"> 
-    <img src="icon.png" width="150px;" class="pe-image-documentation"/>
-</p>
-
-***
-
-## Description
-
-Reads the content from a local file.
-
-***
-
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/icon.png b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/icon.png
deleted file mode 100644
index 2b3a03785..000000000
Binary files a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/icon.png and /dev/null differ
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/strings.en b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/strings.en
deleted file mode 100644
index f2664442d..000000000
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.file/strings.en
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-
-org.apache.streampipes.connect.iiot.protocol.set.file.title=File Set
-org.apache.streampipes.connect.iiot.protocol.set.file.description=Reads the content from a local file.
-
-interval-key.title=Interval [ms]
-interval-key.description=Define waiting time between the files
-
-filePath.title=File
-filePath.description=File Path
-
-
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/documentation.md b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/documentation.md
deleted file mode 100644
index 2ea964000..000000000
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/documentation.md
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You 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.
-  ~
-  -->
-
-## HTTP (Set)
-
-<p align="center"> 
-    <img src="icon.png" width="150px;" class="pe-image-documentation"/>
-</p>
-
-***
-
-## Description
-
-Regularly poll an HTTP endpoint
-
-***
-
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/icon.png b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/icon.png
deleted file mode 100644
index b44424d88..000000000
Binary files a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/icon.png and /dev/null differ
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/strings.en b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/strings.en
deleted file mode 100644
index cc775b028..000000000
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/resources/org.apache.streampipes.connect.iiot.protocol.set.http/strings.en
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-
-org.apache.streampipes.connect.iiot.protocol.set.http.title=HTTP Set
-org.apache.streampipes.connect.iiot.protocol.set.http.description=Regularly poll an HTTP endpoint
-
-url.title=URL
-url.description=Example: http(s)://test-server.com
-
-