01: package dinamica.security;
02:
03: import dinamica.*;
04: import javax.sql.DataSource;
05: import java.sql.*;
06:
07: /**
08: * Retrieve user profile record.
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 GetProfile 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: //get db channel
39: Db db = getDb();
40:
41: //get user profile
42: Recordset user = db.get(getSQL(
43: getResource("getrecord.sql"), inputParams));
44: user.next();
45:
46: publish("getrecord.sql", user);
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: }
|