Ejemplo n.º 1
0
 protected boolean haveRecords(String table) {
   boolean rv = false;
   String countQuery = "SELECT COUNT(*) FROM " + table;
   logsql(countQuery);
   Result dbr = db.executeCountQuery(countQuery);
   if (dbr.isSuccessful()) {
     rv = ((Integer) dbr.objectValue()) > 0;
   } else {
     log("haveRecords(" + table + ")" + dbr.name());
   }
   return rv;
 }
Ejemplo n.º 2
0
 private Result getRoleList(Screen.Button button) {
   Result result;
   Screen next;
   List<Role> roleList = new ArrayList<Role>();
   result = listAllRoles(roleList);
   if (result.isSuccessful()) {
     next = new Screen(this, button.destination());
     next.setValue(Screen.AVAILABLE_ROLES, roleList);
     result.objectValue(next);
   } else {
     log(result.getReason().name());
     log(result.allMessages());
   }
   return result;
 }
Ejemplo n.º 3
0
 private Result getUserList(Screen.Button button) {
   Result result;
   Screen next;
   List<User> userList = new ArrayList<User>();
   result = listUsers(userList);
   if (result.isSuccessful()) {
     next = new Screen(this, button.destination());
     next.setValue(Screen.USERS_LIST, userList);
     result.objectValue(next);
   } else {
     log(result.getReason().name());
     log(result.allMessages());
   }
   return result;
 }
Ejemplo n.º 4
0
 /**
  * DOC
  *
  * @param role
  * @param manager
  * @param privilege
  * @return
  */
 @SuppressWarnings("rawtypes")
 public boolean denyAccess(Role role, Manager manager, Privilege privilege) {
   boolean rv = true;
   String countSql =
       "SELECT count(*) FROM "
           + Role.AUX_ROLE_PRIV
           + " WHERE role_id = ? and manager_id = ? and priv_id = ? ";
   Result r = db.executeCountQuery(countSql);
   if (r.isSuccessful()) {
     Integer count = (Integer) r.objectValue();
     rv = (count == Base.ZERO);
   } else {
     log("Deny access query:" + countSql + " failed:" + r.name());
   }
   return rv;
 }
Ejemplo n.º 5
0
  public Result findRole(String roleId) {
    Result r = new Result();
    if (!loggedIn) {
      r = r.notAuthorized();
      return r;
    }
    Role role = new Role();
    String selectRoleSql = "SELECT * FROM " + Role.AUX_ROLE + " WHERE " + "ID = " + roleId + "  ";

    r = db.executeSingleSelectQuery(selectRoleSql, role);
    if (!role.isValid()) {
      r.error("User object not valid.");
    } else {
      if (r.isSuccessful()) {
        r.objectValue(role);
      }
    }
    return r;
  }
Ejemplo n.º 6
0
  @Override
  public Result findUser(String userId) {
    Result r = new Result();
    if (!loggedIn) {
      r = r.notAuthorized();
      return r;
    }
    User user = new User();
    String selectUserSql = "SELECT * FROM " + User.AUX_USER + " WHERE " + "ID = " + userId + "  ";

    r = db.executeSingleSelectQuery(selectUserSql, user);
    if (!user.isValid()) {
      r.error("User object not valid.");
    } else {
      if (r.isSuccessful()) {
        r.objectValue(user);
      }
    }
    return r;
  }