This is an automated email from the ASF dual-hosted git repository.
dyankiv pushed a commit to branch DATALAB-2999
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
The following commit(s) were added to refs/heads/DATALAB-2999 by this push:
new 597723c16 move autocomplete to image resource
597723c16 is described below
commit 597723c16b0f904dc8174951e27b2c3f1a913bd9
Author: Denys Yankiv <[email protected]>
AuthorDate: Fri Sep 16 18:29:48 2022 +0300
move autocomplete to image resource
---
.../datalab/backendapi/SelfServiceApplication.java | 1 -
.../backendapi/resources/AutoCompleteResource.java | 47 ----------------------
.../resources/ImageExploratoryResource.java | 10 +++++
.../backendapi/resources/dto/SharedWithDTO.java | 6 +--
.../backendapi/service/AutoCompleteService.java | 47 ----------------------
.../service/ImageExploratoryService.java | 1 +
.../service/impl/ImageExploratoryServiceImpl.java | 11 +++++
7 files changed, 24 insertions(+), 99 deletions(-)
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java
index 35e19b710..50f291431 100644
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java
+++
b/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java
@@ -181,7 +181,6 @@ public class SelfServiceApplication extends
Application<SelfServiceApplicationCo
jersey.register(injector.getInstance(OdahuResource.class));
jersey.register(injector.getInstance(OdahuCallback.class));
jersey.register(injector.getInstance(ChangePropertiesResource.class));
- jersey.register(injector.getInstance(AutoCompleteResource.class));
}
private void disableGzipHandlerForGuacamoleServlet(Server server) {
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/AutoCompleteResource.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/AutoCompleteResource.java
deleted file mode 100644
index 551a54414..000000000
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/AutoCompleteResource.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-
-package com.epam.datalab.backendapi.resources;
-
-import com.epam.datalab.auth.UserInfo;
-import com.epam.datalab.backendapi.service.AutoCompleteService;
-import com.google.inject.Inject;
-import io.dropwizard.auth.Auth;
-
-import javax.validation.constraints.NotNull;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-@Path("/autocomplete")
-@Consumes(MediaType.APPLICATION_JSON)
-@Produces(MediaType.APPLICATION_JSON)
-public class AutoCompleteResource {
- private final AutoCompleteService autoCompleteService;
-
- @Inject
- public AutoCompleteResource(AutoCompleteService autoCompleteService) {
- this.autoCompleteService = autoCompleteService;
- }
-
- @GET
- @Path("/users_groups")
- public Response getUsersAndGroups(@Auth UserInfo userInfo, @NotNull
@QueryParam("value") String value){
- return
Response.ok(autoCompleteService.getUsersAndGroupsForSharing(value)).build();
- }
-}
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ImageExploratoryResource.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ImageExploratoryResource.java
index b75584520..da310d640 100644
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ImageExploratoryResource.java
+++
b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ImageExploratoryResource.java
@@ -149,4 +149,14 @@ public class ImageExploratoryResource {
@PathParam("endpoint") String endpoint){
return
Response.ok(imageExploratoryService.getImageSharingInfo(ui.getName(),imageName,projectName,
endpoint)).build();
}
+
+ @GET
+ @Path("share_autocomplete/{imageName}/{projectName}/{endpoint}")
+ public Response getUsersAndGroups(@Auth UserInfo userInfo,
+ @PathParam("imageName") String imageName,
+ @PathParam("projectName") String
projectName,
+ @PathParam("endpoint") String endpoint,
+ @NotNull @QueryParam("value") String
value){
+ return
Response.ok(imageExploratoryService.getUsersAndGroupsForSharing(userInfo.getName(),imageName,
projectName, endpoint, value)).build();
+ }
}
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/SharedWithDTO.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/SharedWithDTO.java
index cac806ed1..5d4267dc7 100644
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/SharedWithDTO.java
+++
b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/SharedWithDTO.java
@@ -20,14 +20,12 @@
package com.epam.datalab.backendapi.resources.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.*;
@Getter
@Setter
@ToString
+@EqualsAndHashCode
@JsonIgnoreProperties(ignoreUnknown = true)
@AllArgsConstructor
public class SharedWithDTO {
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/AutoCompleteService.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/AutoCompleteService.java
deleted file mode 100644
index 5a06c3c87..000000000
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/AutoCompleteService.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-
-package com.epam.datalab.backendapi.service;
-
-import com.epam.datalab.backendapi.dao.UserGroupDAO;
-import com.epam.datalab.backendapi.dao.UserSettingsDAO;
-import com.epam.datalab.backendapi.resources.dto.SharedWithDTO;
-import com.google.inject.Inject;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public class AutoCompleteService {
- public final UserGroupDAO userGroupDAO;
- public final UserSettingsDAO userSettingsDAO;
-
- @Inject
- public AutoCompleteService(UserGroupDAO userGroupDAO, UserSettingsDAO
userSettingsDAO) {
- this.userGroupDAO = userGroupDAO;
- this.userSettingsDAO = userSettingsDAO;
- }
-
- public Set<SharedWithDTO> getUsersAndGroupsForSharing(String name){
- Set<SharedWithDTO> sharedWithDTOS = new HashSet<>();
-
sharedWithDTOS.addAll(userSettingsDAO.getUserNames(name).stream().map(s -> new
SharedWithDTO(SharedWithDTO.Type.USER, s)).collect(Collectors.toSet()));
- sharedWithDTOS.addAll(userGroupDAO.getGroupNames(name).stream().map(s
-> new SharedWithDTO(SharedWithDTO.Type.GROUP, s)).collect(Collectors.toSet()));
- return sharedWithDTOS;
- }
-}
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java
index b66d65077..414b6b52f 100644
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java
+++
b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java
@@ -58,4 +58,5 @@ public interface ImageExploratoryService {
boolean canCreateFromImage(UserInfo userInfo, String imageName, String
project, String endpoint);
+ Set<SharedWithDTO> getUsersAndGroupsForSharing(String userName,String
imageName, String project, String endpoint, String value);
}
diff --git
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java
b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java
index 0db9023c3..8ec5da79f 100644
---
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java
+++
b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java
@@ -368,6 +368,17 @@ public class ImageExploratoryServiceImpl implements
ImageExploratoryService {
}
}
+ @Override
+ public Set<SharedWithDTO> getUsersAndGroupsForSharing(String userName,
String imageName, String project, String endpoint, String value){
+ Set<SharedWithDTO> sharedWith = getImageSharingInfo(userName,
imageName, project, endpoint);
+ Set<SharedWithDTO> canBeSharedWith =
userSettingsDAO.getUserNames(value).stream()
+ .map(s -> new SharedWithDTO(SharedWithDTO.Type.USER,
s)).collect(Collectors.toSet());
+ canBeSharedWith.addAll(userGroupDAO.getGroupNames(value).stream()
+ .map(s -> new SharedWithDTO(SharedWithDTO.Type.GROUP,
s)).collect(Collectors.toSet()));
+ canBeSharedWith.removeAll(sharedWith);
+ return canBeSharedWith;
+ }
+
private ImageSharingStatus getImageSharingStatus(String username,
ImageInfoRecord image){
boolean notShared = image.getSharedWith().getUsers().isEmpty() &&
image.getSharedWith().getGroups().isEmpty();
if(notShared && image.getUser().equals(username)){
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]