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


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src-setup/org/opencms/setup/update6to7/generic/CmsUpdateDBUpdateOU.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:35 $
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.generic;
033:
034:        import org.opencms.setup.CmsSetupDb;
035:        import org.opencms.setup.update6to7.A_CmsUpdateDBPart;
036:
037:        import java.io.IOException;
038:        import java.sql.SQLException;
039:        import java.util.HashMap;
040:        import java.util.Map;
041:
042:        /**
043:         * This class upgrades the database tables containing new OU columns.<p>
044:         * 
045:         * These tables are
046:         * cms_groups
047:         * cms_history_principals
048:         * cms_history_projects
049:         * cms_projects
050:         * cms_users
051:         * 
052:         * @author Roland Metzler
053:         * 
054:         * @version $Revision: 1.2 $ 
055:         * 
056:         * @since 7.0.0
057:         */
058:        public class CmsUpdateDBUpdateOU extends A_CmsUpdateDBPart {
059:
060:            /** Constant for the GROUP_OU column.<p> */
061:            protected static final String GROUP_OU_COLUMN = "GROUP_OU";
062:
063:            /** Constant for the PROJECT_OU column.<p> */
064:            protected static final String PROJECT_OU_COLUMN = "PROJECT_OU";
065:
066:            /** Constant for the query that adds the ous to the table.<p> */
067:            protected static final String QUERY_ADD_OUS_TO_TABLE = "Q_ADD_OUS_TO_TABLE";
068:
069:            /** Constant for the alteration of the table.<p> */
070:            protected static final String QUERY_KEY_ALTER_TABLE = "Q_ALTER_TABLE_ADD_OU_COLUMN";
071:
072:            /** Constant for the replacement in the SQL query for the columnname.<p> */
073:            protected static final String REPLACEMENT_COLUMNNAME = "${columnname}";
074:
075:            /** Constant for the replacement in the SQL query for the tablename.<p> */
076:            protected static final String REPLACEMENT_TABLENAME = "${tablename}";
077:
078:            /** Constant for the CMS_BACKUP_PROJECTS table.<p> */
079:            protected static final String TABLE_BACKUP_PROJECTS = "CMS_BACKUP_PROJECTS";
080:
081:            /** Constant for the CMS_GROUPS table.<p> */
082:            protected static final String TABLE_CMS_GROUPS = "CMS_GROUPS";
083:
084:            /** Constant for the CMS_USERS table.<p> */
085:            protected static final String TABLE_CMS_USERS = "CMS_USERS";
086:
087:            /** Constant for the CMS_PROJECTS table.<p> */
088:            protected static final String TABLE_PROJECTS = "CMS_PROJECTS";
089:
090:            /** Constant for the USER_OU column.<p> */
091:            protected static final String USER_OU_COLUMN = "USER_OU";
092:
093:            /** Constant for the SQL query properties.<p> */
094:            private static final String QUERY_PROPERTY_FILE = "generic/cms_ou_query.properties";
095:
096:            /**
097:             * Constructor.<p>
098:             * 
099:             * @throws IOException if the sql queries properties file could not be read
100:             */
101:            public CmsUpdateDBUpdateOU() throws IOException {
102:
103:                super ();
104:                loadQueryProperties(QUERY_PROPERTIES_PREFIX
105:                        + QUERY_PROPERTY_FILE);
106:            }
107:
108:            /**
109:             * Checks if the column USER_OU is found in the resultset.<p>
110:             * 
111:             * @param dbCon the db connection interface
112:             * @param table the table to check
113:             * @param ouColumn the type of OU to find (e.g. USER_OU or GROUP_OU)
114:             * 
115:             * @return true if the column is in the result set, false if not
116:             */
117:            protected boolean findOUColumn(CmsSetupDb dbCon, String table,
118:                    String ouColumn) {
119:
120:                System.out.println(new Exception().getStackTrace()[0]
121:                        .toString());
122:                return dbCon.hasTableOrColumn(table, ouColumn);
123:            }
124:
125:            /**
126:             * @see org.opencms.setup.update6to7.A_CmsUpdateDBPart#internalExecute(org.opencms.setup.CmsSetupDb)
127:             */
128:            protected void internalExecute(CmsSetupDb dbCon) {
129:
130:                System.out.println(new Exception().getStackTrace()[0]
131:                        .toString());
132:
133:                updateOUs(dbCon, TABLE_CMS_USERS, USER_OU_COLUMN);
134:                updateOUs(dbCon, TABLE_CMS_GROUPS, GROUP_OU_COLUMN);
135:                updateOUs(dbCon, TABLE_PROJECTS, PROJECT_OU_COLUMN);
136:                updateOUs(dbCon, TABLE_BACKUP_PROJECTS, PROJECT_OU_COLUMN);
137:            }
138:
139:            /**
140:             * Updates the database tables with the new OUs if necessary for the given table.<p>
141:             * 
142:             * @param dbCon the db connection interface
143:             * @param table the table to update
144:             * @param ouColumn the column to insert
145:             * 
146:             * @return true if everything worked fine, false if not
147:             */
148:            protected int updateOUs(CmsSetupDb dbCon, String table,
149:                    String ouColumn) {
150:
151:                System.out.println(new Exception().getStackTrace()[0]
152:                        .toString());
153:                int result = 1;
154:                try {
155:
156:                    if (!findOUColumn(dbCon, table, ouColumn)) {
157:                        // Alter the table and add the OUs
158:                        Map replacements = new HashMap();
159:                        replacements.put(REPLACEMENT_TABLENAME, table);
160:                        replacements.put(REPLACEMENT_COLUMNNAME, ouColumn);
161:                        String alterQuery = readQuery(QUERY_KEY_ALTER_TABLE);
162:
163:                        // Update the database and alter the table to add the OUs
164:                        dbCon
165:                                .updateSqlStatement(alterQuery, replacements,
166:                                        null);
167:
168:                        // Insert the value '/' into the OUs
169:                        String insertQuery = readQuery(QUERY_ADD_OUS_TO_TABLE);
170:                        dbCon.updateSqlStatement(insertQuery, replacements,
171:                                null);
172:                        result = 0;
173:                    } else {
174:                        System.out.println("column " + ouColumn + " in table "
175:                                + table + " already exists");
176:                    }
177:                    // Nothing needs to be done
178:                    result = 0;
179:                } catch (SQLException e) {
180:                    e.printStackTrace();
181:                    result = 1;
182:                }
183:
184:                return result;
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.