KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dinamica > security > UpdateProfile


1 package dinamica.security;
2
3 import dinamica.*;
4 import javax.sql.DataSource JavaDoc;
5 import java.sql.*;
6
7 /**
8  * Update user profile.
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 UpdateProfile 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             //update prefs in DB
40
String JavaDoc sql = getSQL(getResource("update.sql"), inputParams);
41             Db db = getDb();
42             db.exec(sql);
43         
44             //reload new stylesheet
45
//reuse Login code
46
Login obj = (Login)getObject("dinamica.security.Login");
47             obj.getUserPrefs(db, inputParams);
48             
49         }
50         catch (Throwable JavaDoc e)
51         {
52             throw e;
53         }
54         finally
55         {
56             if (conn!=null)
57                 conn.close();
58         }
59         
60         return 0;
61         
62     }
63
64 }
65
Popular Tags