org.opencms.setup.db.update6to7.CmsUpdateDBHistoryPrincipals Maven / Gradle / Ivy
Show all versions of opencms-test Show documentation
/*
* This library is part of OpenCms -
* the Open Source Content Management System
*
* Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH & Co. KG, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.setup.db.update6to7;
import org.opencms.setup.CmsSetupDBWrapper;
import org.opencms.setup.CmsSetupDb;
import org.opencms.setup.db.A_CmsUpdateDBPart;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* This class inserts formerly deleted users/groups in the CMS_HISTORY_PRINCIPALS table.
*
* These users/groups are read out of the following tables:
*
* - CMS_BACKUP_RESOURCES
* - CMS_BACKUP_PROJECTS
*
*
* @since 7.0.0
*/
public class CmsUpdateDBHistoryPrincipals extends A_CmsUpdateDBPart {
/** Constant for sql query to create the history principals table. */
protected static final String QUERY_HISTORY_PRINCIPALS_CREATE_TABLE = "Q_HISTORY_PRINCIPALS_CREATE_TABLE";
/** Constant for the CMS_HISTORY_PRINICIPALS table.
*/
protected static final String TABLE_CMS_HISTORY_PRINCIPALS = "CMS_HISTORY_PRINCIPALS";
/** Constant for sql query.
*/
private static final String QUERY_HISTORY_PRINCIPALS_PROJECTS_GROUPS = "Q_HISTORY_PRINCIPALS_PROJECTS_GROUPS";
/** Constant for sql query.
*/
private static final String QUERY_HISTORY_PRINCIPALS_PROJECTS_MANAGERGROUPS = "Q_HISTORY_PRINCIPALS_PROJECTS_MANAGERGROUPS";
/** Constant for sql query.
*/
private static final String QUERY_HISTORY_PRINCIPALS_PROJECTS_PUBLISHED = "Q_HISTORY_PRINCIPALS_PROJECTS_PUBLISHED";
/** Constant for sql query.
*/
private static final String QUERY_HISTORY_PRINCIPALS_PROJECTS_USERS = "Q_HISTORY_PRINCIPALS_PROJECTS_USERS";
/** Constant for sql query.
*/
private static final String QUERY_HISTORY_PRINCIPALS_RESOURCES = "Q_HISTORY_PRINCIPALS_RESOURCES";
/** Constant for the SQL query properties.
*/
private static final String QUERY_PROPERTY_FILE = "cms_history_principals_queries.properties";
/** Constant for the sql query to select the count of history principals.
*/
private static final String QUERY_SELECT_COUNT_HISTORY_PRINCIPALS = "Q_SELECT_COUNT_HISTORY_PRINICPALS";
/** Constant for sql query.
*/
private static final String QUERY_UPDATE_DATEDELETED = "Q_UPDATE_DATEDELETED";
/**
* Constructor.
*
* @throws IOException if the sql queries properties file could not be read
*/
public CmsUpdateDBHistoryPrincipals()
throws IOException {
super();
loadQueryProperties(getPropertyFileLocation() + QUERY_PROPERTY_FILE);
}
/**
* Creates the CMS_HISTORY_PRINCIPALS table if it does not exist yet.
*
* @param dbCon the db connection interface
*
* @throws SQLException if soemthing goes wrong
*/
protected void createHistPrincipalsTable(CmsSetupDb dbCon) throws SQLException {
System.out.println(new Exception().getStackTrace()[0].toString());
if (!dbCon.hasTableOrColumn(TABLE_CMS_HISTORY_PRINCIPALS, null)) {
String createStatement = readQuery(QUERY_HISTORY_PRINCIPALS_CREATE_TABLE);
dbCon.updateSqlStatement(createStatement, null, null);
} else {
System.out.println("table " + TABLE_CMS_HISTORY_PRINCIPALS + " already exists");
}
}
/**
* @see org.opencms.setup.db.A_CmsUpdateDBPart#internalExecute(org.opencms.setup.CmsSetupDb)
*/
@Override
protected void internalExecute(CmsSetupDb dbCon) throws SQLException {
System.out.println(new Exception().getStackTrace()[0].toString());
if (insertHistoryPrincipals(dbCon)) {
List