Thread: [Squirrel-sql-commits] sql12/app/src/net/sourceforge/squirrel_sql/client/update UpdateUtilImpl.jav
A Java SQL client for any JDBC compliant database
Brought to you by:
colbell,
gerdwagner
Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/update In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5732/app/src/net/sourceforge/squirrel_sql/client/update Modified Files: UpdateUtilImpl.java UpdateControllerImpl.java UpdateUtil.java UpdateController.java Log Message: Handle the case where the user wants to change the plugins or translations installed, but there is no updated version to be downloaded. In this case, we copy the core jars to the downloads directory so that the updater CLASSPATH is satisfied. Index: UpdateControllerImpl.java =================================================================== RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/update/UpdateControllerImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** UpdateControllerImpl.java 26 Jul 2008 16:53:22 -0000 1.12 --- UpdateControllerImpl.java 17 Aug 2008 21:16:23 -0000 1.13 *************** *** 21,27 **** import static net.sourceforge.squirrel_sql.client.update.UpdateUtil.RELEASE_XML_FILENAME; - import java.io.File; import java.io.FileNotFoundException; - import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; --- 21,25 ---- *************** *** 51,55 **** import net.sourceforge.squirrel_sql.client.update.xmlbeans.ChannelXmlBean; import net.sourceforge.squirrel_sql.fw.gui.GUIUtils; - import net.sourceforge.squirrel_sql.fw.util.IOUtilities; import net.sourceforge.squirrel_sql.fw.util.IUpdateSettings; import net.sourceforge.squirrel_sql.fw.util.StringManager; --- 49,52 ---- *************** *** 376,391 **** /** ! * @see net.sourceforge.squirrel_sql.client.update.UpdateController#applyChanges(java.util.List) */ ! public void applyChanges(List<ArtifactStatus> artifactStatusList) { try { // Persists the change list to the update directory. _util.saveChangeList(artifactStatusList); ! // Kick off a thread to go and fetch the files one-by-one and register // callback class - DownloadStatusEventHandler pullDownUpdateFiles(artifactStatusList, new DownloadStatusEventHandler()); ! } catch (Exception e) { showErrorMessage(i18n.UPDATE_CHECK_FAILED_TITLE, i18n.EXCEPTION_MSG --- 373,398 ---- /** ! * @see net.sourceforge.squirrel_sql.client.update.UpdateController#applyChanges(java.util.List, boolean) */ ! public void applyChanges(List<ArtifactStatus> artifactStatusList, boolean releaseVersionWillChange) { try { // Persists the change list to the update directory. _util.saveChangeList(artifactStatusList); ! // Kick off a thread to go and fetch the files one-by-one and register // callback class - DownloadStatusEventHandler pullDownUpdateFiles(artifactStatusList, new DownloadStatusEventHandler()); ! ! // if the release version doesn't change, we won't be pulling down core artifacts. So, we just ! // need to make sure that all core files have been copied from their installed locations into the ! // corresponding directory in download, which is in the CLASSPATH of the updater. This covers the ! // case where the update is being run for the first time after install, and no new version is ! // available, but the user wants to install/remove plugins and/or translations. ! // TODO: do we need to show the user a progress dialog here ? ! if (!releaseVersionWillChange) { ! _util.copyDir(_util.getSquirrelLibraryDir(), _util.getCoreDownloadsDir()); ! _util.copyFile(_util.getInstalledSquirrelMainJarLocation(), _util.getCoreDownloadsDir()); ! } } catch (Exception e) { showErrorMessage(i18n.UPDATE_CHECK_FAILED_TITLE, i18n.EXCEPTION_MSG Index: UpdateUtilImpl.java =================================================================== RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/update/UpdateUtilImpl.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** UpdateUtilImpl.java 10 Aug 2008 20:49:25 -0000 1.22 --- UpdateUtilImpl.java 17 Aug 2008 21:16:23 -0000 1.23 *************** *** 253,256 **** --- 253,275 ---- /** + * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#copyDir(java.io.File, java.io.File) + */ + public void copyDir(File fromDir, File toDir) throws FileNotFoundException, IOException + { + if (!fromDir.isDirectory()) { + throw new IllegalArgumentException("Expected fromDir("+fromDir.getAbsolutePath()+ + ") to be a directory."); + } + if (!toDir.isDirectory()) { + throw new IllegalArgumentException("Expected toDir("+toDir.getAbsolutePath()+ + ") to be a directory."); + } + File[] files = toDir.listFiles(); + for (File sourceFile : files) { + copyFile(sourceFile, toDir); + } + } + + /** * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#getLocalReleaseInfo(java.lang.String) */ *************** *** 283,287 **** --- 302,316 ---- } + + /** + * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#getInstalledSquirrelMainJarLocation() + */ + public File getInstalledSquirrelMainJarLocation() + { + return new File(this.getSquirrelHomeDir(), UpdateUtil.SQUIRREL_SQL_JAR_FILENAME); + } + + /** * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#getSquirrelPluginsDir() */ Index: UpdateUtil.java =================================================================== RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/update/UpdateUtil.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** UpdateUtil.java 10 Aug 2008 20:49:25 -0000 1.17 --- UpdateUtil.java 17 Aug 2008 21:16:23 -0000 1.18 *************** *** 74,77 **** --- 74,80 ---- public static final String TRANSLATION_ARTIFACT_ID = "i18n"; + /** The SQuirreL jar that contains the core classes in the "app" module */ + public static final String SQUIRREL_SQL_JAR_FILENAME = "squirrel-sql.jar"; + /** * Downloads the current release available at the specified host and path. *************** *** 138,146 **** * @param to * the file to copy to - * @return true if the file copy succeeded; false otherwise. */ void copyFile(final File from, final File to) throws FileNotFoundException, IOException; /** * Returns an ChannelXmlBean that describes the locally installed release. * --- 141,161 ---- * @param to * the file to copy to */ void copyFile(final File from, final File to) throws FileNotFoundException, IOException; /** + * Lists the specified fromDir and copies all of the files found in that directory to the specified toDir + * directory. + * + * @param fromDir + * the directory to copy files from + * @param toDir + * the directory to copy files to + * @throws FileNotFoundException + * @throws IOException + */ + void copyDir(final File fromDir, final File toDir) throws FileNotFoundException, IOException; + + /** * Returns an ChannelXmlBean that describes the locally installed release. * *************** *** 158,163 **** --- 173,189 ---- File getSquirrelHomeDir(); + /** + * Returns the top-level directory in which all installed plugins of SQuirreL live under. + * + * @return a File representing the plugins directory of SQuirreL + */ File getSquirrelPluginsDir(); + /** + * Returns the top-level directory in which all core libraries (and possibly translations) of SQuirreL + * live under. + * + * @return a File representing the core library directory of SQuirreL + */ File getSquirrelLibraryDir(); *************** *** 267,270 **** --- 293,303 ---- File getI18nBackupDir(); + /** + * Returns the absolute path to the location of the squirrel-sql.jar file. + * + * @return a File representing the current installed squirrel-sql.jar file. + */ + File getInstalledSquirrelMainJarLocation(); + ChangeListXmlBean getChangeList(File changeListFile) throws FileNotFoundException; Index: UpdateController.java =================================================================== RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/update/UpdateController.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UpdateController.java 28 Nov 2007 03:59:21 -0000 1.5 --- UpdateController.java 17 Aug 2008 21:16:23 -0000 1.6 *************** *** 84,92 **** * c. Updater installs updated files * d. SQuirreL starts again. ! * * @param artifactStatusList the list of changes to make to * installed/available artifacts. */ ! void applyChanges(List<ArtifactStatus> artifactStatusList); /** --- 84,94 ---- * c. Updater installs updated files * d. SQuirreL starts again. ! * * @param artifactStatusList the list of changes to make to * installed/available artifacts. + * @param releaseVersionWillChange a boolean value indicating whether or not the changes being applied will + * change the installed release version */ ! void applyChanges(List<ArtifactStatus> artifactStatusList, boolean releaseVersionWillChange); /** |