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

📄 jahiacontainer.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//package org.jahia.data.containers;import java.util.*;                     // Vectorimport org.jahia.utils.*;           // JahiaConsoleimport org.jahia.data.*;            // JahiaDataimport org.jahia.data.fields.*;     // JahiaFieldimport org.jahia.registries.*;      // Registriesimport org.jahia.exceptions.JahiaException;import org.jahia.services.usermanager.JahiaUser;import org.jahia.services.pages.*;import org.jahia.params.*;import org.jahia.services.acl.JahiaBaseACL;import org.jahia.services.acl.ACLResourceInterface;import org.jahia.services.acl.ACLNotFoundException;public class JahiaContainer implements Cloneable , ACLResourceInterface {    private int         ID;    private int         jahiaID;    private int         pageID;    private int         listID;    private int         rank;    private int         ctndefid;    private int         aclID;    /**     * @associates JahiaField     */    private Vector      fields          = new Vector();    /**     * @associates JahiaContainerList     */    private Vector      containerLists  = new Vector();    /***        * constructor        * EV    24.11.2000        *        */    public JahiaContainer(  int     ID,                            int     jahiaID,                            int     pageID,                            int     listID,                            int     rank,                            int     aclID,                            int     ctndefid)    {        this.ID             = ID;        this.jahiaID        = jahiaID;        this.pageID         = pageID;        this.listID         = listID;        this.rank           = rank;        this.aclID          = aclID;        this.ctndefid = ctndefid;    } // end constructor    /***        * accessor methods        * EV    24.11.2000        *        */    public  int             getID()             {   return ID;                          }    public  int             getJahiaID()        {   return jahiaID;                     }    public  int             getSiteID()         {   return jahiaID;                     } //FIXME_MULTISITE Hollis jahiaID or siteID ?    public  int             getPageID()         {   return pageID;                      }    public  int             getListID()         {   return listID;                      }    public  int             getRank()           {   return rank;                        }    public  int             getctndefid() {   return ctndefid;              }    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  Enumeration     getFields()         {   return fields.elements();           }    public  int			    getNbFields()       {   return fields.size();	            }    public  Enumeration     getContainerLists() {   return containerLists.elements();   }    public  void            setID( int ID )     {   this.ID = ID;                       }    public  void    		setctndefid( int ctndefid )	{	this.ctndefid = ctndefid;	}    public  void            setAclID( int aclID ) {   this.aclID = aclID;               }    public  void            setListID( int listID ) { this.listID = listID;             }    public void             setRank( int rank ) { this.rank = rank; }    // end accessor methods    //-------------------------------------------------------------------------    /**     * Clone     */    public Object clone()    {        return new JahiaContainer (ID, jahiaID, pageID, listID, rank, aclID, ctndefid);    }    //-------------------------------------------------------------------------    /***        * getDefinition        *        */    public JahiaContainerDefinition getDefinition()    throws JahiaException    {        JahiaContainerDefinition theDef = JahiaContainerDefinitionsRegistry.getInstance(            ).getDefinition( ctndefid );        if (theDef != null) {            return theDef;        } else {            String msg = "JahiaContainer definition " + ctndefid + " not found in definition registry !";            throw new JahiaException( "Synchronisation error in database",                                        msg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL );        }    } // end getDefinition    //-------------------------------------------------------------------------    /***        * get a field by its fieldname        *        * @param        fieldName       the field name        *        * @exception    throws a critical jahia exception if field not found        *        */    public JahiaField getField( String fieldName )    throws JahiaException    {        JahiaField theField = null;        for (int i=0; i < fields.size(); i++) {            JahiaField aField = (JahiaField) fields.elementAt(i);            if (aField.getDefinition().getName().equals(fieldName)) {                theField = aField;                break;            }        }        if (theField == null) {            // get the page template ID            int pageDefID = ServicesRegistry.getInstance().getJahiaPageService().                    lookupPage (this.getPageID(), null).getPageTemplateID();            JahiaFieldDefinition fDef = this.getDefinition().findFieldInStructure(fieldName, pageDefID );            if (fDef != null) {                theField = ServicesRegistry.getInstance().                               getJahiaFieldService().                               createJahiaField(0, fDef.getJahiaID(), this.getPageID(),                        this.getID(), fDef.getID(), fDef.getType(pageDefID), 0, "",                        this.getRank(), 0 );                // saves in databese                JahiaConsole.println("JahiaContainer.getField",                                     "Creating new field since this is the first access for field " + fieldName);                ServicesRegistry.getInstance().getJahiaFieldService().saveField( theField, this.getAclID(), null );                // saves in container field list                this.addField( theField );            } else {                String msg = "Field " + fieldName +                             " cannot be found in " +                             getDefinition().getName();                JahiaException je = new JahiaException(  msg, "JahiaContainer : " + msg,                    JahiaException.TEMPLATE_ERROR, JahiaException.CRITICAL );            }        }        return theField;    } // end getField    //-------------------------------------------------------------------------    /***        * get a field by its id        *        * @param        fieldID         the field ID        *        * @exception    throws a critical jahia exception if field not found        *        */    public JahiaField getField( int fieldID )    throws JahiaException    {        JahiaField theField = null;        for (int i=0; i < fields.size(); i++) {            JahiaField aField = (JahiaField) fields.elementAt(i);            if (aField.getID() == fieldID) {                theField = aField;                break;            }        }        if (theField == null) {            String msg = "Field " + fieldID + " cannot be found in " + getDefinition().getName();            JahiaException je = new JahiaException(  msg, "JahiaContainer : " + msg,                JahiaException.TEMPLATE_ERROR, JahiaException.CRITICAL );        }        return theField;    } // end getField    //-------------------------------------------------------------------------    /***        * setField        *        */    public synchronized void setField( JahiaField theField )    throws JahiaException    {        for (int i=0; i < fields.size(); i++) {            JahiaField aField = (JahiaField) fields.elementAt(i);            if (aField.getID() == theField.getID()) {                fields.setElementAt(theField, i);

⌨️ 快捷键说明

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