001package fr.ifremer.adagio.synchro.action; 002 003/* 004 * #%L 005 * SIH-Adagio :: Shared 006 * $Id:$ 007 * $HeadURL:$ 008 * %% 009 * Copyright (C) 2012 - 2014 Ifremer 010 * %% 011 * This program is free software: you can redistribute it and/or modify 012 * it under the terms of the GNU Affero General Public License as published by 013 * the Free Software Foundation, either version 3 of the License, or 014 * (at your option) any later version. 015 * 016 * This program 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 019 * GNU General Public License for more details. 020 * 021 * You should have received a copy of the GNU Affero General Public License 022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 023 * #L% 024 */ 025 026import java.io.File; 027import java.io.IOException; 028 029import org.apache.commons.logging.Log; 030import org.apache.commons.logging.LogFactory; 031import org.nuiton.util.Version; 032 033import fr.ifremer.adagio.synchro.config.SynchroConfiguration; 034import fr.ifremer.adagio.synchro.dao.DaoUtils; 035 036public class SynchroImportDataAction { 037 /* Logger */ 038 private static final Log log = LogFactory.getLog(SynchroImportDataAction.class); 039 040 public void run() { 041 if (log.isInfoEnabled()) { 042 log.info("Starting database importation..."); 043 log.info(String.format(" Database directory: %s", SynchroConfiguration.getInstance().getDbDirectory())); 044 log.info(String.format(" JDBC Driver: %s", SynchroConfiguration.getInstance().getJdbcDriver())); 045 log.info(String.format(" JDBC URL: %s", SynchroConfiguration.getInstance().getJdbcURL())); 046 log.info(String.format(" JDBC Username: %s", SynchroConfiguration.getInstance().getJdbcUsername())); 047 } 048 049 boolean isValidConnection = DaoUtils.isValidConnectionProperties(SynchroConfiguration.getInstance().getJdbcDriver(), 050 SynchroConfiguration.getInstance().getJdbcURL(), 051 SynchroConfiguration.getInstance().getJdbcUsername(), 052 SynchroConfiguration.getInstance().getJdbcPassword()); 053 054 if (!isValidConnection) { 055 log.warn("Connection error : could not check database status."); 056 return; 057 } 058 059 // TODO : run the data synchro 060 } 061 062}