001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.setup.db.update7to8.mysql; 029 030import org.opencms.setup.CmsSetupDb; 031 032import java.io.IOException; 033import java.sql.SQLException; 034import java.util.Arrays; 035import java.util.Collections; 036import java.util.List; 037import java.util.Map; 038 039/** 040 * This class creates the new tables for the database version of OpenCms 8.<p> 041 * 042 * The new tables in OpenCms 8 are: 043 * <ul> 044 * <li><code>CMS_LOG</code></li> 045 * </ul> 046 * 047 * @since 8.0.0 048 */ 049public class CmsUpdateDBNewTables extends org.opencms.setup.db.update7to8.CmsUpdateDBNewTables { 050 051 /** Constant for the SQL query properties.<p> */ 052 private static final String QUERY_PROPERTY_FILE = "cms_new_tables_queries.properties"; 053 054 /** 055 * Constructor.<p> 056 * 057 * @throws IOException if the sql queries properties file could not be read 058 */ 059 public CmsUpdateDBNewTables() 060 throws IOException { 061 062 super(); 063 loadQueryProperties(getPropertyFileLocation() + QUERY_PROPERTY_FILE); 064 } 065 066 /** 067 * @see org.opencms.setup.db.A_CmsUpdateDBPart#internalExecute(org.opencms.setup.CmsSetupDb) 068 */ 069 @Override 070 protected void internalExecute(CmsSetupDb dbCon) throws SQLException { 071 072 System.out.println(new Exception().getStackTrace()[0].toString()); 073 074 List<String> elements = Arrays.asList( 075 new String[] { 076 "CMS_LOG", 077 "CMS_COUNTERS", 078 "CMS_OFFLINE_URLNAME_MAPPINGS", 079 "CMS_ONLINE_URLNAME_MAPPINGS", 080 "CMS_SUBSCRIPTION", 081 "CMS_SUBSCRIPTION_VISIT", 082 "CMS_ALIASES", 083 "CMS_REWRITES", 084 "CMS_USER_PUBLISH_LIST"}); 085 086 Map<String, String> replacer = Collections.singletonMap("${tableEngine}", m_poolData.get("engine")); 087 for (String table : elements) { 088 if (!dbCon.hasTableOrColumn(table, null)) { 089 String query = readQuery(table + "_MYSQL"); 090 dbCon.updateSqlStatement(query, replacer, null); 091 } else { 092 System.out.println("table " + table + " already exists"); 093 } 094 } 095 } 096}