* @param groupHeader
* @return the read privileges
*/
public static FirebirdManagerPrivilege readPrivileges(ISession session, String userName,
String relationName, boolean groupHeader) {
FirebirdManagerPrivilege fbPrivilege = new FirebirdManagerPrivilege();
if (!groupHeader) {
try {
Statement stmt = session.getSQLConnection().createStatement();
ResultSet rs = stmt.executeQuery("Select RDB$PRIVILEGE From RDB$USER_PRIVILEGES" +
" Where RDB$USER = '" + userName + "'" +
" and RDB$RELATION_NAME = '" + relationName + "'" +
" Order By RDB$PRIVILEGE");
while (rs.next()) {
String sValue = rs.getString(1).trim();
if (sValue.equals("S"))
fbPrivilege.setSelect(true);
else if (sValue.equals("I"))
fbPrivilege.setInsert(true);
else if (sValue.equals("U"))
fbPrivilege.setUpdate(true);
else if (sValue.equals("D"))
fbPrivilege.setDelete(true);
else if (sValue.equals("R"))
fbPrivilege.setReference(true);
else if (sValue.equals("X"))
fbPrivilege.setExecute(true);
else if (sValue.equals("M"))
fbPrivilege.setMember(true);
} // while (rs.next())
rs.close();
stmt.close();
} catch (SQLException e) {
log.error(e.getLocalizedMessage());