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

bossenti pushed a commit to branch 
2550-data-stream-created-by-python-function-is-not-entirely-correct
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to 
refs/heads/2550-data-stream-created-by-python-function-is-not-entirely-correct 
by this push:
     new e7ec0924cb fix(#2550): change handling of data stream in extensions 
service endpoint
e7ec0924cb is described below

commit e7ec0924cb49712ba82a666f2a90a3fe60b5521d
Author: bossenti <[email protected]>
AuthorDate: Thu Mar 14 15:15:16 2024 +0100

    fix(#2550): change handling of data stream in extensions service endpoint
---
 .../admin/ExtensionsServiceEndpointResource.java     | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git 
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExtensionsServiceEndpointResource.java
 
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExtensionsServiceEndpointResource.java
index 748d9f0a26..a2d83a014f 100644
--- 
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExtensionsServiceEndpointResource.java
+++ 
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/ExtensionsServiceEndpointResource.java
@@ -49,7 +49,6 @@ import org.springframework.web.bind.annotation.RestController;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/api/v2/rdfendpoints")
@@ -121,6 +120,7 @@ public class ExtensionsServiceEndpointResource extends 
AbstractAuthGuardedRestRe
                               String appId) {
     return installedElements
         .stream()
+        .filter(e -> !(e instanceof SpDataStream))  // DataStreams are not 
getting installed
         .anyMatch(e -> e.getAppId().equals(appId));
   }
 
@@ -139,17 +139,19 @@ public class ExtensionsServiceEndpointResource extends 
AbstractAuthGuardedRestRe
         .stream()
         .filter(s -> existingItems.stream().noneMatch(item -> 
s.getAppId().equals(item.getAppId())))
         .map(adapter -> makeItem(adapter, "adapter"))
-        .collect(Collectors.toList());
+        .toList();
   }
 
   private List<ExtensionsServiceEndpointItem> getAllDataStreamEndpoints(
       List<ExtensionsServiceEndpointItem> existingItems) {
     return getAllDataStreams()
         .stream()
-        .filter(s -> existingItems.stream().noneMatch(item -> 
s.getAppId().equals(item.getAppId())))
+        // compared to similar methods we use the elementId here instead of 
the appId
+        // because data streams are supposed to do not have an appId
+        .filter(s -> existingItems.stream().noneMatch(item -> 
s.getElementId().equals(item.getElementId())))
         .filter(s -> !s.isInternallyManaged())
         .map(stream -> makeItem(stream, "stream"))
-        .collect(Collectors.toList());
+        .toList();
   }
 
 
@@ -160,7 +162,7 @@ public class ExtensionsServiceEndpointResource extends 
AbstractAuthGuardedRestRe
         .stream()
         .filter(s -> existingItems.stream().noneMatch(item -> 
s.getAppId().equals(item.getAppId())))
         .map(source -> makeItem(source, "sepa"))
-        .collect(Collectors.toList());
+        .toList();
   }
 
   private List<ExtensionsServiceEndpointItem> getAllDataSinkEndpoints(
@@ -170,7 +172,7 @@ public class ExtensionsServiceEndpointResource extends 
AbstractAuthGuardedRestRe
         .stream()
         .filter(s -> existingItems.stream().noneMatch(item -> 
s.getAppId().equals(item.getAppId())))
         .map(source -> makeItem(source, "action"))
-        .collect(Collectors.toList());
+        .toList();
   }
 
   private ExtensionsServiceEndpointItem makeItem(NamedStreamPipesEntity 
entity, String type) {
@@ -178,7 +180,6 @@ public class ExtensionsServiceEndpointResource extends 
AbstractAuthGuardedRestRe
     endpoint.setInstalled(true);
     endpoint.setDescription(entity.getDescription());
     endpoint.setName(entity.getName());
-    endpoint.setAppId(entity.getAppId());
     endpoint.setType(type);
     endpoint.setAvailable(false);
     endpoint.setElementId(entity.getElementId());
@@ -186,6 +187,11 @@ public class ExtensionsServiceEndpointResource extends 
AbstractAuthGuardedRestRe
     endpoint.setEditable(!(entity.isInternallyManaged()));
     endpoint.setIncludesIcon(entity.isIncludesAssets() && 
entity.getIncludedAssets().contains(Assets.ICON));
     endpoint.setIncludesDocs(entity.isIncludesAssets() && 
entity.getIncludedAssets().contains(Assets.DOCUMENTATION));
+
+    if (!(entity instanceof SpDataStream)) {
+      endpoint.setAppId(entity.getAppId());
+    }
+
     return endpoint;
   }
 

Reply via email to