Source Code Cross Referenced for CmsUpdateDBCmsUsers.java in  » Content-Management-System » opencms » org » opencms » setup » update6to7 » oracle » 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 » Content Management System » opencms » org.opencms.setup.update6to7.oracle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src-setup/org/opencms/setup/update6to7/oracle/CmsUpdateDBCmsUsers.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:48 $
004:         * Version: $Revision: 1.2 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.setup.update6to7.oracle;
033:
034:        import org.opencms.db.oracle.CmsUserDriver;
035:        import org.opencms.setup.CmsSetupDBWrapper;
036:        import org.opencms.setup.CmsSetupDb;
037:        import org.opencms.util.CmsDataTypeUtil;
038:
039:        import java.io.IOException;
040:        import java.io.OutputStream;
041:        import java.sql.SQLException;
042:        import java.util.ArrayList;
043:        import java.util.HashMap;
044:        import java.util.Iterator;
045:        import java.util.List;
046:
047:        /**
048:         * Oracle implementation of the generic update class for the Users.<p>
049:         *
050:         * @author Roland Metzler
051:         * @author Peter Bonrad
052:         *
053:         * @version $Revision: 1.2 $
054:         * 
055:         * @since 7.0.0
056:         */
057:        public class CmsUpdateDBCmsUsers extends
058:                org.opencms.setup.update6to7.generic.CmsUpdateDBCmsUsers {
059:
060:            /** Constant for the query to insert the new user data into the new table CMS_USERDATA.<p> */
061:            private static final String QUERY_ORACLE_USERDATA_UPDATE = "Q_ORACLE_USERDATA_UPDATE";
062:
063:            /** Constant for the SQL query properties.<p> */
064:            private static final String QUERY_PROPERTY_FILE = "oracle/cms_users_queries.properties";
065:
066:            /** Constant for the replacement in the sql query. */
067:            private static final String REPLACEMENT_TABLEINDEX_SPACE = "${indexTablespace}";
068:
069:            /**
070:             * Constructor.<p>
071:             * 
072:             * @throws IOException if the sql queries properties file could not be read
073:             */
074:            public CmsUpdateDBCmsUsers() throws IOException {
075:
076:                super ();
077:                loadQueryProperties(QUERY_PROPERTIES_PREFIX
078:                        + QUERY_PROPERTY_FILE);
079:            }
080:
081:            /**
082:             * @see org.opencms.setup.update6to7.generic.CmsUpdateDBCmsUsers#createUserDataTable(org.opencms.setup.CmsSetupDb)
083:             */
084:            protected void createUserDataTable(CmsSetupDb dbCon)
085:                    throws SQLException {
086:
087:                String indexTablespace = (String) m_poolData
088:                        .get("indexTablespace");
089:
090:                HashMap replacer = new HashMap();
091:                replacer.put(REPLACEMENT_TABLEINDEX_SPACE, indexTablespace);
092:
093:                String createStatement = readQuery(QUERY_CREATE_TABLE_USERDATA);
094:                dbCon.updateSqlStatement(createStatement, replacer, null);
095:
096:                // create indices
097:                List indexElements = new ArrayList();
098:                indexElements.add("CMS_USERDATA_01_IDX_INDEX");
099:                indexElements.add("CMS_USERDATA_02_IDX_INDEX");
100:
101:                Iterator iter = indexElements.iterator();
102:                while (iter.hasNext()) {
103:                    String stmt = readQuery((String) iter.next());
104:
105:                    try {
106:
107:                        // Create the index
108:                        dbCon.updateSqlStatement(stmt, replacer, null);
109:                    } catch (SQLException e) {
110:                        e.printStackTrace();
111:                    }
112:                }
113:            }
114:
115:            /**
116:             * @see org.opencms.setup.update6to7.generic.CmsUpdateDBCmsUsers#writeUserInfo(org.opencms.setup.CmsSetupDb, java.lang.String, java.lang.String, java.lang.Object)
117:             */
118:            protected void writeUserInfo(CmsSetupDb dbCon, String id,
119:                    String key, Object value) {
120:
121:                String query = readQuery(QUERY_INSERT_CMS_USERDATA);
122:
123:                try {
124:                    // Generate the list of parameters to add into the user info table
125:                    List params = new ArrayList();
126:                    params.add(id);
127:                    params.add(key);
128:                    params.add(value.getClass().getName());
129:
130:                    dbCon.updateSqlStatement(query, null, params);
131:                } catch (SQLException e) {
132:                    e.printStackTrace();
133:                }
134:
135:                // update user_info in this special way because of using blob
136:
137:                boolean wasInTransaction = false;
138:
139:                CmsSetupDBWrapper db = null;
140:
141:                try {
142:
143:                    wasInTransaction = !dbCon.getConnection().getAutoCommit();
144:                    if (!wasInTransaction) {
145:                        dbCon.getConnection().setAutoCommit(false);
146:                    }
147:
148:                    String stmt = readQuery(QUERY_ORACLE_USERDATA_UPDATE);
149:
150:                    // Generate the list of parameters to add into the user info table
151:                    List params = new ArrayList();
152:                    params.add(id);
153:                    params.add(key);
154:
155:                    db = dbCon.executeSqlStatement(stmt, null, params);
156:                    if (db.getResultSet().next()) {
157:
158:                        // write serialized user info 
159:                        OutputStream output = CmsUserDriver
160:                                .getOutputStreamFromBlob(db.getResultSet(),
161:                                        "DATA_VALUE");
162:                        output.write(CmsDataTypeUtil.dataSerialize(value));
163:                        output.close();
164:
165:                    } else {
166:                        System.out.println("Could not insert blob");
167:                    }
168:
169:                    if (!wasInTransaction) {
170:                        CmsSetupDBWrapper db2 = null;
171:                        try {
172:                            String commit = readQuery("Q_COMMIT");
173:                            db2 = dbCon.executeSqlStatement(commit, null);
174:                        } finally {
175:                            if (db2 != null) {
176:                                db2.close();
177:                            }
178:                        }
179:                    }
180:
181:                } catch (Exception e) {
182:                    e.printStackTrace();
183:                } finally {
184:
185:                    // close result set
186:                    if (db != null) {
187:                        db.close();
188:                    }
189:
190:                    // rollback
191:                    CmsSetupDBWrapper db2 = null;
192:                    try {
193:                        if (!wasInTransaction) {
194:                            String rollback = readQuery("Q_ROLLBACK");
195:                            db2 = dbCon.executeSqlStatement(rollback, null);
196:                        }
197:                    } catch (Exception e) {
198:                        e.printStackTrace();
199:                    } finally {
200:                        if (db2 != null) {
201:                            db2.close();
202:                        }
203:                    }
204:
205:                    // set auto commit back to original value
206:                    try {
207:                        if (!wasInTransaction) {
208:                            dbCon.getConnection().setAutoCommit(true);
209:                        }
210:                    } catch (Exception e) {
211:                        e.printStackTrace();
212:                    }
213:                }
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.