Search in sources :

Example 6 with VXAccessAudit

use of org.apache.ranger.view.VXAccessAudit in project ranger by apache.

the class SolrAccessAuditsService method populateViewBean.

/**
 * @param doc
 * @return
 */
private VXAccessAudit populateViewBean(SolrDocument doc) {
    VXAccessAudit accessAudit = new VXAccessAudit();
    Object value = null;
    if (logger.isDebugEnabled()) {
        logger.debug("doc=" + doc.toString());
    }
    value = doc.getFieldValue("id");
    if (value != null) {
        // TODO: Converting ID to hashcode for now
        accessAudit.setId((long) value.hashCode());
    }
    value = doc.getFieldValue("cluster");
    if (value != null) {
        accessAudit.setClusterName(value.toString());
    }
    value = doc.getFieldValue("access");
    if (value != null) {
        accessAudit.setAccessType(value.toString());
    }
    value = doc.getFieldValue("enforcer");
    if (value != null) {
        accessAudit.setAclEnforcer(value.toString());
    }
    value = doc.getFieldValue("agent");
    if (value != null) {
        accessAudit.setAgentId(value.toString());
    }
    value = doc.getFieldValue("repo");
    if (value != null) {
        accessAudit.setRepoName(value.toString());
    }
    value = doc.getFieldValue("sess");
    if (value != null) {
        accessAudit.setSessionId(value.toString());
    }
    value = doc.getFieldValue("reqUser");
    if (value != null) {
        accessAudit.setRequestUser(value.toString());
    }
    value = doc.getFieldValue("reqData");
    if (value != null) {
        accessAudit.setRequestData(value.toString());
    }
    value = doc.getFieldValue("resource");
    if (value != null) {
        accessAudit.setResourcePath(value.toString());
    }
    value = doc.getFieldValue("cliIP");
    if (value != null) {
        accessAudit.setClientIP(value.toString());
    }
    value = doc.getFieldValue("logType");
    // if (value != null) {
    // TODO: Need to see what logType maps to in UI
    // accessAudit.setAuditType(solrUtil.toInt(value));
    // }
    value = doc.getFieldValue("result");
    if (value != null) {
        accessAudit.setAccessResult(solrUtil.toInt(value));
    }
    value = doc.getFieldValue("policy");
    if (value != null) {
        accessAudit.setPolicyId(solrUtil.toLong(value));
    }
    value = doc.getFieldValue("repoType");
    if (value != null) {
        accessAudit.setRepoType(solrUtil.toInt(value));
        XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById((long) accessAudit.getRepoType());
        if (xServiceDef != null) {
            accessAudit.setServiceType(xServiceDef.getName());
        }
    }
    value = doc.getFieldValue("resType");
    if (value != null) {
        accessAudit.setResourceType(value.toString());
    }
    value = doc.getFieldValue("reason");
    if (value != null) {
        accessAudit.setResultReason(value.toString());
    }
    value = doc.getFieldValue("action");
    if (value != null) {
        accessAudit.setAction(value.toString());
    }
    value = doc.getFieldValue("evtTime");
    if (value != null) {
        accessAudit.setEventTime(solrUtil.toDate(value));
    }
    value = doc.getFieldValue("seq_num");
    if (value != null) {
        accessAudit.setSequenceNumber(solrUtil.toLong(value));
    }
    value = doc.getFieldValue("event_count");
    if (value != null) {
        accessAudit.setEventCount(solrUtil.toLong(value));
    }
    value = doc.getFieldValue("event_dur_ms");
    if (value != null) {
        accessAudit.setEventDuration(solrUtil.toLong(value));
    }
    value = doc.getFieldValue("tags");
    if (value != null) {
        accessAudit.setTags(value.toString());
    }
    return accessAudit;
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) VXAccessAudit(org.apache.ranger.view.VXAccessAudit)

Aggregations

VXAccessAudit (org.apache.ranger.view.VXAccessAudit)6 ArrayList (java.util.ArrayList)5 VXAccessAuditList (org.apache.ranger.view.VXAccessAuditList)5 XXServiceDef (org.apache.ranger.entity.XXServiceDef)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Date (java.util.Date)2 SearchCriteria (org.apache.ranger.common.SearchCriteria)2 SortField (org.apache.ranger.common.SortField)2 Test (org.junit.Test)2 List (java.util.List)1 XXAccessAudit (org.apache.ranger.entity.XXAccessAudit)1 SolrClient (org.apache.solr.client.solrj.SolrClient)1 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)1 SolrDocument (org.apache.solr.common.SolrDocument)1 SolrDocumentList (org.apache.solr.common.SolrDocumentList)1