KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > communication > forum > ForumACL


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.communication.forum;
6
7 import javax.faces.context.FacesContext;
8 import org.exoplatform.services.communication.forum.*;
9 /**
10  * Sat, Jan 03, 2004 @ 11:16
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: ForumACL.java,v 1.1.1.1 2004/03/02 18:58:51 benjmestrallet Exp $
14  */

15 public class ForumACL {
16   private String JavaDoc user_ ;
17   
18   public ForumACL(String JavaDoc user) {
19     user_ = user ;
20   }
21   
22   public String JavaDoc getRemoteUser() { return user_ ; }
23    
24   public boolean hasViewForumRole(Forum forum) {
25     String JavaDoc role = forum.getViewForumRole() ;
26     if(role == null || role.length() == 0 || "any".equals(role) || "guest".equals(role)) {
27       return true ;
28     }
29     return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role) ;
30   }
31   
32   public boolean hasCreateTopicRole(Forum forum) {
33     String JavaDoc role = forum.getCreateTopicRole() ;
34     if(role == null || role.length() == 0 || "any".equals(role) || "guest".equals(role)) {
35       return true ;
36     }
37     return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role) ;
38   }
39
40   public boolean hasReplyTopicRole(Forum forum) {
41     String JavaDoc role = forum.getReplyTopicRole() ;
42     if(role == null || role.length() == 0 || "any".equals(role) || "guest".equals(role)) {
43       return true ;
44     }
45     return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role) ;
46   }
47
48   public boolean hasModeratorRole(Forum forum) {
49     return forum.isModerator(user_) ;
50   }
51 }
52
Popular Tags