use of org.apache.atlas.model.audit.EntityAuditEventV2 in project atlas by apache.
the class AtlasInstanceConverter method toV2AuditEvent.
public EntityAuditEventV2 toV2AuditEvent(EntityAuditEvent v1Event) throws AtlasBaseException {
EntityAuditEventV2 ret = new EntityAuditEventV2();
ret.setEntityId(v1Event.getEntityId());
ret.setTimestamp(v1Event.getTimestamp());
ret.setUser(v1Event.getUser());
ret.setDetails(v1Event.getDetails());
ret.setEventKey(v1Event.getEventKey());
ret.setAction(getV2AuditAction(v1Event.getAction()));
AtlasEntitiesWithExtInfo entitiesWithExtInfo = toAtlasEntity(v1Event.getEntityDefinition());
if (entitiesWithExtInfo != null && CollectionUtils.isNotEmpty(entitiesWithExtInfo.getEntities())) {
// there will only one source entity
AtlasEntity entity = entitiesWithExtInfo.getEntities().get(0);
ret.setEntity(entity);
}
return ret;
}
use of org.apache.atlas.model.audit.EntityAuditEventV2 in project atlas by apache.
the class EntityAuditListenerV2 method onEntitiesAdded.
@Override
public void onEntitiesAdded(List<AtlasEntity> entities, boolean isImport) throws AtlasBaseException {
List<EntityAuditEventV2> events = new ArrayList<>();
for (AtlasEntity entity : entities) {
EntityAuditEventV2 event = createEvent(entity, isImport ? ENTITY_IMPORT_CREATE : ENTITY_CREATE);
events.add(event);
}
auditRepository.putEventsV2(events);
}
use of org.apache.atlas.model.audit.EntityAuditEventV2 in project atlas by apache.
the class EntityAuditListenerV2 method onClassificationsAdded.
@Override
public void onClassificationsAdded(AtlasEntity entity, List<AtlasClassification> classifications) throws AtlasBaseException {
if (CollectionUtils.isNotEmpty(classifications)) {
List<EntityAuditEventV2> events = new ArrayList<>();
for (AtlasClassification classification : classifications) {
events.add(createEvent(entity, CLASSIFICATION_ADD, "Added classification: " + AtlasType.toJson(classification)));
}
auditRepository.putEventsV2(events);
}
}
use of org.apache.atlas.model.audit.EntityAuditEventV2 in project atlas by apache.
the class HBaseBasedAuditRepository method putEventsV2.
@Override
public void putEventsV2(List<EntityAuditEventV2> events) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("Putting {} events", events.size());
}
Table table = null;
try {
table = connection.getTable(tableName);
List<Put> puts = new ArrayList<>(events.size());
for (EntityAuditEventV2 event : events) {
if (LOG.isDebugEnabled()) {
LOG.debug("Adding entity audit event {}", event);
}
Put put = new Put(getKey(event.getEntityId(), event.getTimestamp()));
addColumn(put, COLUMN_ACTION, event.getAction());
addColumn(put, COLUMN_USER, event.getUser());
addColumn(put, COLUMN_DETAIL, event.getDetails());
if (persistEntityDefinition) {
addColumn(put, COLUMN_DEFINITION, event.getEntity());
}
puts.add(put);
}
table.put(puts);
} catch (IOException e) {
throw new AtlasBaseException(e);
} finally {
try {
close(table);
} catch (AtlasException e) {
throw new AtlasBaseException(e);
}
}
}
use of org.apache.atlas.model.audit.EntityAuditEventV2 in project atlas by apache.
the class HBaseBasedAuditRepository method fromKeyV2.
private EntityAuditEventV2 fromKeyV2(byte[] keyBytes) {
String key = Bytes.toString(keyBytes);
EntityAuditEventV2 event = new EntityAuditEventV2();
if (StringUtils.isNotEmpty(key)) {
String[] parts = key.split(FIELD_SEPARATOR);
event.setEntityId(parts[0]);
event.setTimestamp(Long.valueOf(parts[1]));
event.setEventKey(key);
}
return event;
}
Aggregations