Commit be9b39bf by Madhan Neethiraj

ATLAS-2456: fix in conversion of auditAction string to V1/V2 version of EntityAuditAction

parent bf4bf7fe
......@@ -47,7 +47,35 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
public class EntityAuditEvent implements Serializable {
public enum EntityAuditAction {
ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE, TAG_ADD, TAG_DELETE, TAG_UPDATE,
ENTITY_IMPORT_CREATE, ENTITY_IMPORT_UPDATE, ENTITY_IMPORT_DELETE,
ENTITY_IMPORT_CREATE, ENTITY_IMPORT_UPDATE, ENTITY_IMPORT_DELETE;
public static EntityAuditAction fromString(String strValue) {
switch (strValue) {
case "ENTITY_CREATE":
return ENTITY_CREATE;
case "ENTITY_UPDATE":
return ENTITY_UPDATE;
case "ENTITY_DELETE":
return ENTITY_DELETE;
case "ENTITY_IMPORT_CREATE":
return ENTITY_IMPORT_CREATE;
case "ENTITY_IMPORT_UPDATE":
return ENTITY_IMPORT_UPDATE;
case "ENTITY_IMPORT_DELETE":
return ENTITY_IMPORT_DELETE;
case "CLASSIFICATION_ADD":
case "TAG_ADD":
return TAG_ADD;
case "CLASSIFICATION_DELETE":
case "TAG_DELETE":
return TAG_DELETE;
case "CLASSIFICATION_UPDATE":
case "TAG_UPDATE":
return TAG_UPDATE;
}
throw new IllegalArgumentException("No enum constant " + EntityAuditAction.class.getCanonicalName() + "." + strValue);
}
}
private String entityId;
......
......@@ -45,7 +45,35 @@ public class EntityAuditEventV2 implements Serializable {
public enum EntityAuditAction {
ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE,
ENTITY_IMPORT_CREATE, ENTITY_IMPORT_UPDATE, ENTITY_IMPORT_DELETE,
CLASSIFICATION_ADD, CLASSIFICATION_DELETE, CLASSIFICATION_UPDATE,
CLASSIFICATION_ADD, CLASSIFICATION_DELETE, CLASSIFICATION_UPDATE;
public static EntityAuditAction fromString(String strValue) {
switch (strValue) {
case "ENTITY_CREATE":
return ENTITY_CREATE;
case "ENTITY_UPDATE":
return ENTITY_UPDATE;
case "ENTITY_DELETE":
return ENTITY_DELETE;
case "ENTITY_IMPORT_CREATE":
return ENTITY_IMPORT_CREATE;
case "ENTITY_IMPORT_UPDATE":
return ENTITY_IMPORT_UPDATE;
case "ENTITY_IMPORT_DELETE":
return ENTITY_IMPORT_DELETE;
case "CLASSIFICATION_ADD":
case "TAG_ADD":
return CLASSIFICATION_ADD;
case "CLASSIFICATION_DELETE":
case "TAG_DELETE":
return CLASSIFICATION_DELETE;
case "CLASSIFICATION_UPDATE":
case "TAG_UPDATE":
return CLASSIFICATION_UPDATE;
}
throw new IllegalArgumentException("No enum constant " + EntityAuditAction.class.getCanonicalName() + "." + strValue);
}
}
private String entityId;
......
......@@ -252,7 +252,7 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
continue;
}
event.setUser(getResultString(result, COLUMN_USER));
event.setAction(EntityAuditAction.valueOf(getResultString(result, COLUMN_ACTION)));
event.setAction(EntityAuditAction.fromString(getResultString(result, COLUMN_ACTION)));
event.setDetails(getResultString(result, COLUMN_DETAIL));
if (persistEntityDefinition) {
......@@ -362,7 +362,7 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
continue;
}
event.setUser(getResultString(result, COLUMN_USER));
event.setAction(EntityAuditEvent.EntityAuditAction.valueOf(getResultString(result, COLUMN_ACTION)));
event.setAction(EntityAuditEvent.EntityAuditAction.fromString(getResultString(result, COLUMN_ACTION)));
event.setDetails(getResultString(result, COLUMN_DETAIL));
if (persistEntityDefinition) {
String colDef = getResultString(result, COLUMN_DEFINITION);
......
......@@ -356,54 +356,52 @@ public class AtlasInstanceConverter {
}
private EntityAuditEvent.EntityAuditAction getV1AuditAction(EntityAuditEventV2.EntityAuditAction v2AuditAction) {
EntityAuditEvent.EntityAuditAction ret = null;
switch (v2AuditAction) {
case ENTITY_CREATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_CREATE;
case ENTITY_UPDATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_UPDATE;
case ENTITY_DELETE:
return EntityAuditEvent.EntityAuditAction.ENTITY_DELETE;
case ENTITY_IMPORT_CREATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_IMPORT_CREATE;
case ENTITY_IMPORT_UPDATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_IMPORT_UPDATE;
case ENTITY_IMPORT_DELETE:
ret = EntityAuditEvent.EntityAuditAction.valueOf(v2AuditAction.name());
break;
return EntityAuditEvent.EntityAuditAction.ENTITY_IMPORT_DELETE;
case CLASSIFICATION_ADD:
ret = EntityAuditEvent.EntityAuditAction.valueOf(TAG_ADD.name());
break;
return EntityAuditEvent.EntityAuditAction.TAG_ADD;
case CLASSIFICATION_DELETE:
ret = EntityAuditEvent.EntityAuditAction.valueOf(TAG_DELETE.name());
break;
return EntityAuditEvent.EntityAuditAction.TAG_DELETE;
case CLASSIFICATION_UPDATE:
ret = EntityAuditEvent.EntityAuditAction.valueOf(TAG_UPDATE.name());
break;
return EntityAuditEvent.EntityAuditAction.TAG_UPDATE;
}
return ret;
return null;
}
private EntityAuditEventV2.EntityAuditAction getV2AuditAction(EntityAuditEvent.EntityAuditAction v1AuditAction) {
EntityAuditEventV2.EntityAuditAction ret = null;
switch (v1AuditAction) {
case ENTITY_CREATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_CREATE;
case ENTITY_UPDATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_UPDATE;
case ENTITY_DELETE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_DELETE;
case ENTITY_IMPORT_CREATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_IMPORT_CREATE;
case ENTITY_IMPORT_UPDATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_IMPORT_UPDATE;
case ENTITY_IMPORT_DELETE:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(v1AuditAction.name());
break;
return EntityAuditEventV2.EntityAuditAction.ENTITY_IMPORT_DELETE;
case TAG_ADD:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(CLASSIFICATION_ADD.name());
break;
return EntityAuditEventV2.EntityAuditAction.CLASSIFICATION_ADD;
case TAG_DELETE:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(CLASSIFICATION_DELETE.name());
break;
return EntityAuditEventV2.EntityAuditAction.CLASSIFICATION_DELETE;
case TAG_UPDATE:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(CLASSIFICATION_UPDATE.name());
break;
return EntityAuditEventV2.EntityAuditAction.CLASSIFICATION_UPDATE;
}
return ret;
return null;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment