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

ofuks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2e0b478  [DLAB-1849] Fixed issue with computational shapes
2e0b478 is described below

commit 2e0b478f3ec084f82baf49cfd1ac1d1c8d0edb19
Author: Oleh Fuks <[email protected]>
AuthorDate: Tue Jun 2 16:55:44 2020 +0300

    [DLAB-1849] Fixed issue with computational shapes
---
 .../dlab/backendapi/resources/dto/UserRoleDto.java |  2 ++
 .../impl/InfrastructureTemplateServiceImpl.java    | 35 +++++++++++-----------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserRoleDto.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserRoleDto.java
index 84551af..9035467 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserRoleDto.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserRoleDto.java
@@ -42,6 +42,8 @@ public class UserRoleDto {
        private Set<String> exploratories;
        @JsonProperty("exploratory_shapes")
        private Set<String> exploratoryShapes;
+       @JsonProperty("computational_shapes")
+       private Set<String> computationalShapes;
        private Set<String> groups;
 
        private enum Type {
diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
index 31f73f3..9f3f05f 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
@@ -90,8 +90,7 @@ public class InfrastructureTemplateServiceImpl implements 
InfrastructureTemplate
                                        .peek(e -> 
e.setImage(getSimpleImageName(e.getImage())))
                                        .filter(e -> 
exploratoryGpuIssuesAzureFilter(e, endpointDTO.getCloudProvider()) &&
                                                        
UserRoles.checkAccess(user, RoleType.EXPLORATORY, e.getImage(), roles))
-                                       .peek(e -> filterShapes(user, 
e.getExploratoryEnvironmentShapes(), RoleType.EXPLORATORY_SHAPES,
-                                                       roles))
+                                       .peek(e -> filterShapes(user, 
e.getExploratoryEnvironmentShapes(), RoleType.EXPLORATORY_SHAPES, roles))
                                        .collect(Collectors.toList());
 
                } catch (DlabException e) {
@@ -100,20 +99,6 @@ public class InfrastructureTemplateServiceImpl implements 
InfrastructureTemplate
                }
        }
 
-       /**
-        * Removes shapes for which user does not have an access
-        *
-        * @param user              user
-        * @param environmentShapes shape types
-        * @param roleType
-        * @param roles
-        */
-       private void filterShapes(UserInfo user, Map<String, 
List<ComputationalResourceShapeDto>> environmentShapes,
-                                                         RoleType roleType, 
Set<String> roles) {
-               environmentShapes.forEach((k, v) -> v.removeIf(compResShapeDto 
->
-                               !UserRoles.checkAccess(user, roleType, 
compResShapeDto.getType(), roles)));
-       }
-
        @Override
        public List<FullComputationalTemplate> 
getComputationalTemplates(UserInfo user, String project, String endpoint) {
 
@@ -129,8 +114,7 @@ public class InfrastructureTemplateServiceImpl implements 
InfrastructureTemplate
 
                        return Arrays.stream(array)
                                        .peek(e -> 
e.setImage(getSimpleImageName(e.getImage())))
-                                       .peek(e -> filterShapes(user, 
e.getComputationResourceShapes(), RoleType.COMPUTATIONAL_SHAPES,
-                                                       user.getRoles()))
+                                       .peek(e -> filterShapes(user, 
e.getComputationResourceShapes(), RoleType.COMPUTATIONAL_SHAPES, roles))
                                        .filter(e -> 
UserRoles.checkAccess(user, RoleType.COMPUTATIONAL, e.getImage(), roles))
                                        .map(comp -> 
fullComputationalTemplate(comp, endpointDTO.getCloudProvider()))
                                        .collect(Collectors.toList());
@@ -142,6 +126,21 @@ public class InfrastructureTemplateServiceImpl implements 
InfrastructureTemplate
        }
 
        /**
+        * Removes shapes for which user does not have an access
+        *
+        * @param user              user
+        * @param environmentShapes shape types
+        * @param roleType
+        * @param roles
+        */
+       private void filterShapes(UserInfo user, Map<String, 
List<ComputationalResourceShapeDto>> environmentShapes,
+                                                         RoleType roleType, 
Set<String> roles) {
+               environmentShapes.forEach((k, v) -> v.removeIf(compResShapeDto 
->
+                               !UserRoles.checkAccess(user, roleType, 
compResShapeDto.getType(), roles))
+               );
+       }
+
+       /**
         * Temporary filter for creation of exploratory env due to Azure issues
         */
        private boolean exploratoryGpuIssuesAzureFilter(ExploratoryMetadataDTO 
e, CloudProvider cloudProvider) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to