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

dyankiv pushed a commit to branch DATALAB-3086
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit c3d590d463897ff146810aebd006217832bf0a5c
Author: Denys Yankiv <[email protected]>
AuthorDate: Wed Oct 5 14:53:00 2022 +0300

    fix notebook creation
---
 .../com/epam/datalab/backendapi/resources/ExploratoryResource.java   | 3 ++-
 .../com/epam/datalab/backendapi/service/ImageExploratoryService.java | 1 +
 .../datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ExploratoryResource.java
 
b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ExploratoryResource.java
index c83875e1e..f96d5781b 100644
--- 
a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ExploratoryResource.java
+++ 
b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ExploratoryResource.java
@@ -84,7 +84,8 @@ public class ExploratoryResource implements ExploratoryAPI {
             log.warn("Unauthorized attempt to create a {} by user {}", 
formDTO.getImage(), userInfo.getName());
             throw new DatalabException("You do not have the privileges to 
create a " + formDTO.getTemplateName());
         }
-        if(formDTO.getImageName() != null
+
+        if(imageExploratoryService.imageExistInProject(formDTO.getImageName(), 
formDTO.getProject())
                 && !imageExploratoryService.canCreateFromImage(userInfo, 
formDTO.getImageName(),formDTO.getProject() , formDTO.getEndpoint())){
             log.warn("Unauthorized attempt to create notebook from image  {} 
by user {}", formDTO.getImageName(), userInfo.getName());
             throw new DatalabException("You do not have the privileges to 
create notebook from image " + formDTO.getImageName());
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 af4ad1bd3..5d78c2877 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
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Set;
 
 public interface ImageExploratoryService {
+    boolean imageExistInProject(String imageName, String project);
 
     String createImage(UserInfo user, String project, String exploratoryName, 
String imageName, String imageDescription);
 
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 a0cb98ac7..62f3f270b 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
@@ -104,6 +104,11 @@ public class ImageExploratoryServiceImpl implements 
ImageExploratoryService {
     @Inject
     private SecurityDAO securityDAO;
 
+    @Override
+    public boolean imageExistInProject(String imageName, String project) {
+        return imageExploratoryDao.exist(imageName, project);
+    }
+
     @Audit(action = CREATE, type = IMAGE)
     @Override
     public String createImage(@User UserInfo user, @Project String project, 
String exploratoryName, @ResourceName String imageName, String 
imageDescription) {


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

Reply via email to