You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/11/07 22:39:26 UTC
[4/4] atlas git commit: ATLAS-2251: notification module updates (#4)
ATLAS-2251: notification module updates (#4)
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/f01e46d7
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/f01e46d7
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/f01e46d7
Branch: refs/heads/ATLAS-2251
Commit: f01e46d7399cdf382a5b4dc9a5102b3a4f3f9d6a
Parents: 84f1349
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Tue Nov 7 14:24:25 2017 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Tue Nov 7 14:24:25 2017 -0800
----------------------------------------------------------------------
.../apache/atlas/falcon/hook/FalconHook.java | 7 +-
.../atlas/hbase/bridge/HBaseAtlasHook.java | 45 +-
.../hbase/model/HBaseOperationContext.java | 8 +-
.../org/apache/atlas/hive/hook/HiveHook.java | 27 +-
.../org/apache/atlas/sqoop/hook/SqoopHook.java | 7 +-
.../model/notification/EntityNotification.java | 86 ++++
.../model/notification/HookNotification.java | 103 +++++
.../java/org/apache/atlas/type/AtlasType.java | 58 ++-
.../org/apache/atlas/type/AtlasTypeUtil.java | 18 +-
.../model/instance/AtlasSystemAttributes.java | 2 +-
.../org/apache/atlas/v1/model/instance/Id.java | 2 +-
.../atlas/v1/model/instance/Referenceable.java | 2 +-
.../apache/atlas/v1/model/instance/Struct.java | 2 +-
.../model/notification/EntityNotification.java | 231 ----------
.../notification/EntityNotificationV1.java | 231 ++++++++++
.../v1/model/notification/HookNotification.java | 423 -------------------
.../model/notification/HookNotificationV1.java | 357 ++++++++++++++++
.../apache/atlas/v1/model/typedef/TypesDef.java | 2 +-
.../java/org/apache/atlas/hook/AtlasHook.java | 18 +-
.../notification/NotificationInterface.java | 20 -
.../entity/EntityMessageDeserializer.java | 2 +-
.../hook/HookMessageDeserializer.java | 12 +-
.../org/apache/atlas/hook/AtlasHookTest.java | 53 +--
.../apache/atlas/kafka/KafkaConsumerTest.java | 119 ++----
.../atlas/kafka/KafkaNotificationTest.java | 34 +-
.../notification/AbstractNotificationTest.java | 59 ++-
.../entity/EntityMessageDeserializerTest.java | 72 ----
.../EntityNotificationDeserializerTest.java | 71 ++++
.../entity/EntityNotificationTest.java | 82 ++--
.../hook/HookMessageDeserializerTest.java | 171 --------
.../hook/HookNotificationDeserializerTest.java | 167 ++++++++
.../notification/hook/HookNotificationTest.java | 25 +-
.../NotificationEntityChangeListener.java | 24 +-
.../notification/NotificationHookConsumer.java | 205 +++++----
.../notification/EntityNotificationIT.java | 96 +++--
.../NotificationHookConsumerIT.java | 80 ++--
.../NotificationHookConsumerKafkaTest.java | 66 +--
.../NotificationHookConsumerTest.java | 153 ++++---
.../atlas/web/integration/BaseResourceIT.java | 242 +++++------
39 files changed, 1772 insertions(+), 1610 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
----------------------------------------------------------------------
diff --git a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
index 5912cb0..77177b4 100644
--- a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
+++ b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
@@ -25,8 +25,9 @@ import org.apache.atlas.falcon.event.FalconEvent;
import org.apache.atlas.falcon.publisher.FalconEventPublisher;
import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.kafka.NotificationProvider;
+import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.v1.model.instance.Referenceable;
-import org.apache.atlas.v1.model.notification.HookNotification;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
import org.apache.falcon.FalconException;
import org.apache.falcon.entity.store.ConfigurationStore;
import org.apache.falcon.entity.v0.feed.Feed;
@@ -151,14 +152,14 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher {
private void fireAndForget(FalconEvent event) throws FalconException, URISyntaxException {
LOG.info("Entered Atlas hook for Falcon hook operation {}", event.getOperation());
- List<HookNotification.HookNotificationMessage> messages = new ArrayList<>();
+ List<HookNotification> messages = new ArrayList<>();
Operation op = getOperation(event.getOperation());
String user = getUser(event.getUser());
LOG.info("fireAndForget user:{}", user);
switch (op) {
case ADD:
- messages.add(new HookNotification.EntityCreateRequest(user, createEntities(event, user)));
+ messages.add(new EntityCreateRequest(user, createEntities(event, user)));
break;
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
----------------------------------------------------------------------
diff --git a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
index 6fcaf1b..03e340c 100644
--- a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
+++ b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
@@ -23,8 +23,11 @@ import org.apache.atlas.AtlasConstants;
import org.apache.atlas.hbase.model.HBaseOperationContext;
import org.apache.atlas.hbase.model.HBaseDataTypes;
import org.apache.atlas.hook.AtlasHook;
+import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.v1.model.instance.Referenceable;
-import org.apache.atlas.v1.model.notification.HookNotification;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -219,13 +222,13 @@ public class HBaseAtlasHook extends AtlasHook {
case CREATE_NAMESPACE:
LOG.info("Create NameSpace {}", nameSpaceRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
- hbaseOperationContext.addMessage(new HookNotification.EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef));
+ hbaseOperationContext.addMessage(new EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef));
break;
case ALTER_NAMESPACE:
LOG.info("Modify NameSpace {}", nameSpaceRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
- hbaseOperationContext.addMessage(new HookNotification.EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef));
+ hbaseOperationContext.addMessage(new EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef));
break;
}
}
@@ -235,10 +238,10 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.info("Delete NameSpace {}", nameSpaceQualifiedName);
- hbaseOperationContext.addMessage(new HookNotification.EntityDeleteRequest(hbaseOperationContext.getUser(),
- HBaseDataTypes.HBASE_NAMESPACE.getName(),
- REFERENCEABLE_ATTRIBUTE_NAME,
- nameSpaceQualifiedName));
+ hbaseOperationContext.addMessage(new EntityDeleteRequest(hbaseOperationContext.getUser(),
+ HBaseDataTypes.HBASE_NAMESPACE.getName(),
+ REFERENCEABLE_ATTRIBUTE_NAME,
+ nameSpaceQualifiedName));
}
private void createOrUpdateTableInstance(HBaseOperationContext hbaseOperationContext) {
@@ -252,13 +255,13 @@ public class HBaseAtlasHook extends AtlasHook {
case CREATE_TABLE:
LOG.info("Create Table {}", tableRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
- hbaseOperationContext.addMessage(new HookNotification.EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef));
+ hbaseOperationContext.addMessage(new EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef));
break;
case ALTER_TABLE:
LOG.info("Modify Table {}", tableRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
- hbaseOperationContext.addMessage(new HookNotification.EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef));
+ hbaseOperationContext.addMessage(new EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef));
break;
}
}
@@ -276,10 +279,10 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.info("Delete Table {}", tableQualifiedName);
- hbaseOperationContext.addMessage(new HookNotification.EntityDeleteRequest(hbaseOperationContext.getUser(),
- HBaseDataTypes.HBASE_TABLE.getName(),
- REFERENCEABLE_ATTRIBUTE_NAME,
- tableQualifiedName));
+ hbaseOperationContext.addMessage(new EntityDeleteRequest(hbaseOperationContext.getUser(),
+ HBaseDataTypes.HBASE_TABLE.getName(),
+ REFERENCEABLE_ATTRIBUTE_NAME,
+ tableQualifiedName));
}
private void createOrUpdateColumnFamilyInstance(HBaseOperationContext hbaseOperationContext) {
@@ -291,13 +294,13 @@ public class HBaseAtlasHook extends AtlasHook {
case CREATE_COLUMN_FAMILY:
LOG.info("Create ColumnFamily {}", columnFamilyRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
- hbaseOperationContext.addMessage(new HookNotification.EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef));
+ hbaseOperationContext.addMessage(new EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef));
break;
case ALTER_COLUMN_FAMILY:
LOG.info("Alter ColumnFamily {}", columnFamilyRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
- hbaseOperationContext.addMessage(new HookNotification.EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef));
+ hbaseOperationContext.addMessage(new EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef));
break;
}
}
@@ -316,10 +319,10 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.info("Delete ColumnFamily {}", columnFamilyQualifiedName);
- hbaseOperationContext.addMessage(new HookNotification.EntityDeleteRequest(hbaseOperationContext.getUser(),
- HBaseDataTypes.HBASE_COLUMN_FAMILY.getName(),
- REFERENCEABLE_ATTRIBUTE_NAME,
- columnFamilyQualifiedName));
+ hbaseOperationContext.addMessage(new EntityDeleteRequest(hbaseOperationContext.getUser(),
+ HBaseDataTypes.HBASE_COLUMN_FAMILY.getName(),
+ REFERENCEABLE_ATTRIBUTE_NAME,
+ columnFamilyQualifiedName));
}
@@ -491,7 +494,7 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.debug("==> HBaseAtlasHook.notifyAsPrivilegedAction({})", hbaseOperationContext);
}
- final List<HookNotification.HookNotificationMessage> messages = hbaseOperationContext.getMessages();
+ final List<HookNotification> messages = hbaseOperationContext.getMessages();
try {
@@ -534,7 +537,7 @@ public class HBaseAtlasHook extends AtlasHook {
*
* @param messages hook notification messages
*/
- protected void notifyEntities(List<HookNotification.HookNotificationMessage> messages) {
+ protected void notifyEntities(List<HookNotification> messages) {
final int maxRetries = atlasProperties.getInt(HOOK_NUM_RETRIES, 3);
notifyEntities(messages, maxRetries);
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/model/HBaseOperationContext.java
----------------------------------------------------------------------
diff --git a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/model/HBaseOperationContext.java b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/model/HBaseOperationContext.java
index 33858d4..bc8485b 100644
--- a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/model/HBaseOperationContext.java
+++ b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/model/HBaseOperationContext.java
@@ -19,7 +19,7 @@
package org.apache.atlas.hbase.model;
import org.apache.atlas.hbase.bridge.HBaseAtlasHook;
-import org.apache.atlas.v1.model.notification.HookNotification;
+import org.apache.atlas.model.notification.HookNotification;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -74,7 +74,7 @@ public class HBaseOperationContext {
this(null, nameSpace, null, tableName, null, hColumnDescriptor, columnFamily, operation, ugi, user, owner, hbaseConf);
}
- private List<HookNotification.HookNotificationMessage> messages = new ArrayList<>();
+ private List<HookNotification> messages = new ArrayList<>();
public UserGroupInformation getUgi() {
return ugi;
@@ -120,7 +120,7 @@ public class HBaseOperationContext {
return columnFamily;
}
- public void addMessage(HookNotification.HookNotificationMessage message) {
+ public void addMessage(HookNotification message) {
messages.add(message);
}
@@ -128,7 +128,7 @@ public class HBaseOperationContext {
return owner;
}
- public List<HookNotification.HookNotificationMessage> getMessages() {
+ public List<HookNotification> getMessages() {
return messages;
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
index 5f8dcdb..57f5efb 100755
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
@@ -28,8 +28,11 @@ import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.hook.AtlasHookException;
+import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.v1.model.instance.Referenceable;
-import org.apache.atlas.v1.model.notification.HookNotification;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.fs.Path;
@@ -331,7 +334,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
final String tblQualifiedName = HiveMetaStoreBridge.getTableQualifiedName(dgiBridge.getClusterName(), output.getTable());
LOG.info("Deleting table {} ", tblQualifiedName);
event.addMessage(
- new HookNotification.EntityDeleteRequest(event.getUser(),
+ new EntityDeleteRequest(event.getUser(),
HiveDataTypes.HIVE_TABLE.getName(),
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
tblQualifiedName));
@@ -350,7 +353,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
} else if (Type.DATABASE.equals(output.getType())) {
final String dbQualifiedName = HiveMetaStoreBridge.getDBQualifiedName(dgiBridge.getClusterName(), output.getDatabase().getName());
event.addMessage(
- new HookNotification.EntityDeleteRequest(event.getUser(),
+ new EntityDeleteRequest(event.getUser(),
HiveDataTypes.HIVE_DB.getName(),
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
dbQualifiedName));
@@ -412,7 +415,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
Referenceable newColEntity = new Referenceable(HiveDataTypes.HIVE_COLUMN.getName());
newColEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newColumnQFName);
- event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(),
+ event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_COLUMN.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldColumnQFName, newColEntity));
}
@@ -481,7 +484,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
ArrayList<String> alias_list = new ArrayList<>();
alias_list.add(oldTable.getTableName().toLowerCase());
newEntity.set(HiveMetaStoreBridge.TABLE_ALIAS_LIST, alias_list);
- event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(),
+ event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_TABLE.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldTableQFName, newEntity));
@@ -499,7 +502,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
Referenceable newColEntity = new Referenceable(HiveDataTypes.HIVE_COLUMN.getName());
///Only QF Name changes
newColEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newColumnQFName);
- event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(),
+ event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_COLUMN.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldColumnQFName, newColEntity));
newColEntities.add(newColEntity);
@@ -518,7 +521,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
final Referenceable newSDEntity = new Referenceable(HiveDataTypes.HIVE_STORAGEDESC.getName());
newSDEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newSDQFName);
- event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(),
+ event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_STORAGEDESC.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldSDQFName, newSDEntity));
@@ -593,7 +596,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
}
if (!entities.isEmpty()) {
- event.addMessage(new HookNotification.EntityUpdateRequest(event.getUser(), entities));
+ event.addMessage(new EntityUpdateRequest(event.getUser(), entities));
}
return result;
@@ -719,7 +722,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
private void addEntityUpdateNotificationMessagess(final HiveEventContext event, final Collection<Referenceable> entities) {
// process each entity as separate message to avoid running into OOM errors
for (Referenceable entity : entities) {
- event.addMessage(new HookNotification.EntityUpdateRequest(event.getUser(), entity));
+ event.addMessage(new EntityUpdateRequest(event.getUser(), entity));
}
}
@@ -1089,7 +1092,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
public Map<String, List<ColumnLineageUtils.HiveColumnLineageInfo>> lineageInfo;
- private List<HookNotification.HookNotificationMessage> messages = new ArrayList<>();
+ private List<HookNotification> messages = new ArrayList<>();
public void setInputs(Set<ReadEntity> inputs) {
this.inputs = inputs;
@@ -1172,11 +1175,11 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
return queryStartTime;
}
- public void addMessage(HookNotification.HookNotificationMessage message) {
+ public void addMessage(HookNotification message) {
messages.add(message);
}
- public List<HookNotification.HookNotificationMessage> getMessages() {
+ public List<HookNotification> getMessages() {
return messages;
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
----------------------------------------------------------------------
diff --git a/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java b/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
index aee24ab..5ded92c 100644
--- a/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
+++ b/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
@@ -26,8 +26,9 @@ import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.hook.AtlasHookException;
+import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.v1.model.instance.Referenceable;
-import org.apache.atlas.v1.model.notification.HookNotification;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
import org.apache.atlas.sqoop.model.SqoopDataTypes;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.StringUtils;
@@ -185,8 +186,8 @@ public class SqoopHook extends SqoopJobDataPublisher {
Referenceable procRef = createSqoopProcessInstance(dbStoreRef, hiveTableRef, data, clusterName);
int maxRetries = atlasProperties.getInt(HOOK_NUM_RETRIES, 3);
- HookNotification.HookNotificationMessage message =
- new HookNotification.EntityCreateRequest(AtlasHook.getUser(), dbStoreRef, dbRef, hiveTableRef, procRef);
+ HookNotification message =
+ new EntityCreateRequest(AtlasHook.getUser(), dbStoreRef, dbRef, hiveTableRef, procRef);
AtlasHook.notifyEntities(Arrays.asList(message), maxRetries);
}
catch(Exception e) {
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java b/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java
new file mode 100644
index 0000000..3d03457
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.model.notification;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+/**
+ * Base type of hook message.
+ */
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class EntityNotification implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Type of the hook message.
+ */
+ public enum EntityNotificationType {
+ ENTITY_NOTIFICATION_V1
+ }
+
+ protected EntityNotificationType type;
+
+ public EntityNotification() {
+ this.type = EntityNotificationType.ENTITY_NOTIFICATION_V1;
+ }
+
+ public EntityNotification(EntityNotificationType type) {
+ this.type = type;
+ }
+
+ public EntityNotificationType getType() {
+ return type;
+ }
+
+ public void setType(EntityNotificationType type) {
+ this.type = type;
+ }
+
+ public void normalize() { }
+
+ @Override
+ public String toString() {
+ return toString(new StringBuilder()).toString();
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("EntityNotification{");
+ sb.append("type=").append(type);
+ sb.append("}");
+
+ return sb;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java b/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java
new file mode 100644
index 0000000..ea77a20
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.model.notification;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+/**
+ * Base type of hook message.
+ */
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class HookNotification implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String UNKNOW_USER = "UNKNOWN";
+
+ /**
+ * Type of the hook message.
+ */
+ public enum HookNotificationType {
+ TYPE_CREATE, TYPE_UPDATE, ENTITY_CREATE, ENTITY_PARTIAL_UPDATE, ENTITY_FULL_UPDATE, ENTITY_DELETE
+ }
+
+ protected HookNotificationType type;
+ protected String user;
+
+ public HookNotification() {
+ }
+
+ public HookNotification(HookNotificationType type, String user) {
+ this.type = type;
+ this.user = user;
+ }
+
+ public HookNotificationType getType() {
+ return type;
+ }
+
+ public void setType(HookNotificationType type) {
+ this.type = type;
+ }
+
+ public String getUser() {
+ if (StringUtils.isEmpty(user)) {
+ return UNKNOW_USER;
+ }
+
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public void normalize() { }
+
+ @Override
+ public String toString() {
+ return toString(new StringBuilder()).toString();
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("HookNotification{");
+ sb.append("type=").append(type);
+ sb.append(", user=").append(user);
+ sb.append("}");
+
+ return sb;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/type/AtlasType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasType.java b/intg/src/main/java/org/apache/atlas/type/AtlasType.java
index 63d2a9d..d2a8e1f 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasType.java
@@ -20,14 +20,17 @@ package org.apache.atlas.type;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
+import org.apache.atlas.model.notification.EntityNotification;
+import org.apache.atlas.model.notification.EntityNotification.EntityNotificationType;
+import org.apache.atlas.model.notification.HookNotification;
+import org.apache.atlas.model.notification.HookNotification.HookNotificationType;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
-import org.apache.atlas.v1.model.notification.HookNotification.EntityCreateRequest;
-import org.apache.atlas.v1.model.notification.HookNotification.EntityDeleteRequest;
-import org.apache.atlas.v1.model.notification.HookNotification.EntityPartialUpdateRequest;
-import org.apache.atlas.v1.model.notification.HookNotification.EntityUpdateRequest;
-import org.apache.atlas.v1.model.notification.HookNotification.HookNotificationMessage;
-import org.apache.atlas.v1.model.notification.HookNotification.HookNotificationType;
-import org.apache.atlas.v1.model.notification.HookNotification.TypeRequest;
+import org.apache.atlas.v1.model.notification.EntityNotificationV1;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
+import org.apache.atlas.v1.model.notification.HookNotificationV1.TypeRequest;
import org.codehaus.jackson.*;
import org.codehaus.jackson.map.*;
import org.codehaus.jackson.map.module.SimpleModule;
@@ -57,7 +60,8 @@ public abstract class AtlasType {
atlasSerDeModule.addSerializer(Date.class, new DateSerializer());
atlasSerDeModule.addDeserializer(Date.class, new DateDeserializer());
- atlasSerDeModule.addDeserializer(HookNotificationMessage.class, new HookMessageDeserializer());
+ atlasSerDeModule.addDeserializer(HookNotification.class, new HookNotificationDeserializer());
+ atlasSerDeModule.addDeserializer(EntityNotification.class, new EntityNotificationDeserializer());
mapperV1.registerModule(atlasSerDeModule);
}
@@ -206,15 +210,15 @@ public abstract class AtlasType {
}
}
- static class HookMessageDeserializer extends JsonDeserializer<HookNotificationMessage> {
+ static class HookNotificationDeserializer extends JsonDeserializer<HookNotification> {
@Override
- public HookNotificationMessage deserialize(JsonParser parser, DeserializationContext context) throws IOException {
- HookNotificationMessage ret = null;
- ObjectMapper mapper = (ObjectMapper) parser.getCodec();
- ObjectNode root = (ObjectNode) mapper.readTree(parser);
- JsonNode typeNode = root != null ? root.get("type") : null;
- String strType = typeNode != null ? typeNode.asText() : null;
- HookNotificationType notificationType = strType != null ? HookNotificationType.valueOf(strType) : null;
+ public HookNotification deserialize(JsonParser parser, DeserializationContext context) throws IOException {
+ HookNotification ret = null;
+ ObjectMapper mapper = (ObjectMapper) parser.getCodec();
+ ObjectNode root = (ObjectNode) mapper.readTree(parser);
+ JsonNode typeNode = root != null ? root.get("type") : null;
+ String strType = typeNode != null ? typeNode.asText() : null;
+ HookNotificationType notificationType = strType != null ? HookNotificationType.valueOf(strType) : null;
if (notificationType != null) {
switch (notificationType) {
@@ -244,4 +248,26 @@ public abstract class AtlasType {
return ret;
}
}
+
+ static class EntityNotificationDeserializer extends JsonDeserializer<EntityNotification> {
+ @Override
+ public EntityNotification deserialize(JsonParser parser, DeserializationContext context) throws IOException {
+ EntityNotification ret = null;
+ ObjectMapper mapper = (ObjectMapper) parser.getCodec();
+ ObjectNode root = (ObjectNode) mapper.readTree(parser);
+ JsonNode typeNode = root != null ? root.get("type") : null;
+ String strType = typeNode != null ? typeNode.asText() : null;
+ EntityNotificationType notificationType = strType != null ? EntityNotificationType.valueOf(strType) : EntityNotificationType.ENTITY_NOTIFICATION_V1;
+
+ if (root != null) {
+ switch (notificationType) {
+ case ENTITY_NOTIFICATION_V1:
+ ret = mapper.readValue(root, EntityNotificationV1.class);
+ break;
+ }
+ }
+
+ return ret;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
index 5f3cefd..0652855 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
@@ -17,7 +17,6 @@
*/
package org.apache.atlas.type;
-import com.google.common.collect.ImmutableSet;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasObjectId;
@@ -208,19 +207,19 @@ public class AtlasTypeUtil {
return new AtlasEnumDef(name, description, "1.0", Arrays.asList(enumValues));
}
- public static AtlasClassificationDef createTraitTypeDef(String name, ImmutableSet<String> superTypes, AtlasAttributeDef... attrDefs) {
+ public static AtlasClassificationDef createTraitTypeDef(String name, Set<String> superTypes, AtlasAttributeDef... attrDefs) {
return createTraitTypeDef(name, null, superTypes, attrDefs);
}
- public static AtlasClassificationDef createTraitTypeDef(String name, String description, ImmutableSet<String> superTypes, AtlasAttributeDef... attrDefs) {
+ public static AtlasClassificationDef createTraitTypeDef(String name, String description, Set<String> superTypes, AtlasAttributeDef... attrDefs) {
return createTraitTypeDef(name, description, "1.0", superTypes, attrDefs);
}
- public static AtlasClassificationDef createTraitTypeDef(String name, String description, String version, ImmutableSet<String> superTypes, AtlasAttributeDef... attrDefs) {
+ public static AtlasClassificationDef createTraitTypeDef(String name, String description, String version, Set<String> superTypes, AtlasAttributeDef... attrDefs) {
return new AtlasClassificationDef(name, description, version, Arrays.asList(attrDefs), superTypes);
}
- public static AtlasClassificationDef createAtlasClassificationDef(String name, String description, String version, ImmutableSet<String> superTypes, ImmutableSet<String> entityTypes, AtlasAttributeDef... attrDefs) {
+ public static AtlasClassificationDef createAtlasClassificationDef(String name, String description, String version, Set<String> superTypes, Set<String> entityTypes, AtlasAttributeDef... attrDefs) {
return new AtlasClassificationDef(name, description, version, Arrays.asList(attrDefs), superTypes, entityTypes, null);
}
@@ -232,18 +231,15 @@ public class AtlasTypeUtil {
return new AtlasStructDef(name, description, "1.0", Arrays.asList(attrDefs));
}
- public static AtlasEntityDef createClassTypeDef(String name,
- ImmutableSet<String> superTypes, AtlasAttributeDef... attrDefs) {
+ public static AtlasEntityDef createClassTypeDef(String name, Set<String> superTypes, AtlasAttributeDef... attrDefs) {
return createClassTypeDef(name, null, "1.0", superTypes, attrDefs);
}
- public static AtlasEntityDef createClassTypeDef(String name, String description,
- ImmutableSet<String> superTypes, AtlasAttributeDef... attrDefs) {
+ public static AtlasEntityDef createClassTypeDef(String name, String description, Set<String> superTypes, AtlasAttributeDef... attrDefs) {
return createClassTypeDef(name, description, "1.0", superTypes, attrDefs);
}
- public static AtlasEntityDef createClassTypeDef(String name, String description, String version,
- ImmutableSet<String> superTypes, AtlasAttributeDef... attrDefs) {
+ public static AtlasEntityDef createClassTypeDef(String name, String description, String version, Set<String> superTypes, AtlasAttributeDef... attrDefs) {
return new AtlasEntityDef(name, description, version, Arrays.asList(attrDefs), superTypes);
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/instance/AtlasSystemAttributes.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/instance/AtlasSystemAttributes.java b/intg/src/main/java/org/apache/atlas/v1/model/instance/AtlasSystemAttributes.java
index 30d500d..0b74365 100644
--- a/intg/src/main/java/org/apache/atlas/v1/model/instance/AtlasSystemAttributes.java
+++ b/intg/src/main/java/org/apache/atlas/v1/model/instance/AtlasSystemAttributes.java
@@ -35,7 +35,7 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/instance/Id.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/instance/Id.java b/intg/src/main/java/org/apache/atlas/v1/model/instance/Id.java
index 67e647d..f3087d1 100644
--- a/intg/src/main/java/org/apache/atlas/v1/model/instance/Id.java
+++ b/intg/src/main/java/org/apache/atlas/v1/model/instance/Id.java
@@ -41,7 +41,7 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/instance/Referenceable.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/instance/Referenceable.java b/intg/src/main/java/org/apache/atlas/v1/model/instance/Referenceable.java
index 8fc0acb..f1d28d1 100644
--- a/intg/src/main/java/org/apache/atlas/v1/model/instance/Referenceable.java
+++ b/intg/src/main/java/org/apache/atlas/v1/model/instance/Referenceable.java
@@ -43,7 +43,7 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java b/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java
index 5f61f6c..5aebd4b 100644
--- a/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java
+++ b/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java
@@ -37,7 +37,7 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotification.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotification.java b/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotification.java
deleted file mode 100644
index cb224af..0000000
--- a/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotification.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.v1.model.notification;
-
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
-import org.apache.atlas.v1.model.instance.Referenceable;
-import org.apache.atlas.v1.model.instance.Struct;
-import org.apache.atlas.type.AtlasClassificationType;
-import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
-/**
- * Entity notification
- */
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.PROPERTY)
-public class EntityNotification implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public enum OperationType {
- ENTITY_CREATE,
- ENTITY_UPDATE,
- ENTITY_DELETE,
- TRAIT_ADD,
- TRAIT_DELETE,
- TRAIT_UPDATE
- }
-
- private Referenceable entity;
- private OperationType operationType;
- private List<Struct> traits;
-
-
- // ----- Constructors ------------------------------------------------------
-
- /**
- * No-arg constructor for serialization.
- */
- public EntityNotification() {
- }
-
- /**
- * Construct an EntityNotification.
- *
- * @param entity the entity subject of the notification
- * @param operationType the type of operation that caused the notification
- * @param traits the traits for the given entity
- */
- public EntityNotification(Referenceable entity, OperationType operationType, List<Struct> traits) {
- this.entity = entity;
- this.operationType = operationType;
- this.traits = traits;
- }
-
- /**
- * Construct an EntityNotification.
- *
- * @param entity the entity subject of the notification
- * @param operationType the type of operation that caused the notification
- * @param typeRegistry the Atlas type system
- */
- public EntityNotification(Referenceable entity, OperationType operationType, AtlasTypeRegistry typeRegistry) {
- this(entity, operationType, getAllTraits(entity, typeRegistry));
- }
-
- public Referenceable getEntity() {
- return entity;
- }
-
- public void setEntity(Referenceable entity) {
- this.entity = entity;
- }
-
- public OperationType getOperationType() {
- return operationType;
- }
-
- public void setOperationType(OperationType operationType) {
- this.operationType = operationType;
- }
-
- public List<Struct> getTraits() {
- return traits;
- }
-
- public void setTraits(List<Struct> traits) {
- this.traits = traits;
- }
-
- @JsonIgnore
- public List<Struct> getAllTraits() {
- return traits;
- }
-
- public void normalize() {
- if (entity != null) {
- entity.normailze();
- }
-
- if (traits != null) {
- for (Struct trait : traits) {
- if (trait != null) {
- trait.normailze();
- }
- }
- }
- }
-
- // ----- Object overrides --------------------------------------------------
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- EntityNotification that = (EntityNotification) o;
- return Objects.equals(entity, that.entity) &&
- operationType == that.operationType &&
- Objects.equals(traits, that.traits);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(entity, operationType, traits);
- }
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
-
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("EntityNotification{");
- sb.append("entity=");
- if (entity != null) {
- entity.toString(sb);
- } else {
- sb.append(entity);
- }
- sb.append(", operationType=").append(operationType);
- sb.append(", traits=[");
- AtlasBaseTypeDef.dumpObjects(traits, sb);
- sb.append("]");
- sb.append("}");
-
- return sb;
- }
-
-
- // ----- helper methods ----------------------------------------------------
-
- private static List<Struct> getAllTraits(Referenceable entityDefinition, AtlasTypeRegistry typeRegistry) {
- List<Struct> ret = new LinkedList<>();
-
- for (String traitName : entityDefinition.getTraitNames()) {
- Struct trait = entityDefinition.getTrait(traitName);
- AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName);
- Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null;
-
- ret.add(trait);
-
- if (CollectionUtils.isNotEmpty(superTypeNames)) {
- for (String superTypeName : superTypeNames) {
- Struct superTypeTrait = new Struct(superTypeName);
-
- if (MapUtils.isNotEmpty(trait.getValues())) {
- AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName);
-
- if (superType != null && MapUtils.isNotEmpty(superType.getAllAttributes())) {
- Map<String, Object> superTypeTraitAttributes = new HashMap<>();
-
- for (Map.Entry<String, Object> attrEntry : trait.getValues().entrySet()) {
- String attrName = attrEntry.getKey();
-
- if (superType.getAllAttributes().containsKey(attrName)) {
- superTypeTraitAttributes.put(attrName, attrEntry.getValue());
- }
- }
-
- superTypeTrait.setValues(superTypeTraitAttributes);
- }
- }
-
- ret.add(superTypeTrait);
- }
- }
- }
-
- return ret;
- }
-}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotificationV1.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotificationV1.java b/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotificationV1.java
new file mode 100644
index 0000000..549dbe3
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/v1/model/notification/EntityNotificationV1.java
@@ -0,0 +1,231 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.v1.model.notification;
+
+import org.apache.atlas.model.notification.EntityNotification;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
+import org.apache.atlas.v1.model.instance.Referenceable;
+import org.apache.atlas.v1.model.instance.Struct;
+import org.apache.atlas.type.AtlasClassificationType;
+import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+/**
+ * Entity notification
+ */
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class EntityNotificationV1 extends EntityNotification implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public enum OperationType {
+ ENTITY_CREATE,
+ ENTITY_UPDATE,
+ ENTITY_DELETE,
+ TRAIT_ADD,
+ TRAIT_DELETE,
+ TRAIT_UPDATE
+ }
+
+ private Referenceable entity;
+ private OperationType operationType;
+ private List<Struct> traits;
+
+
+ // ----- Constructors ------------------------------------------------------
+
+ /**
+ * No-arg constructor for serialization.
+ */
+ public EntityNotificationV1() {
+ }
+
+ /**
+ * Construct an EntityNotificationV1.
+ *
+ * @param entity the entity subject of the notification
+ * @param operationType the type of operation that caused the notification
+ * @param traits the traits for the given entity
+ */
+ public EntityNotificationV1(Referenceable entity, OperationType operationType, List<Struct> traits) {
+ this.entity = entity;
+ this.operationType = operationType;
+ this.traits = traits;
+ }
+
+ /**
+ * Construct an EntityNotificationV1.
+ *
+ * @param entity the entity subject of the notification
+ * @param operationType the type of operation that caused the notification
+ * @param typeRegistry the Atlas type system
+ */
+ public EntityNotificationV1(Referenceable entity, OperationType operationType, AtlasTypeRegistry typeRegistry) {
+ this(entity, operationType, getAllTraits(entity, typeRegistry));
+ }
+
+ public Referenceable getEntity() {
+ return entity;
+ }
+
+ public void setEntity(Referenceable entity) {
+ this.entity = entity;
+ }
+
+ public OperationType getOperationType() {
+ return operationType;
+ }
+
+ public void setOperationType(OperationType operationType) {
+ this.operationType = operationType;
+ }
+
+ public List<Struct> getTraits() {
+ return traits;
+ }
+
+ public void setTraits(List<Struct> traits) {
+ this.traits = traits;
+ }
+
+ @JsonIgnore
+ public List<Struct> getAllTraits() {
+ return traits;
+ }
+
+ public void normalize() {
+ super.normalize();
+
+ if (entity != null) {
+ entity.normailze();
+ }
+
+ if (traits != null) {
+ for (Struct trait : traits) {
+ if (trait != null) {
+ trait.normailze();
+ }
+ }
+ }
+ }
+
+ // ----- Object overrides --------------------------------------------------
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ EntityNotificationV1 that = (EntityNotificationV1) o;
+ return Objects.equals(entity, that.entity) &&
+ operationType == that.operationType &&
+ Objects.equals(traits, that.traits);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(entity, operationType, traits);
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("EntityNotificationV1{");
+ super.toString(sb);
+ sb.append(", entity=");
+ if (entity != null) {
+ entity.toString(sb);
+ } else {
+ sb.append(entity);
+ }
+ sb.append(", operationType=").append(operationType);
+ sb.append(", traits=[");
+ AtlasBaseTypeDef.dumpObjects(traits, sb);
+ sb.append("]");
+ sb.append("}");
+
+ return sb;
+ }
+
+
+ // ----- helper methods ----------------------------------------------------
+
+ private static List<Struct> getAllTraits(Referenceable entityDefinition, AtlasTypeRegistry typeRegistry) {
+ List<Struct> ret = new LinkedList<>();
+
+ for (String traitName : entityDefinition.getTraitNames()) {
+ Struct trait = entityDefinition.getTrait(traitName);
+ AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName);
+ Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null;
+
+ ret.add(trait);
+
+ if (CollectionUtils.isNotEmpty(superTypeNames)) {
+ for (String superTypeName : superTypeNames) {
+ Struct superTypeTrait = new Struct(superTypeName);
+
+ if (MapUtils.isNotEmpty(trait.getValues())) {
+ AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName);
+
+ if (superType != null && MapUtils.isNotEmpty(superType.getAllAttributes())) {
+ Map<String, Object> superTypeTraitAttributes = new HashMap<>();
+
+ for (Map.Entry<String, Object> attrEntry : trait.getValues().entrySet()) {
+ String attrName = attrEntry.getKey();
+
+ if (superType.getAllAttributes().containsKey(attrName)) {
+ superTypeTraitAttributes.put(attrName, attrEntry.getValue());
+ }
+ }
+
+ superTypeTrait.setValues(superTypeTraitAttributes);
+ }
+ }
+
+ ret.add(superTypeTrait);
+ }
+ }
+ }
+
+ return ret;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotification.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotification.java b/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotification.java
deleted file mode 100644
index ae0ec15..0000000
--- a/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotification.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.v1.model.notification;
-
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
-import org.apache.atlas.v1.model.instance.Referenceable;
-import org.apache.atlas.v1.model.typedef.TypesDef;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
-/**
- * Contains the structure of messages transferred from hooks to atlas.
- */
-public class HookNotification {
- /**
- * Type of the hook message.
- */
- public enum HookNotificationType {
- TYPE_CREATE, TYPE_UPDATE, ENTITY_CREATE, ENTITY_PARTIAL_UPDATE, ENTITY_FULL_UPDATE, ENTITY_DELETE
- }
-
- /**
- * Base type of hook message.
- */
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
- @XmlRootElement
- @XmlAccessorType(XmlAccessType.PROPERTY)
- public static class HookNotificationMessage implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public static final String UNKNOW_USER = "UNKNOWN";
-
- protected HookNotificationType type;
- protected String user;
-
- public HookNotificationMessage() {
- }
-
- public HookNotificationMessage(HookNotificationType type, String user) {
- this.type = type;
- this.user = user;
- }
-
- public HookNotificationType getType() {
- return type;
- }
-
- public void setType(HookNotificationType type) {
- this.type = type;
- }
-
- public String getUser() {
- if (StringUtils.isEmpty(user)) {
- return UNKNOW_USER;
- }
-
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public void normalize() { }
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
-
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("HookNotificationMessage{");
- sb.append("type=").append(type);
- sb.append(", user=").append(user);
- sb.append("}");
-
- return sb;
- }
- }
-
- /**
- * Hook message for create type definitions.
- */
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
- @XmlRootElement
- @XmlAccessorType(XmlAccessType.PROPERTY)
- public static class TypeRequest extends HookNotificationMessage implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private TypesDef typesDef;
-
- public TypeRequest() {
- }
-
- public TypeRequest(HookNotificationType type, TypesDef typesDef, String user) {
- super(type, user);
- this.typesDef = typesDef;
- }
-
- public TypesDef getTypesDef() {
- return typesDef;
- }
-
- public void setTypesDef(TypesDef typesDef) {
- this.typesDef = typesDef;
- }
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("TypeRequest{");
- super.toString(sb);
- sb.append("typesDef=");
- if (typesDef != null) {
- typesDef.toString(sb);
- }
- sb.append("}");
-
- return sb;
- }
- }
-
- /**
- * Hook message for creating new entities.
- */
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
- @XmlRootElement
- @XmlAccessorType(XmlAccessType.PROPERTY)
- public static class EntityCreateRequest extends HookNotificationMessage implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private List<Referenceable> entities;
-
- public EntityCreateRequest() {
- }
-
- public EntityCreateRequest(String user, Referenceable... entities) {
- this(HookNotificationType.ENTITY_CREATE, Arrays.asList(entities), user);
- }
-
- public EntityCreateRequest(String user, List<Referenceable> entities) {
- this(HookNotificationType.ENTITY_CREATE, entities, user);
- }
-
- protected EntityCreateRequest(HookNotificationType type, List<Referenceable> entities, String user) {
- super(type, user);
-
- this.entities = entities;
- }
-
- public List<Referenceable> getEntities() {
- return entities;
- }
-
- public void setEntities(List<Referenceable> entities) {
- this.entities = entities;
- }
-
- @Override
- public void normalize() {
- super.normalize();
-
- if (entities != null) {
- for (Referenceable entity : entities) {
- if (entity != null) {
- entity.normailze();
- }
- }
- }
- }
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("EntityCreateRequest{");
- super.toString(sb);
- sb.append("entities=[");
- AtlasBaseTypeDef.dumpObjects(getEntities(), sb);
- sb.append("]");
- sb.append("}");
-
- return sb;
- }
- }
-
- /**
- * Hook message for updating entities(full update).
- */
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
- @XmlRootElement
- @XmlAccessorType(XmlAccessType.PROPERTY)
- public static class EntityUpdateRequest extends EntityCreateRequest implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public EntityUpdateRequest() {
- }
-
- public EntityUpdateRequest(String user, Referenceable... entities) {
- this(user, Arrays.asList(entities));
- }
-
- public EntityUpdateRequest(String user, List<Referenceable> entities) {
- super(HookNotificationType.ENTITY_FULL_UPDATE, entities, user);
- }
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("EntityUpdateRequest{");
- super.toString(sb);
- sb.append("entities=[");
- AtlasBaseTypeDef.dumpObjects(getEntities(), sb);
- sb.append("]");
- sb.append("}");
-
- return sb;
- }
- }
-
- /**
- * Hook message for updating entities(partial update).
- */
- public static class EntityPartialUpdateRequest extends HookNotificationMessage {
- private static final long serialVersionUID = 1L;
-
- private String typeName;
- private String attribute;
- private String attributeValue;
- private Referenceable entity;
-
- public EntityPartialUpdateRequest() {
- }
-
- public EntityPartialUpdateRequest(String user, String typeName, String attribute, String attributeValue, Referenceable entity) {
- super(HookNotificationType.ENTITY_PARTIAL_UPDATE, user);
-
- this.typeName = typeName;
- this.attribute = attribute;
- this.attributeValue = attributeValue;
- this.entity = entity;
- }
-
- public String getTypeName() {
- return typeName;
- }
-
- public void setTypeName(String typeName) {
- this.typeName = typeName;
- }
-
- public String getAttribute() {
- return attribute;
- }
-
- public void setAttribute(String attribute) {
- this.attribute = attribute;
- }
-
- public String getAttributeValue() {
- return attributeValue;
- }
-
- public void setAttributeValue(String attributeValue) {
- this.attributeValue = attributeValue;
- }
-
- public Referenceable getEntity() {
- return entity;
- }
-
- public void setEntity(Referenceable entity) {
- this.entity = entity;
- }
-
- @Override
- public void normalize() {
- super.normalize();
-
- if (entity != null) {
- entity.normailze();
- }
- }
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("EntityPartialUpdateRequest{");
- super.toString(sb);
- sb.append("typeName=").append(typeName);
- sb.append("attribute=").append(attribute);
- sb.append("attributeValue=").append(attributeValue);
- sb.append("entity=");
- if (entity != null) {
- entity.toString(sb);
- }
- sb.append("}");
-
- return sb;
- }
- }
-
- /**
- * Hook message for creating new entities.
- */
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
- @XmlRootElement
- @XmlAccessorType(XmlAccessType.PROPERTY)
- public static class EntityDeleteRequest extends HookNotificationMessage implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String typeName;
- private String attribute;
- private String attributeValue;
-
- public EntityDeleteRequest() {
- }
-
- public EntityDeleteRequest(String user, String typeName, String attribute, String attributeValue) {
- this(HookNotificationType.ENTITY_DELETE, user, typeName, attribute, attributeValue);
- }
-
- protected EntityDeleteRequest(HookNotificationType type, String user, String typeName, String attribute, String attributeValue) {
- super(type, user);
-
- this.typeName = typeName;
- this.attribute = attribute;
- this.attributeValue = attributeValue;
- }
-
- public String getTypeName() {
- return typeName;
- }
-
- public void setTypeName(String typeName) {
- this.typeName = typeName;
- }
-
- public String getAttribute() {
- return attribute;
- }
-
- public void setAttribute(String attribute) {
- this.attribute = attribute;
- }
-
- public String getAttributeValue() {
- return attributeValue;
- }
-
- public void setAttributeValue(String attributeValue) {
- this.attributeValue = attributeValue;
- }
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("EntityDeleteRequest{");
- super.toString(sb);
- sb.append("typeName=").append(typeName);
- sb.append("attribute=").append(attribute);
- sb.append("attributeValue=").append(attributeValue);
- sb.append("}");
-
- return sb;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java b/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java
new file mode 100644
index 0000000..c70e7d0
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java
@@ -0,0 +1,357 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.v1.model.notification;
+
+import org.apache.atlas.model.notification.HookNotification;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
+import org.apache.atlas.v1.model.instance.Referenceable;
+import org.apache.atlas.v1.model.typedef.TypesDef;
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+/**
+ * Contains the structure of messages transferred from hooks to atlas.
+ */
+public class HookNotificationV1 {
+
+ /**
+ * Hook message for create type definitions.
+ */
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class TypeRequest extends HookNotification implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private TypesDef typesDef;
+
+ public TypeRequest() {
+ }
+
+ public TypeRequest(HookNotificationType type, TypesDef typesDef, String user) {
+ super(type, user);
+ this.typesDef = typesDef;
+ }
+
+ public TypesDef getTypesDef() {
+ return typesDef;
+ }
+
+ public void setTypesDef(TypesDef typesDef) {
+ this.typesDef = typesDef;
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("TypeRequest{");
+ super.toString(sb);
+ sb.append("typesDef=");
+ if (typesDef != null) {
+ typesDef.toString(sb);
+ }
+ sb.append("}");
+
+ return sb;
+ }
+ }
+
+ /**
+ * Hook message for creating new entities.
+ */
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class EntityCreateRequest extends HookNotification implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private List<Referenceable> entities;
+
+ public EntityCreateRequest() {
+ }
+
+ public EntityCreateRequest(String user, Referenceable... entities) {
+ this(HookNotificationType.ENTITY_CREATE, Arrays.asList(entities), user);
+ }
+
+ public EntityCreateRequest(String user, List<Referenceable> entities) {
+ this(HookNotificationType.ENTITY_CREATE, entities, user);
+ }
+
+ protected EntityCreateRequest(HookNotificationType type, List<Referenceable> entities, String user) {
+ super(type, user);
+
+ this.entities = entities;
+ }
+
+ public List<Referenceable> getEntities() {
+ return entities;
+ }
+
+ public void setEntities(List<Referenceable> entities) {
+ this.entities = entities;
+ }
+
+ @Override
+ public void normalize() {
+ super.normalize();
+
+ if (entities != null) {
+ for (Referenceable entity : entities) {
+ if (entity != null) {
+ entity.normailze();
+ }
+ }
+ }
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("EntityCreateRequest{");
+ super.toString(sb);
+ sb.append("entities=[");
+ AtlasBaseTypeDef.dumpObjects(getEntities(), sb);
+ sb.append("]");
+ sb.append("}");
+
+ return sb;
+ }
+ }
+
+ /**
+ * Hook message for updating entities(full update).
+ */
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class EntityUpdateRequest extends EntityCreateRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public EntityUpdateRequest() {
+ }
+
+ public EntityUpdateRequest(String user, Referenceable... entities) {
+ this(user, Arrays.asList(entities));
+ }
+
+ public EntityUpdateRequest(String user, List<Referenceable> entities) {
+ super(HookNotificationType.ENTITY_FULL_UPDATE, entities, user);
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("EntityUpdateRequest{");
+ super.toString(sb);
+ sb.append("entities=[");
+ AtlasBaseTypeDef.dumpObjects(getEntities(), sb);
+ sb.append("]");
+ sb.append("}");
+
+ return sb;
+ }
+ }
+
+ /**
+ * Hook message for updating entities(partial update).
+ */
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class EntityPartialUpdateRequest extends HookNotification {
+ private static final long serialVersionUID = 1L;
+
+ private String typeName;
+ private String attribute;
+ private String attributeValue;
+ private Referenceable entity;
+
+ public EntityPartialUpdateRequest() {
+ }
+
+ public EntityPartialUpdateRequest(String user, String typeName, String attribute, String attributeValue, Referenceable entity) {
+ super(HookNotificationType.ENTITY_PARTIAL_UPDATE, user);
+
+ this.typeName = typeName;
+ this.attribute = attribute;
+ this.attributeValue = attributeValue;
+ this.entity = entity;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getAttribute() {
+ return attribute;
+ }
+
+ public void setAttribute(String attribute) {
+ this.attribute = attribute;
+ }
+
+ public String getAttributeValue() {
+ return attributeValue;
+ }
+
+ public void setAttributeValue(String attributeValue) {
+ this.attributeValue = attributeValue;
+ }
+
+ public Referenceable getEntity() {
+ return entity;
+ }
+
+ public void setEntity(Referenceable entity) {
+ this.entity = entity;
+ }
+
+ @Override
+ public void normalize() {
+ super.normalize();
+
+ if (entity != null) {
+ entity.normailze();
+ }
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("EntityPartialUpdateRequest{");
+ super.toString(sb);
+ sb.append("typeName=").append(typeName);
+ sb.append("attribute=").append(attribute);
+ sb.append("attributeValue=").append(attributeValue);
+ sb.append("entity=");
+ if (entity != null) {
+ entity.toString(sb);
+ }
+ sb.append("}");
+
+ return sb;
+ }
+ }
+
+ /**
+ * Hook message for entity delete.
+ */
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class EntityDeleteRequest extends HookNotification implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String typeName;
+ private String attribute;
+ private String attributeValue;
+
+ public EntityDeleteRequest() {
+ }
+
+ public EntityDeleteRequest(String user, String typeName, String attribute, String attributeValue) {
+ this(HookNotificationType.ENTITY_DELETE, user, typeName, attribute, attributeValue);
+ }
+
+ protected EntityDeleteRequest(HookNotificationType type, String user, String typeName, String attribute, String attributeValue) {
+ super(type, user);
+
+ this.typeName = typeName;
+ this.attribute = attribute;
+ this.attributeValue = attributeValue;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getAttribute() {
+ return attribute;
+ }
+
+ public void setAttribute(String attribute) {
+ this.attribute = attribute;
+ }
+
+ public String getAttributeValue() {
+ return attributeValue;
+ }
+
+ public void setAttributeValue(String attributeValue) {
+ this.attributeValue = attributeValue;
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("EntityDeleteRequest{");
+ super.toString(sb);
+ sb.append("typeName=").append(typeName);
+ sb.append("attribute=").append(attribute);
+ sb.append("attributeValue=").append(attributeValue);
+ sb.append("}");
+
+ return sb;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/f01e46d7/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java
index f8bcfa3..6a8bcb4 100644
--- a/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java
+++ b/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java
@@ -34,7 +34,7 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)