You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by pi...@apache.org on 2021/02/17 09:56:59 UTC

[atlas] branch master updated: ATLAS-4147 : [Atlas: Glossary Term Bulk Import] When un_supported file type is passed error message displays file type {0}/ATLAS-4148 : [Atlas: Glossary Term Bulk Import] Incorrect error code displayed when no data found in the uploaded file/ATLAS-4134 : [Atlas:Glossary] Update conflict error message for glossary

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

pinal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new d99ea4b  ATLAS-4147 : [Atlas: Glossary Term Bulk Import] When un_supported file type is passed error message displays file type {0}/ATLAS-4148 : [Atlas: Glossary Term Bulk Import] Incorrect error code displayed when no data found in the uploaded file/ATLAS-4134 : [Atlas:Glossary] Update conflict error message for glossary
d99ea4b is described below

commit d99ea4b3fb6dad2c076f073d5b64b2ac5748f70a
Author: chaitali borole <ch...@cloudera.com>
AuthorDate: Wed Feb 17 13:30:04 2021 +0530

    ATLAS-4147 : [Atlas: Glossary Term Bulk Import] When un_supported file type is passed error message displays file type {0}/ATLAS-4148 : [Atlas: Glossary Term Bulk Import] Incorrect error code displayed when no data found in the uploaded file/ATLAS-4134 : [Atlas:Glossary] Update conflict error message for glossary
    
    Signed-off-by: Pinal <pinal-shah>
