Fork me on GitHub

Résultats CPD

Le document suivant contient les résultats de l'inspection CPD CPD 5.3.5.

Duplicatas

Fichier Ligne
fr/paris/lutece/plugins/chat/web/ChatJspBean.java 153
fr/paris/lutece/plugins/chat/web/ChatServlet.java 194
    private String getUserData( HttpServletRequest request )
    {
        StringBuffer strData = new StringBuffer(  );
        ChatRoom room = ChatService.getRoom( request );
        String strPseudo = ChatService.getNickname( request );
        ChatUser user = room.getUser( strPseudo );

        if ( user == null )
        {
            return buildMessage( CMD_KICK, AppPropertiesService.getProperty( MESSAGE_USER_KICKED ) );
        }

        if ( user.isKicked(  ) )
        {
            String strMessage = user.getKickComment(  );
            room.removeUser( strPseudo );

            return buildMessage( CMD_KICK, strMessage );
        }

        if ( user.hasNewPseudo(  ) )
        {
            room.removeOldPseudo( strPseudo );

            return buildMessage( CMD_NEW_PSEUDO, user.getNickname(  ) );
        }

        // List of the messages
        Enumeration entries = user.getChatEntries(  );

        while ( entries.hasMoreElements(  ) )
        {
            ChatEntry entry = (ChatEntry) entries.nextElement(  );

            if ( entry.getTime(  ) < user.getLastAccessTime(  ).getTime(  ) )
            {
                // The message came before the arrival of the user, then go to the next one
                continue;
            }

            switch ( entry.getType(  ) )
            {
                case ChatEntry.TYPE_MESSAGE:
                    strData.append( buildMessage( "<" + entry.getNickname(  ) + "> " + entry.getChatMessage(  ) ) );

                    break;

                case ChatEntry.TYPE_NOTIFICATION:
                    strData.append( buildMessage( entry.getChatMessage(  ) ) );

                    break;

                default:

                    // No data is appended
                    break;
            }
        }

        // List of the users
        Enumeration users = room.getUsers(  );

        while ( users.hasMoreElements(  ) )
        {
            ChatUser u = (ChatUser) users.nextElement(  );
            strData.append( CMD_ADD_USER );

            if ( u.getMode(  ) == ChatUser.MODE_OP )
            {
                strData.append( "@" );
            }
            else if ( u.getMode(  ) == ChatUser.MODE_VOICE )
            {
                strData.append( "+" );
            }

            strData.append( u.getNickname(  ) );

            if ( strPseudo.equals( u.getNickname(  ) ) )
            {
                strData.append( "*" );
            }

            if ( u.isAway(  ) )
            {
                if ( u.getAwayComment(  ) != null )
                {
                    strData.append( " (absent:" + u.getAwayComment(  ) + ")" );
                }
                else
                {
                    strData.append( " (absent)" );
                }
            }

            strData.append( SEPARATOR );
        }

        // Topic of the room
        strData.append( buildMessage( CMD_SET_TOPIC, room.getDescription(  ) ) );
        user.setLastAccessTime( new Date(  ) );

        return strData.toString(  );
    }
}
Fichier Ligne
fr/paris/lutece/plugins/chat/web/ChatJspBean.java 53
fr/paris/lutece/plugins/chat/web/ChatServlet.java 61
{
    private static final long serialVersionUID = -6400074588556875395L;
    private static final String SEPARATOR = "\nend\n";
    private static final String CMD_ADD_USER = "ADD USER:";
    private static final String CMD_ADD_MSG = "ADD MESSAGE:";
    private static final String CMD_SET_TOPIC = "SET TOPIC:";
    private static final String CMD_NEW_PSEUDO = "NEW PSEUDO:";
    private static final String CMD_KICK = "KICK:";
    private static final String CONTENT_TYPE = "text/html";
    private static final String MESSAGE_RECEPTION = "chat.msg.message.received";
    private static final String MESSAGE_CONNEXION_CONFIRMATION = "chat.msg.connexion.established";
    private static final String MESSAGE_INVALID_ROOM = "chat.msg.invalid.room";
    private static final String MESSAGE_USER_BANNED = "chat.msg.user.banned";
    private static final String MESSAGE_USER_ALREADY_EXIST = "chat.msg.user.already.exist";
    private static final String MESSAGE_CONNEXION_FAILED = "chat.msg.connexion.failed";
    private static final String MESSAGE_USER_KICKED = "chat.msg.user.kicked";

    public String process( HttpServletRequest request )