📄 jahiacontainersbaseservice.java
字号:
int ctnid = ((Integer)ctnids.elementAt(i)).intValue(); thisContainer = loadContainer( ctnid, loadFlag, jParams, cachedFieldsInContainer ); if (thisContainer.getID()!=-1) { // no read rights on this container // don't add it to the list! theContainerList.addContainer( thisContainer ); } } if ( theContainerList != null ) { theContainerList.setIsContainersLoaded(true); } return theContainerList; } // end loadContainerList /*** * saves a container list info * saves container list info, but not dependant fields and container lists * if id=0, attributes a new id to container list and creates it in datasource * * @param theContainerList a JahiaContainerList object * @param parentAclID the Acl parent ID * @see org.jahia.data.containers.JahiaContainerList * */ // EV 26.02.2001 added parentAclID public synchronized void saveContainerListInfo( JahiaContainerList theContainerList, int parentAclID ) throws JahiaException { if (theContainerList.getAclID() == 0) { // Start Create a new ACL object for the new container. JahiaBaseACL acl = new JahiaBaseACL (); if (acl != null) { // create a new object by specifying the parent ACL ID (a containerList) if (!acl.create (parentAclID)) { String message = "Could not create an ACL object for a new container."; JahiaConsole.println ("", message+" -> Stop container creation!"); throw new JahiaException ("JahiaContainersBaseService", message, JahiaException.ACL_ERROR, JahiaException.CRITICAL); } else { JahiaConsole.println ("JahiaContainersBaseService", "ACL ["+acl.getID()+"] has just been created! (Container)"); } } else { throw new JahiaException ("JahiaContainersBaseService", "Counld not instanciate the JahiaBaseACL class", JahiaException.ACL_ERROR, JahiaException.CRITICAL); } // End Create ACL theContainerList.setAclID(acl.getID()); } if (theContainerList.getID() == 0) { c_lists.db_create_container_list( theContainerList ); } else { c_lists.db_update_container_list( theContainerList ); } JahiaContainerDefinition cDef = JahiaContainerDefinitionsRegistry.getInstance().getDefinition(theContainerList.getctndefid()); if ( cDef != null ) c_lists_props.setProperties(theContainerList.getID(), cDef.getJahiaID(), theContainerList.getProperties()); } // end saveContainerListInfo /*** * deletes a container list info * deletes a container list info, but not dependant containers * see deleteContainerList for that * * @param listID the container list id to delete * */ public synchronized void deleteContainerListInfo( int listID ) throws JahiaException { c_lists.db_delete_container_list( listID ); c_lists_props.removeProperties(listID); } // end deleteContainerListInfo /*** * deletes a container list info * deletes a container list info, including dependant containers * see deleteContainerList for that * * @param listID the container list id to delete * */ // No ACL check implemented, because when you delete a page you want to // delete every containerlist / container it contains, even if you don't have // the specific rights to do so. public synchronized void deleteContainerList( int listID ) throws JahiaException { // gets list object JahiaContainerList theList = loadContainerListInfo( listID ); // deletes list info deleteContainerListInfo( listID ); // deletes all containers of container list Vector cIDs = getctnidsInList( listID ); for (int i=0; i < cIDs.size(); i++) { int ctnid = ((Integer)cIDs.elementAt(i)).intValue(); deleteContainer( ctnid, null ); } // deletes ACL try { if (theList != null) { JahiaBaseACL theACL = new JahiaBaseACL (theList.getAclID()); theACL.delete (); } } catch (ACLNotFoundException ex) { JahiaException je = new JahiaException ("", "Could not find the ACL ["+Integer.toString (theList.getAclID())+ "] while removing field ["+Integer.toString(listID)+"]", JahiaException.ACL_ERROR, JahiaException.WARNING); } } // end deleteContainerList /*** * loads a container definition by its id * * @param definitionID the container definition id * @return a JahiaContainerDefinition object * @see org.jahia.data.containers.JahiaContainerDefinition * @see org.jahia.data.containers.JahiaContainerStructure * */ public JahiaContainerDefinition loadContainerDefinition( int definitionID ) throws JahiaException { JahiaContainerDefinition result = c_defs.db_load_container_definition( definitionID ); Properties defProps = c_defs_props.getProperties(result.getID()); result.setProperties(defProps); return result; } // end loadContainerDefinition /*** * saves a container definition * if id=0, assigns a new id to the definition and creates it in the datasource * * @param theDefinition the JahiaContainerDefinition to save * @see org.jahia.data.containers.JahiaContainerDefinition * @see org.jahia.data.containers.JahiaContainerStructure * */ public synchronized void saveContainerDefinition( JahiaContainerDefinition theDefinition ) throws JahiaException { if (theDefinition.getID() == 0) { c_defs.db_create_container_definition( theDefinition ); } else { c_defs.db_update_container_definition( theDefinition ); } c_defs_props.setProperties(theDefinition.getID(), theDefinition.getProperties()); } // end saveContainerDefinition /*** * deletes a container definition * * @param theDefinition the JahiaContainerDefinition to delete * @see org.jahia.data.containers.JahiaContainerDefinition * @see org.jahia.data.containers.JahiaContainerStructure * */ public synchronized void deleteContainerDefinition( int definitionID ) throws JahiaException { c_defs.db_delete_container_definition( definitionID ); JahiaContainerDefinitionsRegistry.getInstance().removeContainerDefinition(definitionID); } // end deleteContainerDefinition///////////////////////////////// CacheIO objects /////////////////////////////////////// /** * CacheIO methods for cache_id_container * DJ 06.01.2001 */ private class Cache_id_container_IO implements JahiaCacheIO { // LOAD public Object loadValue (String cacheID, Object paramsIO) throws JahiaException { //JahiaConsole.println ("Cache_id_container_IO", "reading from DB : "+ cacheID +" : " ); Object temp = c_containers.db_load_container( ((Integer)paramsIO).intValue() ); if (temp == null) { throw new JahiaException ("404 - not found.", "The container ["+cacheID+"] could not be found in the"+ " database.", JahiaException.PAGE_ERROR, JahiaException.ERROR); } return temp; } // SAVE public void saveValue (Object theObject, String cacheID, Object paramsIO) throws JahiaException { if (((Integer)paramsIO).intValue() == 0) { // JahiaConsole.println ("Cache_id_container_IO", "creating in DB : "+ cacheID +" : " ); c_containers.db_create_container( (JahiaContainer)theObject ); } else { // JahiaConsole.println ("Cache_id_container_IO", "updating to DB : "+ cacheID +" : " ); c_containers.db_update_container( (JahiaContainer)theObject ); } } // DELETE public void deleteValue (String cacheID, Object paramsIO) throws JahiaException { JahiaConsole.println ("Cache_id_container_IO", "deleting in DB : "+ cacheID +" : " ); c_containers.db_delete_container( Integer.parseInt(cacheID) ); } } //------------------------------------------------------------------------- private synchronized void toDebug (String message) { if (false) { //System.out.println (message); } } //-------------------------------------------------------------------------- /** * returns a DOM representation of all containers of a site * * @param int siteID * @auhtor NK */ public JahiaDOMObject getContainersAsDOM( int siteID ) throws JahiaException{ return c_containers.getContainersAsDOM (siteID); } //-------------------------------------------------------------------------- /** * returns a DOM representation of all container lists of a site * * @param int siteID * @auhtor NK */ public JahiaDOMObject getContainerListsAsDOM( int siteID ) throws JahiaException{ return c_lists.getContainerListsAsDOM (siteID); } //-------------------------------------------------------------------------- /** * returns a DOM representation of all container lists props of a site * * @param int siteID * @auhtor NK */ public JahiaDOMObject getContainerListPropsAsDOM( int siteID ) throws JahiaException{ return c_lists_props.getPropertiesAsDOM (siteID); } //-------------------------------------------------------------------------- /** * returns a DOM representation of all container def of a site * * @param int siteID * @auhtor NK */ public JahiaDOMObject getContainerDefsAsDOM( int siteID ) throws JahiaException{ return c_defs.getContainerDefsAsDOM (siteID); } //-------------------------------------------------------------------------- /** * returns a DOM representation of all container def prop of a site * * @param int siteID * @auhtor NK */ public JahiaDOMObject getContainerDefPropsAsDOM( int siteID ) throws JahiaException{ return c_defs.getContainerDefPropsAsDOM (siteID); } //-------------------------------------------------------------------------- /** * returns a DOM representation of all containers extented properties of a site * * @param int siteID */ public JahiaDOMObject getContainerExtendedPropsAsDOM( int siteID ) throws JahiaException{ return c_defs_props.getPropertiesAsDOM(siteID); } //-------------------------------------------------------------------------- /** * returns a DOM representation of all container structure of a site * * @param int siteID * @auhtor NK */ public JahiaDOMObject getContainerStructsAsDOM( int siteID ) throws JahiaException{ return c_struct.getContainerStructsAsDOM (siteID); } //-------------------------------------------------------------------------- /** * Returns a vector of all Acl ID used by container for a site * Used for site extraction * * @param int siteID * @auhtor NK */ public Vector getAclIDs( int siteID ) throws JahiaException{ return c_utils.db_get_all_acls_id(siteID); } //-------------------------------------------------------------------------- /** * Returns a vector of all ctn lists fields ( field def ) Acl ID for a site * Used for site extraction * * @param int siteID * @auhtor NK */ public Vector getCtnListFieldAclIDs( int siteID ) throws JahiaException{ return c_lists_props.getCtnListFieldACLs(siteID); }} // end JahiaContainersBaseService
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -