![JAR search and dependency download from the Maven repository](/logo.png)
org.kuali.rice.krad.devtools.pdle.PostDataLoadEncryptionDaoJdbc Maven / Gradle / Ivy
/**
* Copyright 2005-2016 The Kuali Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ecl2.php
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kuali.rice.krad.devtools.pdle;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.kuali.rice.core.framework.persistence.jdbc.dao.PlatformAwareDaoBaseJdbc;
import org.kuali.rice.krad.devtools.pdle.PostDataLoadEncryptionDao;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.RowMapper;
public class PostDataLoadEncryptionDaoJdbc extends PlatformAwareDaoBaseJdbc implements PostDataLoadEncryptionDao {
private static final Logger LOG = Logger.getLogger(PostDataLoadEncryptionDaoJdbc.class);
protected static final String AND_SEPARATOR = " AND ";
protected static final String COMMA_SEPARATOR = ", ";
protected static final String BACKUP_TABLE_EXTENSION = "_bak";
protected static final String BACKUP_TABLE_ENCRYPT_IND = "ENCRYPT_IND";
void executeSql(String sql) {
LOG.info("Executing sql: " + sql);
getJdbcTemplate().execute(sql);
}
public void createBackupTable(String tableName) {
executeSql(getDbPlatform().getCreateTableFromTableSql(tableName + "_bak", tableName));
}
public void truncateTable(String tableName) {
executeSql(getDbPlatform().getTruncateTableSql(tableName));
}
public void restoreTableFromBackup(String tableName) {
truncateTable(tableName);
executeSql(getDbPlatform().getInsertDataFromTableSql(tableName, tableName + "_bak"));
}
public void dropBackupTable(String tableName) {
executeSql(getDbPlatform().getDropTableSql(tableName + "_bak"));
}
public boolean doesBackupTableExist(String tableName){
try{
Object tableNameObj = getJdbcTemplate().queryForObject(
"SELECT count(*) FROM " + tableName + BACKUP_TABLE_EXTENSION + " WHERE 0=1", Integer.class);
return true;
} catch(Exception ex){
return false;
}
}
public void addEncryptionIndicatorToBackupTable(String tableName){
executeSql(new StringBuffer().append("ALTER TABLE ")
.append(tableName + BACKUP_TABLE_EXTENSION)
.append(" ADD ")
.append(BACKUP_TABLE_ENCRYPT_IND)
.append(" VARCHAR2(1)").toString());
}
public void dropEncryptionIndicatorFromBackupTable(String tableName){
executeSql(new StringBuffer().append("ALTER TABLE ")
.append(tableName + BACKUP_TABLE_EXTENSION)
.append(" DROP COLUMN ")
.append(BACKUP_TABLE_ENCRYPT_IND).toString());
}
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy