Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
9c0c46db
Commit
9c0c46db
authored
8 years ago
by
Sarath Subramanian
Committed by
Madhan Neethiraj
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1464: option to include only specified attributes in notification message
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
e0c6b98e
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
release-log.txt
release-log.txt
+1
-0
NotificationEntityChangeListener.java
.../atlas/notification/NotificationEntityChangeListener.java
+53
-3
No files found.
release-log.txt
View file @
9c0c46db
...
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1464 option to include only specified attributes in notification message (sarath.kum4r@gmail.com via mneethiraj)
ATLAS-1460 v2 search API updated to return name/description/owner and classification names in result (vimalsharma via mneethiraj)
ATLAS-1434 fixed unit test to use correct type names; updated error message per review comments (ashutoshm via mneethiraj)
ATLAS-1391 Add exclusion mechanism for Atlas audit mechanism (guptaneeru via svimal2106)
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java
View file @
9c0c46db
...
...
@@ -19,6 +19,7 @@ package org.apache.atlas.notification;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.inject.Inject
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.notification.entity.EntityNotification
;
...
...
@@ -31,7 +32,11 @@ import org.apache.atlas.typesystem.Struct;
import
org.apache.atlas.typesystem.types.FieldMapping
;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.TypeSystem
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.configuration.Configuration
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
...
...
@@ -48,6 +53,11 @@ public class NotificationEntityChangeListener implements EntityChangeListener {
private
final
NotificationInterface
notificationInterface
;
private
final
TypeSystem
typeSystem
;
private
Map
<
String
,
List
<
String
>>
notificationAttributesCache
=
new
HashMap
<>();
private
static
final
String
ATLAS_ENTITY_NOTIFICATION_PROPERTY
=
"atlas.notification.entity"
;
static
Configuration
APPLICATION_PROPERTIES
=
null
;
// ----- Constructors ------------------------------------------------------
...
...
@@ -148,14 +158,54 @@ public class NotificationEntityChangeListener implements EntityChangeListener {
List
<
EntityNotification
>
messages
=
new
LinkedList
<>();
for
(
IReferenceableInstance
entityDefinition
:
entityDefinitions
)
{
Referenceable
entity
=
new
Referenceable
(
entityDefinition
);
Referenceable
entity
=
new
Referenceable
(
entityDefinition
);
Map
<
String
,
Object
>
attributesMap
=
entity
.
getValuesMap
();
List
<
String
>
entityNotificationAttrs
=
getNotificationAttributes
(
entity
.
getTypeName
());
if
(
MapUtils
.
isNotEmpty
(
attributesMap
)
&&
CollectionUtils
.
isNotEmpty
(
entityNotificationAttrs
))
{
for
(
String
entityAttr
:
attributesMap
.
keySet
())
{
if
(!
entityNotificationAttrs
.
contains
(
entityAttr
))
{
entity
.
setNull
(
entityAttr
);
}
}
}
EntityNotificationImpl
notification
=
new
EntityNotificationImpl
(
entity
,
operationType
,
getAllTraits
(
entity
,
typeSystem
));
EntityNotificationImpl
notification
=
new
EntityNotificationImpl
(
entity
,
operationType
,
getAllTraits
(
entity
,
typeSystem
));
messages
.
add
(
notification
);
}
notificationInterface
.
send
(
NotificationInterface
.
NotificationType
.
ENTITIES
,
messages
);
}
private
List
<
String
>
getNotificationAttributes
(
String
entityType
)
{
List
<
String
>
ret
=
null
;
initApplicationProperties
();
if
(
notificationAttributesCache
.
containsKey
(
entityType
))
{
ret
=
notificationAttributesCache
.
get
(
entityType
);
}
else
if
(
APPLICATION_PROPERTIES
!=
null
)
{
String
[]
notificationAttributes
=
APPLICATION_PROPERTIES
.
getStringArray
(
ATLAS_ENTITY_NOTIFICATION_PROPERTY
+
"."
+
entityType
+
"."
+
"attributes.include"
);
if
(
notificationAttributes
!=
null
)
{
ret
=
Arrays
.
asList
(
notificationAttributes
);
}
notificationAttributesCache
.
put
(
entityType
,
ret
);
}
return
ret
;
}
private
void
initApplicationProperties
()
{
if
(
APPLICATION_PROPERTIES
==
null
)
{
try
{
APPLICATION_PROPERTIES
=
ApplicationProperties
.
get
();
}
catch
(
AtlasException
ex
)
{
// ignore
}
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment