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

📄 jahiacontainerutilsdb.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return theList;    } // db_get_container_ids_in_container_list    /***        * loads all the fields ids of a specific container        *        * @param           contID              the container ID        * @return          a Vector of field IDs        *        * @exception       raises a JahiaException if a data access error occurs        * @exception       raises a JahiaException if cannot free resources        *        */    public Vector db_get_field_ids_in_container( int contID )    throws JahiaException    {        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        Vector theList = new Vector();        try {            String sqlQuery = "SELECT * FROM jahia_fields_data ";            sqlQuery += "WHERE ctnid_jahia_fields_data=" + contID + " ";            sqlQuery += "ORDER BY rank_jahia_fields_data, id_jahia_fields_data ASC";            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection(33);            stmt = dbConn.createStatement();              rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next()) {                theList.add( new Integer( rs.getInt( "id_jahia_fields_data" ) ) );            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_field_ids_in_container : " + se.getMessage();            JahiaConsole.println( "JahiaContainerUtilsDB", errorMsg + " -> BAILING OUT" );            throw new JahiaException(   "Cannot load containers from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                 JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_field_ids_in_container : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return theList;    } // db_get_field_ids_in_container    /***        * loads all containers definitions ids        *        * @return       a Vector of container definition ids        * @see          org.jahia.data.containers.JahiaContainerDefinition        *        * @exception    throws a critical JahiaException if a data access occurs        * @exception    throws a warning JahiaException if cannot free resources        *        */    public Vector db_get_all_container_definition_ids()    throws JahiaException    {        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        Vector theList = new Vector();        try {            String sqlQuery = "SELECT * FROM jahia_ctn_def";            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection(34);            stmt = dbConn.createStatement();            rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next()) {                theList.add( new Integer( rs.getInt( "id_jahia_ctn_def" ) ) );            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_container_definition_ids : " + se.getMessage() + " -> BAILING OUT";            JahiaConsole.println( "JahiaContainerUtilsDB", errorMsg );            throw new JahiaException(   "Cannot load definitions from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                 JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_all_container_definition_ids : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return theList;    } // end db_get_all_container_definition_ids    /***        * gets all containers id        *        * @return       a Vector of ids        *        * @exception   throws a critical JahiaException if SQL error        * @exception   throws a warning JahiaException if cannot free resources        *        */    public Vector db_get_all_containers_id()    throws JahiaException    {        Vector result = new Vector();        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        JahiaField theField = null;        Integer nb_to_insert;        try {            String sqlQuery = "SELECT id_jahia_ctn_entries FROM jahia_ctn_entries";            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection();            stmt = dbConn.createStatement();            rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next())            {                nb_to_insert = new Integer (rs.getInt("id_jahia_ctn_entries"));                result.addElement (nb_to_insert);            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_containers_id : " + se.getMessage();            JahiaConsole.println( "JahiaFieldsDB", errorMsg + " -> BAILING OUT" );            JahiaException je = new JahiaException(   "Cannot load containers from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.ERROR );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_all_containers_id : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return result;    } // end db_get_all_containers_id    /***        * gets all containers id for a given site        *        * @param int siteID        * @return a Vector of ids        *        * @exception   throws a critical JahiaException if SQL error        * @exception   throws a warning JahiaException if cannot free resources        *        */    public Vector db_get_all_containers_id(int siteID)    throws JahiaException    {        Vector result = new Vector();        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        Integer nb_to_insert;        try {            String sqlQuery = "SELECT id_jahia_ctn_entries FROM jahia_ctn_entries WHERE jahiaid_jahia_ctn_entries =" + siteID;            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection();            stmt = dbConn.createStatement();            rs = stmt.executeQuery( sqlQuery );            while (rs.next())            {                nb_to_insert = new Integer (rs.getInt("id_jahia_ctn_entries"));                result.add (nb_to_insert);            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_containers_id : " + se.getMessage();            JahiaConsole.println( "JahiaFieldsDB", errorMsg + " -> BAILING OUT" );            JahiaException je = new JahiaException(   "Cannot load containers from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.ERROR );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_all_containers_id : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return result;    } // end db_get_all_containers_id    /***        * return a Map of ACL ids for all containers of a given container list        * The key is the ctn id and the value is the acl id.        *        * @param int cListID        * @return Hashtable acls        *        * @exception   throws a critical JahiaException if SQL error        * @exception   throws a warning JahiaException if cannot free resources        *        */    public Hashtable db_get_all_containers_aclid(int cListID)    throws JahiaException    {        Hashtable acls = new Hashtable();        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        Integer nb_to_insert;        try {            String sqlQuery = "SELECT DISTINCT id_jahia_ctn_entries,rights_jahia_ctn_entries FROM jahia_ctn_entries WHERE listid_jahia_ctn_entries =" + cListID;            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection();            stmt = dbConn.createStatement();            rs = stmt.executeQuery( sqlQuery );						Integer ctnID = null;			Integer aclID = null;            while (rs.next())            {                ctnID = new Integer (rs.getInt("id_jahia_ctn_entries"));                aclID = new Integer (rs.getInt("rights_jahia_ctn_entries"));                acls.put(ctnID,aclID);            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_containers_id : " + se.getMessage();            JahiaConsole.println( "JahiaFieldsDB", errorMsg + " -> BAILING OUT" );            JahiaException je = new JahiaException(   "Cannot load containers from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.ERROR );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_all_containers_id : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return acls;    } // end db_get_all_containers_id    /***        * gets all acl for a site        * Used for site extraction        *        * @return       a Vector of ids        *        * @author NK        */    public Vector db_get_all_acls_id(int siteID)    throws JahiaException    {        Vector result = new Vector();        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        JahiaField theField = null;        Integer nb_to_insert;        try {            String sqlQuery = "SELECT DISTINCT rights_jahia_ctn_entries FROM jahia_ctn_entries "            +" WHERE jahiaid_jahia_ctn_entries="+siteID;            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection();            stmt = dbConn.createStatement();            rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next())            {                nb_to_insert = new Integer (rs.getInt("rights_jahia_ctn_entries"));                result.addElement (nb_to_insert);            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_acls_id(int siteID) : " + se.getMessage();            JahiaConsole.println( "JahiaContainerUtilsDB", errorMsg + " A" );            JahiaException je = new JahiaException(   "Cannot load containers from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.ERROR );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                JahiaConsole.println("JahiaContainerUtilsDB.db_get_all_acls_id","error freeing db connection");            }        }        try {            String sqlQuery = "SELECT DISTINCT jahia_ctn_lists.rights_jahia_ctn_lists FROM jahia_ctn_lists,jahia_ctn_def "            +"WHERE jahia_ctn_lists.ctndefid_jahia_ctn_lists ="            +"jahia_ctn_def.id_jahia_ctn_def AND jahia_ctn_def.jahiaid_jahia_ctn_def="+siteID;            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection();            stmt = dbConn.createStatement();            rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next())            {                nb_to_insert = new Integer (rs.getInt("rights_jahia_ctn_lists"));                result.addElement (nb_to_insert);            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_acls_id(int siteID) : " + se.getMessage();            JahiaConsole.println( "JahiaContainerUtilsDB", errorMsg + " -> B" );            JahiaException je = new JahiaException(   "Cannot load containers from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.ERROR );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                JahiaConsole.println("JahiaContainerUtilsDB.db_get_all_acls_id","error freeing db connection");            }        }        return result;    } // end db_get_all_containers_id} // end JahiaContainerUtilsDB

⌨️ 快捷键说明

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