KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > bizlogic > PortalCFGBL


1  /*
2  -- GeiNuke --
3 Copyright (c) 2005 by Roberto Sidoti [geinuke@users.sourceforge.net]
4  http://www.hostingjava.it/-geinuke/
5
6 This file is part of GeiNuke.
7
8     GeiNuke is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12
13     GeiNuke is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with GeiNuke; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */

22 package com.geinuke.bizlogic;
23
24 import java.sql.SQLException JavaDoc;
25
26 import com.geinuke.dao.PortalCFGDAO;
27 import com.geinuke.middle.IPortalCFGBL;
28 import com.geinuke.middle.ISessionBL;
29 import com.geinuke.middle.MiddleFactory;
30 import com.geinuke.util.collection.CachedBL;
31 import com.geinuke.vo.PortalCFGVO;
32 import com.geinuke.vo.SessionVO;
33 import com.geinuke.vo.TopicVO;
34
35
36 public class PortalCFGBL extends CachedBL implements IPortalCFGBL {
37         
38     public PortalCFGBL(){
39         
40     }
41     
42     
43     public PortalCFGVO getPortalCFG()throws BLException{
44         PortalCFGVO po=null;
45         if(portalCFGCache.containsKey("PortalCFGBL.getPortalCFG-")){
46             po=(PortalCFGVO)portalCFGCache.get("PortalCFGBL.getPortalCFG-");
47             return po;
48         }
49         try{
50             PortalCFGDAO dao=new PortalCFGDAO();
51             po=dao.getPortalCFG();
52         }catch(SQLException JavaDoc sqle){
53             throw new DBException(sqle.getMessage());
54         }catch(Throwable JavaDoc t){
55             throw new BLException(t.getMessage());
56         }
57         if(po!=null)
58             portalCFGCache.put("PortalCFGBL.getPortalCFG-",po,7200);
59         return po;
60     }
61     
62     public PortalCFGVO incSessionHits(SessionVO ses)throws BLException{
63         PortalCFGVO po=null;
64         SessionVO aux=null;
65         
66         try{
67             ISessionBL sbl=(ISessionBL)MiddleFactory.getBL("ISessionBL");
68             aux=sbl.getSessionById(ses );
69             PortalCFGDAO dao=new PortalCFGDAO();
70             if(portalCFGCache.containsKey("PortalCFGBL.incSessionHits-")){
71                 po=(PortalCFGVO)portalCFGCache.get("PortalCFGBL.incSessionHits-");
72             }
73             if(aux==null){
74                 portalCFGCache.clear();
75                 po=dao.getPortalCFG();
76                 po.setSessionHits(po.getSessionHits()+1);
77                 dao.updatePortalCFG(po);
78             }else if(po==null)
79                 po=dao.getPortalCFG();
80         }catch(SQLException JavaDoc sqle){
81             throw new DBException(sqle.getMessage());
82         }catch(Throwable JavaDoc t){
83             throw new BLException(t.getMessage());
84         }
85         if(po!=null)
86             portalCFGCache.put("PortalCFGBL.incSessionHits-",po,7200);
87         return po;
88     }
89     
90     public void updatePortalCFG(PortalCFGVO po)throws BLException{
91         portalCFGCache.clear();
92         try{
93             PortalCFGDAO dao=new PortalCFGDAO();
94             dao.updatePortalCFG(po);
95             
96         }catch(SQLException JavaDoc sqle){
97             throw new DBException(sqle.getMessage());
98         }catch(Throwable JavaDoc t){
99             throw new BLException(t.getMessage());
100         }
101         
102     }
103
104 }
105
Popular Tags