diff options
author | cbateman | 2007-04-06 22:29:39 +0000 |
---|---|---|
committer | cbateman | 2007-04-06 22:29:39 +0000 |
commit | ef6611b6d43324653e06e1e142045ce173abddee (patch) | |
tree | 9a6f702851b00ea5d8476c43cc94a0d75e9747c4 | |
parent | bd4e833d3105acecb354eedecebb21bfad4972f5 (diff) | |
download | webtools.jsf-ef6611b6d43324653e06e1e142045ce173abddee.tar.gz webtools.jsf-ef6611b6d43324653e06e1e142045ce173abddee.tar.xz webtools.jsf-ef6611b6d43324653e06e1e142045ce173abddee.zip |
Fix to bug where upgrade flag was always being set in status if migration operation ran.
3 files changed, 34 insertions, 17 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryUpgradeUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryUpgradeUtil.java index 931acc581..1aac400dc 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryUpgradeUtil.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryUpgradeUtil.java @@ -23,7 +23,7 @@ public class JSFLibraryRegistryUpgradeUtil { /** * default state is OK, no upgrade */ - private UpgradeStatus upgradeStatus = new UpgradeStatus(); + private UpgradeStatus upgradeStatus; /** * The workspace-relative part of the URL of the JSF Library Registry @@ -73,6 +73,15 @@ public class JSFLibraryRegistryUpgradeUtil { } /** + * @param originalFile + * @return the backup file name for a file + */ + public static String getBackupFileName(final String originalFile) + { + return originalFile.concat(".bkp"); + } + + /** * Upgrades the JSF Library registry from oldest to newest * @param expectedVersion * @param aJsfLibRegURI - URI of current version registry file @@ -105,25 +114,23 @@ public class JSFLibraryRegistryUpgradeUtil { new UpgradeStatus(IStatus.ERROR, true, "Error detected during upgrade!"); } } + else + { + // TODO: what if can't execute? + upgradeStatus = + new UpgradeStatus(IStatus.ERROR, false, "Error detected during upgrade!"); + } + } + else + { + // everything ok, not upgrade + upgradeStatus = new UpgradeStatus(); } - // on fall-through we will be left in the default - // state which says no upgrade was attempted and - // everything is good } - //does v1 exist? -// URI v1Reg; -// try { -// v1Reg = getRegistryURI(JSF_LIBRARY_REGISTRY_URL); -// file = new File(v1Reg.toFileString()); -// if (file.exists()){ -// upgradeJSFLibraryRegistryFromV1ToV2(v1Reg); -// } catch (MalformedURLException e) { // should never happen since we control the URL's JSFCorePlugin.log(IStatus.ERROR, "Error during loading JSF Library registry", e); } - - } private int getCurVersion() throws MalformedURLException diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/MigrateV1toV2Operation.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/MigrateV1toV2Operation.java index b52e28750..2ddaa1d60 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/MigrateV1toV2Operation.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/MigrateV1toV2Operation.java @@ -39,7 +39,7 @@ class MigrateV1toV2Operation extends VersionUpgradeOperation { public IStatus doExecute(IProgressMonitor monitor, IAdaptable info) { JSFLibraryRegistryUpgradeUtil.copyFile - (_v1Registry.toFileString(), _v1Registry.toFileString().concat(".bkp")); + (_v1Registry.toFileString(), JSFLibraryRegistryUpgradeUtil.getBackupFileName(_v1Registry.toFileString())); JSFLibraryRegistryResourceFactoryImpl resourceFactory = new JSFLibraryRegistryResourceFactoryImpl(); JSFLibraryRegistryResourceImpl res = (JSFLibraryRegistryResourceImpl)resourceFactory.createResource(_v1Registry); try { diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeOperation.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeOperation.java index b8a02917d..937ba7041 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeOperation.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeOperation.java @@ -50,19 +50,29 @@ public class UpgradeOperation extends AbstractOperation { */ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + + boolean upgraded = false; + for (final Iterator it = _stepOperations.iterator(); it.hasNext();) { VersionUpgradeOperation op = (VersionUpgradeOperation) it.next(); - IStatus status = op.execute(monitor, info); + // TODO: move to covariant + UpgradeStatus status = (UpgradeStatus) op.execute(monitor, info); // fail fast if (status.getSeverity() != IStatus.OK) { return status; } + + // once an upgrade is flagged, set flag + if (status.isUpgradeOccurred()) + { + upgraded = true; + } } - return new UpgradeStatus(IStatus.OK, true, "Upgrade succeeded"); + return new UpgradeStatus(IStatus.OK, upgraded, "Upgrade succeeded"); } /** |