use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class AssetREST method getXResourceFile.
@GET
@Path("/resource/{id}")
public Response getXResourceFile(@Context HttpServletRequest request, @PathParam("id") Long id) {
String fileType = searchUtil.extractString(request, new SearchCriteria(), "fileType", "File type", StringUtil.VALIDATION_TEXT);
VXResource resource = getXResource(id);
Response response = null;
if (resource != null && StringUtils.isNotEmpty(fileType)) {
File file = null;
file = assetMgr.getXResourceFile(resource, fileType);
if (file != null) {
response = Response.ok(file, MediaType.APPLICATION_OCTET_STREAM).header("Content-Disposition", "attachment;filename=" + file.getName()).build();
file = null;
}
}
return response;
}
use of org.apache.ranger.common.SearchCriteria 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);
}
}
use of org.apache.ranger.common.SearchCriteria 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);
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class XUserMgr method getXGroupUserFromMap.
public VXGroupUserInfo getXGroupUserFromMap(String groupName) {
checkAdminAccess();
VXGroupUserInfo vxGUInfo = new VXGroupUserInfo();
XXGroup xGroup = daoManager.getXXGroup().findByGroupName(groupName);
if (xGroup == null) {
return vxGUInfo;
}
VXGroup xgroupInfo = xGroupService.populateViewBean(xGroup);
vxGUInfo.setXgroupInfo(xgroupInfo);
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.addParam("xGroupId", xGroup.getId());
VXGroupUserList vxGroupUserList = searchXGroupUsers(searchCriteria);
List<VXUser> vxu = new ArrayList<VXUser>();
logger.debug("removing all the group user mapping for : " + xGroup.getName());
for (VXGroupUser groupUser : vxGroupUserList.getList()) {
XXUser xUser = daoManager.getXXUser().getById(groupUser.getUserId());
if (xUser != null) {
VXUser vxUser = new VXUser();
vxUser.setName(xUser.getName());
XXPortalUser xXPortalUser = daoManager.getXXPortalUser().findByLoginId(xUser.getName());
if (xXPortalUser != null) {
List<String> existingRole = daoManager.getXXPortalUserRole().findXPortalUserRolebyXPortalUserId(xXPortalUser.getId());
if (existingRole != null) {
vxUser.setUserRoleList(existingRole);
}
}
vxu.add(vxUser);
}
}
vxGUInfo.setXuserInfo(vxu);
return vxGUInfo;
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class XUserMgr method getXUserGroups.
public VXGroupList getXUserGroups(Long xUserId) {
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.addParam("xUserId", xUserId);
VXGroupUserList vXGroupUserList = xGroupUserService.searchXGroupUsers(searchCriteria);
VXGroupList vXGroupList = new VXGroupList();
List<VXGroup> vXGroups = new ArrayList<VXGroup>();
if (vXGroupUserList != null) {
List<VXGroupUser> vXGroupUsers = vXGroupUserList.getList();
Set<Long> groupIdList = new HashSet<Long>();
for (VXGroupUser vXGroupUser : vXGroupUsers) {
groupIdList.add(vXGroupUser.getParentGroupId());
}
for (Long groupId : groupIdList) {
VXGroup vXGroup = xGroupService.readResource(groupId);
vXGroups.add(vXGroup);
}
vXGroupList.setVXGroups(vXGroups);
} else {
logger.debug("No groups found for user id : " + xUserId);
}
return vXGroupList;
}
Aggregations