diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemProfile.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemProfile.java index a55ec2fe385..e9c61c2b25e 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemProfile.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemProfile.java @@ -17,6 +17,7 @@ * David Dykstal (IBM) - [197036] removed createHost() shortcut (should use ISystemRegistry), * cleaned javadoc for getFilterPools() * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent + * David Dykstal (IBM) - [200735][Persistence] Delete a profile that contains a connection and restart, profile is back without connections *******************************************************************************/ package org.eclipse.rse.core.model; @@ -36,6 +37,7 @@ import org.eclipse.rse.persistence.IRSEPersistenceProvider; * definitions to RSE. When made inactive, it those definition are no longer * available for use. *
+ * @noimplement This interface is not intended to be implemented by clients. */ public interface ISystemProfile extends IRSEModelObject { @@ -104,6 +106,34 @@ public interface ISystemProfile extends IRSEModelObject { */ public void setActive(boolean flag); + /** + * Suspend this profile. + * Suspended profiles ignore commit requests. + * Profiles are created in a non-suspended state. + * Profiles should be suspended while deleting their contents prior to their own deletion. + * Note that being non-suspended is a different condition than being active. + * A suspended profile may be resumed. + * @since 3.0 + * @see #resume() + */ + public void suspend(); + + /** + * Resume this profile from a suspended state. + * The profile will now honor commit requests. + * @since 3.0 + * @see #suspend() + */ + public void resume(); + + /** + * @return true if the profile is in a suspended state + * @since 3.0 + * @see #suspend() + * @see #resume() + */ + public boolean isSuspended(); + /** * Each profile is persisted by a persistence provider. This returns the instance of the * persistence provider used for this profile. New profiles will use the default persistence diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfile.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfile.java index b323008c5e8..cfd4f16c69f 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfile.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfile.java @@ -18,6 +18,7 @@ * David Dykstal (IBM) - [197036] changed getFilterPools to not force the loading of subsystem configurations * removed createHost, migrated commit logic to SystemProfileManager * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent + * David Dykstal (IBM) - [200735][Persistence] Delete a profile that contains a connection and restart, profile is back without connections *******************************************************************************/ package org.eclipse.rse.internal.core.model; @@ -55,6 +56,12 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd private boolean isActive = true; private String name = null; private boolean defaultPrivate = false; + + /** + * A suspended profile ignored commit requests. + * Profiles must be suspended prior to being deleted. + */ + private boolean suspended = false; /** * Default constructor @@ -124,6 +131,27 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd return poolMgr.getSystemFilterPools(); } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.ISystemProfile#suspend() + */ + public void suspend() { + suspended = true; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.ISystemProfile#resume() + */ + public void resume() { + suspended = false; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.ISystemProfile#isSuspended() + */ + public boolean isSuspended() { + return suspended; + } + /** * Return true if this profile is currently active. */ @@ -235,8 +263,11 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd * @see org.eclipse.rse.core.model.IRSEPersistableContainer#commit() */ public boolean commit() { - IStatus status = SystemProfileManager.getDefault().commitSystemProfile(this); - boolean scheduled = status.isOK(); + boolean scheduled = false; + if (!suspended) { + IStatus status = SystemProfileManager.getDefault().commitSystemProfile(this); + scheduled = status.isOK(); + } return scheduled; } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java index 5a9d5de2653..d11c3deb95b 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java @@ -20,6 +20,7 @@ * David Dykstal (IBM) - [197036] added implementation of run() for commit transaction support * David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent + * David Dykstal (IBM) - [200735][Persistence] Delete a profile that contains a connection and restart, profile is back without connections *******************************************************************************/ package org.eclipse.rse.internal.core.model; @@ -149,6 +150,7 @@ public class SystemProfileManager implements ISystemProfileManager { public ISystemProfile createSystemProfile(String name, boolean makeActive) { ISystemProfile existingProfile = getSystemProfile(name); if (existingProfile != null) { + existingProfile.suspend(); deleteSystemProfile(existingProfile, false); // replace the existing one with a new profile } ISystemProfile newProfile = internalCreateSystemProfile(name); diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java index bbbb77d8d86..2ad0c67ad3d 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java @@ -46,6 +46,7 @@ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields + * David Dykstal (IBM) - [200735][Persistence] Delete a profile that contains a connection and restart, profile is back without connections ********************************************************************************/ package org.eclipse.rse.internal.core.model; @@ -591,6 +592,7 @@ public class SystemRegistry implements ISystemRegistry { try { + newProfile.suspend(); if (newConns != null) for (int idx = 0; idx < newConns.length; idx++) deleteHost(newConns[idx]); @@ -630,6 +632,7 @@ public class SystemRegistry implements ISystemRegistry ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile(); if (profile != defaultProfile) { // load everything + profile.suspend(); loadAll(); // remove connections IHost[] connections = getHostsByProfile(profile); @@ -647,7 +650,8 @@ public class SystemRegistry implements ISystemRegistry manager.deleteSystemProfile(profile, true); // fire events if (connections.length > 0) { // defect 42112 - fireEvent(new SystemResourceChangeEvent(connections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this)); + SystemResourceChangeEvent event = new SystemResourceChangeEvent(connections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this); + fireEvent(event); } fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE, profile, null); } @@ -1963,8 +1967,6 @@ public class SystemRegistry implements ISystemRegistry ((ISubSystemConfiguration) affectedSubSystemFactories.elementAt(idx)).deleteSubSystemsByConnection(conn); } conn.getHostPool().deleteHost(conn); // delete from memory and from disk. - ////Listening to Events now - //SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list fireModelChangeEvent( ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,