Changeset 286

Show
Ignore:
Timestamp:
05/19/08 20:21:59 (8 months ago)
Author:
chris
Message:

Check for invalid monad ranges in access control tables.

Return null rather than an empty set of monads if no monad ranges granted (not sure why right now)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lex/trunk/src/com/qwirx/lex/emdros/EmdrosDatabase.java

    r265 r286  
    406406        } 
    407407    } 
    408  
     408     
    409409    public SetOfMonads getVisibleMonads() 
    410     throws SQLException, EmdrosException 
    411     { 
    412         PreparedStatement stmt = m_LogDatabase.prepareStatement 
    413         ( 
    414             "SELECT Monad_First, Monad_Last " + 
    415             "FROM   user_text_access " + 
    416             "WHERE  (User_Name = ? OR User_Name = 'anonymous')" 
    417         ); 
    418         stmt.setString(1, username); 
    419          
     410    throws DatabaseException 
     411    { 
    420412        SetOfMonads result = new SetOfMonads(); 
    421413         
    422         ResultSet rs = stmt.executeQuery(); 
    423         boolean haveMonads = false; 
    424          
    425         while (rs.next())  
    426         { 
    427             haveMonads = true; 
    428             int first = rs.getInt(1); 
    429             int last  = rs.getInt(2); 
    430             result.add(first, last); 
    431         } 
    432          
    433         stmt.close(); 
    434         rs.close(); 
    435          
    436         if (!haveMonads) 
    437         { 
    438             return null; 
    439         } 
    440          
    441         return result; 
     414        try 
     415        { 
     416            PreparedStatement stmt = m_LogDatabase.prepareStatement 
     417            ( 
     418                "SELECT Monad_First, Monad_Last " + 
     419                "FROM   user_text_access " + 
     420                "WHERE  (User_Name = ? OR User_Name = 'anonymous')" 
     421            ); 
     422            stmt.setString(1, username); 
     423             
     424            ResultSet rs = stmt.executeQuery(); 
     425            boolean haveMonads = false; 
     426             
     427            while (rs.next())  
     428            { 
     429                haveMonads = true; 
     430                int first = rs.getInt(1); 
     431                int last  = rs.getInt(2); 
     432                result.add(first, last); 
     433            } 
     434             
     435            stmt.close(); 
     436            rs.close(); 
     437         
     438            if (!haveMonads) 
     439            { 
     440                return null; 
     441            } 
     442             
     443            return result; 
     444        } 
     445        catch (SQLException e) 
     446        { 
     447            throw new DatabaseException("Failed to get monad " + 
     448                    "access control data", e); 
     449        } 
     450        catch (BadMonadsException e) 
     451        { 
     452            throw new DatabaseException("Failed to get monad " + 
     453                "access control: invalid data in access table", e); 
     454        } 
    442455    } 
    443456