⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jahiacontainerlist.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public void addContainer( JahiaContainer theContainer )    {        /*        int insertPos = containers.size();        for (int i=0; i < containers.size(); i++) {            JahiaContainer aContainer = (JahiaContainer)containers.elementAt(i);            if (theContainer.getRank() < aContainer.getRank()) {                insertPos = i;                break;            }            aContainer = null;        }        containers.insertElementAt( theContainer, insertPos );        */        containers.add(theContainer);    } // end addContainer    //-------------------------------------------------------------------------	/**	 * Returns true if the acl set at container list level allow a field of a given	 * field def name to be editable or not	 *	 * @param String fieldDefName	 * @param JahiaUser the user	 * @return boolean true if the acl return true , false else	 * @author Khue Nguyen	 */	public final boolean isFieldEditable(String fieldDefName, JahiaUser user, int siteID){		boolean result = false;		if ( fieldDefName == null || user == null )			return false;		String val = this.getProperty("view_field_acl_"+fieldDefName);		if ( val != null ){			try {				int aclID = Integer.parseInt(val);		        JahiaBaseACL theACL = null;		        try {		            theACL = new JahiaBaseACL (aclID);		        }		        catch (ACLNotFoundException ex) {		        }		        catch (JahiaException ex) {		        }				return theACL.getPermission(user,JahiaBaseACL.WRITE_RIGHTS, siteID);		  	} catch ( Throwable t ){			}		}		return result;	}    //-------------------------------------------------------------------------	/**	 * Returns true if the acl set at container list level allow a field of a given	 * field def name to be visible ( READ permission )	 *	 * @param String fieldDefName	 * @param JahiaUser the user	 * @return boolean true if the acl return true , false else	 * @author Khue Nguyen	 */	public final boolean isFieldReadable(String fieldDefName, JahiaUser user, int siteID){		boolean result = false;		if ( fieldDefName == null || user == null )			return false;		String val = this.getProperty("view_field_acl_"+fieldDefName);		if ( val != null ){			try {				int aclID = Integer.parseInt(val);		        JahiaBaseACL theACL = null;		        try {		            theACL = new JahiaBaseACL (aclID);		        }		        catch (ACLNotFoundException ex) {		        }		        catch (JahiaException ex) {		        }				return theACL.getPermission(user,JahiaBaseACL.READ_RIGHTS, siteID);		  	} catch ( Throwable t ){			}		}		return result;	}    //-------------------------------------------------------------------------    /**     * Check if the user has read access for the specified containerList. Read access means     * the user can display containerList data.     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has read access for the specified containerList,     *           or false in any other case.     */    public final boolean checkReadAccess (JahiaUser user, int siteID)    {        return checkAccess (user, JahiaBaseACL.READ_RIGHTS, siteID);    }    //-------------------------------------------------------------------------    /**     * Check if the user has Write access for the specified container. Write access means     * the user can add/delete/update containers in the containerList.     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has write access for the specified containerList,     *           or false in any other case.     */    public final boolean checkWriteAccess (JahiaUser user, int siteID)    {        return checkAccess (user, JahiaBaseACL.WRITE_RIGHTS, siteID);    }    //-------------------------------------------------------------------------    /**     * Check if the user has Admin access for the specified container. Admin access means     * the user can set rights on the containerList.     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has admin access for the specified containerList,     *           or false in any other case.     */    public final boolean checkAdminAccess (JahiaUser user, int siteID)    {        return checkAccess (user, JahiaBaseACL.ADMIN_RIGHTS, siteID);    }    //-------------------------------------------------------------------------    private boolean checkAccess (JahiaUser user, int permission, int siteID)    {        if (user == null) {            return false;        }		// NK :Fake container list with acl id = -1 are not yet created in storage		//     and their ACL are therefore fake too, so we return true		if ( aclID == 0 )			return true;        //JahiaConsole.println ("->> containerList checkAccess : containerList ["+Integer.toString (ID)+        //    "], permission ["+Integer.toString (permission)+"], user ["+user.getName()+"]");        boolean result = false;        try        {            // Try to instanciate the ACL.            JahiaBaseACL containerListACL = new JahiaBaseACL (aclID);            // Test the access rights            result = containerListACL.getPermission (user, permission, siteID);            // destroy the object.            containerListACL = null;        }        catch (ACLNotFoundException ex) {            JahiaConsole.println ("JahiaContainerList.checkAccess",                                  "Could not find the ACL ["+Integer.toString(aclID)+                                  "] for containerList ["+Integer.toString(ID)+"]");        }        catch (JahiaException ex) {            JahiaConsole.printe ("JahiaContainerList.checkAccess", ex);        }        //if (!result) {        //    JahiaConsole.println ("JahiaContainerList", "Permission denied for user ["+        //            user.getName()+"] to containerList ["+Integer.toString(ID)+        //            "] for access permission ["+Integer.toString(permission)+"]");        //}        return result;    }    public void setProperties(Properties newProperties) {        this.ctnListProperties = newProperties;    }    public Properties getProperties() {        return this.ctnListProperties;    }    public String getProperty(String propertyName) {        if (this.ctnListProperties != null) {            return this.ctnListProperties.getProperty(propertyName);        } else {            return null;        }    }    public void setProperty(String propertyName, String propertyValue) {        if (this.ctnListProperties != null) {            this.ctnListProperties.setProperty(propertyName, propertyValue);        } else {            JahiaConsole.println("JahiaContainerList.setProperty",                                 "ERROR: Properties object is not defined, ignoring property insertion.");        }    }    /**     * Merge a set of properties passed in parameters with the internal     * properties set. Returns true if the resulting set of internal properties     * must be serialized.     * @param newProperties     * @return true if the result of the merge is a different set of properties     * that needs to be serialized.     */    public boolean mergeProperties(Properties newProperties) {        boolean mustSave = false;        Enumeration newPropKeys = newProperties.keys();        while (newPropKeys.hasMoreElements()) {            String curNewPropName = (String) newPropKeys.nextElement();            String curNewPropValue = newProperties.getProperty(curNewPropName);            if (this.ctnListProperties.containsKey(curNewPropName)) {                String internalPropValue = this.ctnListProperties.getProperty(curNewPropName);                if (!internalPropValue.equals(curNewPropValue)) {                    // properties are not equals, lets set it.                    this.ctnListProperties.setProperty(curNewPropName, curNewPropValue);                    mustSave = true;                }            } else {                // this is a new property.                this.ctnListProperties.setProperty(curNewPropName, curNewPropValue);                mustSave = true;            }        }        return mustSave;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -