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

📄 jahiapagebaseservice.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                JahiaPageNotFoundException,                JahiaTemplateNotFoundException    {        return lookupPage (pageID, null, false);    }    //-------------------------------------------------------------------------    public JahiaPage lookupPage (int pageID)        throws  JahiaException,                JahiaPageNotFoundException,                JahiaTemplateNotFoundException    {        return lookupPage (pageID, null, true);    }    //-------------------------------------------------------------------------    public JahiaPage lookupPage (int pageID, ParamBean jParam)        throws  JahiaException,                JahiaPageNotFoundException,                JahiaTemplateNotFoundException    {        return lookupPage (pageID, jParam, true);    }    //-------------------------------------------------------------------------    // AK 03.05.2001 lookup page whitout checks on templates... by passing new boolean (false).    public JahiaPage lookupPage (int pageID, ParamBean jParam, boolean withTemplates)        throws  JahiaException,                JahiaPageNotFoundException,                JahiaTemplateNotFoundException    {        //JahiaConsole.println("JahiaPageBaseService.lookupPage"," lookup page id=" + pageID );        // Check if the service is running        checkService ();        // Get the raw page infos        JahiaPageInfo pageInfo = lookupPageInfo (pageID);        if (pageInfo == null) {            throw new JahiaPageNotFoundException (pageID);        }        //////////////////////////////////////////////////////////////////////////////////////        // FIXME -Fulco-        //        //  this check should be removed the day we decide to make of links real objects and        //  not a special case of a page.        //        //////////////////////////////////////////////////////////////////////////////////////        // If the page is of DIRECT type, try to get the page Template        // reference. If the page is not of this type, the page template        // is not needed and so the page template reference will be set to null.        JahiaPageDefinition pageTemplate = null;        if(withTemplates)       // AK. only if templates are requested.        {            if ((pageInfo.getPageType() == JahiaPageInfo.TYPE_DIRECT) ||                (pageInfo.getPageType() == JahiaPageInfo.TYPE_LINK))            {                pageTemplate = mTemplateService.lookupPageTemplate (pageInfo.getPageTemplateID());            }        }        // Get the ACL object associated to the page, if the ACL is not found,        // report the error.        JahiaBaseACL acl = new JahiaBaseACL (pageInfo.getAclID ());        if (acl == null) {            throw new JahiaException ("Page ACL not found.",                "The ACL ["+pageInfo.getAclID()+"] could not be found in the"+                " database for page ["+pageID+"]",                JahiaException.PAGE_ERROR, JahiaException.ERROR);        }        // Looks like everything is going well, let's create the page facade !        JahiaPage page = new JahiaPage (pageInfo, pageTemplate, acl, jParam);        pageInfo = null;        pageTemplate = null;        acl = null;        return page;    }    //-------------------------------------------------------------------------    // Return the reference of the requested page info. First try to extract    // the info out of the cache, if not present extract if from the    // database, and add it to the cache.    // Return null if the page info doesn't exist.    private JahiaPageInfo lookupPageInfo (int pageID)        throws JahiaException    {        // Get the raw page infos        JahiaPageInfo pageInfo = (JahiaPageInfo)mPageCache.lookup (pageID);        if (pageInfo == null) {            // the page doesn't exist yet in the cache, load it from the            // database.            pageInfo = mPageDB.loadPageInfo (pageID);            if (pageInfo != null) {                mPageCache.add (pageInfo);            }        }        return pageInfo;    }    //-------------------------------------------------------------------------    public synchronized void shutdown ()    {        //////////////////////////////////////////////////////////////////////////////////////        // FIXME -Fulco- :        //   before shutting down the service, a check should be done to know        //   if a page has an update-lock active. If any active update-lock is        //   active, the system can not be shutdown !        //   If the shutdown process can be forced, a message should indicate the editing        //   user the service is in shutdown process, as soon as he does an action.        //////////////////////////////////////////////////////////////////////////////////////        if (isInitialized()) {            mPageCache.reset ();            mIsServiceInitialized = false;        }    }    //-------------------------------------------------------------------------    // Sorts pages by ID    private void sortPages (Vector pagesList)    {        JahiaPage pageA;        JahiaPage pageB;        for (int i=0; i < pagesList.size(); i++) {            for (int j=i; j < pagesList.size(); j++) {                pageA = (JahiaPage) pagesList.elementAt(i);                pageB = (JahiaPage) pagesList.elementAt(j);                if (pageA.getID() > pageB.getID()) {                    pagesList.setElementAt( pageB, i );                    pagesList.setElementAt( pageA, j );                }            }        }        pageA = null;        pageB = null;    }    //-------------------------------------------------------------------------    /** return a copy (clone) of the jahia page.     *  all the page content and the acl are cloned too.     *  @param   newParentID    int parentID of the cloned page     *                              if -1, newParentID = parentID of the page to clone.     *  @param   newParentAclID int the id of the parent of the acl.     *                              if -1, newParentAclID = parentAclID of the acl to clone.     *  @param   pageToClone        JahiaPage the page to clone.     *  @param   childrenCloned     true if the direct links to children pages are to     *                              be preserved in the copy, false otherwise     *     *  @return  return a JahiaPage which is the clone of the page in parameter.     */     public synchronized JahiaPage clonePage(int newParentID,                                             int newParentAclID,                                             JahiaPage pageToClone,                                             ParamBean jParam,                                             boolean childrenCloned)        throws JahiaException     {        if (pageToClone == null) {            return null;        }        // Check if the service is running        checkService ();        ServicesRegistry sReg = ServicesRegistry.getInstance();        // Verify the page to clone exist        int pageToCloneID = pageToClone.getID();        JahiaPageInfo pageToCloneInfo = pageToClone.getPageInfo();        if (pageToCloneInfo == null) {            throw new JahiaException ("Could not clone page.",                "Could not clone the page : page ["+pageToCloneID+"] not found.",                JahiaException.PAGE_ERROR, JahiaException.ERROR);        }        // Get the next available counter.        int pageID = mPageDB.getNextID ();        // No page hits until now ;)        int counter = 0;        // Get the current date.        String dateOfCreation = new Long((new java.util.Date()).getTime()).toString();        // clone the page's ACL        JahiaBaseACL aclToClone = pageToClone.getACL();        if (aclToClone == null)        {            throw new JahiaException ("Could not clone page.",                "Could not get JahiaBaseACL object.",                JahiaException.PAGE_ERROR, JahiaException.CRITICAL);        }        JahiaBaseACL clonedACL = null;        clonedACL = (JahiaBaseACL)aclToClone.clone();        if (clonedACL == null)        {            throw new JahiaException ("Could not clone page.",                "Could not clone acl.",                JahiaException.PAGE_ERROR, JahiaException.CRITICAL);        }        if (newParentAclID != -1)        {            clonedACL.setParentID(newParentAclID);        }        int pageAclID = clonedACL.getID();        // get the template        JahiaPageDefinition pageTemplate = pageToClone.getPageTemplate();        // clone the JahiaPageInfo        JahiaPageInfo pageInfo = pageToCloneInfo.clonePageInfo(clonedACL.getID(), newParentID, pageID, dateOfCreation);        if (pageInfo == null)        {            throw new JahiaException ("Could not clone page.",                "Could not clone JahiaPageInfo object.",                JahiaException.PAGE_ERROR, JahiaException.CRITICAL);        }        // insert the page info into the database.        if (!mPageDB.insertPageInfo (pageInfo)) {            throw new JahiaException ("Could not clone page.",                "Could not insert the page info into the database",                JahiaException.PAGE_ERROR, JahiaException.CRITICAL);        }        // Let's create the page!!        JahiaPage page = new JahiaPage (pageInfo, pageTemplate, clonedACL, jParam);        if (page == null) {            throw new JahiaException ("Could not clone page.",                "Could not instanciate a new JahiaPage object.",                JahiaException.PAGE_ERROR, JahiaException.CRITICAL);        }        // add the page into the cache        mPageCache.add (pageInfo);        // log the page creation Event        JahiaEvent theEvent = new JahiaEvent( this, jParam, page );        sReg.getJahiaEventService().                    fireAddPage (theEvent);        // clone all container list in page        Vector cListIDs = sReg.getJahiaContainersService(                            ).getContainerListIDsInPage( pageToClone );        int cListID;        for (int i=0; i < cListIDs.size(); i++) {            cListID = ((Integer)cListIDs.elementAt(i)).intValue();            sReg.getJahiaContainersService().cloneContainerList(cListID, pageID, pageAclID, childrenCloned);        }        // clone all fields in page        Vector fieldIDs = sReg.getJahiaFieldService(                            ).getFieldIDsInPage (pageToClone.getID());        int        fieldID;        JahiaField field;        for (int i=0; i < fieldIDs.size(); i++) {            fieldID = ((Integer)fieldIDs.elementAt (i)).intValue ();            field   = sReg.getJahiaFieldService().loadField(fieldID);            sReg.getJahiaFieldService().cloneField(field, 0, pageID, pageAclID, childrenCloned);        }        return page;     }     //-------------------------------------------------------------------------    /** set a new parent to the page.     *  USE this method carefully, it will move all the subtree.     *  @param   newParentID int the new parentID of the page     *  @param   page        JahiaPage the page to clone.     *     *  @return  return a JahiaPage with the new parentID.     */     public synchronized JahiaPage setParentPageID(int newParentID,                                                   JahiaPage page)        throws JahiaException     {        page.setParentID(newParentID);        page.commitChanges(true);        return page;     }    //-------------------------------------------------------------------------    // FH   2 May 2001    // javadocs automaticaly imported.    //    public int getNbPages ()        throws  JahiaException    {        return mUtilsDB.getNbPages ();    }    //-------------------------------------------------------------------------    // FH   2 May 2001    // javadocs automaticaly imported.    //    public int getNbPages (int siteID)        throws  JahiaException    {        return mUtilsDB.getNbPages (siteID);    }    //-------------------------------------------------------------------------    // FH   2 May 2001    // javadocs automaticaly imported.    //    public int getRealNbPages ()        throws  JahiaException    {        return mUtilsDB.getRealNbPages ();    }    //-------------------------------------------------------------------------    // FH   2 May 2001    // javadocs automaticaly imported.    //    public int getRealNbPages (int siteID)        throws  JahiaException    {        return mUtilsDB.getRealNbPages (siteID);    }    //--------------------------------------------------------------------------    /**     * returns a DOM representation of all pages of a site     *     * @param int siteID     * @auhtor NK     */    public JahiaDOMObject getPagesAsDOM( int siteID ) throws JahiaException{        return JahiaPageUtilsDB.getInstance().getPagesAsDOM (siteID);    }    //--------------------------------------------------------------------------    /**     * Returns a vector of all pages' Acl ID of this site     * Need this for site extraction     *     * @param int siteID     * @auhtor NK     */    public Vector getAclIDs( int siteID )    throws JahiaException{        return mUtilsDB.db_get_all_acl_id(siteID);    }}

⌨️ 快捷键说明

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