📄 jahiaabstractacl.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .///** * @author Fulco Houkes * @author MAP * @version 1.1 */package org.jahia.services.acl;import java.util.Vector;import org.jahia.exceptions.JahiaException;import org.jahia.exceptions.database.JahiaDatabaseException;import org.jahia.services.usermanager.JahiaGroup;import org.jahia.services.usermanager.JahiaUser;public abstract class JahiaAbstractACL implements Cloneable{ /** Reference to the ACL object */ protected JahiaACL mACL; /** Reference on the ACL Manager Service */ private JahiaACLManagerService mACLService; /** Error message constant */ private final String INIT_ERROR_MSG = "ACL Object not initialized"; //------------------------------------------------------------------------- // Each of the derived classes should have thier own bit signification, // therefore each derived classe has to define the meaning of each bit. // // FH 8 Jan. 2001 /** * Return a human understandable desc of the bits. * * @return Return a Vector containing the desc of each bit of the * ACL. */ public abstract Vector getBitdesc (); //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Instanciate a new ACL proxy and try to load the specified ACL. * * @param aclID Identification number of the ACL to be loaded. * * @exception ACLNotFoundException * Throws an exception if the current ACL object was not initialized * correctly. * @exception JahiaException * Throws a JahiaException if the ACL Proxy could not be initialized * properly. */ public JahiaAbstractACL (int aclID) throws ACLNotFoundException, JahiaException { init (); load (aclID); } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Instanciates a new empty ACL proxy. * * @exception JahiaException * Throws a JahiaException if the ACL Proxy could not be initialized * properly. */ protected JahiaAbstractACL () throws JahiaException { init (); } /** * Accessor to mACL * * @return the current ACL */ protected JahiaACL getACL() { return mACL; } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Create a new ACL object. If the specified parent can not be found, then * a null parent is transmitted to the ACL Manager's creation method. * * @param parentID * Unique identification number of the parent ACL object. Set this * parameter to -1 if there is not parameter. * @return * Return true if the ACL object could be created successfully, or * return false on any failure. * @throws ACLNotFoundException * @throws JahiaDatabaseException */ public synchronized boolean create (int parentID) throws ACLNotFoundException, JahiaDatabaseException { // get the parent ACL reference if found JahiaACL parent = null; if (parentID > 0) { parent = mACLService.lookupACL (parentID); } // Create the new ACL object. mACL = mACLService.createACL (parent); return (mACL != null); } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Destroy the current ACL referenced inside of the ACL proxy. The proxy * itself will be empty, and any further ACL operation on the proxy will * raise a JahiaACLException. * * @return * Return true on success or false on any failure. * * @exception JahiaACLException * Throws a JahiaACLException if the current ACL object was not * initialized correctly. */ public synchronized boolean delete () throws JahiaACLException { testProxy (); boolean result = false; synchronized (mACL) { if (mACLService.deleteACL (mACL)) { mACL = null; result = true; } } return result; } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Load the specified ACL into the proxy. * * @param aclID * ACL's unique identification number. * @throws ACLNotFoundException * Raise this exception when the specified acl could not be found. * @throws JahiaDatabaseException */ public synchronized void load (int aclID) throws ACLNotFoundException, JahiaDatabaseException { mACL = mACLService.lookupACL (aclID); } //------------------------------------------------------------------------- // FH 8 Jan. 2001 // this function try to get a valid reference on the ACL Manager, needed // for future operations. private void init () throws JahiaException { mACLService = JahiaACLManagerService.getInstance(); if (mACLService == null) { throw new JahiaException ("JahiaAbstractACL", "Abstract ACL could not get the ACL Manager Instance.", JahiaException.SERVICE_ERROR, JahiaException.CRITICAL); } } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Return the unique identification number of the current ACL object. * * @return * Return the unique identification number of the current ACL. * * @exception JahiaACLException * Throws an exception if the current ACL object was not initialized * correctly. */ public int getID () throws JahiaACLException { testProxy (); return mACL.getID (); } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Get the parent ID from the current ACL. * * @return the parent ID from the current ACL. * @throws JahiaACLException */ public int getParentID () throws JahiaACLException { testProxy (); return mACL.getParentID (); } /** * Get the inheritance flag from the current ACL * * @return the ACL inheritance status. * @throws JahiaACLException */ public final int getInheritance() throws JahiaACLException { testProxy(); return mACL.getInheritance(); } /** * Set the inheritance flag to the current ACL and update cache. * * @param inheritance The inheritance flag (INHERITANCE, NO_INHERITANCE). * @return true if flag set whithout problem. * @throws JahiaACLException */ public final boolean setInheritance(int inheritance) throws JahiaACLException { testProxy(); synchronized (mACL) { return mACL.setInheritance(inheritance); } } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Return a clone of the user entry in the ACL. * * @param user * The user reference * * @return * The user entry clone, or null if the user has no entry in the ACL. * @throws JahiaACLException */ public JahiaACLEntry getUserEntry (JahiaUser user) throws JahiaACLException { testProxy(); return mACL.getUserEntry (user); } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Add a new access for the specified user. If the user is already present * in the ACL object, the access is replaced by the new one. * * @param user * Reference to a non-null user object. * @param entry * Reference to a valid non-null ACL entry. * * @return * Return true on success or false on any failure. * * @exception JahiaACLException * Throws an exception if the current ACL object was not initialized * correctly. */ public boolean setUserEntry (JahiaUser user, JahiaACLEntry entry) throws JahiaACLException { testProxy (); synchronized (mACL) { return mACL.setUserEntry (user, entry); } } //------------------------------------------------------------------------- // FH 8 Jan. 2001 /** * Remove the user access in the current ACL object. * * @param user * Reference to a non-null user object. * * @return * Return true on success or false on any failure.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -