📄 portletwidgetsdbserializer.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////--------------------------// PortletWidgetsDBSerializer//--------------------------// J閞鬽e B閐at 18.12.2000//--------------------------package org.jahia.layout;import java.sql.*; // ResultSetimport java.util.*; // Vectorimport org.jahia.utils.*; // JahiaConsoleimport org.jahia.registries.*; // ServicesRegistryimport org.jahia.exceptions.JahiaException; // Jahia Exceptionsimport org.jahia.services.database.*; // DataBase Services/** * This class takes care of serializing the various layout widgets to the Jahia * database system. * @author Jerome Bedat */public class PortletWidgetsDBSerializer { private static PortletWidgetsDBSerializer theObject = null; private DesktopBean theDesktop; private PortletBean thePortlet; private SkinBean theSkin; private int thePortletsCount; private int theDesktopsCount; /** * PortletWidgetsDBSerializer * * @author J閞鬽e B閐at * */ private PortletWidgetsDBSerializer() { JahiaConsole.println( "PortletWidgetsDBSerializer", "***** Starting the Portlets DataBase Manager *****" ); } // end constructor /** * getInstance * * @author J閞鬽e B閐at * */ public static synchronized PortletWidgetsDBSerializer getInstance() { if (theObject == null) { theObject = new PortletWidgetsDBSerializer(); } return theObject; } // end getInstance /** * load_portlet_skin * * @author J閞鬽e B閐at * */ public SkinBean load_portlet_skin(int theID) throws JahiaException { Connection dbConn = null; Statement stmt = null; ResultSet rs = null; try { String sqlQuery = "SELECT * FROM jahiatemplates_portet_skin WHERE (skin_id=" + theID + ")"; dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection(87); stmt = dbConn.createStatement(); rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt, sqlQuery ); theSkin = null; while (rs.next()) { theSkin = new SkinBean(rs.getInt("skin_id"), rs.getString("skin_name"), rs.getString("skin_url")); } } catch (SQLException se) { theSkin = null; String errorMsg = "Error in load_portlet_skin : " + se.getMessage(); JahiaConsole.println( "JahiaDBManager", errorMsg + " -> BAILING OUT" ); throw new JahiaException( "Cannot load portlet skin data from the database", errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL ); } finally { try { ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn); if ( stmt != null ) stmt.close(); //if ( rs != null ) rs.close(); } catch ( SQLException ex ) { JahiaException je = new JahiaException( "Cannot free resources", "load_portlet_skin : cannot free resources", JahiaException.DATABASE_ERROR, JahiaException.WARNING ); } } return theSkin; } // end load_portlet_skin /** * load_desktop_skin * * @author J閞鬽e B閐at * */ public SkinBean load_desktop_skin(int theID) throws JahiaException { Connection dbConn = null; Statement stmt = null; ResultSet rs = null; try { String sqlQuery = "SELECT * FROM jahiatemplates_desktop_skin WHERE (skin_id=" + theID + ")"; dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection(88); stmt = dbConn.createStatement(); rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt, sqlQuery ); theSkin = null; while (rs.next()) { theSkin = new SkinBean(rs.getInt("skin_id"), rs.getString("skin_name"), rs.getString("skin_url")); } } catch (SQLException se) { theSkin = null; String errorMsg = "Error in load_desktop_skin : " + se.getMessage(); JahiaConsole.println( "JahiaDBManager", errorMsg + " -> BAILING OUT" ); throw new JahiaException( "Cannot load desktop skin data from the database", errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL ); } finally { try { ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn); if ( stmt != null ) stmt.close(); //if ( rs != null ) rs.close(); } catch ( SQLException ex ) { JahiaException je = new JahiaException( "Cannot free resources", "load_desktop_skin : cannot free resources", JahiaException.DATABASE_ERROR, JahiaException.WARNING ); } } return theSkin; } // end load_desktop_skin}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -