APISonar


mage.server.services.impl.LogServiceImpl.instance.log

> mage > server > services > impl > LogServiceImpl > instance > log
mage APIs server APIs services APIs impl APIs LogServiceImpl APIs instance APIs log APIs

Example 1
public synchronized void disconnect(String sessionId, boolean voluntary) {
        Session session = sessions.get(sessionId);
        sessions.remove(sessionId);
        if (session != null) {
            if (voluntary) {
                session.kill();
                LogServiceImpl.instance.log(LogKeys.KEY_SESSION_KILLED, sessionId);
            } else {
                session.disconnect();
                LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED, sessionId);
            }
        } else {
            logger.info("could not find session with id " + sessionId);
        }
    }
Example 2
public void endUserSession(String sessionId, String userSessionId) {
        if (isAdmin(sessionId)) {
            disconnect(userSessionId, DisconnectReason.AdminDisconnect);
            LogServiceImpl.instance.log(LogKeys.KEY_SESSION_END_BY_ADMIN, sessionId, userSessionId);
        }
    }
Example 3
protected <T> T executeWithResult(String actionName, final String sessionId, final ActionWithResult<T> action, boolean checkAdminRights) throws MageException {
        if (checkAdminRights) {
            if (!SessionManager.getInstance().isAdmin(sessionId)) {
                LogServiceImpl.instance.log(LogKeys.KEY_NOT_ADMIN, actionName, sessionId);
                return action.negativeResult();
            }
        }
        return executeWithResult(actionName, sessionId, action);
    }
Example 4
public TableView createTournamentTable(final String sessionId, final UUID roomId, final TournamentOptions options) throws MageException {
        return executeWithResult("createTournamentTable", sessionId, new ActionWithTableViewResult() {
            public TableView execute() throws MageException {
                UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
                TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTournamentTable(userId, options);
                logger.info("Tournament table " + table.getTableId() + " created");
                LogServiceImpl.instance.log(LogKeys.KEY_TOURNAMENT_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString());
                return table;
            }
        });
    }
Example 5
public boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException {
        try {
            if (version.compareTo(Main.getVersion()) != 0) {
                logger.info("MageVersionException: userName=" + userName + ", version=" + version);
                LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, userName, version.toString(), Main.getVersion().toString(), sessionId);
                throw new MageVersionException(version, Main.getVersion());
            }
            return SessionManager.getInstance().registerUser(sessionId, userName);
        } catch (Exception ex) {
            if (ex instanceof MageVersionException)
                throw (MageVersionException)ex;
            handleException(ex);
        }
        return false;
    }
Example 6
public void sendFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
        if (title != null && message != null) {
            execute("sendFeedbackMessage", sessionId, new Action() {
                public void execute() {
                    String host = SessionManager.getInstance().getSession(sessionId).getHost();
                    FeedbackServiceImpl.instance.feedback(username, title, type, message, email, host);
                    LogServiceImpl.instance.log(LogKeys.KEY_FEEDBACK_ADDED, sessionId, username, host);
                }
            });
        }
    }
Example 7
public void disconnectUser(String sessionId, String userSessionId) {
        if (isAdmin(sessionId)) {
            User userAdmin, user;
            if ((userAdmin = getUserFromSession(sessionId)) != null) {
                if ((user = getUserFromSession(userSessionId)) != null) {
                    user.showUserMessage("Admin operation","Your session was disconnected by Admin.");
                    userAdmin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected.");
                    disconnect(userSessionId, DisconnectReason.AdminDisconnect);
                    LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED_BY_ADMIN, sessionId, userSessionId);
                } else {
                    userAdmin.showUserMessage("Admin operation","User with sessionId " + userSessionId + " could not be found!");
                }
            }
        }
    }