Search in sources :

Example 1 with DateUtil

use of org.apache.ranger.common.DateUtil in project ranger by apache.

the class AssetMgr method getAccessLogs.

public VXAccessAuditList getAccessLogs(SearchCriteria searchCriteria) {
    if (searchCriteria == null) {
        searchCriteria = new SearchCriteria();
    }
    if (searchCriteria.getParamList() != null && !searchCriteria.getParamList().isEmpty()) {
        int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
        Date temp = null;
        DateUtil dateUtil = new DateUtil();
        if (searchCriteria.getParamList().containsKey("startDate")) {
            temp = (Date) searchCriteria.getParamList().get("startDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("startDate", temp);
        }
        if (searchCriteria.getParamList().containsKey("endDate")) {
            temp = (Date) searchCriteria.getParamList().get("endDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("endDate", temp);
        }
    }
    if (searchCriteria.getSortType() == null) {
        searchCriteria.setSortType("desc");
    } else if (!"asc".equalsIgnoreCase(searchCriteria.getSortType()) && !"desc".equalsIgnoreCase(searchCriteria.getSortType())) {
        searchCriteria.setSortType("desc");
    }
    if (RangerBizUtil.AUDIT_STORE_SOLR.equalsIgnoreCase(xaBizUtil.getAuditDBType())) {
        return solrAccessAuditsService.searchXAccessAudits(searchCriteria);
    } else {
        return xAccessAuditService.searchXAccessAudits(searchCriteria);
    }
}
Also used : DateUtil(org.apache.ranger.common.DateUtil) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date)

Example 2 with DateUtil

use of org.apache.ranger.common.DateUtil in project ranger by apache.

the class SessionMgr method searchAuthSessions.

/**
 * @param searchCriteria
 * @return
 */
public VXAuthSessionList searchAuthSessions(SearchCriteria searchCriteria) {
    if (searchCriteria == null) {
        searchCriteria = new SearchCriteria();
    }
    if (searchCriteria.getParamList() != null && !searchCriteria.getParamList().isEmpty()) {
        int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
        java.util.Date temp = null;
        DateUtil dateUtil = new DateUtil();
        if (searchCriteria.getParamList().containsKey("startDate")) {
            temp = (java.util.Date) searchCriteria.getParamList().get("startDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("startDate", temp);
        }
        if (searchCriteria.getParamList().containsKey("endDate")) {
            temp = (java.util.Date) searchCriteria.getParamList().get("endDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("endDate", temp);
        }
    }
    return authSessionService.search(searchCriteria);
}
Also used : DateUtil(org.apache.ranger.common.DateUtil) SearchCriteria(org.apache.ranger.common.SearchCriteria)

Example 3 with DateUtil

use of org.apache.ranger.common.DateUtil in project ranger by apache.

the class AssetMgr method getUgsyncAudits.

public VXUgsyncAuditInfoList getUgsyncAudits(SearchCriteria searchCriteria) {
    if (searchCriteria == null) {
        searchCriteria = new SearchCriteria();
    }
    if (searchCriteria.getParamList() != null && !searchCriteria.getParamList().isEmpty()) {
        int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
        Date temp = null;
        DateUtil dateUtil = new DateUtil();
        if (searchCriteria.getParamList().containsKey("startDate")) {
            temp = (Date) searchCriteria.getParamList().get("startDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("startDate", temp);
        }
        if (searchCriteria.getParamList().containsKey("endDate")) {
            temp = (Date) searchCriteria.getParamList().get("endDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("endDate", temp);
        }
    }
    if (searchCriteria.getSortType() == null) {
        searchCriteria.setSortType("desc");
    } else if (!"asc".equalsIgnoreCase(searchCriteria.getSortType()) && !"desc".equalsIgnoreCase(searchCriteria.getSortType())) {
        searchCriteria.setSortType("desc");
    }
    return xUgsyncAuditInfoService.searchXUgsyncAuditInfoList(searchCriteria);
}
Also used : DateUtil(org.apache.ranger.common.DateUtil) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date)

Example 4 with DateUtil

use of org.apache.ranger.common.DateUtil in project ranger by apache.

the class AssetMgr method searchXPolicyExportAudits.

/*
	 * (non-Javadoc)
	 *
	 * @see
	 * org.apache.ranger.biz.AssetMgrBase#searchXPolicyExportAudits(org.apache.ranger.
	 * common.SearchCriteria)
	 */
@Override
public VXPolicyExportAuditList searchXPolicyExportAudits(SearchCriteria searchCriteria) {
    if (searchCriteria == null) {
        searchCriteria = new SearchCriteria();
    }
    if (searchCriteria.getParamList() != null && !searchCriteria.getParamList().isEmpty()) {
        int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
        Date temp = null;
        DateUtil dateUtil = new DateUtil();
        if (searchCriteria.getParamList().containsKey("startDate")) {
            temp = (Date) searchCriteria.getParamList().get("startDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("startDate", temp);
        }
        if (searchCriteria.getParamList().containsKey("endDate")) {
            temp = (Date) searchCriteria.getParamList().get("endDate");
            temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
            temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
            searchCriteria.getParamList().put("endDate", temp);
        }
    }
    return xPolicyExportAuditService.searchXPolicyExportAudits(searchCriteria);
}
Also used : DateUtil(org.apache.ranger.common.DateUtil) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date)

Example 5 with DateUtil

use of org.apache.ranger.common.DateUtil in project ranger by apache.

the class AssetMgr method getReportLogs.

public VXTrxLogList getReportLogs(SearchCriteria searchCriteria) {
    if (xaBizUtil.isAdmin() || xaBizUtil.isKeyAdmin() || xaBizUtil.isAuditAdmin() || xaBizUtil.isAuditKeyAdmin()) {
        if (searchCriteria == null) {
            searchCriteria = new SearchCriteria();
        }
        if (searchCriteria.getParamList() != null && !searchCriteria.getParamList().isEmpty()) {
            int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
            Date temp = null;
            DateUtil dateUtil = new DateUtil();
            if (searchCriteria.getParamList().containsKey("startDate")) {
                temp = (Date) searchCriteria.getParamList().get("startDate");
                temp = dateUtil.getDateFromGivenDate(temp, 0, 0, 0, 0);
                temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
                searchCriteria.getParamList().put("startDate", temp);
            }
            if (searchCriteria.getParamList().containsKey("endDate")) {
                temp = (Date) searchCriteria.getParamList().get("endDate");
                temp = dateUtil.getDateFromGivenDate(temp, 0, 23, 59, 59);
                temp = dateUtil.addTimeOffset(temp, clientTimeOffsetInMinute);
                searchCriteria.getParamList().put("endDate", temp);
            }
            if (searchCriteria.getParamList().containsKey("owner")) {
                XXPortalUser xXPortalUser = rangerDaoManager.getXXPortalUser().findByLoginId((searchCriteria.getParamList().get("owner").toString()));
                if (xXPortalUser != null) {
                    searchCriteria.getParamList().put("owner", xXPortalUser.getId());
                } else {
                    searchCriteria.getParamList().put("owner", 0);
                }
            }
        }
        VXTrxLogList vXTrxLogList = xTrxLogService.searchXTrxLogs(searchCriteria);
        Long count = xTrxLogService.searchXTrxLogsCount(searchCriteria);
        vXTrxLogList.setTotalCount(count);
        List<VXTrxLog> newList = validateXXTrxLogList(vXTrxLogList.getVXTrxLogs());
        vXTrxLogList.setVXTrxLogs(newList);
        return vXTrxLogList;
    } else {
        throw restErrorUtil.create403RESTException("Permission Denied !");
    }
}
Also used : XXPortalUser(org.apache.ranger.entity.XXPortalUser) DateUtil(org.apache.ranger.common.DateUtil) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date)

Aggregations

DateUtil (org.apache.ranger.common.DateUtil)6 SearchCriteria (org.apache.ranger.common.SearchCriteria)6 Date (java.util.Date)5 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 XXPortalUser (org.apache.ranger.entity.XXPortalUser)1 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)1 RangerPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem)1 RangerService (org.apache.ranger.plugin.model.RangerService)1 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)1 RangerContextEnricherDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef)1 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)1 VXGroupList (org.apache.ranger.view.VXGroupList)1 VXMetricAuditDetailsCount (org.apache.ranger.view.VXMetricAuditDetailsCount)1 VXMetricContextEnricher (org.apache.ranger.view.VXMetricContextEnricher)1 VXMetricPolicyCount (org.apache.ranger.view.VXMetricPolicyCount)1