KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > portal > impl > PortalACLImpl


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.services.portal.impl;
6
7 import org.exoplatform.services.portal.PortalACL;
8 import org.exoplatform.services.portal.model.*;
9 /**
10  * Apr 20, 2004
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: PortalACLImpl.java,v 1.4 2004/09/28 15:13:53 tuan08 Exp $
14  **/

15 public class PortalACLImpl implements PortalACL {
16     
17   public PortalACLImpl() {
18     
19   }
20   
21   public boolean hasViewPagePermission(Page page, String JavaDoc user) {
22     if(ADMIN_PERMISSION.equals(user)) return true ;
23     if(OWNER_PERMISSION.equals(page.getViewPermission())) return page.getOwner().equals(user) ;
24     return ANY_PERMISSION.equals(page.getViewPermission());
25     
26   }
27   
28   public boolean hasEditPagePermission(Page page, String JavaDoc user) {
29     if(ADMIN_PERMISSION.equals(user)) return true ;
30     if(OWNER_PERMISSION.equals(page.getEditPermission())) return page.getOwner().equals(user) ;
31     return ANY_PERMISSION.equals(page.getOwner()) ;
32   }
33   
34   public boolean hasViewPortalPermission(PortalConfig config, String JavaDoc user) {
35     if(ADMIN_PERMISSION.equals(user)) return true ;
36     if(OWNER_PERMISSION.equals(config.getViewPermission())) return config.getOwner().equals(user) ;
37     return ANY_PERMISSION.equals(config.getViewPermission()) ;
38   }
39   
40   public boolean hasEditPortalPermission(PortalConfig config, String JavaDoc user) {
41     if(ADMIN_PERMISSION.equals(user)) return true ;
42     if(OWNER_PERMISSION.equals(config.getEditPermission())) return config.getOwner().equals(user) ;
43     return ANY_PERMISSION.equals(config.getEditPermission()) ;
44   }
45   
46   public boolean hasViewNodePermission(Node node, String JavaDoc portalOwner, String JavaDoc user) {
47     if(ADMIN_PERMISSION.equals(user)) return true ;
48     if(OWNER_PERMISSION.equals(node.getViewPermission())) return portalOwner.equals(user) ;
49     return ANY_PERMISSION.equals(node.getViewPermission()) ;
50   }
51   
52   public boolean hasEditNodePermission(Node node, String JavaDoc portalOwner, String JavaDoc user) {
53     if(ADMIN_PERMISSION.equals(user)) return true ;
54     if(OWNER_PERMISSION.equals(node.getEditPermission())) return portalOwner.equals(user) ;
55     return ANY_PERMISSION.equals(node.getEditPermission()) ;
56   }
57   
58   public String JavaDoc[] getPermissionList() {
59     return new String JavaDoc[] {ANY_PERMISSION, OWNER_PERMISSION, ADMIN_PERMISSION } ;
60   }
61 }
Popular Tags