View Javadoc
1   package fr.ifremer.adagio.synchro.action;
2   
3   /*
4    * #%L
5    * SIH-Adagio :: Shared
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2014 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  import java.io.File;
27  import java.io.IOException;
28  
29  import org.apache.commons.logging.Log;
30  import org.apache.commons.logging.LogFactory;
31  import org.nuiton.util.Version;
32  
33  import fr.ifremer.adagio.synchro.config.SynchroConfiguration;
34  import fr.ifremer.adagio.synchro.dao.DaoUtils;
35  
36  public class SynchroImportDataAction {
37  	/* Logger */
38  	private static final Log log = LogFactory.getLog(SynchroImportDataAction.class);
39  
40  	public void run() {
41  		if (log.isInfoEnabled()) {
42  			log.info("Starting database importation...");
43  			log.info(String.format(" Database directory: %s", SynchroConfiguration.getInstance().getDbDirectory()));
44  			log.info(String.format(" JDBC Driver: %s", SynchroConfiguration.getInstance().getJdbcDriver()));
45  			log.info(String.format(" JDBC URL: %s", SynchroConfiguration.getInstance().getJdbcURL()));
46  			log.info(String.format(" JDBC Username: %s", SynchroConfiguration.getInstance().getJdbcUsername()));
47  		}
48  
49  		boolean isValidConnection = DaoUtils.isValidConnectionProperties(SynchroConfiguration.getInstance().getJdbcDriver(),
50  				SynchroConfiguration.getInstance().getJdbcURL(),
51  				SynchroConfiguration.getInstance().getJdbcUsername(),
52  				SynchroConfiguration.getInstance().getJdbcPassword());
53  
54  		if (!isValidConnection) {
55  			log.warn("Connection error : could not check database status.");
56  			return;
57  		}
58  
59  		// TODO : run the data synchro
60  	}
61  
62  }