You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by "dominikriemer (via GitHub)" <gi...@apache.org> on 2023/12/05 20:21:42 UTC

[PR] feat(#2276): Migrate rest interfaces to spring

dominikriemer opened a new pull request, #2277:
URL: https://github.com/apache/streampipes/pull/2277

   <!--
     ~ 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.
     ~
     -->
     
     <!--
   Thanks for contributing! Here are some tips you can follow to help us incorporate your contribution quickly and easily:
   1. If this is your first time, please read our contributor guidelines:
       - https://streampipes.apache.org/getinvolved.html
       - https://cwiki.apache.org/confluence/display/STREAMPIPES/Getting+Started
   2. Make sure the PR title is formatted like: `[#<GitHub issue id>] PR title ...`
   3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., `[WIP][#<GitHub issue id>] PR title ...`.
   4. Please write your PR title to summarize what this PR proposes/fixes.
   5. Link the PR to the corresponding GitHub issue (if present) in the `Development` section in the right menu bar. 
   6. Be sure to keep the PR description updated to reflect all changes.
   7. If possible, provide a concise example to reproduce the issue for a faster review.
   8. Make sure tests pass via `mvn clean install`.
   9. (Optional) If the contribution is large, please file an Apache ICLA
       - http://apache.org/licenses/icla.pdf
   -->
   
   ### Purpose
   <!--
   Please clarify what changes you are proposing and describe how those changes will address the issue.
   Furthermore, describe potential consequences the changes might have.
   -->
   
   See #2276 
   
   ### Remarks
   <!--
   Is there anything left we need to pay attention on?
   Are there some references that might be important? E.g. links to Confluence, or discussions
   on the mailing list or GitHub.
   -->
   PR introduces (a) breaking change(s): no
   
   PR introduces (a) deprecation(s): no
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(#2276): Migrate rest interfaces to spring

Posted by "dominikriemer (via GitHub)" <gi...@apache.org>.
dominikriemer commented on code in PR #2277:
URL: https://github.com/apache/streampipes/pull/2277#discussion_r1422472663


##########
streampipes-rest-core-base/src/main/java/org/apache/streampipes/rest/core/base/impl/AbstractRestResource.java:
##########
@@ -37,16 +36,59 @@
 import org.apache.streampipes.storage.api.IVisualizationStorage;
 import org.apache.streampipes.storage.management.StorageDispatcher;
 
+import org.apache.http.HttpStatus;
 import org.apache.http.client.ClientProtocolException;
-
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.ResponseEntity;
 
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URLDecoder;
 
-public abstract class AbstractRestResource extends AbstractSharedRestInterface {

Review Comment:
   The AbstractRestResource contains database access helpers which are not present in the extensions. AbstractSharedRestInterface is the top class which contains shared methods by core + extensions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(#2276): Migrate rest interfaces to spring

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #2277:
URL: https://github.com/apache/streampipes/pull/2277#discussion_r1422400730


##########
streampipes-service-core-minimal/src/main/java/org/apache/streampipes/service/core/minimal/StreamPipesCoreApplicationMinimal.java:
##########
@@ -36,7 +35,7 @@
 
 @Configuration
 @EnableAutoConfiguration
-@Import({StreamPipesResourceConfig.class,
+@Import({//StreamPipesResourceConfig.class,

Review Comment:
   Can it be removed or should it not be a comment?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(#2276): Migrate rest interfaces to spring

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #2277:
URL: https://github.com/apache/streampipes/pull/2277#discussion_r1422395727


##########
streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/GeneralConfigurationResource.java:
##########
@@ -67,23 +59,35 @@ public Response updateGeneralConfiguration(GeneralConfig config) {
     return ok();
   }
 
-  @GET
-  @Path("keys")
-  @Produces("multipart/mixed")
+  // TODO

Review Comment:
   ```suggestion
   ```



##########
streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementAsset.java:
##########
@@ -22,47 +22,41 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.io.IOException;
 
-@Path("/v2/pe")
+@RestController
+@RequestMapping("/api/v2/pe")
 public class PipelineElementAsset extends AbstractRestResource {
 
   private static final Logger LOG = LoggerFactory.getLogger(PipelineElementAsset.class);
 
-  @GET
-  @Path("{appId}/assets/icon")
-  @Produces("image/png")
-  public Response getIconAsset(@PathParam("appId") String appId) {
+  @GetMapping(path = "/{appId}/assets/icon", produces = "image/png")
+  public ResponseEntity<?> getIconAsset(@PathVariable("appId") String appId) {
     try {
       return ok(AssetManager.getAssetIcon(appId));
     } catch (IOException e) {
       return fail();
     }
   }
 
-  @GET
-  @Path("{appId}/assets/documentation")
-  @Produces(MediaType.TEXT_PLAIN)
-  public Response getDocumentationAsset(@PathParam("appId") String appId) {
+  @GetMapping(path = "/{appId}/assets/documentation", produces = MediaType.TEXT_PLAIN_VALUE)
+  public ResponseEntity<?> getDocumentationAsset(@PathVariable("appId") String appId) {
     try {
       return ok(AssetManager.getAssetDocumentation(appId));
     } catch (IOException e) {
       return fail();
     }
   }
 
-  @GET
-  @Path("{appId}/assets/{assetName}")
-  @Produces("image/png")
-  public Response getAsset(@PathParam("appId") String appId, @PathParam("assetName") String
+  @GetMapping(path = "/{appId}/assets/{assetName}", produces = "image/png")

Review Comment:
   ```suggestion
     @GetMapping(path = "/{appId}/assets/{assetName}", produces = MediaType.IMAGE_PNG)
   ```



##########
streampipes-rest-core-base/src/main/java/org/apache/streampipes/rest/core/base/impl/AbstractRestResource.java:
##########
@@ -37,16 +36,59 @@
 import org.apache.streampipes.storage.api.IVisualizationStorage;
 import org.apache.streampipes.storage.management.StorageDispatcher;
 
+import org.apache.http.HttpStatus;
 import org.apache.http.client.ClientProtocolException;
-
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.ResponseEntity;
 
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URLDecoder;
 
-public abstract class AbstractRestResource extends AbstractSharedRestInterface {

Review Comment:
   Why do we remove abstraction here? Can we completely get rid of the `AbstractSharedRestInterface`?
   If so, we can do this in a follow up task.



##########
streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/GeneralConfigurationResource.java:
##########
@@ -67,23 +59,35 @@ public Response updateGeneralConfiguration(GeneralConfig config) {
     return ok();
   }
 
-  @GET
-  @Path("keys")
-  @Produces("multipart/mixed")
+  // TODO
+  @GetMapping(path = "keys", produces = "multipart/mixed")

Review Comment:
   ```suggestion
     @GetMapping(path = "keys", produces = MediaType.MULTIPART_MIXED)
   ```



##########
streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementAsset.java:
##########
@@ -22,47 +22,41 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.io.IOException;
 
-@Path("/v2/pe")
+@RestController
+@RequestMapping("/api/v2/pe")
 public class PipelineElementAsset extends AbstractRestResource {
 
   private static final Logger LOG = LoggerFactory.getLogger(PipelineElementAsset.class);
 
-  @GET
-  @Path("{appId}/assets/icon")
-  @Produces("image/png")
-  public Response getIconAsset(@PathParam("appId") String appId) {
+  @GetMapping(path = "/{appId}/assets/icon", produces = "image/png")

Review Comment:
   ```suggestion
     @GetMapping(path = "/{appId}/assets/icon", produces = MediaType.IMAGE_PNG)
   ```



##########
ui/cypress/support/utils/DataDownloadDialogUtils.ts:
##########
@@ -80,10 +80,13 @@ export class DataDownloadDialogUtils {
             (downloadFileString: string) => {
                 cy.readFile(
                     `cypress/fixtures/dataDownloadDialog/${resultFileLocation}`,
-                ).then(expectedResultString => {
-                    expect(expectedResultString).to.deep.equal(
-                        downloadFileString,
-                    );
+                ).then(expectedResult => {
+                    console.log(expectedResult);

Review Comment:
   ```suggestion
   ```



##########
streampipes-service-core-minimal/src/main/java/org/apache/streampipes/service/core/minimal/StreamPipesCoreApplicationMinimal.java:
##########
@@ -36,7 +35,7 @@
 
 @Configuration
 @EnableAutoConfiguration
-@Import({StreamPipesResourceConfig.class,
+@Import({//StreamPipesResourceConfig.class,

Review Comment:
   ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(#2276): Migrate rest interfaces to spring

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti merged PR #2277:
URL: https://github.com/apache/streampipes/pull/2277


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org