This is an automated email from the ASF dual-hosted git repository. riemer pushed a commit to branch move-logic-from-rest-extensions in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit ad1488a93fe83cf16e3db066db0762a5c1ff19bc Author: Dominik Riemer <[email protected]> AuthorDate: Fri Mar 13 12:03:50 2026 +0100 Remove welcome page from extensions service --- pom.xml | 6 - .../management/ExtensionAdapterManagement.java | 22 +++ .../extensions/management}/model/Description.java | 2 +- streampipes-rest-extensions/pom.xml | 15 -- .../AbstractPipelineElementResource.java | 8 -- .../streampipes/rest/extensions/WelcomePage.java | 72 ---------- .../rest/extensions/html/HTMLGenerator.java | 82 ----------- .../rest/extensions/html/JSONGenerator.java | 61 -------- .../extensions/html/page/WelcomePageGenerator.java | 154 --------------------- .../StreamPipesExtensionsServiceBase.java | 2 - 10 files changed, 23 insertions(+), 401 deletions(-) diff --git a/pom.xml b/pom.xml index 3ad42e83b3..efbe0d1d6c 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,6 @@ <!-- needs to be lower than 4.x.x, see https://github.com/apache/streampipes/issues/1495 --> <rdf4j.version>3.7.7</rdf4j.version> - <rendersnake.version>1.9.0</rendersnake.version> <rocketmq.version>5.0.2</rocketmq.version> <jsrosbridge.version>0.2.0</jsrosbridge.version> <s3.version>2.25.14</s3.version> @@ -773,11 +772,6 @@ <artifactId>jts-core</artifactId> <version>${jts-core.version}</version> </dependency> - <dependency> - <groupId>org.rendersnake</groupId> - <artifactId>rendersnake</artifactId> - <version>${rendersnake.version}</version> - </dependency> <dependency> <groupId>org.simplejavamail</groupId> <artifactId>simple-java-mail</artifactId> diff --git a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/ExtensionAdapterManagement.java b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/ExtensionAdapterManagement.java new file mode 100644 index 0000000000..f5db078801 --- /dev/null +++ b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/ExtensionAdapterManagement.java @@ -0,0 +1,22 @@ +/* + * 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.extensions.management; + +public class ExtensionAdapterManagement { +} diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/model/Description.java b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/model/Description.java similarity index 98% rename from streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/model/Description.java rename to streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/model/Description.java index 67bdeba0af..b6d579ad11 100644 --- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/model/Description.java +++ b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/model/Description.java @@ -16,7 +16,7 @@ * */ -package org.apache.streampipes.rest.extensions.html.model; +package org.apache.streampipes.extensions.management.model; public class Description { diff --git a/streampipes-rest-extensions/pom.xml b/streampipes-rest-extensions/pom.xml index 1af3208a7e..94159c3c00 100644 --- a/streampipes-rest-extensions/pom.xml +++ b/streampipes-rest-extensions/pom.xml @@ -54,21 +54,6 @@ <artifactId>swagger-annotations-jakarta</artifactId> </dependency> - <dependency> - <groupId>org.rendersnake</groupId> - <artifactId>rendersnake</artifactId> - <exclusions> - <exclusion> - <groupId>jakarta.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-webmvc</artifactId> - </exclusion> - </exclusions> - </dependency> - <!-- Test dependencies --> <dependency> <groupId>org.junit.jupiter</groupId> diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java index 7ed606c056..8021159a9b 100644 --- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java +++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java @@ -95,10 +95,6 @@ public abstract class AbstractPipelineElementResource< return rewrite(config.getDescription(), config.getAssetResolver()); } - protected NamedStreamPipesEntity prepareElement(NamedStreamPipesEntity desc) { - return rewrite(desc, null); - } - protected T getDeclarerById(String appId) { return getElementDeclarers().get(appId); } @@ -108,10 +104,6 @@ public abstract class AbstractPipelineElementResource< return declarer.declareConfig().getDescription(); } - protected NamedStreamPipesEntity rewrite(NamedStreamPipesEntity desc) { - return rewrite(desc, null); - } - protected NamedStreamPipesEntity rewrite(NamedStreamPipesEntity desc, AssetResolver assetResolver) { diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/WelcomePage.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/WelcomePage.java deleted file mode 100644 index aa9454b5f3..0000000000 --- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/WelcomePage.java +++ /dev/null @@ -1,72 +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.rest.extensions; - -import org.apache.streampipes.extensions.api.connect.StreamPipesAdapter; -import org.apache.streampipes.extensions.api.pe.IStreamPipesPipelineElement; -import org.apache.streampipes.extensions.management.init.DeclarersSingleton; -import org.apache.streampipes.rest.extensions.html.HTMLGenerator; -import org.apache.streampipes.rest.extensions.html.JSONGenerator; -import org.apache.streampipes.rest.extensions.html.page.WelcomePageGenerator; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Collection; - -@RestController -@RequestMapping("/") -public class WelcomePage { - - @GetMapping(produces = MediaType.TEXT_HTML_VALUE) - public String getWelcomePageHtml() { - WelcomePageGenerator welcomePage = getWelcomePageGenerator(); - HTMLGenerator html = new HTMLGenerator(welcomePage.buildUris()); - return html.buildHtml(); - } - - @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public String getWelcomePageJson() { - WelcomePageGenerator welcomePage = getWelcomePageGenerator(); - JSONGenerator json = new JSONGenerator(welcomePage.buildUris()); - return json.buildJson(); - } - - private WelcomePageGenerator getWelcomePageGenerator() { - return new WelcomePageGenerator( - DeclarersSingleton.getInstance().getBaseUri(), - getPipelineElements(), - getAdapters()); - } - - private Collection<IStreamPipesPipelineElement<?>> getPipelineElements() { - return DeclarersSingleton - .getInstance() - .getDeclarers() - .values(); - } - - private Collection<StreamPipesAdapter> getAdapters() { - return DeclarersSingleton - .getInstance() - .getAdapters(); - } -} diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/HTMLGenerator.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/HTMLGenerator.java deleted file mode 100644 index 8d5dec7d5a..0000000000 --- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/HTMLGenerator.java +++ /dev/null @@ -1,82 +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.rest.extensions.html; - -import org.apache.streampipes.rest.extensions.html.model.Description; - -import org.rendersnake.HtmlCanvas; - -import java.io.IOException; -import java.util.List; - -import static org.rendersnake.HtmlAttributesFactory.class_; -import static org.rendersnake.HtmlAttributesFactory.href; -import static org.rendersnake.HtmlAttributesFactory.name; - -public class HTMLGenerator { - - private List<Description> descriptions; - - public HTMLGenerator(List<Description> descriptions) { - this.descriptions = descriptions; - } - - public String buildHtml() { - HtmlCanvas html = new HtmlCanvas(); - try { - html - .head() - .meta(name("viewport").content("width=device-width, initial-scale=1")) - .macros().javascript("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js") - .macros().stylesheet("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css") - .macros().javascript("https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js") - .style().write("body {padding-top: 70px;}")._style() - ._head() - .body() - .nav(class_("navbar navbar-inverse navbar-fixed-top").style("background:#0A3F54")) - .div(class_("container")) - .div(class_("navbar-header")) - .a(class_("navbar-brand").style("color:white;")) - .content("StreamPipes Extensions Service") - ._div() - ._div() - ._nav() - .div(class_("container")); - - html.h4().write("This is a developer-oriented view." - + "Navigate to 'Install Pipeline Elements' in the StreamPipes " - + "UI to import the elements shown here.")._h4(); - - for (Description description : descriptions) { - - html.h3(); - html.write(description.getName()); - html._h3(); - html.h4().write("URI: ").a(href(description.getDescriptionUrl())) - .content(description.getDescriptionUrl())._h4(); - html.h4().write("Description: ").write(description.getDescription())._h4(); - } - html._div(); - html._body(); - } catch (IOException e) { - e.printStackTrace(); - } - return html.toHtml(); - } -} diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/JSONGenerator.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/JSONGenerator.java deleted file mode 100644 index 28e772842f..0000000000 --- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/JSONGenerator.java +++ /dev/null @@ -1,61 +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.rest.extensions.html; - -import org.apache.streampipes.rest.extensions.html.model.Description; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - -import java.util.List; - -public class JSONGenerator { - - private final List<Description> description; - - public JSONGenerator(List<Description> description) { - this.description = description; - } - - public String buildJson() { - JsonArray jsonArray = new JsonArray(); - description.forEach(d -> jsonArray.add(getJsonElement(d))); - return jsonArray.toString(); - } - - private JsonObject getJsonElement(Description d) { - return makeDescription(d); - } - - private JsonObject makeDescription(Description d) { - JsonObject obj = new JsonObject(); - obj.add("uri", new JsonPrimitive(d.getDescriptionUrl())); - obj.add("appId", new JsonPrimitive(d.getAppId())); - obj.add("elementId", new JsonPrimitive(d.getElementId())); - obj.add("name", new JsonPrimitive(d.getName())); - obj.add("description", new JsonPrimitive(d.getDescription())); - obj.add("type", new JsonPrimitive(d.getType())); - obj.add("editable", new JsonPrimitive(d.isEditable())); - obj.add("includesIcon", new JsonPrimitive(d.isIncludesIcon())); - obj.add("includesDocs", new JsonPrimitive(d.isIncludesDocs())); - obj.add("available", new JsonPrimitive(true)); - return obj; - } -} diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/page/WelcomePageGenerator.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/page/WelcomePageGenerator.java deleted file mode 100644 index 31602d0504..0000000000 --- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/html/page/WelcomePageGenerator.java +++ /dev/null @@ -1,154 +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.rest.extensions.html.page; - -import org.apache.streampipes.extensions.api.assets.AssetResolver; -import org.apache.streampipes.extensions.api.assets.DefaultAssetResolver; -import org.apache.streampipes.extensions.api.connect.StreamPipesAdapter; -import org.apache.streampipes.extensions.api.pe.IStreamPipesDataProcessor; -import org.apache.streampipes.extensions.api.pe.IStreamPipesDataSink; -import org.apache.streampipes.extensions.api.pe.IStreamPipesDataStream; -import org.apache.streampipes.extensions.api.pe.IStreamPipesPipelineElement; -import org.apache.streampipes.extensions.management.locales.LabelGenerator; -import org.apache.streampipes.model.SpDataStream; -import org.apache.streampipes.model.base.NamedStreamPipesEntity; -import org.apache.streampipes.model.connect.adapter.AdapterDescription; -import org.apache.streampipes.model.extensions.ExtensionAssetType; -import org.apache.streampipes.model.graph.DataProcessorDescription; -import org.apache.streampipes.model.graph.DataSinkDescription; -import org.apache.streampipes.rest.extensions.html.model.Description; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - - -public class WelcomePageGenerator { - - private static final Logger LOG = LoggerFactory.getLogger(WelcomePageGenerator.class); - - protected List<Description> descriptions; - protected Collection<IStreamPipesPipelineElement<?>> pipelineElements; - protected Collection<StreamPipesAdapter> adapters; - protected String baseUri; - - public WelcomePageGenerator(String baseUri, - Collection<IStreamPipesPipelineElement<?>> pipelineElements, - Collection<StreamPipesAdapter> adapters) { - this.pipelineElements = pipelineElements; - this.adapters = adapters; - this.baseUri = baseUri; - this.descriptions = new ArrayList<>(); - } - - public List<Description> buildUris() { - List<Description> descriptions = new ArrayList<>(); - - pipelineElements.forEach(pipelineElement -> descriptions.add(getPipelineElementDescription(pipelineElement))); - adapters.forEach(adapter -> descriptions.add(getAdapterDescription(adapter))); - - return descriptions; - } - - private Description getAdapterDescription(StreamPipesAdapter adapter) { - var entity = adapter.declareConfig().getAdapterDescription(); - return getDescription( - entity, - adapter.declareConfig().getAssetResolver(), - "adapter", - "api/v1/worker/adapters/" - ); - } - - private Description getPipelineElementDescription(IStreamPipesPipelineElement<?> declarer) { - var entity = declarer.declareConfig().getDescription(); - return getDescription( - entity, - new DefaultAssetResolver(entity.getAppId()), getType(declarer), getPathPrefix(declarer) - ); - } - - private Description getDescription(NamedStreamPipesEntity entity, - AssetResolver assetResolver, - String type, - String pathPrefix) { - Description desc = new Description(); - // TODO remove after full internationalization support has been implemented - updateLabel(entity, desc, assetResolver); - desc.setType(type); - desc.setElementId(entity.getElementId()); - desc.setAppId(entity.getAppId()); - desc.setEditable(!(entity.isInternallyManaged())); - desc.setIncludesDocs(entity.isIncludesAssets() - && entity.getIncludedAssets().contains(ExtensionAssetType.DOCUMENTATION)); - desc.setIncludesIcon(entity.isIncludesAssets() - && entity.getIncludedAssets().contains(ExtensionAssetType.ICON)); - String uri = baseUri + pathPrefix; - desc.setDescriptionUrl(uri + entity.getAppId()); - return desc; - } - - private String getPathPrefix(IStreamPipesPipelineElement<?> pipelineElement) { - if (pipelineElement instanceof IStreamPipesDataSink) { - return "sec/"; - } else if (pipelineElement instanceof IStreamPipesDataProcessor) { - return "sepa/"; - } else if (pipelineElement instanceof IStreamPipesDataStream) { - return "stream/"; - } else { - return ""; - } - } - - private String getType(IStreamPipesPipelineElement<?> pipelineElement) { - var elementDescription = pipelineElement.declareConfig().getDescription(); - if (elementDescription instanceof DataSinkDescription) { - return "action"; - } else if (elementDescription instanceof SpDataStream) { - return "stream"; - } else if (elementDescription instanceof DataProcessorDescription) { - return "sepa"; - } else if (elementDescription instanceof AdapterDescription) { - return "adapter"; - } else { - throw new RuntimeException("Could not get type for element " + elementDescription.getClass()); - } - } - - private void updateLabel(NamedStreamPipesEntity entity, - Description desc, - AssetResolver assetResolver) { - if (!entity.isIncludesLocales()) { - desc.setName(entity.getName()); - desc.setDescription(entity.getDescription()); - } else { - LabelGenerator lg = new LabelGenerator(entity, true, assetResolver); - try { - desc.setName(lg.getElementTitle()); - desc.setDescription(lg.getElementDescription()); - } catch (IOException e) { - LOG.error("Error while updating description of %s".formatted(entity.getAppId()), e); - } - } - } -} diff --git a/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/StreamPipesExtensionsServiceBase.java b/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/StreamPipesExtensionsServiceBase.java index 80e8ffde21..995536e113 100644 --- a/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/StreamPipesExtensionsServiceBase.java +++ b/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/StreamPipesExtensionsServiceBase.java @@ -36,7 +36,6 @@ import org.apache.streampipes.model.extensions.configuration.SpServiceConfigurat import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceRegistration; import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceTag; import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceTagPrefix; -import org.apache.streampipes.rest.extensions.WelcomePage; import org.apache.streampipes.rest.shared.exception.SpRestExceptionHandler; import org.apache.streampipes.rest.shared.serializer.JacksonConfiguration; import org.apache.streampipes.service.base.BaseNetworkingConfig; @@ -67,7 +66,6 @@ import java.util.stream.Collectors; @EnableAutoConfiguration @Import({ WebSecurityConfig.class, - WelcomePage.class, ServiceHealthResource.class, SpRestExceptionHandler.class, StreamPipesPrometheusConfig.class,
