}
private ApplicationAcls getApplicationAclsForUser(String username, int appid) {
PreparedStatement stmt = null;
ResultSet rs = null;
ApplicationAcls appAcls = null;
try {
stmt = conn.prepareStatement("SELECT acls FROM applicationacls " +
"WHERE (appid = ? AND username = ?)",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
stmt.setInt(1, appid);
stmt.setString(2, username);
rs = stmt.executeQuery();
int acls;
if(rs.next()) {
acls = rs.getInt(1);
appAcls = new ApplicationAcls(acls);
}
else {
rs.close();
stmt.setString(2, "ALL");
rs = stmt.executeQuery();
if(rs.next()) {
acls = rs.getInt(1);
appAcls = new ApplicationAcls(acls);
}
}
}
catch (Exception e) {
}
finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException sqlEx) { } // ignore
rs = null;
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlEx) { } // ignore
stmt = null;
}
}
//default to no permissions.
if(appAcls == null)
appAcls = new ApplicationAcls();
return appAcls;
}