1 5 package org.exoplatform.services.portal.impl; 6 7 import org.exoplatform.services.portal.PortalACL; 8 import org.exoplatform.services.portal.model.*; 9 15 public class PortalACLImpl implements PortalACL { 16 17 public PortalACLImpl() { 18 19 } 20 21 public boolean hasViewPagePermission(Page page, String 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 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 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 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 portalOwner, String 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 portalOwner, String 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 [] getPermissionList() { 59 return new String [] {ANY_PERMISSION, OWNER_PERMISSION, ADMIN_PERMISSION } ; 60 } 61 } | Popular Tags |