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.update6to7.mysql; 029 030import org.opencms.setup.CmsSetupDb; 031 032import java.io.IOException; 033import java.sql.SQLException; 034import java.util.Collections; 035import java.util.Map; 036 037/** 038 * This class creates the table CMS_CONTENTS and fills it with data from the tables CMS_BACKUP_CONTENTS and CMS_ONLINE_CONTENTS.<p> 039 */ 040public class CmsUpdateDBContentTables extends org.opencms.setup.db.update6to7.CmsUpdateDBContentTables { 041 042 /** Constant for the sql query to create the CMS_CONTENTS table.<p> */ 043 private static final String QUERY_CREATE_CMS_CONTENTS_TABLE_MYSQL = "Q_CREATE_CMS_CONTENTS_TABLE_MYSQL"; 044 045 /** Constant for the SQL query properties.<p> */ 046 private static final String QUERY_PROPERTY_FILE = "cms_content_table_queries.properties"; 047 048 /** 049 * Constructor.<p> 050 * 051 * @throws IOException if the query properties cannot be read 052 */ 053 public CmsUpdateDBContentTables() 054 throws IOException { 055 056 super(); 057 loadQueryProperties(getPropertyFileLocation() + QUERY_PROPERTY_FILE); 058 } 059 060 /** 061 * Creates the CMS_CONTENTS table if it does not exist yet.<p> 062 * 063 * @param dbCon the db connection interface 064 * 065 * @throws SQLException if something goes wrong 066 */ 067 @Override 068 protected void createContentsTable(CmsSetupDb dbCon) throws SQLException { 069 070 System.out.println(new Exception().getStackTrace()[0].toString()); 071 if (!dbCon.hasTableOrColumn(TABLE_CMS_CONTENTS, null)) { 072 String query = readQuery(QUERY_CREATE_CMS_CONTENTS_TABLE_MYSQL); 073 Map<String, String> replacer = Collections.singletonMap("${tableEngine}", m_poolData.get("engine")); 074 dbCon.updateSqlStatement(query, replacer, null); 075 } else { 076 System.out.println("table " + TABLE_CMS_CONTENTS + " already exists"); 077 } 078 } 079}