01: package dinamica.security;
02:
03: import dinamica.*;
04: import javax.sql.DataSource;
05: import java.sql.*;
06:
07: /**
08: * Update user profile.
09: * <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: /* (non-Javadoc)
18: * @see dinamica.GenericTransaction#service(dinamica.Recordset)
19: */
20: public int service(Recordset inputParams) throws Throwable {
21:
22: super .service(inputParams);
23:
24: //get security datasource
25: String jndiName = (String) getContext().getAttribute(
26: "dinamica.security.datasource");
27: if (jndiName == null)
28: throw new Throwable(
29: "Context attribute [dinamica.security.datasource] is null, check your security filter configuration.");
30:
31: //get datasource and DB connection
32: DataSource ds = Jndi.getDataSource(jndiName);
33: Connection conn = ds.getConnection();
34: this .setConnection(conn);
35:
36: try {
37:
38: //update prefs in DB
39: String sql = getSQL(getResource("update.sql"), inputParams);
40: Db db = getDb();
41: db.exec(sql);
42:
43: //reload new stylesheet
44: //reuse Login code
45: Login obj = (Login) getObject("dinamica.security.Login");
46: obj.getUserPrefs(db, inputParams);
47:
48: } catch (Throwable e) {
49: throw e;
50: } finally {
51: if (conn != null)
52: conn.close();
53: }
54:
55: return 0;
56:
57: }
58:
59: }
|