KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dinamica > security > GetProfile


1 package dinamica.security;
2
3 import dinamica.*;
4 import javax.sql.DataSource JavaDoc;
5 import java.sql.*;
6
7 /**
8  * Retrieve user profile record.
9  * <br><br>
10  * (c) 2004 Martin Cordova<br>
11  * This code is released under the LGPL license<br>
12  * Dinamica Framework - http://www.martincordova.com
13  * @author Martin Cordova (dinamica@martincordova.com)
14  * */

15 public class GetProfile extends GenericTransaction
16 {
17
18     /* (non-Javadoc)
19      * @see dinamica.GenericTransaction#service(dinamica.Recordset)
20      */

21     public int service(Recordset inputParams) throws Throwable JavaDoc
22     {
23
24         super.service(inputParams);
25
26         //get security datasource
27
String JavaDoc jndiName = (String JavaDoc)getContext().getAttribute("dinamica.security.datasource");
28         if (jndiName==null)
29             throw new Throwable JavaDoc("Context attribute [dinamica.security.datasource] is null, check your security filter configuration.");
30         
31         //get datasource and DB connection
32
DataSource JavaDoc ds = Jndi.getDataSource(jndiName);
33         Connection conn = ds.getConnection();
34         this.setConnection(conn);
35
36         try
37         {
38             
39             //get db channel
40
Db db = getDb();
41             
42             //get user profile
43
Recordset user = db.get(getSQL(getResource("getrecord.sql"), inputParams));
44             user.next();
45
46             //get style sheets
47
Recordset s = db.get(getSQL(getResource("styles.sql"), inputParams));
48
49             publish("getrecord.sql", user);
50             publish("styles.sql", s);
51             
52         }
53         catch (Throwable JavaDoc e)
54         {
55             throw e;
56         }
57         finally
58         {
59             if (conn!=null)
60                 conn.close();
61         }
62         
63         return 0;
64
65     }
66
67 }
68
Popular Tags