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:44:42 UTC

[atlas] branch master updated (98b7118 -> 625bfd2)

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

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


    from 98b7118  ATLAS-4391 - NoSuchFileException for {atlas.log.dir}/atlas-metrics.out
     new d160138  ATLAS-3917: While deleting parent tag, shows incorrect message
     new 625bfd2  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 master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 625bfd2064b36597eee795b51ed03b1d39190107
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>
---
 .../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 master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit d160138d5e7d23cd8c4345dba55c140dc9bc84b2
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>
---
 .../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