atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [2/2] incubator-atlas git commit: ATLAS-1721: updated action-string in the audit logs generated during import
Date Wed, 12 Apr 2017 18:51:05 GMT
ATLAS-1721: updated action-string in the audit logs generated during import

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit cb554197785dd012f919321c41b69c166a6dc840)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/dc5ad76f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/dc5ad76f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/dc5ad76f

Branch: refs/heads/0.8-incubating
Commit: dc5ad76f6d8f2617ce1cc932f07a9f02ddc404b6
Parents: e4bddff
Author: ashutoshm <amestry@hortonworks.com>
Authored: Tue Apr 11 13:14:32 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Wed Apr 12 11:43:56 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/atlas/EntityAuditEvent.java |  4 ++--
 dashboardv2/public/js/utils/Enums.js            |  5 ++++-
 .../repository/audit/EntityAuditListener.java   | 21 ++++++++++++++------
 .../graph/v1/AtlasEntityChangeNotifier.java     | 18 ++++++++---------
 .../store/graph/v1/AtlasEntityStoreV1.java      |  8 ++++----
 .../atlas/services/DefaultMetadataService.java  | 15 ++++++++------
 .../service/DefaultMetadataServiceTest.java     |  6 +++---
 .../atlas/listener/EntityChangeListener.java    | 11 +++++-----
 .../NotificationEntityChangeListener.java       |  6 +++---
 9 files changed, 55 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/client/src/main/java/org/apache/atlas/EntityAuditEvent.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/atlas/EntityAuditEvent.java b/client/src/main/java/org/apache/atlas/EntityAuditEvent.java
index 7eaa556..e541531 100644
--- a/client/src/main/java/org/apache/atlas/EntityAuditEvent.java
+++ b/client/src/main/java/org/apache/atlas/EntityAuditEvent.java
@@ -20,7 +20,6 @@ package org.apache.atlas;
 
 import org.apache.atlas.typesystem.IReferenceableInstance;
 import org.apache.atlas.typesystem.json.InstanceSerialization;
-import org.apache.commons.lang.StringUtils;
 
 import java.util.Objects;
 
@@ -29,7 +28,8 @@ import java.util.Objects;
  */
 public class EntityAuditEvent {
     public enum EntityAuditAction {
-        ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE, TAG_ADD, TAG_DELETE
+        ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE, TAG_ADD, TAG_DELETE,
+        ENTITY_IMPORT_CREATE, ENTITY_IMPORT_UPDATE, ENTITY_IMPORT_DELETE
     }
 
     private String entityId;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/dashboardv2/public/js/utils/Enums.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/Enums.js b/dashboardv2/public/js/utils/Enums.js
index c779cd4..a44490a 100644
--- a/dashboardv2/public/js/utils/Enums.js
+++ b/dashboardv2/public/js/utils/Enums.js
@@ -26,7 +26,10 @@ define(['require'], function(require) {
         ENTITY_UPDATE: "Entity Updated",
         ENTITY_DELETE: "Entity Deleted",
         TAG_ADD: "Tag Added",
-        TAG_DELETE: "Tag Deleted"
+        TAG_DELETE: "Tag Deleted",
+        ENTITY_IMPORT_CREATE: "Entity Created by import",
+        ENTITY_IMPORT_UPDATE: "Entity Updated by import",
+        ENTITY_IMPORT_DELETE: "Entity Deleted by import"
     }
 
     Enums.entityStateReadOnly = {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
index 3f03c50..9d0f802 100644
--- a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
+++ b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
@@ -55,10 +55,10 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities) throws
AtlasException {
+    public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities, boolean
isImport) throws AtlasException {
         List<EntityAuditEvent> events = new ArrayList<>();
         for (ITypedReferenceableInstance entity : entities) {
-            EntityAuditEvent event = createEvent(entity, EntityAuditAction.ENTITY_CREATE);
+            EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_CREATE
: EntityAuditAction.ENTITY_CREATE);
             events.add(event);
         }
 
@@ -66,10 +66,10 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities)
throws AtlasException {
+    public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities,
boolean isImport) throws AtlasException {
         List<EntityAuditEvent> events = new ArrayList<>();
         for (ITypedReferenceableInstance entity : entities) {
-            EntityAuditEvent event = createEvent(entity, EntityAuditAction.ENTITY_UPDATE);
+            EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_UPDATE
: EntityAuditAction.ENTITY_UPDATE);
             events.add(event);
         }
 
@@ -100,10 +100,10 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities)
throws AtlasException {
+    public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities,
boolean isImport) throws AtlasException {
         List<EntityAuditEvent> events = new ArrayList<>();
         for (ITypedReferenceableInstance entity : entities) {
-            EntityAuditEvent event = createEvent(entity, EntityAuditAction.ENTITY_DELETE,
"Deleted entity");
+            EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_DELETE
: EntityAuditAction.ENTITY_DELETE, "Deleted entity");
             events.add(event);
         }
 
