Search in sources :

Example 1 with 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) {
    LogInfo logInfo = getLogInfo(activityType, null);
    log(logInfo);
}
Also used : LogInfo(org.openkilda.log.model.LogInfo)

Example 2 with 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);
}
Also used : LogInfo(org.openkilda.log.model.LogInfo)

Example 3 with 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;
}
Also used : LogInfo(org.openkilda.log.model.LogInfo) ArrayList(java.util.ArrayList) UserActivityEntity(org.openkilda.log.dao.entity.UserActivityEntity)

Example 4 with LogInfo

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;
}
Also used : LogInfo(org.openkilda.log.model.LogInfo)

Example 5 with LogInfo

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;
}
Also used : LogInfo(org.openkilda.log.model.LogInfo) ArrayList(java.util.ArrayList) UserEntity(org.usermanagement.dao.entity.UserEntity) HashSet(java.util.HashSet)

Aggregations

LogInfo (org.openkilda.log.model.LogInfo)6 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 RequestContext (org.openkilda.auth.model.RequestContext)1 UserActivityEntity (org.openkilda.log.dao.entity.UserActivityEntity)1 UserEntity (org.usermanagement.dao.entity.UserEntity)1