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_ ...@@ -47,7 +47,35 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
public class EntityAuditEvent implements Serializable { public class EntityAuditEvent implements Serializable {
public enum EntityAuditAction { public enum EntityAuditAction {
ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE, TAG_ADD, TAG_DELETE, TAG_UPDATE, 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; private String entityId;
......
...@@ -45,7 +45,35 @@ public class EntityAuditEventV2 implements Serializable { ...@@ -45,7 +45,35 @@ public class EntityAuditEventV2 implements Serializable {
public enum EntityAuditAction { public enum EntityAuditAction {
ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE, ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE,
ENTITY_IMPORT_CREATE, ENTITY_IMPORT_UPDATE, ENTITY_IMPORT_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; private String entityId;
......
...@@ -252,7 +252,7 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository ...@@ -252,7 +252,7 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
continue; continue;
} }
event.setUser(getResultString(result, COLUMN_USER)); 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)); event.setDetails(getResultString(result, COLUMN_DETAIL));
if (persistEntityDefinition) { if (persistEntityDefinition) {
...@@ -362,7 +362,7 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository ...@@ -362,7 +362,7 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
continue; continue;
} }
event.setUser(getResultString(result, COLUMN_USER)); 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)); event.setDetails(getResultString(result, COLUMN_DETAIL));
if (persistEntityDefinition) { if (persistEntityDefinition) {
String colDef = getResultString(result, COLUMN_DEFINITION); String colDef = getResultString(result, COLUMN_DEFINITION);
......
...@@ -356,54 +356,52 @@ public class AtlasInstanceConverter { ...@@ -356,54 +356,52 @@ public class AtlasInstanceConverter {
} }
private EntityAuditEvent.EntityAuditAction getV1AuditAction(EntityAuditEventV2.EntityAuditAction v2AuditAction) { private EntityAuditEvent.EntityAuditAction getV1AuditAction(EntityAuditEventV2.EntityAuditAction v2AuditAction) {
EntityAuditEvent.EntityAuditAction ret = null;
switch (v2AuditAction) { switch (v2AuditAction) {
case ENTITY_CREATE: case ENTITY_CREATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_CREATE;
case ENTITY_UPDATE: case ENTITY_UPDATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_UPDATE;
case ENTITY_DELETE: case ENTITY_DELETE:
return EntityAuditEvent.EntityAuditAction.ENTITY_DELETE;
case ENTITY_IMPORT_CREATE: case ENTITY_IMPORT_CREATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_IMPORT_CREATE;
case ENTITY_IMPORT_UPDATE: case ENTITY_IMPORT_UPDATE:
return EntityAuditEvent.EntityAuditAction.ENTITY_IMPORT_UPDATE;
case ENTITY_IMPORT_DELETE: case ENTITY_IMPORT_DELETE:
ret = EntityAuditEvent.EntityAuditAction.valueOf(v2AuditAction.name()); return EntityAuditEvent.EntityAuditAction.ENTITY_IMPORT_DELETE;
break;
case CLASSIFICATION_ADD: case CLASSIFICATION_ADD:
ret = EntityAuditEvent.EntityAuditAction.valueOf(TAG_ADD.name()); return EntityAuditEvent.EntityAuditAction.TAG_ADD;
break;
case CLASSIFICATION_DELETE: case CLASSIFICATION_DELETE:
ret = EntityAuditEvent.EntityAuditAction.valueOf(TAG_DELETE.name()); return EntityAuditEvent.EntityAuditAction.TAG_DELETE;
break;
case CLASSIFICATION_UPDATE: case CLASSIFICATION_UPDATE:
ret = EntityAuditEvent.EntityAuditAction.valueOf(TAG_UPDATE.name()); return EntityAuditEvent.EntityAuditAction.TAG_UPDATE;
break;
} }
return ret; return null;
} }
private EntityAuditEventV2.EntityAuditAction getV2AuditAction(EntityAuditEvent.EntityAuditAction v1AuditAction) { private EntityAuditEventV2.EntityAuditAction getV2AuditAction(EntityAuditEvent.EntityAuditAction v1AuditAction) {
EntityAuditEventV2.EntityAuditAction ret = null;
switch (v1AuditAction) { switch (v1AuditAction) {
case ENTITY_CREATE: case ENTITY_CREATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_CREATE;
case ENTITY_UPDATE: case ENTITY_UPDATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_UPDATE;
case ENTITY_DELETE: case ENTITY_DELETE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_DELETE;
case ENTITY_IMPORT_CREATE: case ENTITY_IMPORT_CREATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_IMPORT_CREATE;
case ENTITY_IMPORT_UPDATE: case ENTITY_IMPORT_UPDATE:
return EntityAuditEventV2.EntityAuditAction.ENTITY_IMPORT_UPDATE;
case ENTITY_IMPORT_DELETE: case ENTITY_IMPORT_DELETE:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(v1AuditAction.name()); return EntityAuditEventV2.EntityAuditAction.ENTITY_IMPORT_DELETE;
break;
case TAG_ADD: case TAG_ADD:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(CLASSIFICATION_ADD.name()); return EntityAuditEventV2.EntityAuditAction.CLASSIFICATION_ADD;
break;
case TAG_DELETE: case TAG_DELETE:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(CLASSIFICATION_DELETE.name()); return EntityAuditEventV2.EntityAuditAction.CLASSIFICATION_DELETE;
break;
case TAG_UPDATE: case TAG_UPDATE:
ret = EntityAuditEventV2.EntityAuditAction.valueOf(CLASSIFICATION_UPDATE.name()); return EntityAuditEventV2.EntityAuditAction.CLASSIFICATION_UPDATE;
break;
} }
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