This is an automated email from the ASF dual-hosted git repository. bossenti pushed a commit to branch fix-documentation-asset-overview in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 5c2e0fae761d414851d079b52e95c9a66fbff502 Author: bossenti <[email protected]> AuthorDate: Thu May 16 10:32:33 2024 +0200 fix: correctly retrieve documentation for asset overview --- .../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..db450ba44b 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 @@ -20,6 +20,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; import org.springframework.http.MediaType; @@ -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();
