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

📄 jahiacontainersbaseservice.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        }        Hashtable cachedFieldsFromContainers=c_utils.db_load_all_fields_from_container_from_page(jData.params().getPageID());		Vector ctnLists = new Vector();		JahiaContainerList cList = null;        Vector definitions = getctndefidsInPage( jData.page() );        for (int a=0; a < definitions.size(); a++) {            JahiaContainerDefinition theDefinition =                        (JahiaContainerDefinition) definitions.elementAt(a);            // loads all container list ids corresponding to page id and def id            Vector listIDs = getContainerListIDs(                        jData.params().getPage().getID(),                        theDefinition.getID() );  			// 05.05.2002 NK: Search,Sort,Filtering purpose  			// Filtering must be evaluated before.  			// Actually, filters are defined in template JSP files.			// that is why container list are loaded wihtout their containers here.            if (listIDs.size() > 0) {                // if container lists found, loads them by their id                for (int i=0; i < listIDs.size(); i++) {                    int listID = ((Integer)listIDs.elementAt(i)).intValue();              		cList = loadContainerListInfo( listID ); // container list loaded wihtout its containers !!         			if ( cList != null ){         				ctnLists.add( cList );         			}                }            }        }        // loads all container definitions on the page        JahiaContainerSet theSet = new JahiaContainerSet( jData, cachedFieldsFromContainers , ctnLists );        return theSet;    } // end buildContainerStructureForPage    /***        * gets all container definitions ids on a page        *        * @param        thePage         the page object        * @return       a Vector of container definition IDs        *        */    public Vector getctndefidsInPage( JahiaPage thePage )    throws JahiaException    {        return JahiaContainerDefinitionsRegistry.getInstance().                        getDefinitionsInTemplate( thePage.getPageTemplateID() );    } // end getctndefidsInPage    /***        * gets all container list ids on a page, by their definition id        *        * @param        pageID          the page id        * @param        defID           the container definition id        * @return       a Vector of containerlist IDs        *        */    public Vector getContainerListIDs( int pageID, int defID )    throws JahiaException    {        return c_utils.db_get_container_list_ids( pageID, defID );    } // end getContainerListIDs    /***        * gets all container list ids on a page        *        * DO NOT CACHE THIS METHOD (it depends on other caches values) !!        *        * @param        pageID          the page id        * @param        defID           the container definition id        * @return       a Vector of containerlist IDs        *        */    public Vector getContainerListIDsInPage( JahiaPage thePage )    throws JahiaException    {        Vector listIDs = new Vector();        Vector definitions = getctndefidsInPage( thePage );        for (int i=0; i < definitions.size(); i++) {            JahiaContainerDefinition theDefinition = (JahiaContainerDefinition) definitions.elementAt(i);            listIDs.addAll( getContainerListIDs( thePage.getID(), theDefinition.getID() ) );        }        return listIDs;    } // end getContainerListIDsInPage    /**     * gets all container ids in a container list. This list uses stored     * ranks to order its values     *     * @param        listID          the container list id     * @return       a Vector of container IDs     *     * @todo we might want to cache these values in memory in order to     * improve performance.     */    public Vector getctnidsInList( int listID )    throws JahiaException    {        return c_utils.db_get_container_ids_in_container_list( listID );    } // end getctnidsInList    /**     * Gets all container ids in a container list with ordering on a given field.     * If the fieldName is null, not ordering applied     *     * @param        int listID          the container list id     * @param        String fieldName    the fieldname on which to filter     * @param        boolean asc         Asc. or desc. ordering ( true = asc )     * @return       a Vector of container IDs     *     * @todo we might want to cache these values in memory in order to     * improve performance.	 * @author NK     */    public Vector getctnidsInList( int listID , String fieldName, boolean asc)    throws JahiaException    {    	if ( fieldName == null || fieldName.trim().equals("") ){        	return c_utils.db_get_container_ids_in_container_list( listID );    	}        return c_utils.db_get_container_ids_in_container_list( listID, fieldName, asc );    } // end getctnidsInList    /**     * gets all container ids for a given site. This list uses stored     * ranks to order its values     *     * @param int siteID, the given site id.     * @return Vector a vector of container IDs     *     */    public Vector getCtnIds( int siteID )    throws JahiaException    {        return c_utils.db_get_all_containers_id( siteID );    }    /***        * gets all field ids in a container        *        * @param        ctnid         the container id        * @return       a Vector of field IDs        *        */    public Vector getFieldIDsInContainer( int ctnid )    throws JahiaException    {        return c_utils.db_get_field_ids_in_container( ctnid );    } // end getFieldIDsInContainer    /***        * gets a container list id by its container list name and page id        *        * @param        containerName       the container name        * @param        pageID              the page ID        * @return       a container list id        *        */    public int getContainerListID( String containerName, int pageID )    throws JahiaException    {        return c_utils.db_get_container_list_id( containerName, pageID );    } // end getContainerListID    /***        * gets all container definition ids in Jahia        *        * @return       a Vector of container definition IDs        *        */    public Vector getAllContainerDefinitionIDs()    throws JahiaException    {        return c_utils.db_get_all_container_definition_ids();    } // end getAllContainerDefinitionIDs    /***        * loads a container info, by its container id        * NO RIGHTS CHECKS ! see loadContainer(ctnid,LoadFlags,jParams) for that.        *        * @param        ctnid         the container id        * @return       a JahiaContainer object, without field values        * @see          org.jahia.data.containers.JahiaContainer        *        */    public JahiaContainer loadContainerInfo( int ctnid )    throws JahiaException {        Integer ctnIDInt = new Integer(ctnid);        JahiaContainer containerFromCache = (JahiaContainer) cacheContainers.getValue(ctnIDInt);        JahiaContainer result;        if (containerFromCache != null) {            result = (JahiaContainer) containerFromCache.clone();        } else {            // load it            result = c_containers.db_load_container( ctnid );            if (result == null)            {                throw new JahiaException ("404 - not found.",                "The container ["+ctnid+"] could not be found in the"+                " database.",                JahiaException.PAGE_ERROR, JahiaException.ERROR);            }            cacheContainers.setValue(result.clone(), new Integer(ctnid));        }        return result;    } // end loadContainerInfo    /***        * loads a container by its container id        * loads a container info and fields by its container id, but not dependant containerlists        * this method cannot load request-specific values (i.e. applications);        * see the loadContainer( ctnid, loadFlag, jParams) for that.        *        * NO RIGHTS CHECKS ! see loadContainer(ctnid,LoadFlags,jParams) for that.        *        * DO NOT CACHE THIS METHOD (it depends on other caches values) !!        *        * @param        ctnid         the container id        * @param        loadFlag            the loadFlag        * @see          org.jahia.data.containers.JahiaContainer        * @see          org.jahia.data.fields.LoadFlags        *        */    public JahiaContainer loadContainer( int ctnid, int loadFlag )    throws JahiaException    {        return loadContainer( ctnid, loadFlag, null );    } // end loadContainer    /***        * loads a container by its container id        * loads a container info and fields by its container id, but not dependant containerlists        * this method can load request-specific values (i.e. applications);        *        * DO NOT CACHE THIS METHOD (it depends on other caches values) !!        *        * @param        ctnid         the container id        * @param        loadFlag            the loadFlag        * @param        jParams             the ParamBean object, containing request and response        * @see          org.jahia.data.containers.JahiaContainer        * @see          org.jahia.data.fields.LoadFlags        *        */        // DJ 29.01.2001 - added ACL checks        // if there are no read rights -> return an empty container with -1 as ID.    public JahiaContainer loadContainer( int ctnid, int loadFlag, ParamBean jParams )    throws JahiaException    {        return loadContainer (ctnid, loadFlag, jParams, new Hashtable());    }    // the hashtable cachedFieldsInContainer is here if we already have a hashtable    // with containerID as key, and a Vector of fieldIDs in object, see buildContainerStructure.    public JahiaContainer loadContainer( int ctnid, int loadFlag, ParamBean jParams, Hashtable cachedFieldsInContainer )    throws JahiaException    {        // loads container info        JahiaContainer theContainer = loadContainerInfo( ctnid );        // loads container fields        // check for correct rights on container        if (jParams!=null) 			// no jParams, can't check for rights        {            JahiaUser   currentUser = jParams.getUser();            if (currentUser != null)            {                toDebug ("loadContainer(): checking rights...");                // if the user has no read rights, return the container with no fields.                if (!theContainer.checkReadAccess (currentUser))                {                    toDebug ("loadContainer(): NO read rights! -> returning null");                    theContainer.setID(-1);		// special flag to say the container is not loaded                    return theContainer;                }                toDebug ("loadContainer(): read rights OK");            } else {                throw new JahiaException ("No user present !",                     "No current user defined in the params in loadField() method.",                     JahiaException.USER_ERROR, JahiaException.ERROR);                    }        }        // end check rights on container        Vector fieldIDs = (Vector)cachedFieldsInContainer.get(new Integer(ctnid));        // not already in cache -> load it        if (fieldIDs==null)        {            fieldIDs = getFieldIDsInContainer( ctnid );        }        for (int i=0; i < fieldIDs.size(); i++) {            int fieldID = ((Integer)fieldIDs.elementAt(i)).intValue();            if (jParams == null) {                theContainer.addField( ServicesRegistry.getInstance().getJahiaFieldService(                                            ).loadField( fieldID, loadFlag ) );            } else {                theContainer.addField( ServicesRegistry.getInstance().getJahiaFieldService(                                            ).loadField( fieldID, loadFlag, jParams ) );            }        }        return theContainer;    } // end loadContainer    /***        * saves the container info        * saves the container info        * if id=0, assigns a new id to container and creates it in datasource        * if listid=0, assigns a new listid to container and creates it in datasource        *        * @param        theContainer        a JahiaContainer object        * @param        parentID            parent container id        * @param        parentAclID         the Acl parent ID        * @param		jParams				the current ParamBean        * @see          org.jahia.data.containers.JahiaContainer        *        */    //      DJ          29.01.01            added ACL check    //                                      Note : the new ACLs are created here and not in the engine.    //      EV          26.02.2001          added parentAclID - acl is no more a dirty hack ;)    //    public synchronized void saveContainerInfo( JahiaContainer  theContainer,                                                int             parentID,                                                int             parentAclID,                                                ParamBean       jParams )    throws JahiaException    {        // start check for correct rights.        if (jParams!=null) 			// no jParams, can't check for rights        {            JahiaUser   currentUser = jParams.getUser();            if (currentUser != null)            {                toDebug ("saveContainerInfo(): checking rights...");                // if the user has no write rights, exit method.                if (!theContainer.checkWriteAccess (currentUser))                {                    toDebug ("saveContainerInfo(): NO write rights! -> don't save");                    return;                }                toDebug ("saveContainerInfo(): write rights OK");            } else {                throw new JahiaException ("No user present !",                     "No current user defined in the params in saveContainerInfo() method.",                     JahiaException.USER_ERROR, JahiaException.ERROR);                    }        }        // end check rights.        if (theContainer.getID() == 0) {            // container not yet exists -> we have to give him an ID !            if (theContainer.getListID() == 0) {                // container is not yet in a list -> we have to create a list !                JahiaContainerList newList = new JahiaContainerList( 0, parentID, theContainer.getPageID(),                                                theContainer.getctndefid(), 0 );                saveContainerListInfo( newList, parentAclID );                //create default acl for container list edit view field                JahiaField aField = null;                Enumeration fList = theContainer.getFields();                while (fList.hasMoreElements())

⌨️ 快捷键说明

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