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

bossenti pushed a commit to branch rel/0.95.0
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/rel/0.95.0 by this push:
     new 113a3f247d fix: correctly retrieve documentation for asset overview 
(#2872)
113a3f247d is described below

commit 113a3f247d9b8bd7b13eeca74af9fe5823b59298
Author: Tim <[email protected]>
AuthorDate: Fri May 17 08:31:00 2024 +0200

    fix: correctly retrieve documentation for asset overview (#2872)
    
    * fix: correctly retrieve documentation for asset overview
    
    * style: fix import order
---
 .../streampipes/rest/impl/PipelineElementAsset.java       | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementAsset.java
 
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementAsset.java
index f0d628d7f9..bd09bb173e 100644
--- 
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementAsset.java
+++ 
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementAsset.java
@@ -19,6 +19,7 @@ package org.apache.streampipes.rest.impl;
 
 import org.apache.streampipes.manager.assets.AssetManager;
 import org.apache.streampipes.rest.core.base.impl.AbstractRestResource;
+import org.apache.streampipes.storage.management.StorageDispatcher;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -49,6 +50,20 @@ public class PipelineElementAsset extends 
AbstractRestResource {
   @GetMapping(path = "/{appId}/assets/documentation", produces = 
MediaType.TEXT_PLAIN_VALUE)
   public ResponseEntity<?> getDocumentationAsset(@PathVariable("appId") String 
appId) {
     try {
+      //If the provided appId contains "sp:spdatastream",
+      //it indicates usage by the asset-overview view where the data stream ID 
is supplied.
+      //In such cases, the appId of the adapter description needs retrieval 
for successful documentation loading.
+      if (appId.contains("sp:spdatastream")) {
+        var dataStream = StorageDispatcher.INSTANCE
+            .getNoSqlStore()
+            .getDataStreamStorage()
+            .getDataStreamByAppId(appId);
+        var adapterDescription = StorageDispatcher.INSTANCE
+            .getNoSqlStore()
+            .getAdapterInstanceStorage()
+            .getAdapter(dataStream.getCorrespondingAdapterId());
+        appId = adapterDescription.getAppId();
+      }
       return ok(AssetManager.getAssetDocumentation(appId));
     } catch (IOException e) {
       return fail();

Reply via email to