Package org.nemesis.forum

Examples of org.nemesis.forum.ForumPermissions


    //use the superclass like the other iterators do.
    super(iterator, authorization, permissions);

    while (iterator.hasNext()) {
      Forum forum = (Forum) iterator.next();
      ForumPermissions forumPermissions = forum.getPermissions(authorization);
      //Create a new permissions object with the combination of the
      //permissions of this object and tempPermissions.
      //Check and see if the user has READ permissions. If not, throw an
      //an UnauthorizedException.
      if (forumPermissions.get(Constants.SYSTEM_ADMIN)
        || forumPermissions.get(Constants.FORUM_ADMIN)
        || forumPermissions.get(Constants.MODERATOR)) {
        ForumProxy proxy = new ForumProxy(forum, authorization, forumPermissions);
        forums.add(proxy);
      }
    }
View Full Code Here


    super(iterator, authorization, permissions);
  }

  public Object next() throws NoSuchElementException {
    Group group = (Group) iterator.next();
    ForumPermissions groupPermissions = group.getPermissions(authorization);
    ForumPermissions newPermissions = new ForumPermissions(permissions, groupPermissions);
    return new GroupProxy(group, authorization, newPermissions);
  }
View Full Code Here

    //use the superclass like the other iterators do.
    super(iterator, authorization, permissions);

    while (iterator.hasNext()) {
      Forum forum = (Forum) iterator.next();
      ForumPermissions forumPermissions =
        forum.getPermissions(authorization);
      //Create a new permissions object with the combination of the
      //permissions of this object and tempPermissions.
      //Check and see if the user has READ permissions. If not, throw an
      //an UnauthorizedException.
     
      //AJOUT systemadmin
      if (forumPermissions.get(Constants.READ)
      || forumPermissions.get(Constants.SYSTEM_ADMIN)
      || forumPermissions.get(Constants.FORUM_ADMIN)
      || forumPermissions.get(Constants.MODERATOR)
      ) {
        ForumProxy proxy =
          new ForumProxy(forum, authorization, forumPermissions);
        forums.add(proxy);
      }
View Full Code Here

        super(iterator, authorization, permissions);
    }

    public Object next() throws NoSuchElementException {
        User user = (User)iterator.next();
        ForumPermissions userPermissions = user.getPermissions(authorization);
        ForumPermissions newPermissions =
                new ForumPermissions(permissions, userPermissions);
        return new UserProxy(user, authorization, newPermissions);
    }
View Full Code Here

    }
  }

  public User getUser(int userID) throws UserNotFoundException {
    User user = profileManager.getUser(userID);
    ForumPermissions userPermissions = user.getPermissions(authorization);
    ForumPermissions newPermissions =
      new ForumPermissions(permissions, userPermissions);
    return new UserProxy(user, authorization, newPermissions);
  }
View Full Code Here

    return new UserProxy(user, authorization, newPermissions);
  }

  public User getUser(String username) throws UserNotFoundException {
    User user = profileManager.getUser(username);
    ForumPermissions userPermissions = user.getPermissions(authorization);
    ForumPermissions newPermissions =
      new ForumPermissions(permissions, userPermissions);
    return new UserProxy(user, authorization, newPermissions);
  }
View Full Code Here

    return profileManager.getSpecialUser();
  }

  public Group getGroup(int groupID) throws GroupNotFoundException {
    Group group = profileManager.getGroup(groupID);
    ForumPermissions groupPermissions = group.getPermissions(authorization);
    ForumPermissions newPermissions =
      new ForumPermissions(permissions, groupPermissions);
    return new GroupProxy(group, authorization, newPermissions);
  }
View Full Code Here

    return new GroupProxy(group, authorization, newPermissions);
  }

  public Group getGroup(String name) throws GroupNotFoundException {
    Group group = profileManager.getGroup(name);
    ForumPermissions groupPermissions = group.getPermissions(authorization);
    ForumPermissions newPermissions =
      new ForumPermissions(permissions, groupPermissions);
    return new GroupProxy(group, authorization, newPermissions);
  }
View Full Code Here

    Cache userPermCache = (Cache) getCacheManager().get(DbCacheManager.USER_PERMS_CACHE, new Integer(-1));

    //Simple case: if cache is turned on and the user is already cached,
    //we can simply return the cached permissions.
    if (userPermCache != null) {
      ForumPermissions permissions = (ForumPermissions) userPermCache.get(new Integer(userID));
      if (permissions != null) {
        return permissions;
      }
    }

    //Not so simple case: cache is not turned on or the user permissions
    //have not been cached yet.
    boolean isAnonymous = (userID == -1);
    boolean isUser = !isAnonymous;

    ForumPermissions finalPermissions = ForumPermissions.none();
    // check each forum for a specific permission
    Iterator allForums = this.forums();
    Forum forum;
    ForumPermissions forumUserPermissions;
    while (allForums.hasNext()) {
      forum = (Forum) allForums.next();
      forumUserPermissions = getUserPermissions(userID, forum.getID());
      finalPermissions = new ForumPermissions(finalPermissions, forumUserPermissions);
    }

    //Step 1 - Get permissions for the User. This includes anonymous
    //perms, "special user" perms, and the specific perms for the user.
    if (isUser) {
      ForumPermissions userPermissions = getUserPermissions(userID, -1);
      //Combine permissions
      finalPermissions = new ForumPermissions(finalPermissions, userPermissions);
    }
    //Add in anonymous perms.
    ForumPermissions anonyPermissions = null;
    if (userPermCache != null) {
      anonyPermissions = (ForumPermissions) userPermCache.get(new Integer(-1));
    }
    //Otherwise, do our own lookup.
    if (anonyPermissions == null) {
      anonyPermissions = getUserPermissions(-1, -1);
      //Add to cache so it will be there next time.
      if (userPermCache != null) {
        userPermCache.add(new Integer(-1), anonyPermissions);
      }
    }
    //Combine permissions
    finalPermissions = new ForumPermissions(finalPermissions, anonyPermissions);

    //If they are a valid user, figure out "any user" permissions.
    if (isUser) {
      ForumPermissions specialUserPermissions = null;
      //Check for cache
      if (userPermCache != null) {
        specialUserPermissions = (ForumPermissions) userPermCache.get(new Integer(0));
      }
      //Otherwise, do our own lookup.
      if (specialUserPermissions == null) {
        specialUserPermissions = getUserPermissions(0, -1);
        //Add to cache so it will be there next time.
        if (userPermCache != null) {
          userPermCache.add(new Integer(0), specialUserPermissions);
        }
      }
      //Combine permissions
      finalPermissions = new ForumPermissions(finalPermissions, specialUserPermissions);
    }

    //Step 2 -- get Permissions for all groups the user is in.
    int[] groups = ((DbProfileManager) getProfileManager()).getUserGroups(userID);
    for (int i = 0; i < groups.length; i++) {
      ForumPermissions groupPermissions = getGroupPermissions(groups[i], -1);
      finalPermissions = new ForumPermissions(finalPermissions, groupPermissions);
    }

    //Finally, add user to cache so it will be there next time.
    if (isUser && userPermCache != null) {
      userPermCache.add(new Integer(userID), finalPermissions);
View Full Code Here

        con.close();
      } catch (Exception e) {
        log.error("",e);
      }
    }
    return new ForumPermissions(permissions);
  }
View Full Code Here

TOP

Related Classes of org.nemesis.forum.ForumPermissions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.