KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > transactions > security > InsertUser


1 package transactions.security;
2
3 import dinamica.*;
4
5 /**
6  * Insert user record and its associated application roles
7  * <br><br>
8  * Creation date: 5/03/2004<br>
9  * Last Update: 5/03/2004<br>
10  * (c) 2004 Martin Cordova<br>
11  * This code is released under the LGPL license<br>
12  * @author Martin Cordova (dinamica@martincordova.com)
13  * */

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

20     public int service(Recordset inputParams) throws Throwable JavaDoc
21     {
22
23         int rc = super.service(inputParams);
24                 
25         //get sql template for insert-user
26
String JavaDoc sql = getResource("insert.sql");
27         
28         //generate sql for insert-user
29
sql = this.getSQL(sql, inputParams);
30         
31         //get db connection
32
Db db = getDb();
33         
34         //insert user
35
db.exec(sql);
36
37         //get identity value
38
Recordset rsId = db.get("select @@identity user_id");
39         rsId.next();
40
41         //insert into password history table
42
sql = getResource("insert-passlog.sql");
43         sql = this.getSQL(sql, inputParams);
44         sql = this.getSQL(sql, rsId);
45         db.exec(sql);
46         
47         //insert roles using utility reusable object
48
sql = getResource("insert-roles.sql");
49         sql = this.getSQL(sql, rsId);
50         InsertRoles r = (InsertRoles)getObject("transactions.security.InsertRoles");
51         r.saveRoles(sql);
52         
53         return rc;
54         
55     }
56
57 }
58
Popular Tags