Project

General

Profile

« Previous | Next » 

Revision 9107

Added by Jing Tao almost 10 years ago

Add a cap to only write 512 characters of the user-agent to db.

View differences:

src/edu/ucsb/nceas/metacat/EventLog.java
81 81
     */
82 82
    private static EventLog self = null;
83 83
    private Logger logMetacat = Logger.getLogger(EventLog.class);
84
    private static final int USERAGENTLENGTH = 512;
84 85

  
85 86
    /**
86 87
     * A private constructor that initializes the class when getInstance() is
......
183 184
            // Get a database connection from the pool
184 185
            dbConn = DBConnectionPool.getDBConnection("EventLog.insertLogEntry");
185 186
            serialNumber = dbConn.getCheckOutSerialNumber();
187
            String userAgent = logData.getUserAgent();
188
            if(userAgent != null && userAgent.length() > USERAGENTLENGTH) {
189
                userAgent = userAgent.substring(0, USERAGENTLENGTH);
190
            }
186 191
            
187 192
            // Execute the insert statement
188 193
            PreparedStatement stmt = dbConn.prepareStatement(insertString);
189 194
            
190 195
            stmt.setString(1, logData.getIpAddress());
191
            stmt.setString(2, logData.getUserAgent());
196
            stmt.setString(2, userAgent);
192 197
            stmt.setString(3, logData.getPrincipal());
193 198
            stmt.setString(4, logData.getDocid());
194 199
            stmt.setString(5, logData.getEvent());

Also available in: Unified diff