=== added file 'local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/AdvanceMySqlBackupFormAction.java' --- local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/AdvanceMySqlBackupFormAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/AdvanceMySqlBackupFormAction.java 2011-09-08 05:43:00 +0000 @@ -0,0 +1,82 @@ +package org.hisp.dhis.config.action; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.rowset.SqlRowSet; + +import com.opensymphony.xwork2.Action; + +public class AdvanceMySqlBackupFormAction implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private JdbcTemplate jdbcTemplate; + + public void setJdbcTemplate( JdbcTemplate jdbcTemplate ) + { + this.jdbcTemplate = jdbcTemplate; + } + // ------------------------------------------------------------------------- + // Input and Output Parameters + // ------------------------------------------------------------------------- + + private List availableTables = new ArrayList(); + + public List getAvailableTables() + { + return availableTables; + } + + private List availableViews = new ArrayList(); + + public List getAvailableViews() + { + return availableViews; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + public String execute() throws Exception + { + + //String query = "SHOW TABLES"; + String query = "SHOW FULL TABLES"; + + SqlRowSet rs = jdbcTemplate.queryForRowSet( query ); + + while ( rs.next() ) + { + // availableTables.add( rs.getString( 1 ) ); + + String tableName = rs.getString( 1 ); + String tableType = rs.getString( 2 ); + + if( tableType.equalsIgnoreCase( "VIEW" ) ) + { + availableViews.add( tableName ); + } + else + { + availableTables.add( tableName ); + } + } + + //System.out.println(" Total No of Tables is :" + availableTables.size() ); + //System.out.println(" Total No of View is :" + availableViews.size() ); + /* + int i =1; + for( String table : availableTables ) + { + System.out.println(" Table " + i + " is : " + table ); + i++; + } + */ + return SUCCESS; + } +} === added file 'local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/AdvanceMySqlBackupResultAction.java' --- local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/AdvanceMySqlBackupResultAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/AdvanceMySqlBackupResultAction.java 2011-09-08 05:43:00 +0000 @@ -0,0 +1,178 @@ +package org.hisp.dhis.config.action; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.hisp.dhis.config.ConfigurationService; +import org.hisp.dhis.config.Configuration_IN; +import org.hisp.dhis.system.database.DatabaseInfoProvider; +import org.springframework.beans.factory.annotation.Required; + +import com.opensymphony.xwork2.Action; + +public class AdvanceMySqlBackupResultAction implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + private ConfigurationService configurationService; + + private DatabaseInfoProvider provider; + + @Required + public void setConfigurationService( ConfigurationService configurationService ) + { + this.configurationService = configurationService; + } + + @Required + public void setProvider( DatabaseInfoProvider provider ) + { + this.provider = provider; + } + + // ------------------------------------------------------------------------- + // Input and Output Parameters + // ------------------------------------------------------------------------- + + private List selectedTables = new ArrayList(); + + public List getSelectedTables() + { + return selectedTables; + } + + public void setSelectedTables( List selectedTables ) + { + this.selectedTables = selectedTables; + } + + private String status; + + public String getStatus() + { + return status; + } + private String backupFilePath; + + public String getBackupFilePath() + { + return backupFilePath; + } + + private String statusMessage; + + public String getStatusMessage() + { + return statusMessage; + } + + private SimpleDateFormat simpleDateFormat; + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + + + public String execute() throws Exception + { + status = "INPUT"; + System.out.println(" Total No of Selected Tables for Backup is :" + selectedTables.size() ); + + System.out.println( "Backup Start Time is : " + new Date() ); + + String dbName = provider.getDatabaseInfo().getName(); + String userName = provider.getDatabaseInfo().getUser(); + String password = provider.getDatabaseInfo().getPassword(); + + String mySqlPath = configurationService.getConfigurationByKey( Configuration_IN.KEY_MYSQLPATH ).getValue(); + + Calendar curDateTime = Calendar.getInstance(); + Date curDate = new Date(); + curDateTime.setTime( curDate ); + + simpleDateFormat = new SimpleDateFormat( "ddMMMyyyy-HHmmssSSS" ); + + String tempFolderName = simpleDateFormat.format( curDate ); + + backupFilePath = configurationService.getConfigurationByKey( Configuration_IN.KEY_BACKUPDATAPATH ).getValue(); + backupFilePath += tempFolderName; + + File newdir = new File( backupFilePath ); + if( !newdir.exists() ) + { + newdir.mkdirs(); + } + + backupFilePath += "/" + "dhis2.sql"; + //System.out.println(" MY-SQL Path is :" + mySqlPath ); + String backupCommand = ""; + + String temTables = ""; + for( String table : selectedTables ) + { + + temTables += " " + table; + //backupCommand += backupCommand + " " + table +" -r "+backupFilePath; + } + + //System.out.println(" Tables are :" + temTables ); + + try + { + if( password == null || password.trim().equals( "" ) ) + { + backupCommand = mySqlPath + "mysqldump -u "+ userName +" "+ dbName + " "+ temTables +" -r "+backupFilePath; + + //backupCommand = mySqlPath + "mysqldump -u "+ userName +" "+ dbName +" -r "+backupFilePath; + } + else + { + backupCommand = mySqlPath + "mysqldump -u "+ userName +" -p"+ password +" "+ dbName + " "+ temTables +" -r "+backupFilePath; + + //backupCommand = mySqlPath + "mysqldump -u "+ userName +" -p"+ password +" "+ dbName +" -r "+backupFilePath; + } + //System.out.println(" Backup Command is :" + backupCommand ); + + Runtime rt = Runtime.getRuntime(); + + Process process = rt.exec( backupCommand ); + + process.waitFor(); + + if( process.exitValue() == 0 ) + { + statusMessage = "Backup taken succussfully at : "+backupFilePath; + + status = "SUCCESS"; + } + else + { + statusMessage = "Not able to take Backup, Please try again"; + } + + } + catch ( Exception e ) + { + System.out.println("Exception : "+e.getMessage()); + + statusMessage = "Not able to take Backup, Please check MySQL configuration and SQL file path."; + } + + //System.out.println(" Backup Path is :" + backupFilePath ); + System.out.println( "Backup End Time is : " + new Date() ); + /* + int i =1; + for( String table : selectedTables ) + { + System.out.println(" Table " + i + " is : " + table ); + i++; + } + */ + return SUCCESS; + } +} === modified file 'local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/TakeMySqlBackupAction.java' --- local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/TakeMySqlBackupAction.java 2010-11-16 19:03:53 +0000 +++ local/in/dhis-web-maintenance-in/src/main/java/org/hisp/dhis/config/action/TakeMySqlBackupAction.java 2011-09-08 05:43:00 +0000 @@ -97,7 +97,7 @@ } backupFilePath += "/" + "dhis2.sql"; - + System.out.println(" MY-SQL Path is :" + mySqlPath ); String backupCommand = ""; try @@ -111,6 +111,7 @@ backupCommand = mySqlPath + "mysqldump -u "+ userName +" -p"+ password +" "+ dbName +" -r "+backupFilePath; } + System.out.println(" Backup Command is :" + backupCommand ); Runtime rt = Runtime.getRuntime(); Process process = rt.exec( backupCommand ); @@ -134,8 +135,10 @@ statusMessage = "Not able to take Backup, Please check MySQL configuration and SQL file path."; } - + System.out.println(" Backup Path is :" + backupFilePath ); return SUCCESS; + + } - + } === modified file 'local/in/dhis-web-maintenance-in/src/main/resources/META-INF/dhis/beans.xml' --- local/in/dhis-web-maintenance-in/src/main/resources/META-INF/dhis/beans.xml 2010-11-16 19:03:53 +0000 +++ local/in/dhis-web-maintenance-in/src/main/resources/META-INF/dhis/beans.xml 2011-09-08 05:43:00 +0000 @@ -38,5 +38,16 @@ + + + + + + + + + === modified file 'local/in/dhis-web-maintenance-in/src/main/resources/struts.xml' --- local/in/dhis-web-maintenance-in/src/main/resources/struts.xml 2010-10-28 09:17:13 +0000 +++ local/in/dhis-web-maintenance-in/src/main/resources/struts.xml 2011-09-08 05:43:00 +0000 @@ -44,7 +44,23 @@ 1024 - + + + /main.vm + /dhis-web-maintenance-in/advanceMysqlBackupForm.vm + /dhis-web-maintenance-in/menu.vm + css/StylesForTags.css + F_CONFIGURE_DOWNLOAD_BACKUP + + + + /main.vm + /dhis-web-maintenance-in/advanceMysqlBackupResult.vm + /dhis-web-maintenance-in/menu.vm + css/StylesForTags.css + F_CONFIGURE_DOWNLOAD_BACKUP + + /main.vm === added file 'local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/advanceMysqlBackupForm.vm' --- local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/advanceMysqlBackupForm.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/advanceMysqlBackupForm.vm 2011-09-08 05:43:00 +0000 @@ -0,0 +1,115 @@ +

Take Advance MySQL Backup

+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + +
 
Available TablesSelected Tables
+ + +
+
+
+ +
+ +

No of Available Tables : $availableTables.size()

+ +
+
+
+
+
+
+ === added file 'local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/advanceMysqlBackupResult.vm' --- local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/advanceMysqlBackupResult.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/advanceMysqlBackupResult.vm 2011-09-08 05:43:00 +0000 @@ -0,0 +1,15 @@ + + +

+ +

$statusMessage + #if( $!status == "SUCCESS" ) + + #else +

No of Selected Tables : $selectedTables.size()

+ #end + + +

+ +

\ No newline at end of file === modified file 'local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/menu.vm' --- local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/menu.vm 2010-10-28 09:17:13 +0000 +++ local/in/dhis-web-maintenance-in/src/main/webapp/dhis-web-maintenance-in/menu.vm 2011-09-08 05:43:00 +0000 @@ -29,6 +29,7 @@
  • Configuration
  • Take MySQL Backup
  • Maintenance
  • +
  • Advance MySQL Backup