use of org.openkilda.log.model.LogInfo in project open-kilda by telstra.
the class ActivityLogger method log.
public void log(final ActivityType activityType) {
LogInfo logInfo = getLogInfo(activityType, null);
log(logInfo);
}
use of org.openkilda.log.model.LogInfo in project open-kilda by telstra.
the class ActivityLogger method log.
public void log(final ActivityType activityType, final String objectId) {
LogInfo logInfo = getLogInfo(activityType, objectId);
log(logInfo);
}
use of org.openkilda.log.model.LogInfo in project open-kilda by telstra.
the class UserActivityService method getLogs.
/**
* Gets the logs.
*
* @param userIds the user ids
* @param activityIds the activity ids
* @param startTime the start time
* @param endTime the end time
* @return the logs
*/
private List<LogInfo> getLogs(final List<Long> userIds, final List<Long> activityIds, final Date startTime, final Date endTime) {
List<UserActivityEntity> userActivityEntityList = new ArrayList<>();
if (ValidatorUtil.isNull(userIds) && ValidatorUtil.isNull(activityIds)) {
userActivityEntityList = userActivityRepository.findByActivityTimeGreaterThanEqualAndActivityTimeLessThanEqual(startTime, endTime);
} else if (!ValidatorUtil.isNull(userIds) && ValidatorUtil.isNull(activityIds)) {
userActivityEntityList = userActivityRepository.findByUserIdInAndActivityTimeGreaterThanEqualAndActivityTimeLessThanEqual(userIds, startTime, endTime);
} else if (!ValidatorUtil.isNull(userIds) && !ValidatorUtil.isNull(activityIds)) {
userActivityEntityList = userActivityRepository.findByUserIdInAndActivityTimeGreaterThanEqualAndActivityTimeLessThanEqualAndActivity_IdIn(userIds, startTime, endTime, activityIds);
} else if (ValidatorUtil.isNull(userIds)) {
userActivityEntityList = userActivityRepository.findByActivityTimeGreaterThanEqualAndActivityTimeLessThanEqualAndActivity_IdIn(startTime, endTime, activityIds);
}
List<LogInfo> logs = new ArrayList<LogInfo>();
for (UserActivityEntity userActivityEntity : userActivityEntityList) {
logs.add(LogConversionUtil.getLogInfo(userActivityEntity));
}
return logs;
}
use of org.openkilda.log.model.LogInfo in project open-kilda by telstra.
the class LogConversionUtil method getLogInfo.
/**
* Gets the log info.
*
* @param userActivity the user activity
* @return the log info
*/
public static LogInfo getLogInfo(final UserActivityEntity userActivity) {
LogInfo info = new LogInfo();
info.setUserId(userActivity.getUserId());
info.setActivityType(ActivityType.getActivityById(userActivity.getActivity().getId()));
info.setObjectId(userActivity.getObjectId());
info.setActivityTime(userActivity.getActivityTime());
info.setClientIpAddress(userActivity.getClientIp());
return info;
}
use of org.openkilda.log.model.LogInfo in project open-kilda by telstra.
the class UserActivityLogService method getActivityLog.
/**
* Gets the activity log.
*
* @param users the users
* @param activities the activities
* @param start the start
* @param end the end
* @return the activity log
*/
public List<LogInfo> getActivityLog(final List<Long> users, final List<String> activities, final String start, final String end) {
List<LogInfo> logs = userActivityService.getLogs(users, activities, start, end);
List<LogInfo> appAdminlogs = new ArrayList<LogInfo>();
if (!ValidatorUtil.isNull(logs)) {
Set<Long> userIds = new HashSet<Long>();
for (LogInfo log : logs) {
if (serverContext.getRequestContext().getUserId() != 1 && log.getUserId() == 1) {
appAdminlogs.add(log);
}
userIds.add(log.getUserId());
}
logs.removeAll(appAdminlogs);
List<UserEntity> usersList = userRepository.findByUserIdIn(userIds);
for (int i = 0; i < logs.size(); i++) {
UserEntity userEntity = getUser(logs.get(i).getUserId(), usersList);
if (userEntity != null) {
logs.get(i).setUsername(userEntity.getUsername());
} else {
logs.get(i).setUsername(String.valueOf(logs.get(i).getUserId()));
}
}
}
return logs;
}
Aggregations