📄 jahiacontainerslogic.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .///*** * JahiaContainersLogic * @author Eric Vassalli * * Holds all the methods to build a container logical tree structure * *///// logic_build_container_tree( int pageID, ParamBean jParams )//package org.jahia.services.containers;import java.sql.*; // ResultSetimport java.util.*; // Vectorimport org.jahia.params.*; // ParamBeanimport org.jahia.data.*; // JahiaDataimport org.jahia.utils.*; // JahiaConsoleimport org.jahia.data.fields.*; // JahiaFieldimport org.jahia.data.containers.*; // JahiaContainersimport org.jahia.registries.*; // ServiceRegistryimport org.jahia.exceptions.JahiaException;public class JahiaContainersLogic{ /*** * constructor * */ public JahiaContainersLogic() { } // end constructor /*** * sorts the container tree * * @param theTree the actual tree, unsorted * @return a Vector of filled container lists * @see org.jahia.data.containers.JahiaContainerList * */ public void logic_sort_container_tree( Vector theTree ) throws JahiaException { // build dependencies between container lists for (int i=0; i < theTree.size(); i++) { JahiaContainerList theList = (JahiaContainerList) theTree.elementAt(i); if (theList.getParentEntryID() != 0) { if (logic_add_container_list_to_container( theList, theList.getParentEntryID(), theTree )) { theTree.removeElementAt(i); i--; } } } } // end logic_build_container_tree /*** * adds a container list to a container in the tree * * @param theContainerList the container list to add * @param thectnid the container id to add the container list to * @param theTree the Tree Vector * @return true if succeeded, false if failed * */ private boolean logic_add_container_list_to_container( JahiaContainerList theContainerList, int thectnid, Vector theTree ) throws JahiaException { JahiaContainer theContainer = logic_find_container_in_list( thectnid, theTree.elements() ); if (theContainer != null) { if (theContainerList == null) { JahiaConsole.println("JahiaContainersLogic.logic_add_container_list_to_container", "Hey, the container list is null !!" ); } theContainer.addContainerList( theContainerList ); return true; } else { String errorMsg = "Error in container structure : container " + thectnid + " is referrenced"; errorMsg += " by list " + theContainerList.getID() + ", but does not exist."; JahiaException je = new JahiaException( errorMsg, errorMsg, JahiaException.DATABASE_ERROR, JahiaException.WARNING ); return false; } } // end logic_add_container_list_to_container /*** * finds a container object by its id in the tree structure * * @param thectnid the container id * */ private JahiaContainer logic_find_container_in_list( int thectnid, Enumeration containerLists ) { while (containerLists.hasMoreElements()) { JahiaContainerList theContainerList = (JahiaContainerList) containerLists.nextElement(); Enumeration containers = theContainerList.getContainers(); while (containers.hasMoreElements()) { JahiaContainer theContainer = (JahiaContainer) containers.nextElement(); if (theContainer.getID() != thectnid) { Enumeration listInContainer = theContainer.getContainerLists(); while (listInContainer.hasMoreElements()) { JahiaContainer tmpContainer = logic_find_container_in_list( thectnid, listInContainer ); if (tmpContainer != null) { return tmpContainer; } } } else { return theContainer; } } } return null; } // end logic_find_container_in_list} // end JahiaContainersLogic
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -