You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by nb...@apache.org on 2021/08/17 11:47:04 UTC

[atlas] branch branch-2.0 updated (1a47359 -> 36ce8f0)

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

nbonte pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git.


    from 1a47359  ATLAS-4390: Changed Atlas branch to release-2.2.0-rc1
     new 4059156  ATLAS-3917: While deleting parent tag, shows incorrect message
     new 36ce8f0  ATLAS-4233: Audits: When a term is added or removed, v1 api displays action as null instead of TERM_ADD or TERM_DELETE

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../converters/AtlasInstanceConverter.java         |  8 +++++++
 .../store/graph/v2/AtlasTypeDefGraphStoreV2.java   |  4 ++--
 .../v2/AtlasClassificationDefStoreV2Test.java      | 27 ++++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)

[atlas] 02/02: ATLAS-4233: Audits: When a term is added or removed, v1 api displays action as null instead of TERM_ADD or TERM_DELETE

Posted by nb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nbonte pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 36ce8f09760db7a8d7170b2ceafc7ee4e97f1478
Author: Shraddha Chauhan <sh...@freestoneinfotech.com>
AuthorDate: Mon Aug 9 18:49:15 2021 +0530

    ATLAS-4233: Audits: When a term is added or removed, v1 api displays action as null instead of TERM_ADD or TERM_DELETE
    
    Signed-off-by: Nikhil Bonte <nb...@apache.org>
    (cherry picked from commit 625bfd2064b36597eee795b51ed03b1d39190107)
---
 .../atlas/repository/converters/AtlasInstanceConverter.java       | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
index 5c08874..c1aef7b 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
@@ -411,6 +411,10 @@ public class AtlasInstanceConverter {
                 return EntityAuditEvent.EntityAuditAction.LABEL_ADD;
             case LABEL_DELETE:
                 return EntityAuditEvent.EntityAuditAction.LABEL_DELETE;
+            case TERM_ADD:
+                return EntityAuditEvent.EntityAuditAction.TERM_ADD;
+            case TERM_DELETE:
+                return EntityAuditEvent.EntityAuditAction.TERM_DELETE;
         }
 
         return null;
@@ -442,6 +446,10 @@ public class AtlasInstanceConverter {
                 return EntityAuditEventV2.EntityAuditActionV2.PROPAGATED_CLASSIFICATION_DELETE;
             case PROPAGATED_TAG_UPDATE:
                 return EntityAuditEventV2.EntityAuditActionV2.PROPAGATED_CLASSIFICATION_UPDATE;
+            case TERM_ADD:
+                return EntityAuditEventV2.EntityAuditActionV2.TERM_ADD;
+            case TERM_DELETE:
+                return EntityAuditEventV2.EntityAuditActionV2.TERM_DELETE;
         }
 
         return null;

[atlas] 01/02: ATLAS-3917: While deleting parent tag, shows incorrect message

Posted by nb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nbonte pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 40591564a4552a4086017d18bcb1047cb90a19fe
Author: Shraddha Chauhan <sh...@freestoneinfotech.com>
AuthorDate: Tue Aug 17 16:05:09 2021 +0530

    ATLAS-3917: While deleting parent tag, shows incorrect message
    
    Signed-off-by: Nikhil Bonte <nb...@apache.org>
    (cherry picked from commit d160138d5e7d23cd8c4345dba55c140dc9bc84b2)
---
 .../store/graph/v2/AtlasTypeDefGraphStoreV2.java   |  4 ++--
 .../v2/AtlasClassificationDefStoreV2Test.java      | 27 ++++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasTypeDefGraphStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasTypeDefGraphStoreV2.java
index b9d41bb..5da6fde 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasTypeDefGraphStoreV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasTypeDefGraphStoreV2.java
@@ -270,9 +270,9 @@ public class AtlasTypeDefGraphStoreV2 extends AtlasTypeDefGraphStore {
 
     void deleteTypeVertex(AtlasVertex vertex) throws AtlasBaseException {
         Iterator<AtlasEdge> inEdges = vertex.getEdges(AtlasEdgeDirection.IN).iterator();
-
         if (inEdges.hasNext()) {
-            throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES);
+            String name        = vertex.getProperty(Constants.TYPENAME_PROPERTY_KEY, String.class);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
         }
 
         Iterable<AtlasEdge> edges = vertex.getEdges(AtlasEdgeDirection.OUT);
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2Test.java
index 3242a33..b8f52f9 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2Test.java
@@ -17,16 +17,26 @@
  */
 package org.apache.atlas.repository.store.graph.v2;
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 import static org.testng.Assert.assertEquals;
 
 import com.google.inject.Inject;
+import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.TestModules;
+import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.repository.Constants;
+import org.apache.atlas.repository.graphdb.AtlasEdge;
+import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
+import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Guice;
 import org.testng.annotations.Test;
 
+import java.util.ArrayList;
+
 /**
  * Tests for AtlasClassificationDefStoreV2
  */
@@ -65,4 +75,21 @@ public class AtlasClassificationDefStoreV2Test {
   public void testIsValidName(String data, boolean expected) {
     assertEquals(classificationDefStore.isValidName(data), expected);
   }
+
+  @Test
+  public void testDeleteReferencedTraitFail() {
+    AtlasVertex typeVertex = mock(AtlasVertex.class);
+    when(typeVertex.getProperty(Constants.TYPENAME_PROPERTY_KEY, String.class)).thenReturn("Tag11");
+    when(typeVertex.getEdges(AtlasEdgeDirection.IN)).thenReturn(() -> {
+      ArrayList<AtlasEdge> list = new ArrayList<>();
+      list.add(mock(AtlasEdge.class));
+      return list.iterator();
+    });
+    try {
+      classificationDefStore.deleteByName("Tag11", typeVertex );
+    } catch (AtlasBaseException abe) {
+      assertEquals(abe.getMessage(), AtlasErrorCode.TYPE_HAS_REFERENCES.getFormattedErrorMessage("Tag11"));
+      assertEquals(abe.getAtlasErrorCode() , AtlasErrorCode.TYPE_HAS_REFERENCES);
+    }
+  }
 }
\ No newline at end of file