| 1 2 23 package com.geinuke.bizlogic; 24 25 import java.sql.SQLException ; 26 import java.util.ArrayList ; 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 sqle){ 49 throw new DBException(sqle.getMessage()); 50 }catch(Throwable 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 sqle){ 64 throw new DBException(sqle.getMessage()); 65 }catch(Throwable 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 sqle){ 79 throw new DBException(sqle.getMessage()); 80 }catch(Throwable t){ 81 throw new BLException(t.getMessage()); 82 } 83 return s; 84 } 85 86 public ArrayList getSessionsByIdRole(int idr)throws BLException { 87 ArrayList list=null; 88 try{ 89 SessionDAO dao=new SessionDAO(); 90 list=dao.getSessionsByIdRole(idr); 91 }catch(SQLException sqle){ 92 throw new DBException(sqle.getMessage()); 93 }catch(Throwable t){ 94 throw new BLException(t.getMessage()); 95 } 96 if(list==null) 97 list=new ArrayList (); 98 return list; 99 } 100 101 public ArrayList getLastSessions(int idr,int maxDim)throws BLException { 102 ArrayList list=null; 103 try{ 104 SessionDAO dao=new SessionDAO(); 105 list=dao.getLastSessions(idr); 106 }catch(SQLException sqle){ 107 throw new DBException(sqle.getMessage()); 108 }catch(Throwable t){ 109 throw new BLException(t.getMessage()); 110 } 111 if(list==null) 112 list=new ArrayList (); 113 else{ 114 if(list.size()>maxDim) 115 list=new ArrayList (list.subList(0,maxDim)); 116 } 117 return list; 118 } 119 120 121 122 } 123 | Popular Tags |