@@ -279,6 +279,15 @@ public class EntityAuditListener implements EntityChangeListener {
             case TAG_DELETE:
                 ret = "Deleted trait: ";
                 break;
+            case ENTITY_IMPORT_CREATE:
+                ret = "Created by import: ";
+                break;
+            case ENTITY_IMPORT_UPDATE:
+                ret = "Updated by import: ";
+                break;
+            case ENTITY_IMPORT_DELETE:
+                ret = "Deleted by import: ";
+                break;
             default:
                 ret = "Unknown: ";
         }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
index 0439ada..f3d9ca7 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
@@ -63,7 +63,7 @@ public class AtlasEntityChangeNotifier {
         this.instanceConverter     = instanceConverter;
     }
 
-    public void onEntitiesMutated(EntityMutationResponse entityMutationResponse) throws AtlasBaseException
{
+    public void onEntitiesMutated(EntityMutationResponse entityMutationResponse, boolean
isImport) throws AtlasBaseException {
         if (CollectionUtils.isEmpty(entityChangeListeners) || instanceConverter == null)
{
             return;
         }
@@ -79,10 +79,10 @@ public class AtlasEntityChangeNotifier {
         doFullTextMapping(updatedEntities);
         doFullTextMapping(partiallyUpdatedEntities);
 
-        notifyListeners(createdEntities, EntityOperation.CREATE);
-        notifyListeners(updatedEntities, EntityOperation.UPDATE);
-        notifyListeners(partiallyUpdatedEntities, EntityOperation.PARTIAL_UPDATE);
-        notifyListeners(deletedEntities, EntityOperation.DELETE);
+        notifyListeners(createdEntities, EntityOperation.CREATE, isImport);
+        notifyListeners(updatedEntities, EntityOperation.UPDATE, isImport);
+        notifyListeners(partiallyUpdatedEntities, EntityOperation.PARTIAL_UPDATE, isImport);
+        notifyListeners(deletedEntities, EntityOperation.DELETE, isImport);
     }
 
     public void onClassificationAddedToEntity(String entityId, List<AtlasClassification>
classifications) throws AtlasBaseException {
@@ -125,7 +125,7 @@ public class AtlasEntityChangeNotifier {
         }
     }
 
-    private void notifyListeners(List<AtlasEntityHeader> entityHeaders, EntityOperation
operation) throws AtlasBaseException {
+    private void notifyListeners(List<AtlasEntityHeader> entityHeaders, EntityOperation
operation, boolean isImport) throws AtlasBaseException {
         if (CollectionUtils.isEmpty(entityHeaders)) {
             return;
         }
@@ -136,14 +136,14 @@ public class AtlasEntityChangeNotifier {
             try {
                 switch (operation) {
                     case CREATE:
-                        listener.onEntitiesAdded(typedRefInsts);
+                        listener.onEntitiesAdded(typedRefInsts, isImport);
                         break;
                     case UPDATE:
                     case PARTIAL_UPDATE:
-                        listener.onEntitiesUpdated(typedRefInsts);
+                        listener.onEntitiesUpdated(typedRefInsts, isImport);
                         break;
                     case DELETE:
-                        listener.onEntitiesDeleted(typedRefInsts);
+                        listener.onEntitiesDeleted(typedRefInsts, isImport);
                         break;
                 }
             } catch (AtlasException e) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
index 32b1ea8..27f6928 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
@@ -232,7 +232,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
         }
 
         // Notify the change listeners
-        entityChangeNotifier.onEntitiesMutated(ret);
+        entityChangeNotifier.onEntitiesMutated(ret, entityStream instanceof EntityImportStream);
 
         return ret;
     }
@@ -340,7 +340,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
         EntityMutationResponse ret = deleteVertices(deletionCandidates);
 
         // Notify the change listeners
-        entityChangeNotifier.onEntitiesMutated(ret);
+        entityChangeNotifier.onEntitiesMutated(ret, false);
 
         return ret;
     }
@@ -376,7 +376,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
         EntityMutationResponse ret = deleteVertices(deletionCandidates);
 
         // Notify the change listeners
-        entityChangeNotifier.onEntitiesMutated(ret);
+        entityChangeNotifier.onEntitiesMutated(ret, false);
 
         return ret;
     }
@@ -406,7 +406,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
         EntityMutationResponse ret = deleteVertices(deletionCandidates);
 
         // Notify the change listeners
-        entityChangeNotifier.onEntitiesMutated(ret);
+        entityChangeNotifier.onEntitiesMutated(ret, false);
 
         return ret;
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
b/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
index d9ce8c4..fd85ef0 100755
--- a/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
+++ b/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
@@ -21,7 +21,6 @@ package org.apache.atlas.services;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.inject.Provider;
-
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasErrorCode;
@@ -73,10 +72,14 @@ import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-
 import javax.inject.Inject;
 import javax.inject.Singleton;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
 
 
 
@@ -701,7 +704,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
     private void onEntitiesAdded(List<String> guids) throws AtlasException {
         List<ITypedReferenceableInstance> entities = loadEntities(guids);
         for (EntityChangeListener listener : entityChangeListeners) {
-            listener.onEntitiesAdded(entities);
+            listener.onEntitiesAdded(entities, false);
         }
     }
 
@@ -718,7 +721,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
     private void onEntitiesUpdated(List<String> guids) throws AtlasException {
         List<ITypedReferenceableInstance> entities = loadEntities(guids);
         for (EntityChangeListener listener : entityChangeListeners) {
-            listener.onEntitiesUpdated(entities);
+            listener.onEntitiesUpdated(entities, false);
         }
     }
 
@@ -787,7 +790,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
 
     private void onEntitiesDeleted(List<ITypedReferenceableInstance> entities) throws
AtlasException {
         for (EntityChangeListener listener : entityChangeListeners) {
-            listener.onEntitiesDeleted(entities);
+            listener.onEntitiesDeleted(entities, false);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
index 7e828a1..c6d7e9d 100644
--- a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
@@ -1244,12 +1244,12 @@ public class DefaultMetadataServiceTest {
         private List<String> updatedEntities = new ArrayList<>();
 
         @Override
-        public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities)
+        public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities,
boolean isImport)
             throws AtlasException {
         }
 
         @Override
-        public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities)
+        public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities,
boolean isImport)
             throws AtlasException {
             updatedEntities.clear();
             for (ITypedReferenceableInstance entity : entities) {
@@ -1268,7 +1268,7 @@ public class DefaultMetadataServiceTest {
         }
 
         @Override
-        public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities)
+        public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities,
boolean isImport)
             throws AtlasException {
             deletedEntities.clear();
             for (ITypedReferenceableInstance entity : entities) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/server-api/src/main/java/org/apache/atlas/listener/EntityChangeListener.java
----------------------------------------------------------------------
diff --git a/server-api/src/main/java/org/apache/atlas/listener/EntityChangeListener.java
b/server-api/src/main/java/org/apache/atlas/listener/EntityChangeListener.java
index 256e839..346c8a2 100644
--- a/server-api/src/main/java/org/apache/atlas/listener/EntityChangeListener.java
+++ b/server-api/src/main/java/org/apache/atlas/listener/EntityChangeListener.java
@@ -19,7 +19,6 @@
 package org.apache.atlas.listener;
 
 import org.apache.atlas.AtlasException;
-import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.typesystem.IStruct;
 import org.apache.atlas.typesystem.ITypedReferenceableInstance;
 
@@ -29,24 +28,25 @@ import java.util.Collection;
  * Entity (a Typed instance) change notification listener.
  */
 public interface EntityChangeListener {
-
     /**
      * This is upon adding new entities to the repository.
      *
      * @param entities  the created entities
      *
+     * @param isImport
      * @throws AtlasException if the listener notification fails
      */
-    void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities) throws AtlasException;
+    void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities, boolean
isImport) throws AtlasException;
 
     /**
      * This is upon updating an entity.
      *
      * @param entities        the updated entities
      *
+     * @param isImport
      * @throws AtlasException if the listener notification fails
      */