---
 intg/src/main/java/org/apache/atlas/AtlasErrorCode.java   | 10 +++++-----
 .../java/org/apache/atlas/glossary/GlossaryService.java   |  2 +-
 .../src/main/java/org/apache/atlas/util/FileUtils.java    |  2 +-
 .../org/apache/atlas/glossary/GlossaryServiceTest.java    | 15 +++++++++++++++
 4 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index ad67fa9..884f81f 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -167,9 +167,10 @@ public enum AtlasErrorCode {
     INVALID_BUSINESS_METADATA_NAME_FOR_ENTITY_TYPE(400, "ATLAS-400-00-095", "Invalid business-metadata: {0} specified for entity, applicable business-metadata: {1}"),
     BUSINESS_METADATA_ATTRIBUTE_DOES_NOT_EXIST(400, "ATLAS-400-00-096", "Business-metadata attribute does not exist in entity: {0}"),
     BUSINESS_METADATA_ATTRIBUTE_ALREADY_EXISTS(400, "ATLAS-400-00-097", "Business-metadata attribute already exists in entity: {0}"),
-    INVALID_FILE_TYPE(400, "ATLAS-400-00-098", "The provided file type {0} is not supported."),
+    INVALID_FILE_TYPE(400, "ATLAS-400-00-098", "The provided file type: {0} is not supported. Expected file formats are .csv and .xls."),
     INVALID_BUSINESS_ATTRIBUTES_IMPORT_DATA(400, "ATLAS-400-00-099","The uploaded file was not processed due to following errors : {0}"),
     ATTRIBUTE_NAME_INVALID_CHARS(400, "ATLAS-400-00-09A", "{0}: invalid name. Attribute names must begin with a letter followed by a sequence of letters, numbers, or '_' characters"),
+    NO_DATA_FOUND(400, "ATLAS-400-00-09B", "No data found in the uploaded file"),
     UNAUTHORIZED_ACCESS(403, "ATLAS-403-00-001", "{0} is not authorized to perform {1}"),
 
     // All Not found enums go here
@@ -192,9 +193,8 @@ public enum AtlasErrorCode {
     INVALID_LINEAGE_ENTITY_TYPE(404, "ATLAS-404-00-011", "Given instance guid {0} with type {1} is not a valid lineage entity type."),
     INSTANCE_GUID_DELETED(404, "ATLAS-404-00-012", "Given instance guid {0} has been deleted"),
     NO_PROPAGATED_CLASSIFICATIONS_FOUND_FOR_ENTITY(404, "ATLAS-404-00-013", "No propagated classifications associated with entity: {0}"),
-    NO_DATA_FOUND(404, "ATLAS-404-00-014", "No data found in the uploaded file"),
-    FILE_NAME_NOT_FOUND(404, "ATLAS-404-00-015", "File name should not be blank"),
-    NO_TYPE_NAME_ON_VERTEX(404, "ATLAS-404-00-016", "No typename found for given entity with guid: {0}"),
+    FILE_NAME_NOT_FOUND(404, "ATLAS-404-00-014", "File name should not be blank"),
+    NO_TYPE_NAME_ON_VERTEX(404, "ATLAS-404-00-015", "No typename found for given entity with guid: {0}"),
 
     // All data conflict errors go here
     TYPE_ALREADY_EXISTS(409, "ATLAS-409-00-001", "Given type {0} already exists"),
@@ -203,7 +203,7 @@ public enum AtlasErrorCode {
     RELATIONSHIP_ALREADY_EXISTS(409, "ATLAS-409-00-004", "relationship {0} already exists between entities {1} and {2}"),
     TYPE_HAS_RELATIONSHIPS(409, "ATLAS-409-00-005", "Given type {0} has associated relationshipDefs"),
     SAVED_SEARCH_ALREADY_EXISTS(409, "ATLAS-409-00-006", "search named {0} already exists for user {1}"),
-    GLOSSARY_ALREADY_EXISTS(409, "ATLAS-409-00-007", "Glossary with qualifiedName {0} already exists"),
+    GLOSSARY_ALREADY_EXISTS(409, "ATLAS-409-00-007", "Glossary with name {0} already exists"),
     GLOSSARY_TERM_ALREADY_EXISTS(409, "ATLAS-409-00-009", "Glossary term with qualifiedName {0} already exists"),
     GLOSSARY_CATEGORY_ALREADY_EXISTS(409, "ATLAS-409-00-00A", "Glossary category with qualifiedName {0} already exists"),
 
diff --git a/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java b/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java
index 82243e2..6e10a96 100644
--- a/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java
+++ b/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java
@@ -149,7 +149,7 @@ public class GlossaryService {
         }
 
         if (glossaryExists(atlasGlossary)) {
-            throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_ALREADY_EXISTS, atlasGlossary.getQualifiedName());
+            throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_ALREADY_EXISTS, atlasGlossary.getName());
         }
 
         AtlasGlossary storeObject = dataAccess.save(atlasGlossary);
diff --git a/repository/src/main/java/org/apache/atlas/util/FileUtils.java b/repository/src/main/java/org/apache/atlas/util/FileUtils.java
index 71ac9e3..57df9ab 100644
--- a/repository/src/main/java/org/apache/atlas/util/FileUtils.java
+++ b/repository/src/main/java/org/apache/atlas/util/FileUtils.java
@@ -62,7 +62,7 @@ public class FileUtils {
         } else if (extension.equalsIgnoreCase(XLS.name()) || extension.equalsIgnoreCase(XLSX.name())) {
             ret = readExcel(inputStream, extension);
         } else {
-            throw new AtlasBaseException(AtlasErrorCode.INVALID_FILE_TYPE);
+            throw new AtlasBaseException(AtlasErrorCode.INVALID_FILE_TYPE, fileName);
         }
 
         if (CollectionUtils.isEmpty(ret)) {
diff --git a/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java b/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
index 54e00a4..5867f2a 100644
--- a/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
@@ -40,6 +40,7 @@ import org.apache.atlas.repository.store.graph.AtlasEntityStore;
 import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
 import org.apache.atlas.store.AtlasTypeDefStore;
 import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.atlas.util.FileUtils;
 import org.apache.atlas.utils.AtlasJson;
 import org.apache.atlas.utils.TestLoadModelUtils;
 import org.apache.commons.collections.CollectionUtils;
@@ -961,6 +962,20 @@ public class GlossaryServiceTest {
     }
 
     @Test
+    public void testFileExtension() throws IOException {
+        InputStream inputStream = getFile(CSV_FILES, "incorrectEXT.py");
+        final String userDir  = System.getProperty("user.dir");
+        String       filePath = getTestFilePath(userDir, CSV_FILES, "incorrectEXT.py");
+        File         f          = new File(filePath);
+        try {
+            FileUtils.readFileData("incorrectEXT.py", inputStream);
+            fail("Error occurred : Incorrect file extension.");
+        } catch (AtlasBaseException e) {
+            assertEquals(e.getMessage(),"The provided file type: " + f.getName() + " is not supported. Expected file formats are .csv and .xls.");
+        }
+    }
+
+    @Test
     public void testIncorrectFileException() {
         InputStream inputStream = getFile(CSV_FILES, "incorrectFile.csv");