Source Code Cross Referenced for UserLoader.java in  » Groupware » hipergate » com » knowgate » acl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.acl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          Copyright (C) 2005  Know Gate S.L. All rights reserved.
003:                              C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005:          Redistribution and use in source and binary forms, with or without
006:          modification, are permitted provided that the following conditions
007:          are met:
008:
009:          1. Redistributions of source code must retain the above copyright
010:             notice, this list of conditions and the following disclaimer.
011:
012:          2. The end-user documentation included with the redistribution,
013:             if any, must include the following acknowledgment:
014:             "This product includes software parts from hipergate
015:             (http://www.hipergate.org/)."
016:             Alternately, this acknowledgment may appear in the software itself,
017:             if and wherever such third-party acknowledgments normally appear.
018:
019:          3. The name hipergate must not be used to endorse or promote products
020:             derived from this software without prior written permission.
021:             Products derived from this software may not be called hipergate,
022:             nor may hipergate appear in their name, without prior written
023:             permission.
024:
025:          This library is distributed in the hope that it will be useful,
026:          but WITHOUT ANY WARRANTY; without even the implied warranty of
027:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029:          You should have received a copy of hipergate License with this code;
030:          if not, visit http://www.hipergate.org or mail to info@hipergate.org
031:         */
032:
033:        package com.knowgate.acl;
034:
035:        import java.util.Map;
036:        import java.util.Date;
037:        import java.util.Arrays;
038:        import java.util.Iterator;
039:
040:        import java.sql.Types;
041:        import java.sql.Timestamp;
042:        import java.sql.Connection;
043:        import java.sql.SQLException;
044:        import java.sql.PreparedStatement;
045:
046:        import com.knowgate.acl.ACLUser;
047:        import com.knowgate.acl.ACLGroup;
048:        import com.knowgate.misc.Gadgets;
049:        import com.knowgate.debug.DebugFile;
050:        import com.knowgate.hipergate.datamodel.ImportLoader;
051:        import com.knowgate.hipergate.datamodel.ColumnList;
052:
053:        /**
054:         * <p>Load user data from a single source</p>
055:         * @author Sergio Montoro Ten
056:         * @version 1.0
057:         */
058:        public class UserLoader implements  ImportLoader {
059:
060:            private Object[] aValues;
061:
062:            private PreparedStatement oUserUpdt, oUserInsr, oGroupInsr;
063:            private int iLastDomainId;
064:            private String sLastGroupId, sLastGroupNm;
065:
066:            public UserLoader() {
067:                aValues = new Object[ColumnNames.length];
068:                for (int c = aValues.length - 1; c >= 0; c--)
069:                    aValues[c] = null;
070:                iLastDomainId = 0;
071:                sLastGroupId = "";
072:                sLastGroupNm = "";
073:            }
074:
075:            // ---------------------------------------------------------------------------
076:
077:            /**
078:             * Set all column values to null
079:             */
080:            public void setAllColumnsToNull() {
081:                if (DebugFile.trace) {
082:                    DebugFile
083:                            .writeln("Begin ContactLoader.setAllColumnsToNull()");
084:                    DebugFile.incIdent();
085:                }
086:
087:                for (int c = aValues.length - 1; c >= 0; c--)
088:                    aValues[c] = null;
089:
090:                if (DebugFile.trace) {
091:                    DebugFile.decIdent();
092:                    DebugFile
093:                            .writeln("End ContactLoader.setAllColumnsToNull()");
094:                }
095:            } // setAllColumnsToNull
096:
097:            // ---------------------------------------------------------------------------
098:
099:            /**
100:             * <p>Get column index at ColumnNames array given its name</p>
101:             * This method performs binary search assuming that ColumnNames is sorted in
102:             * ascending order
103:             * @param sColumnName String Column name (case insensitive)
104:             * @return int Column index or -1 if not found
105:             */
106:            public int getColumnIndex(String sColumnName) {
107:                int iIndex = Arrays.binarySearch(ColumnNames, sColumnName,
108:                        String.CASE_INSENSITIVE_ORDER);
109:                if (iIndex < 0)
110:                    iIndex = -1;
111:                return iIndex;
112:            }
113:
114:            // ---------------------------------------------------------------------------
115:
116:            public int columnCount() {
117:                return aValues.length;
118:            }
119:
120:            // ---------------------------------------------------------------------------
121:
122:            public String[] columnNames() throws IllegalStateException {
123:                return ColumnNames;
124:            }
125:
126:            // ---------------------------------------------------------------------------
127:
128:            /**
129:             * Put value for a given column
130:             * @param iColumnIndex Column index [0..getColumnCount()-1]
131:             * @param oValue Value for column
132:             * @throws ArrayIndexOutOfBoundsException
133:             */
134:            public void put(int iColumnIndex, Object oValue)
135:                    throws ArrayIndexOutOfBoundsException {
136:                aValues[iColumnIndex] = oValue;
137:            }
138:
139:            // ---------------------------------------------------------------------------
140:
141:            /**
142:             * <p>Put value for a given column</p>
143:             * If a previous value already exists then it is replaced
144:             * @param sColumnName Column name (case sensitive)
145:             * @param oValue Value for column
146:             * @throws ArrayIndexOutOfBoundsException
147:             */
148:            public void put(String sColumnName, Object oValue)
149:                    throws ArrayIndexOutOfBoundsException {
150:                int iColumnIndex = getColumnIndex(sColumnName.toLowerCase());
151:                if (-1 == iColumnIndex)
152:                    throw new ArrayIndexOutOfBoundsException(
153:                            "Cannot find column named " + sColumnName);
154:                aValues[iColumnIndex] = oValue;
155:            }
156:
157:            // ---------------------------------------------------------------------------
158:
159:            /**
160:             * Put all values from a map on their corresponding columns matching by name
161:             * @param oValues Map
162:             */
163:            public void putAll(Map oValues) {
164:                int iColumnIndex;
165:                String sColumnName;
166:                if (DebugFile.trace) {
167:                    DebugFile.writeln("Begin UserLoader.putAll()");
168:                    DebugFile.incIdent();
169:                }
170:                Iterator oIter = oValues.keySet().iterator();
171:                while (oIter.hasNext()) {
172:                    sColumnName = (String) oIter.next();
173:                    iColumnIndex = getColumnIndex(sColumnName.toLowerCase());
174:                    if (iColumnIndex > 0) {
175:                        Object oVal = oValues.get(sColumnName);
176:                        if (oVal == null)
177:                            aValues[iColumnIndex] = null;
178:                        else if (oVal.getClass().getName().startsWith("[L")) {
179:                            aValues[iColumnIndex] = java.lang.reflect.Array
180:                                    .get(oVal, 0);
181:                        } else {
182:                            aValues[iColumnIndex] = oVal;
183:                        }
184:                        if (DebugFile.trace)
185:                            DebugFile.writeln(sColumnName.toLowerCase() + "="
186:                                    + aValues[iColumnIndex]);
187:                    } else {
188:                        if (DebugFile.trace)
189:                            DebugFile.writeln(sColumnName + " not found");
190:                    }// fi (iColumnIndex)
191:                } // wend
192:                if (DebugFile.trace) {
193:                    DebugFile.decIdent();
194:                    DebugFile.writeln("End UserLoader.putAll()");
195:                }
196:            } // putAll
197:
198:            // ---------------------------------------------------------------------------
199:
200:            /**
201:             * Get column by index
202:             * @param iColumnIndex int Colunm index [0..getColumnCount()-1]
203:             * @return Object Column value
204:             * @throws ArrayIndexOutOfBoundsException
205:             */
206:            public Object get(int iColumnIndex)
207:                    throws ArrayIndexOutOfBoundsException {
208:                return aValues[iColumnIndex];
209:            } // get
210:
211:            // ---------------------------------------------------------------------------
212:
213:            /**
214:             * Get column by name
215:             * @param sColumnName String Column name (case sensitive)
216:             * @return Object Column value
217:             * @throws ArrayIndexOutOfBoundsException If no column with sucjh name was found
218:             */
219:            public Object get(String sColumnName)
220:                    throws ArrayIndexOutOfBoundsException {
221:                int iColumnIndex = getColumnIndex(sColumnName.toLowerCase());
222:                if (-1 == iColumnIndex)
223:                    throw new ArrayIndexOutOfBoundsException(
224:                            "Cannot find column named " + sColumnName);
225:                return aValues[iColumnIndex];
226:            }
227:
228:            // ---------------------------------------------------------------------------
229:
230:            private String getColNull(int iColIndex)
231:                    throws ArrayIndexOutOfBoundsException, ClassCastException {
232:                if (DebugFile.trace) {
233:                    if (iColIndex < 0 || iColIndex >= aValues.length)
234:                        throw new ArrayIndexOutOfBoundsException(
235:                                "UserLoader.getColNull() column index "
236:                                        + String.valueOf(iColIndex)
237:                                        + " must be in the range between 0 and "
238:                                        + String.valueOf(aValues.length));
239:                    DebugFile.writeln("UserLoader.getColNull("
240:                            + String.valueOf(iColIndex) + ") : "
241:                            + aValues[iColIndex]);
242:                }
243:                String sRetVal;
244:                if (null == aValues[iColIndex])
245:                    sRetVal = null;
246:                else {
247:                    try {
248:                        sRetVal = aValues[iColIndex].toString();
249:                    } catch (ClassCastException cce) {
250:                        if (aValues[iColIndex] == null)
251:                            throw new ClassCastException(
252:                                    "UserLoader.getColNull("
253:                                            + String.valueOf(iColIndex)
254:                                            + ") could not cast null to String");
255:                        else
256:                            throw new ClassCastException(
257:                                    "UserLoader.getColNull("
258:                                            + String.valueOf(iColIndex)
259:                                            + ") could not cast "
260:                                            + aValues[iColIndex].getClass()
261:                                                    .getName() + " "
262:                                            + aValues[iColIndex] + " to String");
263:                    }
264:                    if (sRetVal.length() == 0
265:                            || sRetVal.equalsIgnoreCase("null"))
266:                        sRetVal = null;
267:                }
268:                return sRetVal;
269:            } // getColNull
270:
271:            // ---------------------------------------------------------------------------
272:
273:            private static boolean test(int iInputValue, int iBitMask) {
274:                return (iInputValue & iBitMask) != 0;
275:            } // test
276:
277:            // ---------------------------------------------------------------------------
278:
279:            /**
280:             * <p>Prepare statements for execution</p>
281:             * This method needs to be called only once if the default constructor was used.<br>
282:             * If ContactLoader(Connection) constructor was used, there is no need to call prepare()
283:             * and a SQLException will be raised if the attempt is made.<br>
284:             * It is neccesary to call close() always for prepared instances as a failure
285:             * to do so will leave open cursors on the database causing it eventually to stop.
286:             * @param oConn Connection Open JDBC database connection
287:             * @param oColList ColumnList This parameter is ignored
288:             * @throws SQLException
289:             */
290:            public void prepare(Connection oConn, ColumnList oColList)
291:                    throws SQLException {
292:
293:                if (DebugFile.trace) {
294:                    DebugFile.writeln("Begin UserLoader.prepare()");
295:                    DebugFile.incIdent();
296:                }
297:
298:                oUserInsr = oConn
299:                        .prepareStatement("INSERT INTO k_users (dt_created,id_domain,tx_nickname,tx_pwd,tx_pwd_sign,bo_change_pwd,bo_searchable,bo_active,len_quota,max_quota,tp_account,id_account,dt_last_update,dt_last_visit,dt_cancel,tx_main_email,tx_alt_email,nm_user,tx_surname1,tx_surname2,tx_challenge,tx_reply,dt_pwd_expires,gu_category,gu_workarea,nm_company,de_title,id_gender,dt_birth,ny_age,marital_status,tx_education,icq_id,sn_passport,tp_passport,tx_comments,gu_user) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
300:                oUserUpdt = oConn
301:                        .prepareStatement("UPDATE k_users SET id_domain=?,tx_nickname=?,tx_pwd=?,tx_pwd_sign=?,bo_change_pwd=?,bo_searchable=?,bo_active=?,len_quota=?,max_quota=?,tp_account=?,id_account=?,dt_last_update=?,dt_last_visit=?,dt_cancel=?,tx_main_email=?,tx_alt_email=?,nm_user=?,tx_surname1=?,tx_surname2=?,tx_challenge=?,tx_reply=?,dt_pwd_expires=?,gu_category=?,gu_workarea=?,nm_company=?,de_title=?,id_gender=?,dt_birth=?,ny_age=?,marital_status=?,tx_education=?,icq_id=?,sn_passport=?,tp_passport=?,tx_comments=? WHERE gu_user=?");
302:                oGroupInsr = oConn
303:                        .prepareStatement("INSERT INTO k_x_group_user (gu_user,gu_acl_group) VALUES(?,?)");
304:
305:                if (DebugFile.trace) {
306:                    DebugFile.decIdent();
307:                    DebugFile.writeln("End UserLoader.prepare()");
308:                }
309:            }
310:
311:            // ---------------------------------------------------------------------------
312:
313:            public void close() throws SQLException {
314:                if (null != oGroupInsr) {
315:                    oGroupInsr.close();
316:                    oGroupInsr = null;
317:                }
318:                if (null != oUserUpdt) {
319:                    oUserUpdt.close();
320:                    oUserUpdt = null;
321:                }
322:                if (null != oUserInsr) {
323:                    oUserInsr.close();
324:                    oUserInsr = null;
325:                }
326:            }
327:
328:            // ---------------------------------------------------------------------------
329:
330:            public void store(Connection oConn, String sWorkArea, int iFlags)
331:                    throws SQLException, IllegalArgumentException,
332:                    NullPointerException, ClassCastException,
333:                    NumberFormatException {
334:
335:                if (oUserInsr == null || oUserUpdt == null)
336:                    throw new SQLException(
337:                            "Invalid command sequece. Must call UserLoader.prepare() before UserLoader.store()");
338:
339:                if (!test(iFlags, MODE_APPEND) && !test(iFlags, MODE_UPDATE))
340:                    throw new IllegalArgumentException(
341:                            "UserLoader.store() Flags bitmask must contain either MODE_APPEND, MODE_UPDATE or both");
342:
343:                if (null == getColNull(id_domain))
344:                    throw new NullPointerException(
345:                            "UserLoader.store() id_domain cannot be null");
346:
347:                if (DebugFile.trace) {
348:                    DebugFile.writeln("Begin UserLoader.store([Connection],"
349:                            + sWorkArea + "," + String.valueOf(iFlags) + ")");
350:                    DebugFile.incIdent();
351:                    StringBuffer oRow = new StringBuffer();
352:                    oRow.append('{');
353:                    oRow.append(ColumnNames[0] + "=");
354:                    oRow.append(aValues[0] == null ? "null" : aValues[0]);
355:                    for (int d = 1; d < aValues.length; d++) {
356:                        oRow.append("," + ColumnNames[d] + "=");
357:                        oRow.append(aValues[d] == null ? "null" : aValues[d]);
358:                    } // next
359:                    oRow.append('}');
360:                    DebugFile.writeln(oRow.toString());
361:                }
362:
363:                int iAffected = 0;
364:                Timestamp tsNow = new Timestamp(new Date().getTime());
365:                int iDomainId = Integer.parseInt(get(id_domain).toString());
366:
367:                if (null == get(gu_workarea)) {
368:                    if (DebugFile.trace)
369:                        DebugFile.writeln("setting workarea to " + sWorkArea);
370:                    put(gu_workarea, sWorkArea);
371:                } else {
372:                    if (DebugFile.trace)
373:                        DebugFile.writeln("workarea for current record is "
374:                                + getColNull(gu_workarea));
375:                }
376:
377:                if (null == getColNull(gu_user)
378:                        && null != getColNull(tx_nickname)) {
379:                    put(gu_user, ACLUser.getIdFromNick(oConn, iDomainId,
380:                            getColNull(tx_nickname)));
381:                }
382:
383:                if (test(iFlags, MODE_UPDATE) && null != getColNull(gu_user)) {
384:                    oUserUpdt.setInt(1, iDomainId);
385:                    oUserUpdt.setObject(2, get(tx_nickname), Types.VARCHAR);
386:                    oUserUpdt.setObject(3, get(tx_pwd), Types.VARCHAR);
387:                    oUserUpdt.setObject(4, get(tx_pwd_sign), Types.VARCHAR);
388:                    oUserUpdt.setObject(5, get(bo_change_pwd), Types.SMALLINT);
389:                    oUserUpdt.setObject(6, get(bo_searchable), Types.SMALLINT);
390:                    oUserUpdt.setObject(7, get(bo_active), Types.SMALLINT);
391:                    oUserUpdt.setObject(8, get(len_quota), Types.DECIMAL);
392:                    oUserUpdt.setObject(9, get(max_quota), Types.DECIMAL);
393:                    oUserUpdt.setObject(10, get(tp_account), Types.CHAR);
394:                    oUserUpdt.setObject(11, get(id_account), Types.CHAR);
395:                    if (aValues[dt_last_update] == null)
396:                        oUserUpdt.setTimestamp(12, tsNow);
397:                    else
398:                        oUserUpdt.setObject(12, aValues[dt_last_update],
399:                                Types.TIMESTAMP);
400:                    if (aValues[dt_last_visit] == null)
401:                        oUserUpdt.setNull(13, Types.TIMESTAMP);
402:                    else
403:                        oUserUpdt.setObject(13, aValues[dt_last_visit],
404:                                Types.TIMESTAMP);
405:                    if (aValues[dt_cancel] == null)
406:                        oUserUpdt.setNull(14, Types.TIMESTAMP);
407:                    else
408:                        oUserUpdt.setObject(14, aValues[dt_cancel],
409:                                Types.TIMESTAMP);
410:                    oUserUpdt.setObject(15, get(tx_main_email), Types.VARCHAR);
411:                    oUserUpdt.setObject(16, get(tx_alt_email), Types.VARCHAR);
412:                    oUserUpdt.setObject(17, get(nm_user), Types.VARCHAR);
413:                    oUserUpdt.setObject(18, get(tx_surname1), Types.VARCHAR);
414:                    oUserUpdt.setObject(19, get(tx_surname2), Types.VARCHAR);
415:                    oUserUpdt.setObject(20, get(tx_challenge), Types.VARCHAR);
416:                    oUserUpdt.setObject(21, get(tx_reply), Types.VARCHAR);
417:                    if (aValues[dt_pwd_expires] == null)
418:                        oUserUpdt.setNull(22, Types.TIMESTAMP);
419:                    else
420:                        oUserUpdt.setObject(22, aValues[dt_pwd_expires],
421:                                Types.TIMESTAMP);
422:                    oUserUpdt.setObject(23, get(gu_category), Types.CHAR);
423:                    oUserUpdt.setObject(24, get(gu_workarea), Types.CHAR);
424:                    oUserUpdt.setObject(25, get(nm_company), Types.VARCHAR);
425:                    oUserUpdt.setObject(26, get(de_title), Types.VARCHAR);
426:                    oUserUpdt.setObject(27, get(id_gender), Types.CHAR);
427:                    if (aValues[dt_birth] == null)
428:                        oUserUpdt.setNull(28, Types.TIMESTAMP);
429:                    else
430:                        oUserUpdt.setObject(28, aValues[dt_birth],
431:                                Types.TIMESTAMP);
432:                    oUserUpdt.setObject(29, get(ny_age), Types.SMALLINT);
433:                    oUserUpdt.setObject(30, get(marital_status), Types.CHAR);
434:                    oUserUpdt.setObject(31, get(tx_education), Types.VARCHAR);
435:                    oUserUpdt.setObject(32, get(icq_id), Types.VARCHAR);
436:                    oUserUpdt.setObject(33, get(sn_passport), Types.VARCHAR);
437:                    oUserUpdt.setObject(34, get(tp_passport), Types.VARCHAR);
438:                    oUserUpdt.setObject(35, get(tx_comments), Types.VARCHAR);
439:                    oUserUpdt.setString(36, getColNull(gu_user));
440:                    iAffected = oUserUpdt.executeUpdate();
441:                }
442:
443:                if (0 == iAffected && test(iFlags, MODE_APPEND)) {
444:                    aValues[gu_user] = Gadgets.generateUUID();
445:                    oUserInsr.setTimestamp(1, tsNow);
446:                    oUserInsr.setInt(2, iDomainId);
447:                    oUserInsr.setObject(3, get(tx_nickname), Types.VARCHAR);
448:                    oUserInsr.setObject(4, get(tx_pwd), Types.VARCHAR);
449:                    oUserInsr.setObject(5, get(tx_pwd_sign), Types.VARCHAR);
450:                    oUserInsr.setObject(6, get(bo_change_pwd), Types.SMALLINT);
451:                    oUserInsr.setObject(7, get(bo_searchable), Types.SMALLINT);
452:                    oUserInsr.setObject(8, get(bo_active), Types.SMALLINT);
453:                    oUserInsr.setObject(9, get(len_quota), Types.DECIMAL);
454:                    oUserInsr.setObject(10, get(max_quota), Types.DECIMAL);
455:                    oUserInsr.setObject(11, get(tp_account), Types.CHAR);
456:                    oUserInsr.setObject(12, get(id_account), Types.CHAR);
457:                    if (aValues[dt_last_update] == null)
458:                        oUserInsr.setTimestamp(13, tsNow);
459:                    else
460:                        oUserInsr.setObject(13, aValues[dt_last_update],
461:                                Types.TIMESTAMP);
462:                    if (aValues[dt_last_visit] == null)
463:                        oUserInsr.setNull(14, Types.TIMESTAMP);
464:                    else
465:                        oUserInsr.setObject(14, aValues[dt_last_visit],
466:                                Types.TIMESTAMP);
467:                    if (aValues[dt_cancel] == null)
468:                        oUserInsr.setNull(15, Types.TIMESTAMP);
469:                    else
470:                        oUserInsr.setObject(15, aValues[dt_cancel],
471:                                Types.TIMESTAMP);
472:                    oUserInsr.setObject(16, get(tx_main_email), Types.VARCHAR);
473:                    oUserInsr.setObject(17, get(tx_alt_email), Types.VARCHAR);
474:                    oUserInsr.setObject(18, get(nm_user), Types.VARCHAR);
475:                    oUserInsr.setObject(19, get(tx_surname1), Types.VARCHAR);
476:                    oUserInsr.setObject(20, get(tx_surname2), Types.VARCHAR);
477:                    oUserInsr.setObject(21, get(tx_challenge), Types.VARCHAR);
478:                    oUserInsr.setObject(22, get(tx_reply), Types.VARCHAR);
479:                    if (aValues[dt_pwd_expires] == null)
480:                        oUserInsr.setNull(23, Types.TIMESTAMP);
481:                    else
482:                        oUserInsr.setObject(23, aValues[dt_pwd_expires],
483:                                Types.TIMESTAMP);
484:                    oUserInsr.setObject(24, get(gu_category), Types.CHAR);
485:                    oUserInsr.setObject(25, get(gu_workarea), Types.CHAR);
486:                    oUserInsr.setObject(26, get(nm_company), Types.VARCHAR);
487:                    oUserInsr.setObject(27, get(de_title), Types.VARCHAR);
488:                    oUserInsr.setObject(28, get(id_gender), Types.CHAR);
489:                    if (aValues[dt_birth] == null)
490:                        oUserInsr.setNull(29, Types.TIMESTAMP);
491:                    else
492:                        oUserInsr.setObject(29, aValues[dt_birth],
493:                                Types.TIMESTAMP);
494:                    oUserInsr.setObject(30, get(ny_age), Types.SMALLINT);
495:                    oUserInsr.setObject(31, get(marital_status), Types.CHAR);
496:                    oUserInsr.setObject(32, get(tx_education), Types.VARCHAR);
497:                    oUserInsr.setObject(33, get(icq_id), Types.VARCHAR);
498:                    oUserInsr.setObject(34, get(sn_passport), Types.VARCHAR);
499:                    oUserInsr.setObject(35, get(tp_passport), Types.VARCHAR);
500:                    oUserInsr.setObject(36, get(tx_comments), Types.VARCHAR);
501:                    oUserInsr.setString(37, getColNull(gu_user));
502:                    oUserInsr.execute();
503:                }
504:
505:                if (null == aValues[gu_acl_group]
506:                        && null != aValues[nm_acl_group]) {
507:                    if (iDomainId == iLastDomainId
508:                            && sLastGroupNm.equals(aValues[nm_acl_group])) {
509:                        put(gu_acl_group, sLastGroupId);
510:                    } else {
511:                        put(gu_acl_group, ACLGroup.getIdFromName(oConn,
512:                                iDomainId, getColNull(nm_acl_group)));
513:                        iLastDomainId = iDomainId;
514:                        sLastGroupNm = getColNull(nm_acl_group);
515:                        sLastGroupId = getColNull(gu_acl_group);
516:                    }
517:                }
518:
519:                if (null != aValues[gu_acl_group]) {
520:                    oGroupInsr.setString(1, getColNull(gu_user));
521:                    oGroupInsr.setString(1, getColNull(gu_acl_group));
522:                    try {
523:                        oGroupInsr.execute();
524:                    } catch (SQLException ignore) {
525:                        if (DebugFile.trace)
526:                            DebugFile.writeln("UserLoader.store() User "
527:                                    + getColNull(tx_nickname) + "("
528:                                    + getColNull(gu_user)
529:                                    + ") already exists at group "
530:                                    + getColNull(nm_acl_group) + "("
531:                                    + getColNull(gu_acl_group) + ")");
532:                    }
533:                } // fi
534:
535:                if (DebugFile.trace) {
536:                    DebugFile.decIdent();
537:                    DebugFile.writeln("End UserLoader.store()");
538:                }
539:            } // store
540:
541:            // ---------------------------------------------------------------------------
542:
543:            // Keep this list sorted
544:            private static final String[] ColumnNames = { "", "bo_active",
545:                    "bo_change_pwd", "bo_searchable", "de_title", "dt_birth",
546:                    "dt_cancel", "dt_created", "dt_last_update",
547:                    "dt_last_visit", "dt_pwd_expires", "gu_acl_group",
548:                    "gu_category", "gu_user", "gu_workarea", "icq_id",
549:                    "id_account", "id_domain", "id_gender", "len_quota",
550:                    "marital_status", "max_quota", "nm_acl_group",
551:                    "nm_company", "nm_user", "nm_workarea", "ny_age",
552:                    "sn_passport", "tp_account", "tp_passport", "tx_alt_email",
553:                    "tx_challenge", "tx_comments", "tx_education",
554:                    "tx_main_email", "tx_nickname", "tx_pwd", "tx_pwd_sign",
555:                    "tx_reply", "tx_surname1", "tx_surname2" };
556:
557:            // Keep these column indexes in sync with ColumnNames array
558:            public static int bo_active = 1;
559:            public static int bo_change_pwd = 2;
560:            public static int bo_searchable = 3;
561:            public static int de_title = 4;
562:            public static int dt_birth = 5;
563:            public static int dt_cancel = 6;
564:            public static int dt_created = 7;
565:            public static int dt_last_update = 8;
566:            public static int dt_last_visit = 9;
567:            public static int dt_pwd_expires = 10;
568:            public static int gu_acl_group = 11;
569:            public static int gu_category = 12;
570:            public static int gu_user = 13;
571:            public static int gu_workarea = 14;
572:            public static int icq_id = 15;
573:            public static int id_account = 16;
574:            public static int id_domain = 17;
575:            public static int id_gender = 18;
576:            public static int len_quota = 19;
577:            public static int marital_status = 20;
578:            public static int max_quota = 21;
579:            public static int nm_acl_group = 22;
580:            public static int nm_company = 23;
581:            public static int nm_user = 24;
582:            public static int nm_workarea = 25;
583:            public static int ny_age = 26;
584:            public static int sn_passport = 27;
585:            public static int tp_account = 28;
586:            public static int tp_passport = 29;
587:            public static int tx_alt_email = 30;
588:            public static int tx_challenge = 31;
589:            public static int tx_comments = 32;
590:            public static int tx_education = 33;
591:            public static int tx_main_email = 34;
592:            public static int tx_nickname = 35;
593:            public static int tx_pwd = 36;
594:            public static int tx_pwd_sign = 37;
595:            public static int tx_reply = 38;
596:            public static int tx_surname1 = 39;
597:            public static int tx_surname2 = 40;
598:
599:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.