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

📄 jahiapagebaseservice.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                           getFilesByPage(theVictim.getJahiaID(),theVictim.getID(),false);            JahiaFile f = null;            boolean flag = false;            for (int i=0; i<files.size(); i++)            {                f = (JahiaFile)files.get(i);                flag = ServicesRegistry.getInstance().getJahiaFilemanagerService().                       deleteFileDB(f.getFileID());                flag = ServicesRegistry.getInstance().getJahiaFilemanagerService().                       deleteFile(f);            }            // now ... kill the victim !!            JahiaPageInfo pageInfo = theVictim.getPageInfo();            mPageDB.deletePageInfo (pageInfo.getID());            pageInfo.killObject();            // be sure it's really dead !            theVictim = null;            pageInfo = null;        }        else {            throw new JahiaOperationNotAllowedException(theVictim.getID(),            "It is not allowed to delete the current page. Delete it from its parent page.");        }    }    //-------------------------------------------------------------------------    public int findPageIDFromLevel (int pageID, int levelNb)        throws JahiaException    {        int levelCount = 0;        int parentID = -1;        JahiaPage thePage = lookupPage (pageID);        if (levelNb != -1) {            while (levelCount < levelNb) {                parentID = thePage.getParentID();                if (parentID > 0) {                    thePage = lookupPage (parentID);                } else {                    return -1;                }                levelCount++;            }        } else {            while (parentID > 0) {                parentID = thePage.getParentID();                if (parentID > 0) {                    thePage = lookupPage (parentID);                }            }        }        return thePage.getID();    }    //-------------------------------------------------------------------------    public Enumeration getAllPages (int siteID, int loadFlag, ParamBean jParam,                                    JahiaUser user)        throws JahiaException    {        // Check if the service is running        checkService ();        Vector result = new Vector ();        // the user must be non null        if (user != null) {            // get all the pages IDs in the specified site.            Vector allPages = getPageIDsInSite (siteID);            // for each page ID, lookup the page, and check if the page            // matches the load flags and if the user is authorized to see it.            for (int i=0; i<allPages.size(); i++) {                try {                    Integer id = (Integer)allPages.get (i);                    if ( id.intValue()>0 ){                        JahiaPage page = lookupPage (id.intValue(), jParam);                        if (page != null) {                            if (authorizePageLoad (page, loadFlag, jParam)) {                                result.add (page);                            }                        }                    }                    id = null;                }                catch (JahiaPageNotFoundException ex) {                    // the page could not be found, ignore and don't add it                    // into the resulting Vector.                }                catch (JahiaTemplateNotFoundException ex) {                    // The page has an invalid page template, ignore and                    // don't add it into the resulting Vector.                }                catch (JahiaException ex) {                    // An error occured, just don't add the page into the                    // resulting Vector.                }            }            allPages = null;        }        return result.elements();    }    //-------------------------------------------------------------------------    /** Returns an instance of the page service */    public static synchronized JahiaPageBaseService getInstance()        throws JahiaException    {        if (mObject == null) {            mObject = new JahiaPageBaseService();        }        return mObject;    }    //-------------------------------------------------------------------------    public Vector getAllSiteIDs ()        throws JahiaException    {        // Check if the service is running        checkService ();        Vector sites = new Vector();        sites.add (new Integer(1));    // big fuckin' fake :) .... as you said !!! (Fulco)        return sites;    }    //-------------------------------------------------------------------------    public Vector getPageIDsInSite (int siteID)        throws JahiaException    {        // Check if the service is running        checkService ();        return mUtilsDB.getPageIDsInSite (siteID);    }    //-------------------------------------------------------------------------    public Vector getPageIDsInSite (int siteID, int linkType)        throws JahiaException    {        // Check if the service is running        checkService ();        return mUtilsDB.getPageIDsInSite (siteID, linkType);    }    //-------------------------------------------------------------------------    public Vector getPageIDsWithTemplate (int templateID)        throws JahiaException    {        // Check if the service is running        checkService ();        return mUtilsDB.getPageIDsWithTemplate (templateID);    }    //-------------------------------------------------------------------------    public Vector getPageChilds (int pageID, int loadFlag, ParamBean jParam)        throws JahiaException    {        // Check if the service is running        checkService ();        Vector childs   = new Vector ();        // get all the child page IDs        Vector childIDs = mUtilsDB.getPageChildIDs (pageID);        // For each child page ID, get the page reference.        for (int i=0; i<childIDs.size(); i++) {            Integer id = (Integer)childIDs.get (i);            // try to get the page reference.            try {                JahiaPage page = lookupPage (id.intValue(), jParam);                id = null;                JahiaUser user = null;                if (jParam != null) {                    user = jParam.getUser();                }                // if the page exists add it to the child list if it matches                // the loading flag.                if ((page != null) && (user != null)) {                    if (authorizePageLoad (page, loadFlag, jParam)) {                        childs.add (page);                    }                }                user = null;            }            catch (JahiaPageNotFoundException ex) {                // The page could not be found, don't add it into the resulting                // Vector.            }            catch (JahiaTemplateNotFoundException ex) {                // The page template could not be found, don't add it into the                // resulting Vector.            }        }        childIDs = null;        // sort pages by IDs        sortPages (childs);        return childs;    }    public Vector getPageChilds (int pageID, int loadFlag, JahiaUser user)        throws JahiaException    {        // Check if the service is running        checkService ();        Vector childs   = new Vector ();        // get all the child page IDs        Vector childIDs = mUtilsDB.getPageChildIDs (pageID);        // For each child page ID, get the page reference.        for (int i=0; i<childIDs.size(); i++) {            Integer id = (Integer)childIDs.get (i);            // try to get the page reference.            try {                JahiaPage page = lookupPage (id.intValue(), null);                id = null;                // if the page exists add it to the child list if it matches                // the loading flag.                if ((page != null) && (user != null)) {                    if (authorizePageLoad (page, loadFlag, user)) {                        childs.add (page);                    }                }            }            catch (JahiaPageNotFoundException ex) {                // The page could not be found, don't add it into the resulting                // Vector.            }            catch (JahiaTemplateNotFoundException ex) {                // The page template could not be found, don't add it into the                // resulting Vector.            }        }        childIDs = null;        // sort pages by IDs        sortPages (childs);        return childs;    }    //-------------------------------------------------------------------------    public Vector getPagePath (int pageID, ParamBean jParams)        throws JahiaException    {        // Check if the service is running        checkService ();        Vector      path = new Vector();        JahiaPage   thePage;        thePage = lookupPage (pageID, jParams);        path.add (thePage);        if (thePage != null) {            while (thePage.getParentID () > 0) {                thePage = lookupPage (thePage.getParentID (), jParams);                path.insertElementAt (thePage, 0);            }        }        thePage = null;        return path;    }    //-------------------------------------------------------------------------    public Vector getPagesPointingOnPage (int pageID, ParamBean jParam)        throws JahiaException    {        // Check if the service is running        checkService ();        Vector pages = new Vector();        Vector pageIDs = mUtilsDB.getPageIDsPointingOnPage (pageID);        for (int i=0; i < pageIDs.size(); i++) {            // get the page ID            int pID = ((Integer)pageIDs.elementAt(i)).intValue();            // get the page reference            try {                JahiaPage aPage = lookupPage (pID, jParam);                // if the page exists, add it to the vector                if (aPage != null) {                    pages.add (aPage);                }                aPage = null;            }            catch (JahiaPageNotFoundException ex) {            }            catch (JahiaTemplateNotFoundException ex) {            }        }        pageIDs = null;        return pages;    }    //-------------------------------------------------------------------------    public Vector getPageSubTree (int pageID, int loadFlag, ParamBean jParam)        throws JahiaException    {        // Check if the service is running        checkService ();        int parentID;        Vector subTree = getPageChilds (pageID, loadFlag, jParam);        for (int i=0; i < subTree.size(); i++) {            JahiaPage aPage = (JahiaPage) subTree.elementAt(i);            subTree.addAll (getPageSubTree (aPage.getID(), loadFlag, jParam));            aPage = null;        }        return subTree;    }    //-------------------------------------------------------------------------    public synchronized void init ()        throws JahiaException    {        JahiaConsole.println ("JahiaPageService", "   ** Initializing the Page Service ...");        // do not allow initialization when the service is still running        if (!isInitialized ()) {            // Initialize the pages cache            JahiaConsole.println ("JahiaPageService", "    - Instanciate the page cache ...");            mPageCache = JahiaPageCache.getInstance();            // get the page DB access instance            JahiaConsole.println ("JahiaPageService", "    - Instanciate the database page tools ...");            mPageDB = JahiaPagesDB.getInstance();            // get the page utilities DB access instance            JahiaConsole.println ("JahiaPageService", "    - Instanciate the database page utility tools ...");            mUtilsDB = JahiaPageUtilsDB.getInstance();            // get the template service reference.            JahiaConsole.println ("JahiaPageService", "    - Get the Page Template Service instance ...");            ServicesRegistry services = ServicesRegistry.getInstance();            if (services != null) {                mTemplateService = services.getJahiaPageTemplateService ();            }            if ((mPageCache != null) &&                (mPageDB != null) &&                (mUtilsDB != null) &&                (mTemplateService != null))            {                mIsServiceInitialized = true;                JahiaConsole.println ("JahiaPageService", "   ** Page Service successfully initialized!");            } else {                // invalidate the previous initializations                mPageCache       = null;                mPageDB          = null;                mUtilsDB         = null;                mTemplateService = null;                // and raise an exception :(                throw new JahiaException ("Page Service initialization error.",                        "Page Service could not be initialized successfully.",                        JahiaException.SERVICE_ERROR, JahiaException.KISS_YOUR_ASS_GOODBYE);            }        }    }    //-------------------------------------------------------------------------    public JahiaPage lookupPageWhitoutTemplates (int pageID)        throws  JahiaException,

⌨️ 快捷键说明

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