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

📄 jahiafield.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////  JahiaField//  EV      31.10.2000//  YG      17.07.2001////  getID//  getJahiaID//  getPageID//  getFieldDefID//  getctnid//  getType//  getConnectType//  getValue//  getRank//  getAclID//  getDefinition//  getProperties//  setProperties////	checkReadAccess//	checkWriteAccess////  setID//  setAclID//  setValue//  setctnid//  setConnectType//  setObject//  getObject//package org.jahia.data.fields;import java.util.*;                     // Hashtableimport org.jahia.utils.*;           // JahiaConsoleimport org.jahia.data.*;            //import org.jahia.data.cache.*;      // Cachableimport org.jahia.registries.*;      // Registriesimport org.jahia.exceptions.JahiaException;import org.jahia.services.usermanager.JahiaUser;import org.jahia.services.acl.ACLResourceInterface;import org.jahia.services.acl.JahiaBaseACL;import org.jahia.services.acl.ACLNotFoundException;import org.jahia.params.*;          // ParamBeanpublic abstract class JahiaField implements Cloneable, ACLResourceInterface {    protected int         ID;    protected int         jahiaID;    protected int         pageID;    protected int         ctnid;    protected int         fieldDefID;    protected int         fieldType;    protected int         connectType;    protected String      fieldValue = "";    protected String      fieldRawValue = "";    protected int         rank;    protected int         aclID;    protected Object      objectItem;     // can be used to pass any object    protected Hashtable   theProperties;    /***        * constructor        * EV    31.10.2000        * YG    17.07.2001        *        * protected to avoid instanciation from outside        * the package, but allow subclasses to call it.        * The subclasses contructor MUST have the same parameters !!        */    protected JahiaField(   Integer         ID,                            Integer         jahiaID,                            Integer         pageID,                            Integer         ctnid,                            Integer         fieldDefID,                            Integer         fieldType,                            Integer         connectType,                            String          fieldValue,                            Integer         rank,                            Integer         aclID )    {        setID( ID.intValue() );        this.jahiaID        = jahiaID.intValue();        this.pageID         = pageID.intValue();        this.fieldDefID     = fieldDefID.intValue();        this.ctnid          = ctnid.intValue();        this.fieldType      = fieldType.intValue();        this.connectType    = connectType.intValue();        this.fieldValue     = fieldValue;        this.rank           = rank.intValue();        this.aclID          = aclID.intValue();        this.theProperties  = new Hashtable();    } // end constructor    /***        * accessor methods        * EV    31.10.2000        *        */    public  int     getID()             {   return ID;              }    public  int     getJahiaID()        {   return jahiaID;         }    public  int     getSiteID()        	{   return jahiaID;         } // FIXME_MULTISITE Hollis humm jahiaID or siteID ?    public  int     getPageID()         {   return pageID;          }    public  int     getFieldDefID()     {   return fieldDefID;      }    public  int     getctnid()          {   return ctnid;     }    public  int     getType()           {   return fieldType;       }    public  int     getConnectType()    {   return connectType;     }    public  int     getRank()           {   return rank;            }    public final int getAclID()    		{   return aclID;           }    public final JahiaBaseACL getACL()		{		JahiaBaseACL acl = null;		try {			acl = new JahiaBaseACL(getAclID());		} catch ( Throwable t ) {			t.printStackTrace();		}		return acl;    }    public	Object	getObject()			{	return objectItem;		}    public  void    setID( int ID )                     {   this.ID = ID;                       }    public  void    setAclID( int aclID )               {   this.aclID = aclID;                 }    public  void    setType( int fieldType )            {   this.fieldType = fieldType;         }    public  void    setValue( String fieldValue )       {   this.fieldValue = fieldValue;       }    public  void    setctnid( int ctnid )               {   this.ctnid = ctnid;     }    public  void    setFieldDefID(int fieldDefID)		{	this.fieldDefID = fieldDefID;		}    public  void    setConnectType( int connectType )   {   this.connectType = connectType;     }    public  void    setObject( Object objectItem )      {   this.objectItem = objectItem;       }    // end accessor methods    public  String  getValue() {        return fieldValue;    }    public  String  getRawValue() {        return fieldRawValue;    }    public void setRawValue(String fieldRawValue) {        this.fieldRawValue = fieldRawValue;    }    /***        * Properties methods        *        */    public Hashtable getProperties()    {        return theProperties;    }    public void setProperties( Hashtable someProperties )    {        if (someProperties != null) {            theProperties = someProperties;        }    } // end Properties methods    // abstract methods    // YG 17.07.2001    // Must be implemented into inherited class    // because they depends of field types    /**    * load the information specific to a type    * set the Object parameter with a JahiaPage    * or a file, for example.    *    */    public abstract  void load(int loadFlag, ParamBean jParams)    throws JahiaException;    /**    * save the information specific to a type    * save the Object in relation with the field    * a JahiaPage or a file, for example.    *    */    public abstract void save(ParamBean jParams)    throws JahiaException;    /**    * delete the information specific to a type    * delete the Object in relation with the field    * a JahiaPage or a file, for example.    *    */    public abstract void delete(ParamBean jParams)    throws JahiaException;    /**    * Returns an hashtable of indexable attributes , pairs [attribute name/value].    * Can return an empty map    *    * @return Hashtable a map of indexable attributes , pairs [attribute name/value]    */    public abstract Hashtable getIndexableAttributes();    /**    * return the name of the engine    * which correspond to the field type.    *    */    public abstract String getEngineName();    /**    * return the information    * to display for the ranking.    * the filename or the page name for example.    *    */    public abstract String getFieldContent4Ranking()    throws JahiaException;    /**    * return the "off" icon name    *    */    public abstract String getIconNameOff();    /**    * return the "on" icon name    *    */    public abstract String getIconNameOn();    /**    * clone the field and copy the relating file    * if necessary.    *    */    public abstract JahiaField cloneField(int newctnid, int newPageID, int clonedAclID, boolean childrenCloned)    throws JahiaException;    /**     * Clone     */    public abstract Object clone();    //{        //return new JahiaField (ID, jahiaID, pageID, ctnid, fieldDefID,        //                      fieldType, connectType, fieldValue, rank, aclID);    //}    // end abstract methods    /***        * getDefinition        *        */    public JahiaFieldDefinition getDefinition()    throws JahiaException    {        JahiaFieldDefinition theDef = JahiaFieldDefinitionsRegistry.getInstance().getDefinition( fieldDefID );        if (theDef != null) {            return theDef;        } else {            String msg = "JahiaField definition " + fieldDefID + " not found in definitions registry !";            throw new JahiaException( "Synchronisation error in database",                                        msg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL );        }    } // end getDefinition    //-------------------------------------------------------------------------    /**     * Check if the user has read access for the specified field. Read access means     * displaying field data.     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has read access for the specified field,     *           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 field. Write access means     * updating field data.     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has write access for the specified field,     *           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 field. Admin access means     * setting rights on data.     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has admin access for the specified field,     *           or false in any other case.     */    public final boolean checkAdminAccess (JahiaUser user, int siteID)    {        return checkAccess (user, JahiaBaseACL.ADMIN_RIGHTS, siteID);    }    // Note : There are no Admin rights on fields.    //-------------------------------------------------------------------------    private boolean checkAccess (JahiaUser user, int permission, int siteID)    {        if (user == null) {            return false;        }        //JahiaConsole.println ("->> field checkAccess : field ["+Integer.toString (ID)+        //                      "], permission ["+Integer.toString (permission)+"], user ["+user.getName()+"]");        boolean result = false;        try        {            // Try to instanciate the ACL.            JahiaBaseACL fieldACL = new JahiaBaseACL (aclID);            // Test the access rights            result = fieldACL.getPermission (user, permission, siteID);            // destroy the object.            fieldACL = null;        }        catch (ACLNotFoundException ex) {            //JahiaConsole.println ("JahiaField", "Could not find the ACL ["+Integer.toString(aclID)+            //        "] for field ["+Integer.toString(ID)+"]");        }        catch (JahiaException ex) {            JahiaConsole.println ("JahiaField", "JahiaException caught in checkAccess.");        }        //if (!result) {        //    JahiaConsole.println ("JahiaField", "Permission denied for user ["+        //            user.getName()+"] to field ["+Integer.toString(ID)+        //            "] for access permission ["+Integer.toString(permission)+"]");        //}        return result;    }	/**	 * Generate an html anchor composed by the fieldID	 *	 * @author NK	 */	public String getAnchor(){		StringBuffer anchor = new StringBuffer("<A NAME=");		anchor.append(this.getID());		anchor.append("></A>");		return anchor.toString();	}} // end JahiaField

⌨️ 快捷键说明

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