Commit 3ff785a8 by sidmishra Committed by Sarath Subramanian

ATLAS-3726: Added extra field to admin audit for result count

parent ec48c09a
......@@ -479,6 +479,14 @@
"isIndexable": false,
"isOptional": true,
"isUnique": false
},
{
"name": "resultCount",
"typeName": "long",
"cardinality": "SINGLE",
"isIndexable": true,
"isOptional": true,
"isUnique": false
}
]
},
......
......@@ -49,6 +49,7 @@ public class AtlasAuditEntry extends AtlasBaseModelObject implements Serializabl
private Date endTime;
private String clientId;
private String result;
private long resultCount;
public AtlasAuditEntry() {
}
......@@ -115,6 +116,14 @@ public class AtlasAuditEntry extends AtlasBaseModelObject implements Serializabl
this.result = result;
}
public long getResultCount() {
return resultCount;
}
public void setResultCount(long resultCount) {
this.resultCount = resultCount;
}
@Override
public StringBuilder toString(StringBuilder sb) {
sb.append(", userName: ").append(userName);
......@@ -124,6 +133,7 @@ public class AtlasAuditEntry extends AtlasBaseModelObject implements Serializabl
sb.append(", startTime: ").append(startTime);
sb.append(", endTime: ").append(endTime);
sb.append(", result: ").append(result);
sb.append(", resultCount: ").append(resultCount);
return sb;
}
......
......@@ -62,7 +62,7 @@ public class AtlasAuditService {
}
public void add(String userName, AuditOperation operation, String clientId, Date startTime,
Date endTime, String params, String result) throws AtlasBaseException {
Date endTime, String params, String result, long resultCount) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasAuditService.add()");
}
......@@ -76,6 +76,7 @@ public class AtlasAuditService {
entry.setEndTime(endTime);
entry.setParams(params);
entry.setResult(result);
entry.setResultCount(resultCount);
save(entry);
......
......@@ -35,18 +35,19 @@ import java.util.Arrays;
@Component
public class AtlasAuditEntryDTO extends AbstractDataTransferObject<AtlasAuditEntry> {
public static final String ATTRIBUTE_USER_NAME = "userName";
public static final String ATTRIBUTE_OPERATION = "operation";
public static final String ATTRIBUTE_PARAMS = "params";
public static final String ATTRIBUTE_START_TIME = "startTime";
public static final String ATTRIBUTE_END_TIME = "endTime";
public static final String ATTRIBUTE_CLIENT_ID = "clientId";
public static final String ATTRIBUTE_RESULT = "result";
public static final String ATTRIBUTE_USER_NAME = "userName";
public static final String ATTRIBUTE_OPERATION = "operation";
public static final String ATTRIBUTE_PARAMS = "params";
public static final String ATTRIBUTE_START_TIME = "startTime";
public static final String ATTRIBUTE_END_TIME = "endTime";
public static final String ATTRIBUTE_CLIENT_ID = "clientId";
public static final String ATTRIBUTE_RESULT = "result";
public static final String ATTRIBUTE_RESULT_COUNT = "resultCount";
private static final Set<String> ATTRIBUTE_NAMES = new HashSet<>(Arrays.asList(ATTRIBUTE_USER_NAME,
ATTRIBUTE_OPERATION, ATTRIBUTE_PARAMS,
ATTRIBUTE_START_TIME, ATTRIBUTE_END_TIME,
ATTRIBUTE_CLIENT_ID, ATTRIBUTE_RESULT));
ATTRIBUTE_CLIENT_ID, ATTRIBUTE_RESULT, ATTRIBUTE_RESULT_COUNT));
@Inject
public AtlasAuditEntryDTO(AtlasTypeRegistry typeRegistry) {
......@@ -69,6 +70,7 @@ public class AtlasAuditEntryDTO extends AbstractDataTransferObject<AtlasAuditEnt
entry.setEndTime((Date) attributes.get(ATTRIBUTE_END_TIME));
entry.setClientId((String) attributes.get(ATTRIBUTE_CLIENT_ID));
entry.setResult((String) attributes.get(ATTRIBUTE_RESULT));
entry.setResultCount((long) attributes.get(ATTRIBUTE_RESULT_COUNT));
return entry;
}
......@@ -94,6 +96,7 @@ public class AtlasAuditEntryDTO extends AbstractDataTransferObject<AtlasAuditEnt
entity.setAttribute(ATTRIBUTE_END_TIME, obj.getEndTime());
entity.setAttribute(ATTRIBUTE_CLIENT_ID, obj.getClientId());
entity.setAttribute(ATTRIBUTE_RESULT, obj.getResult());
entity.setAttribute(ATTRIBUTE_RESULT_COUNT, obj.getResultCount());
return entity;
}
......
......@@ -134,7 +134,7 @@ public class AdminPurgeTest extends AtlasTestBase {
auditService.add(DEFAULT_USER, AtlasAuditEntry.AuditOperation.PURGE,
CLIENT_HOST, startTimestamp, new Date(), guids.toString(),
response.getPurgedEntitiesIds());
response.getPurgedEntitiesIds(), response.getPurgedEntities().size());
AuditSearchParameters auditParameterNull = createAuditParameter("audit-search-parameter-without-filter");
assertAuditEntry(auditService, auditParameterNull);
......
......@@ -479,7 +479,7 @@ public class AdminResource {
auditService.add(AtlasAuthorizationUtils.getCurrentUserName(), AuditOperation.PURGE,
clientId != null ? clientId : "", startTime, endTime, guids.toString(),
resp.getPurgedEntitiesIds());
resp.getPurgedEntitiesIds(), resp.getPurgedEntities().size());
}
return resp;
......
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