-    void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities) throws
AtlasException;
+    void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities, boolean
isImport) throws AtlasException;
 
     /**
      * This is upon adding a new trait to a typed instance.
@@ -72,7 +72,8 @@ public interface EntityChangeListener {
      * This is upon deleting entities from the repository.
      *
      * @param entities the deleted entities
+     * @param isImport
      * @throws AtlasException
      */
-    void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities) throws
AtlasException;
+    void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities, boolean
isImport) throws AtlasException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dc5ad76f/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java
b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java
index 978b21d..565eea7 100644
--- a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java
+++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java
@@ -77,12 +77,12 @@ public class NotificationEntityChangeListener implements EntityChangeListener
{
     // ----- EntityChangeListener ----------------------------------------------
 
     @Override
-    public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities) throws
AtlasException {
+    public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities, boolean
isImport) throws AtlasException {
         notifyOfEntityEvent(entities, EntityNotification.OperationType.ENTITY_CREATE);
     }
 
     @Override
-    public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities)
throws AtlasException {
+    public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities,
boolean isImport) throws AtlasException {
         notifyOfEntityEvent(entities, EntityNotification.OperationType.ENTITY_UPDATE);
     }
 
@@ -97,7 +97,7 @@ public class NotificationEntityChangeListener implements EntityChangeListener
{
     }
 
     @Override
-    public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities)
throws AtlasException {
+    public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities,
boolean isImport) throws AtlasException {
         notifyOfEntityEvent(entities, EntityNotification.OperationType.ENTITY_DELETE);
     }
 


Mime
View raw message