KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 package com.geinuke.bizlogic;
24
25 import java.sql.SQLException JavaDoc;
26 import java.util.ArrayList JavaDoc;
27
28 import com.geinuke.dao.SessionDAO;
29 import com.geinuke.middle.ISessionBL;
30 import com.geinuke.vo.SessionVO;
31
32
33
34 public class SessionBL implements ISessionBL {
35     
36     
37     public SessionBL(){
38         
39     }
40     
41         
42     public void insSession(SessionVO s)throws BLException{
43         
44         try{
45             SessionDAO dao=new SessionDAO();
46             dao.insertSession(s);
47             
48         }catch(SQLException JavaDoc sqle){
49             throw new DBException(sqle.getMessage());
50         }catch(Throwable JavaDoc t){
51             throw new BLException(t.getMessage());
52         }
53         
54     }
55     
56     public void updateSessions(SessionVO s)throws BLException{
57         
58         try{
59             SessionDAO dao=new SessionDAO();
60             dao.deleteExpiredSessions(s.getTime()- (10*1000*60) );
61             dao.deleteSession(s);
62             dao.insertSession(s);
63         }catch(SQLException JavaDoc sqle){
64             throw new DBException(sqle.getMessage());
65         }catch(Throwable JavaDoc t){
66             throw new BLException(t.getMessage());
67         }
68         
69     }
70     
71     
72     
73     public SessionVO getSessionById(SessionVO ses)throws BLException {
74         SessionVO s=null;
75         try{
76             SessionDAO dao=new SessionDAO();
77             s=dao.getSessionByID(ses);
78         }catch(SQLException JavaDoc sqle){
79             throw new DBException(sqle.getMessage());
80         }catch(Throwable JavaDoc t){
81             throw new BLException(t.getMessage());
82         }
83         return s;
84     }
85     
86     public ArrayList JavaDoc getSessionsByIdRole(int idr)throws BLException {
87         ArrayList JavaDoc list=null;
88         try{
89             SessionDAO dao=new SessionDAO();
90             list=dao.getSessionsByIdRole(idr);
91         }catch(SQLException JavaDoc sqle){
92             throw new DBException(sqle.getMessage());
93         }catch(Throwable JavaDoc t){
94             throw new BLException(t.getMessage());
95         }
96         if(list==null)
97             list=new ArrayList JavaDoc();
98         return list;
99     }
100     
101     public ArrayList JavaDoc getLastSessions(int idr,int maxDim)throws BLException {
102         ArrayList JavaDoc list=null;
103         try{
104             SessionDAO dao=new SessionDAO();
105             list=dao.getLastSessions(idr);
106         }catch(SQLException JavaDoc sqle){
107             throw new DBException(sqle.getMessage());
108         }catch(Throwable JavaDoc t){
109             throw new BLException(t.getMessage());
110         }
111         if(list==null)
112             list=new ArrayList JavaDoc();
113         else{
114             if(list.size()>maxDim)
115                 list=new ArrayList JavaDoc(list.subList(0,maxDim));
116         }
117         return list;
118     }
119     
120     
121     
122 }
123
Popular Tags