1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

[170932][api][refactor] revamp persistence manager interface

This commit is contained in:
David Dykstal 2007-04-19 06:04:49 +00:00
parent d6c7ba4fad
commit 5be124e200
48 changed files with 896 additions and 1082 deletions

View file

@ -274,17 +274,6 @@ public class SystemResourceManager implements SystemResourceConstants
}
*/
// -----------------------------------
// GET A SPECIFIC PROFILE FOLDER...
// -----------------------------------
/**
* Get profiles folder for a given profile
*/
public static IFolder getProfileFolder(ISystemProfile profile)
{
return getProfileFolder(profile.getName());
}
/**
* Get profiles folder for a given profile name
*/
@ -293,9 +282,6 @@ public class SystemResourceManager implements SystemResourceConstants
return getResourceHelpers().getOrCreateFolder(getRemoteSystemsProject(),profileName);
}
/*
* --------------------------------------------------------------------------------------------------------------------------------
* USER ACTIONS SUBTREE FOLDER METHODS...

View file

@ -337,6 +337,5 @@ public interface ISystemFilterPool extends IRSEPersistableReferencedObject, ISys
* @generated
*/
void setNonRenamable(boolean value);
public ISystemFilterPool createSystemFilterPool(String name, boolean allowNestedFilters, boolean isDeletable, boolean tryToRestore);
}

View file

@ -201,11 +201,10 @@ public interface ISystemFilterPoolReferenceManager extends IRSEBasePersistableRe
* Given a filter pool name, create a referencing object and add it to the list.
* This creates an unresolved reference to that filter pool. It will be resolved on first use.
* <p> Calls back to inform provider
* @param filterPoolManager the manager that can be used to resolve the reference.
* @param filterPoolName the name of the filter pool being referenced.
* @return new filter pool reference
*/
public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPoolManager filterPoolManager, String filterPoolName);
public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName);
/**
* Given a filter pool, locate the referencing object for it and remove it from the list.

View file

@ -18,6 +18,7 @@ package org.eclipse.rse.core.filters;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
@ -25,15 +26,11 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.RSEPersistableObject;
import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
import org.eclipse.rse.internal.core.filters.ISystemFilterConstants;
import org.eclipse.rse.internal.core.filters.SystemFilterPool;
import org.eclipse.rse.logging.Logger;
import org.eclipse.rse.persistence.IRSEPersistenceManager;
//
//
/**
* A filter pool manager manages filter pools.
@ -190,10 +187,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
*/
protected boolean singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT;
/**
* @generated This field/method will be replaced during code generation.
*/
protected java.util.List pools = null;
protected List pools = null;
/**
* Constructor
@ -224,7 +218,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* individual filter pool level.
* @param savePolicy The save policy for the filter pools and filters. One of the
* following constants from the
* {@link org.eclipse.rse.internal.core.filters.ISystemFilterConstants SystemFilterConstants} interface:
* {@link ISystemFilterConstants} interface:
* <ul>
* <li>SAVE_POLICY_NONE - no files, all save/restore handled elsewhere
* <li>SAVE_POLICY_ONE_FILE_PER_MANAGER - one file: mgrName.xmi
@ -238,26 +232,8 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
public static ISystemFilterPoolManager createSystemFilterPoolManager(ISystemProfile profile, Logger logger,
ISystemFilterPoolManagerProvider caller, String name, boolean allowNestedFilters,
int savePolicy, IRSEFilterNamingPolicy namingPolicy) {
SystemFilterPoolManager mgr = null;
if (namingPolicy == null) namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
try {
mgr = (SystemFilterPoolManager) RSECorePlugin.getThePersistenceManager().restoreFilterPoolManager(profile, logger, caller, name);
/*
if (savePolicy != SystemFilterConstants.SAVE_POLICY_NONE)
mgr = (SystemFilterPoolManagerImpl)restore(;
*/
} catch (Exception exc) // real error trying to restore, versus simply not found.
{
// todo: something. Log the exception somewhere?
}
if (mgr == null) // not found or some serious error.
{
mgr = createManager(profile);
}
if (mgr != null) {
mgr.initialize(logger, caller, name, allowNestedFilters);
}
SystemFilterPoolManager mgr = SystemFilterPoolManager.createManager(profile);
mgr.initialize(logger, caller, name, allowNestedFilters);
return mgr;
}
@ -276,30 +252,29 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Private helper method to initialize state
*/
public void initialize(Logger logger, ISystemFilterPoolManagerProvider caller, String name, boolean allowNestedFilters) {
if (!initialized) initialize(logger, caller, name); // core data
{
java.util.List pools = getPools();
ISystemFilterPool pool = null;
Vector poolNames = getSystemFilterPoolNamesVector();
for (int idx = 0; idx < poolNames.size(); idx++) {
String poolName = (String) poolNames.elementAt(idx);
pool = RSECorePlugin.getThePersistenceManager().restoreFilterPool(poolName);
pool.setSystemFilterPoolManager(this);
pools.add(pool);
/** FIXME test
if (pool.specialCaseNoDataRestored)
{
pool.setDeletable(true); // what else to do?
//pool.setSupportsNestedFilters(allowNestedFilters); will be cascaded down anyway
}
*/
}
if (!initialized) {
initialize(logger, caller, name); // core data
}
setSupportsNestedFilters(allowNestedFilters); // cascade it down
invalidatePoolCache();
// List pools = getPools();
// ISystemFilterPool pool = null;
// Vector poolNames = getSystemFilterPoolNamesVector();
// for (int idx = 0; idx < poolNames.size(); idx++) {
// String poolName = (String) poolNames.elementAt(idx);
//// pool = RSECorePlugin.getThePersistenceManager().restoreFilterPool(poolName);
// pool = null; // that's what the above returned
// pool.setSystemFilterPoolManager(this);
// pools.add(pool);
//
// /** FIXME test
// if (pool.specialCaseNoDataRestored)
// {
// pool.setDeletable(true); // what else to do?
// //pool.setSupportsNestedFilters(allowNestedFilters); will be cascaded down anyway
// }
// */
// }
}
/*
@ -309,7 +284,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
public void initialize(Logger logger, ISystemFilterPoolManagerProvider caller, String name) {
this.logger = logger;
setProvider(caller);
setNameGen(name);
setName(name);
setFilterPoolManager(); // cascade it down
initialized = true;
}
@ -331,14 +306,11 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
/**
* Set the name of this manager.
* Intercepted so the file get be renamed for SAVE_POLICY_ONE_FILE_PER_MANAGER.
*/
public void setName(String name) {
String oldName = getName();
if (oldName != null) {
if (!oldName.equals(name)) {
this.name = name;
}
public void setName(String newName) {
if ((name == null && newName != null) || !name.equals(newName)) {
this.name = newName;
setDirty(true);
}
}
@ -473,7 +445,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
public ISystemFilterPool[] getSystemFilterPools() {
//System.out.println("Inside getSFPools for mgr "+getName()+". poolArray null? "+(poolArray==null));
if ((poolArray == null) || (getPools().size() != poolArray.length)) {
java.util.List pools = getPools();
List pools = getPools();
poolArray = new ISystemFilterPool[pools.size()];
Iterator i = pools.iterator();
int idx = 0;
@ -499,7 +471,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Get list of filter pool names currently existing.
*/
public Vector getSystemFilterPoolNamesVector() {
java.util.List pools = getPools();
List pools = getPools();
if ((poolNames == null) || (poolNames.size() != pools.size())) // been invalidated?
{
poolNames = new Vector();
@ -540,30 +512,20 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Calls back to inform provider of this event
*/
public ISystemFilterPool createSystemFilterPool(String poolName, boolean isDeletable) throws Exception {
// always trim the pool name, MOF does not handle trailing or preceding spaces
poolName = poolName.trim();
if (getSystemFilterPool(poolName) != null) return null;
ISystemFilterPool pool = null;
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
ISystemFilterPool filterPool = registry.getSystemFilterPool();
pool = filterPool.createSystemFilterPool(poolName, supportsNestedFilters(), isDeletable, ISystemFilterConstants.TRY_TO_RESTORE_NO);
if (pool != null) {
poolName = poolName.trim();
if (getSystemFilterPool(poolName) == null) {
pool = new SystemFilterPool(poolName, supportsNestedFilters(), isDeletable);
pool.setSystemFilterPoolManager(this);
pool.setStringsCaseSensitive(areStringsCaseSensitive());
if (isSetSupportsDuplicateFilterStrings()) pool.setSupportsDuplicateFilterStrings(supportsDuplicateFilterStrings());
// add to model
java.util.List pools = getPools();
pool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings() && supportsDuplicateFilterStrings());
List pools = getPools();
pools.add(pool);
//System.out.println("Inside createSFPool for mgr "+getName()+". Pool "+name+" added");
invalidatePoolCache();
// save to disk...
commit(pool);
// if caller provider, callback to inform them of this event
if ((caller != null) && !suspendCallbacks) caller.filterEventFilterPoolCreated(pool);
if ((caller != null) && !suspendCallbacks) {
caller.filterEventFilterPoolCreated(pool);
}
}
return pool;
}
@ -601,8 +563,9 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
// DWD removing a pool should mark its parent profile as dirty and cause a save to be "scheduled"
// remove from model
java.util.List pools = getPools();
List pools = getPools();
pools.remove(pool);
invalidatePoolCache();
/* FIXME
// now in EMF, the pools are "owned" by the Resource, and only referenced by this pool manager,
@ -1530,7 +1493,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
/* FIXME
String fileName = getRootSaveFileName(namingPolicy, name);
java.util.List ext = getMOFHelpers(logger).restore(mgrFolder,fileName);
List ext = getMOFHelpers(logger).restore(mgrFolder,fileName);
SystemFilterPoolManager mgr = null;
@ -1652,25 +1615,13 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
/**
* @generated This field/method will be replaced during code generation
*/
public java.util.List getPools() {
public List getPools() {
if (pools == null) {
pools = new ArrayList();
//FIXME new EObjectResolvingeList(SystemFilterPool.class, this, FiltersPackage.SYSTEM_FILTER_POOL_MANAGER__POOLS);
}
return pools;
}
/**
* @generated This field/method will be replaced during code generation.
*/
public void setNameGen(String newName) {
String oldName = name;
if (oldName != newName) {
name = newName;
setDirty(true);
}
}
/**
* @generated This field/method will be replaced during code generation.
*/
@ -1727,8 +1678,9 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Uses the save policy specified in this manager's factory method.
*/
public boolean commit() {
IRSEPersistenceManager mgr = RSECorePlugin.getThePersistenceManager();
return mgr.commit(this);
ISystemProfile profile = getSystemProfile();
boolean result = profile.commit();
return result;
}
/**
@ -1741,12 +1693,11 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
}
public IRSEPersistableContainer getPersistableParent() {
return _profile;
return null;
}
public IRSEPersistableContainer[] getPersistableChildren() {
IRSEPersistableContainer[] result = getSystemFilterPools();
return result;
return new IRSEPersistableContainer[0];
}
}

View file

@ -21,6 +21,9 @@
package org.eclipse.rse.core.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import org.eclipse.core.runtime.Platform;
@ -511,7 +514,11 @@ public class Host extends RSEModelObject implements IHost {
}
public IRSEPersistableContainer[] getPersistableChildren() {
IConnectorService[] result = getConnectorServices();
List children = new ArrayList(10);
children.addAll(Arrays.asList(getPropertySets()));
children.addAll(Arrays.asList(getConnectorServices()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;
}

View file

@ -153,5 +153,12 @@ public interface IPropertySet {
* or <code>false</code> if the key has not been part of the set.
*/
public boolean removeProperty(String key);
/**
* Sets the container of this property set. Used to notify the
* container of a change in a property.
* @param container
*/
public void setContainer(IPropertySetContainer container);
}

View file

@ -49,22 +49,7 @@ public interface IRSEPersistableContainer {
* @param flag true if the object was restored.
*/
public void setWasRestored(boolean flag);
/**
* Notifies the object that it is being restored. Typically this will
* suppress any marking of the object as dirty and related objects as
* tainted while the restore is taking place. Should be used only by
* persistence providers.
*/
public void beginRestore();
/**
* Notifies the object that it is has been restored. This will
* enable the object to be marked as dirty if subsequent changes
* are made to it. Should be used only by persistence providers.
*/
public void endRestore();
/**
* An object is dirty if a change has been made to it that requires
* it to be persisted.
@ -106,8 +91,7 @@ public interface IRSEPersistableContainer {
* Sets the tainted attribute for this object. This should set to
* true only by child objects when they have been marked dirty or tainted.
* Setting this to true will cause all parent objects in the containment
* hierarchy to be marked tainted. Setting this to false will cause all
* children to be marked as not tainted.
* hierarchy to be marked tainted.
* It should be set to false only by a persistence manager when the
* object has been committed.
* @param flag the tainted state of the object.

View file

@ -16,6 +16,7 @@
package org.eclipse.rse.core.model;
import java.util.List;
import java.util.Vector;
/**
@ -44,10 +45,16 @@ public interface ISystemProfileManager {
public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive);
/**
* @return an array of all existing profiles.
* @return an array of all existing profiles. This is guaranteed to contain the
* default private profile.
*/
public ISystemProfile[] getSystemProfiles();
/**
* @return the number of profiles known to this manager.
*/
public int getSize();
/**
* @return an array of all existing profile names.
*/
@ -129,7 +136,9 @@ public interface ISystemProfileManager {
* @return The list of profiles known to this manager. This list is generated
* at the point of this call and may thus be manipulated by the caller.
*/
java.util.List getProfiles();
public List getProfiles();
public void addSystemProfile(ISystemProfile profile);
// /**
// * Reusable method to return a name validator for renaming a profile.

View file

@ -22,7 +22,6 @@ import java.util.Vector;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterStartHere;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.ISubSystem;
@ -44,8 +43,6 @@ public interface ISystemRegistry extends ISchedulingRule {
public ISystemFilterStartHere getSystemFilterStartHere();
public ISystemFilterPool getSystemFilterPool();
// ----------------------------------
// UI METHODS...
// ----------------------------------

View file

@ -17,10 +17,9 @@
package org.eclipse.rse.core.model;
/**
*
*/
public class Property implements IProperty {
import java.util.Observable;
public class Property extends Observable implements IProperty {
private String _name;
private String _label;
@ -35,6 +34,7 @@ public class Property implements IProperty {
_value = property.getValue();
_type = property.getType();
_isEnabled = property.isEnabled();
touch();
}
public Property(String name, String value, IPropertyType type, boolean isEnabled) {
@ -42,6 +42,7 @@ public class Property implements IProperty {
_value = value;
_type = type;
_isEnabled = isEnabled;
touch();
}
/* (non-Javadoc)
@ -55,7 +56,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setLabel(java.lang.String)
*/
public void setLabel(String label) {
_label = label;
if (!stringsAreEqual(_label, label)) {
_label = label;
touch();
}
}
/* (non-Javadoc)
@ -72,7 +76,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setValue(java.lang.String)
*/
public void setValue(String value) {
_value = value;
if (!stringsAreEqual(_value, value)) {
_value = value;
touch();
}
}
/* (non-Javadoc)
@ -86,7 +93,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setType(org.eclipse.rse.core.model.IPropertyType)
*/
public void setType(IPropertyType type) {
_type = type;
if (_type != type) {
_type = type;
touch();
}
}
/* (non-Javadoc)
@ -100,7 +110,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setEnabled(boolean)
*/
public void setEnabled(boolean flag) {
_isEnabled = flag;
if (_isEnabled != flag) {
_isEnabled = flag;
touch();
}
}
/* (non-Javadoc)
@ -114,7 +127,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setReadOnly(boolean)
*/
public void setReadOnly(boolean flag) {
_isReadOnly = flag;
if (_isReadOnly != flag) {
_isReadOnly = flag;
touch();
}
}
/* (non-Javadoc)
@ -123,5 +139,16 @@ public class Property implements IProperty {
public boolean isReadOnly() {
return _isReadOnly;
}
private boolean stringsAreEqual(String s1, String s2) {
if (s1 == s2) return true;
if (s1 == null) return false;
return s1.equals(s2);
}
private void touch() {
setChanged();
notifyObservers();
}
}

View file

@ -19,6 +19,8 @@ package org.eclipse.rse.core.model;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.Set;
/**
@ -27,9 +29,10 @@ import java.util.Set;
* Not thread-safe since the underlying {@link java.util.HashMap} is
* not thread-safe.
*/
public class PropertySet implements IPropertySet {
public class PropertySet extends RSEPersistableObject implements IPropertySet, Observer {
private String _name;
private Map _properties;
private IPropertySetContainer _container = null;
protected static IPropertyType _defaultType = PropertyType.getStringPropertyType();
@ -47,6 +50,7 @@ public class PropertySet implements IPropertySet {
IProperty property = propertySet.getProperty(key);
addProperty(key, new Property(property));
}
setDirty(true);
}
/**
@ -56,6 +60,7 @@ public class PropertySet implements IPropertySet {
public PropertySet(String name) {
_name = name;
_properties = new HashMap();
setDirty(true);
}
public String getName() {
@ -68,16 +73,17 @@ public class PropertySet implements IPropertySet {
public void setDescription(String description) {
addProperty(DESCRIPTION_KEY, description);
setDirty(true);
}
public String[] getPropertyKeys() {
Set set = _properties.keySet();
return (String[]) set.toArray(new String[set.size()]);
}
public void setName(String name) {
_name = name;
setDirty(true);
}
public void setProperties(Map map) {
@ -85,7 +91,11 @@ public class PropertySet implements IPropertySet {
for (Iterator z = map.keySet().iterator(); z.hasNext();) {
String key = (String) z.next();
Object value = map.get(key);
_properties.put(key, value);
if (value instanceof IProperty) {
addProperty(key, (IProperty)value);
} else if (value instanceof String) {
addProperty(key, (String)value);
}
}
}
@ -100,6 +110,7 @@ public class PropertySet implements IPropertySet {
*/
public IProperty addProperty(String key, IProperty property) {
_properties.put(key, property);
setDirty(true);
return property;
}
@ -109,10 +120,10 @@ public class PropertySet implements IPropertySet {
//FIXME should throw a NumberFormatException or similar,
//if the value does not fit the type of the existing property.
property.setValue(value);
return property;
} else {
return addProperty(key, value, _defaultType);
property = addProperty(key, value, _defaultType);
}
return property;
}
public IProperty addProperty(String key, String value, IPropertyType type) {
@ -121,7 +132,10 @@ public class PropertySet implements IPropertySet {
}
public boolean removeProperty(String key) {
return _properties.remove(key) != null;
Object value = _properties.remove(key);
if (value == null) return false;
setDirty(true);
return true;
}
public IProperty getProperty(String key) {
@ -143,5 +157,28 @@ public class PropertySet implements IPropertySet {
}
return null;
}
public boolean commit() {
return getPersistableParent().commit();
}
public IRSEPersistableContainer[] getPersistableChildren() {
return new IRSEPersistableContainer[0];
}
public IRSEPersistableContainer getPersistableParent() {
IRSEPersistableContainer result = null;
if (_container instanceof IRSEPersistableContainer) {
result = (IRSEPersistableContainer) _container;
}
return result;
}
public void setContainer(IPropertySetContainer container) {
_container = container;
}
public void update(Observable o, Object arg) {
setDirty(true);
}
}

View file

@ -44,6 +44,7 @@ public abstract class PropertySetContainer extends RSEPersistableObject implemen
public IPropertySet createPropertySet(String name, String description) {
IPropertySet newSet = new PropertySet(name);
newSet.setContainer(this);
newSet.addProperty(IPropertySet.DESCRIPTION_KEY, description);
_propertySets.put(name, newSet);
return newSet;
@ -51,11 +52,13 @@ public abstract class PropertySetContainer extends RSEPersistableObject implemen
public IPropertySet createPropertySet(String name) {
IPropertySet newSet = new PropertySet(name);
newSet.setContainer(this);
_propertySets.put(name, newSet);
return newSet;
}
public boolean addPropertySet(IPropertySet set) {
set.setContainer(this);
_propertySets.put(set.getName(), set);
return true;
}

View file

@ -29,22 +29,5 @@ public abstract class RSEModelObject extends PropertySetContainer implements IRS
public String getDescription() {
return RSEModelResources.RESID_MODELOBJECTS_MODELOBJECT_DESCRIPTION;
}
/**
* Does a null-aware string comparison. Two strings that are
* <code>null</code> will compare equal. Otherwise the result is
* the same as s1.equals(s2), if s1 is not null.
* @param s1 The first string to compare
* @param s2 the second string
* @return true if the strings are equal or both null.
*/
protected boolean compareStrings(String s1, String s2) {
boolean result = false;
if (s1 == null) {
result = (s2 == null);
} else {
result = s1.equals(s2);
}
return result;
}
}

View file

@ -74,10 +74,8 @@ public abstract class RSEModelOperation {
* Ends a transaction. Schedules all changed profiles for save.
*/
private static void endTransaction() {
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
ISystemProfileManager profileManager = registry.getSystemProfileManager();
IRSEPersistenceManager persistenceManager = RSECorePlugin.getDefault().getPersistenceManager();
persistenceManager.commit(profileManager);
persistenceManager.commitProfiles();
}
/**

View file

@ -1,11 +1,11 @@
package org.eclipse.rse.core.model;
public abstract class RSEPersistableObject implements IRSEPersistableContainer {
private boolean _isDirty = false;
private boolean _wasRestored = false;
private boolean _isTainted = false;
private boolean _restoring = false;
public RSEPersistableObject() {
super();
@ -16,21 +16,8 @@ public abstract class RSEPersistableObject implements IRSEPersistableContainer {
}
public final void setDirty(boolean flag) {
if (!_restoring) {
_isDirty = flag;
if (flag) {
setTainted(true);
}
}
}
public final void beginRestore() {
_restoring = true;
}
public final void endRestore() {
_restoring = false;
setWasRestored(true);
_isDirty = flag;
setTainted(flag);
}
public final boolean wasRestored() {
@ -46,21 +33,28 @@ public abstract class RSEPersistableObject implements IRSEPersistableContainer {
}
public final void setTainted(boolean flag) {
if (!_restoring) {
_isTainted = flag;
if (_isTainted) {
IRSEPersistableContainer parent = getPersistableParent();
if (parent != null) {
parent.setTainted(true);
}
} else {
IRSEPersistableContainer[] children = getPersistableChildren();
for (int i = 0; i < children.length; i++) {
IRSEPersistableContainer child = children[i];
child.setTainted(false);
}
boolean taintParent = flag && !_isTainted;
_isTainted = flag;
if (taintParent) {
IRSEPersistableContainer parent = getPersistableParent();
if (parent != null) {
parent.setTainted(true);
}
}
}
/**
* Does a null-aware string comparison. Two strings that are
* <code>null</code> will compare equal. Otherwise the result is
* the same as s1.equals(s2), if s1 is not null.
* @param s1 The first string to compare
* @param s2 the second string
* @return true if the strings are equal or both null.
*/
protected boolean compareStrings(String s1, String s2) {
if (s1 == s2) return true;
if (s1 == null) return false;
return s1.equals(s2);
}
}

View file

@ -18,11 +18,11 @@
package org.eclipse.rse.core.subsystems;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.RSEModelObject;
@ -253,8 +253,12 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
public IRSEPersistableContainer[] getPersistableChildren() {
List children = new ArrayList(20);
children.add(getRemoteServerLauncherProperties());
IServerLauncherProperties launcherProperties = getRemoteServerLauncherProperties();
if (launcherProperties != null) {
children.add(getRemoteServerLauncherProperties());
}
children.addAll(_registeredSubSystems);
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;

View file

@ -18,7 +18,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.RSEPersistableObject;
public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService
{
@ -752,6 +751,9 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#isTainted()
*/
public boolean isTainted() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
@ -761,6 +763,9 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#setTainted(boolean)
*/
public void setTainted(boolean flag) {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
@ -769,26 +774,16 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
}
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableParent()
*/
public IRSEPersistableContainer getPersistableParent() {
return getHost();
}
public void beginRestore() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.beginRestore();
}
}
public void endRestore() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.endRestore();
}
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableChildren()
*/
public IRSEPersistableContainer[] getPersistableChildren() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)

View file

@ -17,6 +17,7 @@
package org.eclipse.rse.internal.core.filters;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
@ -1384,6 +1385,7 @@ public class SystemFilter extends SystemReferencedObject implements ISystemFilte
if (filterStringVector != null) {
children.addAll(filterStringVector);
}
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;

View file

@ -17,7 +17,9 @@
package org.eclipse.rse.internal.core.filters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.resources.IFolder;
@ -256,103 +258,22 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
* @generated This field/method will be replaced during code generation.
*/
protected java.util.List filters = null;
private static SystemFilterPool _instance;
/**
/**
* Default constructor
*/
protected SystemFilterPool()
public SystemFilterPool(String poolName, boolean allowNestedFilters, boolean isDeletable)
{
super();
helpers = new SystemFilterContainerCommonMethods();
}
public static SystemFilterPool getDefault()
{
if (_instance == null)
{
_instance = new SystemFilterPool();
setRelease(RSECorePlugin.CURRENT_RELEASE);
if (!initialized) {
initialize(poolName, savePolicy, namingPolicy);
}
return _instance;
}
/**
* Static factory method for creating a new filter pool. Will
* first try to restore it, and if that fails will create a new instance and
* return it.
* <p>
* Use this method only if you are not using a SystemFilterPoolManager, else
* use the createSystemFilterPool method in that class.
*
* This folder will be created if it does not already exist.
* @param name the name of the filter pool. Typically this is also the name
* of the given folder, but this is not required. For the save policy of one file
* per pool, the name of the file is derived from this.
* @param allowNestedFilters true if filters inside this filter pool are
* to allow nested filters.
* @param isDeletable true if this filter pool is allowed to be deleted by users.
* @param tryToRestore true to attempt a restore first, false if a pure create operation.
*/
public ISystemFilterPool createSystemFilterPool(
String name,
boolean allowNestedFilters,
boolean isDeletable,
boolean tryToRestore)
{
SystemFilterPool pool = null;
if (tryToRestore)
{
try
{
pool = (SystemFilterPool)RSECorePlugin.getThePersistenceManager().restoreFilterPool(name);
}
catch (Exception exc) // real error trying to restore, versus simply not found.
{
// todo: something? Log the exception somewhere?
}
}
if (pool == null) // not found or some serious error.
{
pool = createPool();
}
if (pool != null)
{
pool.initialize(name, allowNestedFilters, isDeletable);
}
return pool;
}
// temporary!
//public boolean isSharable() {return isSharable; }
//public void setIsSharable(boolean is) { isSharable = is; }
/*
* Private helper method.
* Uses MOF to create an instance of this class.
*/
protected static SystemFilterPool createPool()
{
ISystemFilterPool pool = new SystemFilterPool();
// FIXME SystemFilterImpl.initMOF().createSystemFilterPool();
pool.setRelease(RSECorePlugin.CURRENT_RELEASE);
return (SystemFilterPool)pool;
}
/*
* Private helper method to initialize attributes
*/
protected void initialize(String name,
boolean allowNestedFilters,
boolean isDeletable)
{
if (!initialized)
initialize(name, savePolicy, namingPolicy);
setDeletable(isDeletable); // mof attribute
//System.out.println("In initialize() for filter pool " + getName() + ". isDeletable= " + isDeletable);
setSupportsNestedFilters(allowNestedFilters); // cascades to each filter
}
}
/*
* Private helper method to core initialization, from either createXXX or restore.
*/
@ -1321,17 +1242,25 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public boolean commit()
{
ISystemProfile profile = getSystemFilterPoolManager().getSystemProfile();
boolean result = profile.commit();
return result;
return getPersistableParent().commit();
}
public IRSEPersistableContainer getPersistableParent() {
return mgr;
ISystemProfile profile = null;
ISystemFilterPoolManager filterPoolManager = getSystemFilterPoolManager();
if (filterPoolManager != null) {
profile = filterPoolManager.getSystemProfile();
}
return profile;
}
public IRSEPersistableContainer[] getPersistableChildren() {
return getSystemFilters();
List children = new ArrayList(10);
children.addAll(Arrays.asList(getSystemFilters()));
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;
}
}

View file

@ -16,9 +16,6 @@
package org.eclipse.rse.internal.core.filters;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.RSECorePlugin;
@ -35,6 +32,7 @@ import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.references.SystemPersistableReferencingObject;
/**
@ -66,13 +64,10 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
/**
* Constructs a new filter pool reference. This is an unresolved reference.
* It is resolved on first use by using the supplied filterPoolManager.
* @param filterPoolManager the manager used to resolve the reference.
* @param filterPoolName the name of the filter pool.
*/
public SystemFilterPoolReference(ISystemFilterPoolManager filterPoolManager, String filterPoolName) {
public SystemFilterPoolReference(String filterPoolName) {
this();
this.filterPoolManager = filterPoolManager;
setReferencedObjectName(filterPoolName);
}
@ -105,28 +100,48 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
* @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolName()
*/
public String getReferencedFilterPoolName() {
String savedName = super.getReferencedObjectName();
String poolName = null;
int idx = savedName.indexOf(DELIMITER);
if (idx >= 0)
poolName = savedName.substring(idx + DELIMITER_LENGTH);
else
poolName = savedName;
return poolName;
/*
* A filter pool reference stores the name of the filter pool it references in the form managerName___filterPoolName.
* or in the unqualified form of filterPoolName which references a locally defined filter pool.
* ___ is the delimiter. Absence of the delimiter indicates an unqualified name.
* The filter pool manager name is the same as its owning profile.
*/
String savedName = getReferencedObjectName();
String[] parts = savedName.split(DELIMITER, 2);
String result = parts[0];
if (parts.length == 2) {
result = parts[1];
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolManagerName()
*/
public String getReferencedFilterPoolManagerName() {
String savedName = super.getReferencedObjectName();
String mgrName = null;
int idx = savedName.indexOf(DELIMITER);
if (idx >= 0)
mgrName = savedName.substring(0, idx);
else
mgrName = savedName;
return mgrName;
/*
* A filter pool reference stores the name of the filter pool it references in the form managerName___filterPoolName.
* or in the unqualified form of filterPoolName which references a locally defined filter pool.
* ___ is the delimiter. Absence of the delimiter indicates an unqualified name.
* The filter pool manager name is the same as its owning profile.
*/
String result = null;
String savedName = getReferencedObjectName();
String[] parts = savedName.split(DELIMITER, 2);
if (parts.length == 2) {
result = parts[0];
} else {
ISystemFilterPoolReferenceManagerProvider provider = getProvider();
if (provider instanceof ISubSystem) {
ISubSystem subsystem = (ISubSystem) provider;
ISystemProfile profile = subsystem.getSystemProfile();
result = profile.getName();
}
}
if (result == null) {
RSECorePlugin.getDefault().getLogger().logWarning("Unexpected condition: filter pool manager name not found.", null); //$NON-NLS-1$
}
return result;
}
/* (non-Javadoc)
@ -150,28 +165,20 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
ISystemFilterPool filterPool = (ISystemFilterPool) getReferencedObject();
if (filterPool == null) {
String filterPoolName = getReferencedFilterPoolName();
String profileName = getReferencedFilterPoolManagerName();
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
ISystemProfile profile = registry.getSystemProfile(profileName);
ISubSystem subsystem = (ISubSystem) getProvider();
ISubSystemConfiguration config = subsystem.getSubSystemConfiguration();
filterPoolManager = config.getFilterPoolManager(profile);
filterPool = filterPoolManager.getSystemFilterPool(filterPoolName);
if (filterPool == null) {
Pattern p = Pattern.compile("(^.*):"); //$NON-NLS-1$
Matcher m = p.matcher(filterPoolName);
if (m.find()) {
String profileName = m.group(1);
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
ISystemProfile profile = registry.getSystemProfile(profileName);
if (profile != null) {
ISystemFilterPool[] pools = profile.getFilterPools();
for (int i = 0; i < pools.length && filterPool == null; i++) {
ISystemFilterPool pool = pools[i];
if (filterPoolName.equals(pool.getName())) filterPool = pool;
}
}
}
}
if (filterPool != null) {
setReferenceToFilterPool(filterPool);
}
}
setReferenceBroken(filterPool == null);
if (filterPool != null) {
setReferenceToFilterPool(filterPool);
setReferenceBroken(false);
} else {
setReferenceBroken(true);
}
return filterPool;
}
@ -234,7 +241,7 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
* @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getFullName()
*/
public String getFullName() {
return super.getReferencedObjectName();
return getReferencedObjectName();
}
/* (non-Javadoc)

View file

@ -16,6 +16,8 @@
package org.eclipse.rse.internal.core.filters;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
@ -384,9 +386,10 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Create a filter pool reference. This creates an unresolved raw reference that
* must be added to the managed lists by the caller.
* That will be attempted to be resolved on first use.
* @param filterPoolName the fully qualified filter pool name
*/
private ISystemFilterPoolReference createSystemFilterPoolReference(ISystemFilterPoolManager filterPoolManager, String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolManager, filterPoolName);
private ISystemFilterPoolReference createSystemFilterPoolReference(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolName);
invalidateFilterPoolReferencesCache();
return filterPoolReference;
}
@ -503,10 +506,16 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/
public ISystemFilterPool[] getReferencedSystemFilterPools() {
ISystemFilterPoolReference[] refs = getSystemFilterPoolReferences();
ISystemFilterPool[] pools = new ISystemFilterPool[refs.length];
for (int idx = 0; idx < pools.length; idx++)
pools[idx] = refs[idx].getReferencedFilterPool();
return pools;
List pools = new ArrayList(refs.length);
for (int idx = 0; idx < refs.length; idx++) {
ISystemFilterPool pool = refs[idx].getReferencedFilterPool();
if (pool != null) {
pools.add(pool);
}
}
ISystemFilterPool[] result = new ISystemFilterPool[pools.size()];
pools.toArray(result);
return result;
}
/**
@ -542,8 +551,8 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/* (non-Javadoc)
* @see org.eclipse.rse.filters.ISystemFilterPoolReferenceManager#addReferenceToSystemFilterPool(org.eclipse.rse.filters.ISystemFilterPoolManager, java.lang.String)
*/
public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPoolManager filterPoolManager, String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolManager, filterPoolName);
public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolName);
addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this);
invalidateFilterPoolReferencesCache();

View file

@ -18,7 +18,6 @@ package org.eclipse.rse.internal.core.filters;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.filters.ISystemFilter;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider;

View file

@ -14,11 +14,15 @@
* David Dykstal (IBM) - 142806: refactoring persistence framework
********************************************************************************/
package org.eclipse.rse.internal.model;
package org.eclipse.rse.internal.core.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.model.IHost;
@ -28,9 +32,7 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.core.model.RSEModelResources;
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
import org.eclipse.rse.ui.RSEUIPlugin;
/**
* A profile contains hosts and filter pools. It is the unit of save/restore for RSE model
@ -39,9 +41,9 @@ import org.eclipse.rse.ui.RSEUIPlugin;
public class SystemProfile extends RSEModelObject implements ISystemProfile, IAdaptable
{
private ISystemProfileManager mgr;
private IRSEPersistenceProvider provider;
private boolean active;
private ISystemProfileManager mgr = null;
private IRSEPersistenceProvider provider = null;
private boolean isActive = true;
private String name = null;
private boolean defaultPrivate = false;
@ -52,6 +54,11 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
{
super();
}
public SystemProfile(String name, boolean isActive) {
this.name = name;
this.isActive = isActive;
}
/**
* Set the in-memory pointer back to the parent system profile manager
@ -75,7 +82,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/
public IHost createHost(String systemType, String connectionName, String hostName, String description) throws Exception
{
return RSEUIPlugin.getTheSystemRegistry().createHost(getName(), systemType, connectionName, hostName, description);
return RSECorePlugin.getDefault().getSystemRegistry().createHost(getName(), systemType, connectionName, hostName, description);
}
/**
@ -83,7 +90,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/
public IHost[] getHosts()
{
return RSEUIPlugin.getTheSystemRegistry().getHostsByProfile(this);
return RSECorePlugin.getDefault().getSystemRegistry().getHostsByProfile(this);
}
/**
@ -91,7 +98,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/
public ISystemFilterPool[] getFilterPools()
{
ISubSystemConfiguration[] ssFactories = RSEUIPlugin.getTheSystemRegistry().getSubSystemConfigurations();
ISubSystemConfiguration[] ssFactories = RSECorePlugin.getDefault().getSystemRegistry().getSubSystemConfigurations();
Vector poolsVector = new Vector();
for (int idx = 0; idx < ssFactories.length; idx++)
{
@ -121,14 +128,15 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/
public boolean isActive()
{
return active;
return isActive;
}
/**
* Reset whether this profile is currently active.
*/
public void setActive(boolean active)
{
this.active = active;
this.isActive = active;
setDirty(true);
}
/**
@ -175,6 +183,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
public void setName(String newName)
{
name = newName;
setDirty(true);
}
/**
@ -193,11 +202,12 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
public void setDefaultPrivate(boolean newDefaultPrivate)
{
defaultPrivate = newDefaultPrivate;
setDirty(true);
}
public boolean commit()
{
return RSEUIPlugin.getThePersistenceManager().commit(this);
return RSECorePlugin.getThePersistenceManager().commitProfile(this);
}
/**
@ -209,11 +219,12 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
}
public IRSEPersistableContainer[] getPersistableChildren() {
ISystemFilterPool[] pools = getFilterPools();
IHost[] hosts = getHosts();
IRSEPersistableContainer[] result = new IRSEPersistableContainer[pools.length + hosts.length];
System.arraycopy(pools, 0, result, 0, pools.length);
System.arraycopy(hosts, 0, result, pools.length, hosts.length);
List children = new ArrayList(10);
children.addAll(Arrays.asList(getFilterPools()));
children.addAll(Arrays.asList(getHosts()));
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;
}
@ -224,10 +235,11 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
return provider;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfile#setPersistenceProvider(org.eclipse.rse.persistence.IRSEPersistenceProvider)
*/
public void setPersistenceProvider(IRSEPersistenceProvider provider) {
this.provider = provider;
}
}

View file

@ -15,49 +15,48 @@
* - moved SystemPreferencesManager to a new plugin
********************************************************************************/
package org.eclipse.rse.internal.model;
package org.eclipse.rse.internal.core.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.model.SystemStartHere;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.validators.ISystemValidator;
import org.eclipse.rse.ui.validators.ValidatorProfileName;
import org.eclipse.rse.logging.Logger;
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
/**
* A class that manages a list of SystemProfile objects.
* This should be used as a singleton.
*/
public class SystemProfileManager implements ISystemProfileManager {
private List _profiles = null;
private String[] profileNames = null;
private Vector profileNamesVector = null;
private static ISystemProfileManager singleton = null;
private static final String PROFILE_FILE_NAME = "profile"; //$NON-NLS-1$
private List _profiles = new ArrayList(10);
// private String[] profileNames = null;
// private Vector profileNamesVector = null;
private static SystemProfileManager singleton = null;
private boolean restoring = false;
/**
* Ordinarily there should be only one instance of a SystemProfileManager
* created on the system, so the static method {@link #getSystemProfileManager()} is
* created on the system, so the static method {@link #getDefault()} is
* preferred to using this.
*/
private SystemProfileManager() {
super();
}
/**
* @return (and create if necessary) the singleton instance of this class.
*/
public static ISystemProfileManager getSystemProfileManager() {
public static SystemProfileManager getDefault() {
if (singleton == null) {
singleton = new SystemProfileManager();
RSEUIPlugin.getThePersistenceManager().restore(singleton); // restores all of RSE
RSECorePlugin.getThePersistenceManager().restoreProfiles();
}
return singleton;
}
@ -81,18 +80,16 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see ISystemProfileManager#createSystemProfile(String, boolean)
*/
public ISystemProfile createSystemProfile(String name, boolean makeActive) {
// FIXME - used to use MOF
ISystemProfile existingProfile = getSystemProfile(name);
if (existingProfile != null) {
deleteSystemProfile(existingProfile, false); // replace the existing one with a new profile
}
ISystemProfile newProfile = internalCreateSystemProfileAndFolder(name);
ISystemProfile newProfile = internalCreateSystemProfile(name);
if (makeActive) {
RSEPreferencesManager.addActiveProfile(name);
((SystemProfile) newProfile).setActive(makeActive);
}
RSEUIPlugin.getThePersistenceManager().commit(this);
newProfile.commit();
return newProfile;
}
@ -107,124 +104,58 @@ public class SystemProfileManager implements ISystemProfileManager {
((SystemProfile) profile).setActive(makeActive);
}
/*
* private version that avoids name collision check
*/
private ISystemProfile internalCreateSystemProfile(String name) {
ISystemProfile profile = new SystemProfile();
initialize(profile, name);
profile.setDefaultPrivate(name.equalsIgnoreCase(RSEPreferencesManager.getDefaultPrivateSystemProfileName()));
return profile;
}
/*
* private version that avoids name collision check
*/
private ISystemProfile internalCreateSystemProfileAndFolder(String name) {
ISystemProfile profile = internalCreateSystemProfile(name);
// FIXME This is where the old style folders get created for profiles.
// This is no longer needed but
// SystemResourceManager.getProfileFolder(profile); // creates proj/profileName folder
return profile;
}
/*
* private method to initialize state for new profile
*/
private void initialize(ISystemProfile profile, String name) {
profile.setName(name);
profile.setProfileManager(this);
getProfiles().add(profile);
invalidateCache();
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
*/
public ISystemProfile[] getSystemProfiles() {
List profiles = getProfiles();
// Ensure that one Profile is the default Profile - defect 48995 NH
boolean defaultProfileExist = false;
for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
ISystemProfile profile = (ISystemProfile) profiles.get(idx);
if (profile.isDefaultPrivate()) {
defaultProfileExist = true;
}
}
if (!defaultProfileExist) {
// Check if the Profile exists with name same as the LocalMachine Name - this is the default we give
// when creating connections.
for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
ISystemProfile profile = (ISystemProfile) profiles.get(idx);
String initProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
if (profile.getName().equalsIgnoreCase(initProfileName)) {
profile.setDefaultPrivate(true);
defaultProfileExist = true;
}
}
// If did not find such a profile then the first profile found besides Team is set to be the default profile
if (!defaultProfileExist) {
for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
ISystemProfile profile = (ISystemProfile) profiles.get(idx);
if (!profile.getName().equalsIgnoreCase(RSEPreferencesManager.getDefaultTeamProfileName())) {
profile.setDefaultPrivate(true);
RSEUIPlugin.getThePersistenceManager().commit(SystemStartHere.getSystemProfileManager());
defaultProfileExist = true;
}
}
}
if (!defaultProfileExist) {
// If Team is the only profile - then put a message in the log - do not make Team to be default
if (profiles.size() == 1 && ((ISystemProfile) profiles.get(0)).getName().equalsIgnoreCase("Team")) //$NON-NLS-1$
{
SystemBasePlugin.logWarning("Only one Profile Team exists - there is no Default Profile"); //$NON-NLS-1$
} else {
// sonething must have gone wrong - it should not come here
SystemBasePlugin.logWarning("Something went wrong and the default profile is not set"); //$NON-NLS-1$
}
}
}
return (ISystemProfile[]) profiles.toArray(new ISystemProfile[profiles.size()]);
return getSystemProfiles(!restoring);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNames()
*/
public String[] getSystemProfileNames() {
if (profileNames == null) {
ISystemProfile[] profiles = getSystemProfiles();
profileNames = new String[profiles.length];
for (int idx = 0; idx < profiles.length; idx++)
profileNames[idx] = profiles[idx].getName();
ISystemProfile[] profiles = getSystemProfiles();
String[] profileNames = new String[profiles.length];
for (int i = 0; i < profiles.length; i++) {
ISystemProfile profile = profiles[i];
profileNames[i] = profile.getName();
}
return profileNames;
// if (profileNames == null) {
// ISystemProfile[] profiles = getSystemProfiles();
// profileNames = new String[profiles.length];
// for (int idx = 0; idx < profiles.length; idx++)
// profileNames[idx] = profiles[idx].getName();
// }
// return profileNames;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNamesVector()
*/
public Vector getSystemProfileNamesVector() {
if (profileNamesVector == null) {
ISystemProfile[] profiles = getSystemProfiles();
profileNamesVector = new Vector(profiles.length);
for (int idx = 0; idx < profiles.length; idx++)
profileNamesVector.addElement(profiles[idx].getName());
}
return profileNamesVector;
}
/**
* Something changed so invalide cache of profiles so it will be regenerated
*/
protected void invalidateCache() {
//DY profiles = null;
profileNames = null;
profileNamesVector = null;
List names = Arrays.asList(getSystemProfileNames());
Vector result = new Vector(names.size());
result.addAll(names);
return result;
// if (profileNamesVector == null) {
// ISystemProfile[] profiles = getSystemProfiles();
// profileNamesVector = new Vector(profiles.length);
// for (int idx = 0; idx < profiles.length; idx++)
// profileNamesVector.addElement(profiles[idx].getName());
// }
// return profileNamesVector;
}
// /**
// * Something changed so invalide cache of profiles so it will be regenerated
// */
// protected void invalidateCache() {
// profileNames = null;
// profileNamesVector = null;
// }
//
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String)
*/
@ -245,7 +176,7 @@ public class SystemProfileManager implements ISystemProfileManager {
String oldName = profile.getName();
profile.setName(newName);
if (isActive) RSEPreferencesManager.renameActiveProfile(oldName, newName);
invalidateCache();
// invalidateCache();
// FIXME RSEUIPlugin.getThePersistenceManager().save(this);
}
@ -255,7 +186,7 @@ public class SystemProfileManager implements ISystemProfileManager {
public void deleteSystemProfile(ISystemProfile profile, boolean persist) {
String oldName = profile.getName();
boolean isActive = isSystemProfileActive(oldName);
getProfiles().remove(profile);
_profiles.remove(profile);
/* FIXME in EMF the profiles are "owned" by the Resource, and only referenced by the profile manager,
* so just removing it from the manager is not enough, it must also be removed from its resource.
* No longer needed since EMF is not in use.
@ -264,9 +195,10 @@ public class SystemProfileManager implements ISystemProfileManager {
* res.getContents().remove(profile);
*/
if (isActive) RSEPreferencesManager.deleteActiveProfile(oldName);
invalidateCache();
// invalidateCache();
if (persist) {
RSEUIPlugin.getThePersistenceManager().deleteProfile(oldName);
IRSEPersistenceProvider provider = profile.getPersistenceProvider();
RSECorePlugin.getThePersistenceManager().deleteProfile(provider, oldName);
}
}
@ -430,100 +362,115 @@ public class SystemProfileManager implements ISystemProfileManager {
return getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName());
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getProfiles()
*/
public List getProfiles() {
List result = new ArrayList(_profiles.size());
result.addAll(_profiles);
return result;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSize()
*/
public int getSize() {
return _profiles.size();
}
/**
* Adds a newly restored profile to this manager
* @param profile the profile to add
*/
public void addSystemProfile(ISystemProfile profile) {
_profiles.add(profile);
String name = profile.getName();
if (profile.isActive()) {
RSEPreferencesManager.addActiveProfile(name);
}
profile.setDefaultPrivate(name.equalsIgnoreCase(RSEPreferencesManager.getDefaultPrivateSystemProfileName()));
}
private ISystemProfile[] getSystemProfiles(boolean ensureDefaultPrivateProfileExists) {
if (ensureDefaultPrivateProfileExists) {
ensureDefaultPrivateProfile();
}
ISystemProfile[] result = new ISystemProfile[_profiles.size()];
_profiles.toArray(result);
return result;
}
public void setRestoring(boolean flag) {
restoring = flag;
}
private ISystemProfile internalCreateSystemProfile(String name) {
ISystemProfile newProfile = new SystemProfile();
newProfile.setName(name);
newProfile.setProfileManager(this);
_profiles.add(newProfile);
// invalidateCache();
newProfile.setDefaultPrivate(name.equalsIgnoreCase(RSEPreferencesManager.getDefaultPrivateSystemProfileName()));
return newProfile;
}
private void ensureDefaultPrivateProfile() {
// Ensure that one Profile is the default Profile - defect 48995 NH
boolean defaultProfileExists = false;
for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
ISystemProfile profile = (ISystemProfile) z.next();
defaultProfileExists = profile.isDefaultPrivate();
}
if (!defaultProfileExists) {
// find one with the right name
String defaultPrivateProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
ISystemProfile profile = (ISystemProfile) z.next();
if (profile.getName().equals(defaultPrivateProfileName)) {
profile.setDefaultPrivate(true);
defaultProfileExists = true;
}
}
}
if (!defaultProfileExists) {
// Find the first profile that is not the Team profile and make it the default private profile
String defaultTeamProfileName = RSEPreferencesManager.getDefaultTeamProfileName();
for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
ISystemProfile profile = (ISystemProfile) z.next();
if (!profile.getName().equals(defaultTeamProfileName)) {
profile.setDefaultPrivate(true);
defaultProfileExists = true;
}
}
}
if (!defaultProfileExists) {
// If Team is the only profile - then put a message in the log and create the default private profile
Logger logger = RSECorePlugin.getDefault().getLogger();
logger.logWarning("Only one Profile Team exists - there is no Default Profile"); //$NON-NLS-1$
createDefaultPrivateProfile();
}
}
private void createDefaultPrivateProfile() {
ISystemProfile profile = new SystemProfile();
String initProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
profile.setName(initProfileName);
profile.setDefaultPrivate(true);
_profiles = new ArrayList();
_profiles.add(profile);
}
/**
* Instantiate a user profile given its name.
* @param userProfileName the name of the profile to find or create
* @return the profile that was found or created.
*/
protected ISystemProfile getOrCreateSystemProfile(String userProfileName) {
private ISystemProfile getOrCreateSystemProfile(String userProfileName) {
ISystemProfile userProfile = getSystemProfile(userProfileName);
if (userProfile == null) {
userProfile = internalCreateSystemProfileAndFolder(userProfileName);
userProfile = internalCreateSystemProfile(userProfileName);
}
return userProfile;
}
/**
* No longer used.
* @param profileName the name of the profile from which to construct the name
* @return the unqualified save file name with the extension .xmi
*/
public static String getSaveFileName(String profileName) {
return null;
//FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profileName)); no longer needed.
}
/**
* No longer used.
* @param profile the profile from which to construct the name
* @return the unqualified save file name with the extension .xmi
*/
public static String getSaveFileName(ISystemProfile profile) {
return null;
//FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profile)); no longer needed.
}
/**
* No longer used.
* @param profile the profile from which to retrieve the root.
* @return the root save file name without the extension .xmi
*/
protected static String getRootSaveFileName(ISystemProfile profile) {
return getRootSaveFileName(profile.getName());
}
/**
* No longer used.
* @param profileName the name of the profile
* @return the root save file name without the extension .xmi
*/
protected static String getRootSaveFileName(String profileName) {
//String fileName = profileName; // may be a bad idea to include manager name in it!
String fileName = PROFILE_FILE_NAME;
return fileName;
}
/**
* Reusable method to return a name validator for renaming a profile.
* @param profileName the current profile name on updates. Can be null for new profiles. Used
* to remove from the existing name list the current connection.
* @return the validator
*/
public ISystemValidator getProfileNameValidator(String profileName) {
//Vector v = getActiveSystemProfileNamesVector();
Vector v = getSystemProfileNamesVector();
if (profileName != null) v.removeElement(profileName);
ISystemValidator nameValidator = new ValidatorProfileName(v);
return nameValidator;
}
/**
* Reusable method to return a name validator for renaming a profile.
* @param profile the current profile object on updates. Can be null for new profiles. Used
* to remove from the existing name list the current connection.
* @return the validator
*/
public ISystemValidator getProfileNameValidator(ISystemProfile profile) {
if (profile != null)
return getProfileNameValidator(profile.getName());
else
return getProfileNameValidator((String) null);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getProfiles()
*/
public List getProfiles() {
if (_profiles == null) {
ISystemProfile profile = new SystemProfile();
String initProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
profile.setName(initProfileName);
profile.setDefaultPrivate(true);
_profiles = new ArrayList();
_profiles.add(profile);
//profiles = null;//FIXME new EObjectResolvingeList(SystemProfile.class, this, ModelPackage.SYSTEM_PROFILE_MANAGER__PROFILES);
}
return _profiles;
}
}

View file

@ -16,7 +16,9 @@
********************************************************************************/
package org.eclipse.rse.internal.core.subsystems;
import org.eclipse.rse.core.RSECorePlugin;
import java.util.Arrays;
import java.util.List;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.RSEModelObject;
@ -59,7 +61,10 @@ public abstract class ServerLauncher extends RSEModelObject implements IServerLa
}
public IRSEPersistableContainer[] getPersistableChildren() {
return new IRSEPersistableContainer[0];
List children = Arrays.asList(getPropertySets());
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;
}
/**

View file

@ -16,11 +16,13 @@
package org.eclipse.rse.internal.persistence;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
@ -29,19 +31,13 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.rse.core.IRSEPreferenceNames;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider;
import org.eclipse.rse.core.filters.SystemFilterPoolManager;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemHostPool;
import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.persistence.dom.RSEDOMExporter;
import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter;
import org.eclipse.rse.logging.Logger;
@ -58,129 +54,117 @@ import org.eclipse.rse.persistence.dom.RSEDOM;
public class RSEPersistenceManager implements IRSEPersistenceManager {
private static final int STATE_NONE = 0;
private static final int STATE_IMPORTING = 1;
private static final int STATE_EXPORTING = 2;
private static final int STATE_LOADING = 1;
private static final int STATE_SAVING = 2;
private static IProject remoteSystemsProject = null;
public static final String RESOURCE_PROJECT_NAME = "RemoteSystemsConnections"; //$NON-NLS-1$
/**
* Get the default remote systems project.
* @return IProject handle of the project. Use exists() to test existence.
* @return IProject handle of the project.
*/
public static IProject getRemoteSystemsProject() {
if (remoteSystemsProject == null)
{
remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject();
}
return remoteSystemsProject;
}
private Map loadedProviders = new HashMap(10);
private Map knownProviders = new HashMap(10);
private int _currentState = STATE_NONE;
private RSEDOMExporter _exporter;
private RSEDOMImporter _importer;
public RSEPersistenceManager(ISystemRegistry registry) {
// _registry = registry;
_exporter = RSEDOMExporter.getInstance();
_exporter.setSystemRegistry(registry);
_importer = RSEDOMImporter.getInstance();
_importer.setSystemRegistry(registry);
getProviderExtensions();
}
public boolean commit(ISystemFilterPoolManager filterPoolManager) {
if (filterPoolManager.isDirty()) {
commit(filterPoolManager.getSystemProfile());
filterPoolManager.setDirty(false);
}
return false;
public boolean isExporting() {
return _currentState == STATE_SAVING;
}
public boolean commit(ISystemHostPool connectionPool) {
if (connectionPool.isDirty()) {
commit(connectionPool.getSystemProfile());
connectionPool.setDirty(false);
}
/*
Host[] connections = connectionPool.getHosts();
for (int idx = 0; idx < connections.length; idx++)
{
if (!saveHost(connectionPool, connections[idx]))
{
return false;
}
}
return true;
*/
return false; // all persistence should be at profile level
public boolean isImporting() {
return _currentState == STATE_LOADING;
}
public void registerPersistenceProvider(String id, IRSEPersistenceProvider provider) {
knownProviders.put(id, provider);
}
/**
* Attempt to save single profile to disk.
*/
public boolean commit(ISystemProfile profile) {
public boolean commitProfile(ISystemProfile profile) {
boolean result = false;
if (profile != null) {
return save(profile, false);
result = save(profile, true);
}
return false;
return result;
}
/**
* Save all profiles to disk
*/
public boolean commit(ISystemProfileManager profileManager) {
ISystemProfile[] profiles = profileManager.getSystemProfiles();
for (int idx = 0; idx < profiles.length; idx++) {
public boolean commitProfiles() {
boolean ok = true;
ISystemProfile[] profiles = RSECorePlugin.getDefault().getSystemRegistry().getAllSystemProfiles();
for (int idx = 0; idx < profiles.length && ok; idx++) {
try {
commit(profiles[idx]);
ok = commitProfile(profiles[idx]);
} catch (Exception exc) {
Logger logger = RSECorePlugin.getDefault().getLogger();
String profileName = profiles[idx].getName();
String message = "Error saving profile " + profileName; //$NON-NLS-1$
logger.logError(message, exc);
return false;
ok = false;
}
}
return true;
return ok;
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#migrateProfile(org.eclipse.rse.core.model.ISystemProfile, org.eclipse.rse.persistence.IRSEPersistenceProvider)
*/
public void migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider) {
IRSEPersistenceProvider oldProvider = profile.getPersistenceProvider();
oldProvider = (oldProvider == null) ? getDefaultPersistenceProvider() : oldProvider;
IRSEPersistenceProvider newProvider = persistenceProvider;
newProvider = (newProvider == null) ? getDefaultPersistenceProvider() : newProvider;
if (oldProvider != newProvider) {
profile.setPersistenceProvider(newProvider);
profile.commit();
deleteProfile(oldProvider, profile.getName());
}
}
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#deleteProfile(java.lang.String)
*/
public void deleteProfile(final String profileName) {
public void deleteProfile(final IRSEPersistenceProvider persistenceProvider, final String profileName) {
Job job = new Job(Messages.RSEPersistenceManager_DeleteProfileJobName) {
protected IStatus run(IProgressMonitor monitor) {
IRSEPersistenceProvider provider = getRSEPersistenceProvider();
IStatus result = provider.deleteProfile(profileName, monitor);
IRSEPersistenceProvider p = persistenceProvider != null ? persistenceProvider : getDefaultPersistenceProvider();
IStatus result = p.deleteProfile(profileName, monitor);
return result;
}
};
job.schedule();
}
private RSEDOM exportRSEDOM(ISystemProfile profile, boolean force) {
RSEDOM dom = _exporter.createRSEDOM(profile, force);
return dom;
}
/**
* Retrieves the default persistence provider for this workbench configuration.
* Several persistence providers may be registered, but the default one is used for all
* profiles that do not have one explicitly specified.
* This persistence provider's identifier is specified in the org.eclipse.rse.core/defaultPersistenceProvider
* preference and can be specified a product's plugin_customization.ini file.
* @see IRSEPreferenceNames
* @return the default IRSEPersistenceProvider for this installation.
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#restoreProfiles()
*/
public IRSEPersistenceProvider getRSEPersistenceProvider() {
Preferences preferences = RSECorePlugin.getDefault().getPluginPreferences();
String providerName = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER);
IRSEPersistenceProvider provider = getRSEPersistenceProvider(providerName);
return provider;
public ISystemProfile[] restoreProfiles() {
List profiles = loadProfiles();
ISystemProfile[] result = new ISystemProfile[profiles.size()];
profiles.toArray(result);
return result;
}
public ISystemProfile restoreProfile(IRSEPersistenceProvider provider, String profileName) {
ISystemProfile result = load(provider, profileName);
return result;
}
/**
@ -189,216 +173,163 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
* @param id The id of the persistence provider, as denoted by the id attribute on its declaration.
* @return an IRSEPersistenceProvider which may be null if this id is not found.
*/
public IRSEPersistenceProvider getRSEPersistenceProvider(String id) {
Logger logger = RSECorePlugin.getDefault().getLogger();
IRSEPersistenceProvider provider = (IRSEPersistenceProvider) loadedProviders.get(id);
if (provider == null) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] providerCandidates = registry.getConfigurationElementsFor("org.eclipse.rse.core", "persistenceProviders"); //$NON-NLS-1$ //$NON-NLS-2$
for (int j = 0; j < providerCandidates.length; j++) {
IConfigurationElement providerCandidate = providerCandidates[j];
if (providerCandidate.getName().equals("persistenceProvider")) { //$NON-NLS-1$
String candidateId = providerCandidate.getAttribute("id"); //$NON-NLS-1$
if (candidateId != null) {
if (candidateId.equals(id)) {
try {
provider = (IRSEPersistenceProvider) providerCandidate.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) {
logger.logError("Exception loading persistence provider", e); //$NON-NLS-1$
}
}
} else {
logger.logError("Missing id attribute in persistenceProvider element", null); //$NON-NLS-1$
}
} else {
logger.logError("Invalid element in persistenceProviders extension point", null); //$NON-NLS-1$
}
public IRSEPersistenceProvider getPersistenceProvider(String id) {
IRSEPersistenceProvider provider = null;
Object providerCandidate = knownProviders.get(id);
if (providerCandidate instanceof IConfigurationElement) {
IConfigurationElement element = (IConfigurationElement) providerCandidate;
try {
provider = (IRSEPersistenceProvider) element.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) {
Logger logger = RSECorePlugin.getDefault().getLogger();
logger.logError("Exception loading persistence provider", e); //$NON-NLS-1$
}
if (provider == null) {
logger.logError("Persistence provider not found.", null); //$NON-NLS-1$
if (provider != null) {
knownProviders.put(id, provider);
}
loadedProviders.put(id, provider); // even if provider is null
} else if (providerCandidate instanceof IRSEPersistenceProvider) {
provider = (IRSEPersistenceProvider) providerCandidate;
}
return provider;
}
private RSEDOM importRSEDOM(String domName) {
RSEDOM dom = null;
IRSEPersistenceProvider provider = getRSEPersistenceProvider();
if (provider != null) {
dom = provider.loadRSEDOM(domName, null);
} else {
Logger logger = RSECorePlugin.getDefault().getLogger();
logger.logError("Persistence provider is not available.", null); //$NON-NLS-1$
}
return dom;
/* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#getPersistenceProviderIds()
*/
public String[] getPersistenceProviderIds() {
Set ids = knownProviders.keySet();
String[] result = new String[ids.size()];
ids.toArray(result);
return result;
}
public synchronized boolean isExporting() {
return _currentState == STATE_EXPORTING;
}
public synchronized boolean isImporting() {
return _currentState == STATE_IMPORTING;
/**
* Retrieves the default persistence provider for this workbench configuration.
* Several persistence providers may be registered, but the default one is used for all
* profiles that do not have one explicitly specified.
* This persistence provider's identifier is specified in the org.eclipse.rse.core/DEFAULT_PERSISTENCE_PROVIDER
* preference and can be specified a product's plugin_customization.ini file.
* @see IRSEPreferenceNames
* @return the default IRSEPersistenceProvider for this installation.
*/
private IRSEPersistenceProvider getDefaultPersistenceProvider() {
Preferences preferences = RSECorePlugin.getDefault().getPluginPreferences();
String providerId = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER);
IRSEPersistenceProvider provider = getPersistenceProvider(providerId);
return provider;
}
/**
* Loads and restores RSE artifacts from the last session
* @param profileManager
* @return true if the profiles are loaded
* Loads the map of known providers from the extensions made by all the plugins.
* This is done once at initialization of the manager. As these ids are resolved to
* their providers as needed, the configuration elements are replaced in the map
* by the persistence providers they reference.
*/
private boolean load(ISystemProfileManager profileManager) {
boolean successful = true;
synchronized(this) {
if (isExporting() || isImporting()) {
successful = false;
} else {
setState(STATE_IMPORTING);
}
}
if(successful) {
try {
IProject project = getRemoteSystemsProject();
if (!project.isSynchronized(IResource.DEPTH_ONE)) project.refreshLocal(IResource.DEPTH_ONE, null);
IRSEPersistenceProvider persistenceProvider = getRSEPersistenceProvider();
String[] profileNames = persistenceProvider.getSavedProfileNames();
for (int i = 0; i < profileNames.length; i++) {
String profileName = profileNames[i];
RSEDOM dom = importRSEDOM(profileName);
if (dom != null) {
ISystemProfile restoredProfile = _importer.restoreProfile(profileManager, dom);
if (restoredProfile == null) {
successful = false;
}
} else {
successful = false;
}
private void getProviderExtensions() {
Logger logger = RSECorePlugin.getDefault().getLogger();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] providerCandidates = registry.getConfigurationElementsFor("org.eclipse.rse.core", "persistenceProviders"); //$NON-NLS-1$ //$NON-NLS-2$
for (int j = 0; j < providerCandidates.length; j++) {
IConfigurationElement configurationElement = providerCandidates[j];
if (configurationElement.getName().equals("persistenceProvider")) { //$NON-NLS-1$
String candidateId = configurationElement.getAttribute("id"); //$NON-NLS-1$
if (candidateId != null) {
knownProviders.put(candidateId, configurationElement);
} else {
logger.logError("Missing id attribute in persistenceProvider element", null); //$NON-NLS-1$
}
} catch (Exception e) {
e.printStackTrace();
successful = false;
} finally {
setState(STATE_NONE);
} else {
logger.logError("Invalid element in persistenceProviders extension point", null); //$NON-NLS-1$
}
}
return successful;
}
public void registerRSEPersistenceProvider(String id, IRSEPersistenceProvider provider) {
loadedProviders.put(id, provider);
private List loadProfiles() {
List profiles = new ArrayList(10);
String[] ids = getPersistenceProviderIds();
for (int i = 0; i < ids.length; i++) {
String id = ids[i];
IRSEPersistenceProvider provider = getPersistenceProvider(id);
if (provider != null) {
profiles.addAll(loadProfiles(provider));
}
}
return profiles;
}
public boolean restore(ISystemFilterPool filterPool) {
//System.out.println("restore filterpool");
// DWD function Is this method really needed?
return false;
}
public boolean restore(ISystemHostPool connectionPool) {
return false;
}
public boolean restore(ISystemProfileManager profileManager) {
return load(profileManager);
}
public ISystemFilterPool restoreFilterPool(String name) {
//System.out.println("restore filter pool "+name);
// DWD function is this method really needed?
return null;
private List loadProfiles(IRSEPersistenceProvider persistenceProvider) {
List profiles = new ArrayList(10);
String[] profileNames = persistenceProvider.getSavedProfileNames();
for (int i = 0; i < profileNames.length; i++) {
String profileName = profileNames[i];
ISystemProfile profile = load(persistenceProvider, profileName);
profiles.add(profile);
}
return profiles;
}
/**
* Creates a filter pool manager for a particular SubSystemConfiguration and SystemProfile. Called
* "restore" for historcal reasons.
* @param profile the profile that will own this ISystemFilterPoolManager. There is one of these per profile.
* @param logger the logging object for logging errors. Each ISystemFilterPoolManager has one of these.
* @param caller The creator/owner of this ISystemFilterPoolManager, this ends up being a SubSystemConfiguration.
* @param name the name of the manager to restore. File name is derived from it when saving to one file.
* @return the "restored" manager.
* Loads a profile of the given name using the given persistence provider. If the provider cannot
* find a profile with that name, return null.
* @param provider the persistence provider that understands the name and can produce a profile.
* @param profileName the name of the profile to produce
* @return the profile or null
*/
public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name) {
SystemFilterPoolManager mgr = SystemFilterPoolManager.createManager(profile);
mgr.initialize(logger, caller, name); // core data
mgr.setWasRestored(false); // managers are not "restored from disk" since they are not persistent of themselves
return mgr;
private synchronized ISystemProfile load(IRSEPersistenceProvider provider, String profileName) {
ISystemProfile profile = null;
if (_currentState == STATE_NONE) {
_currentState = STATE_LOADING;
RSEDOM dom = provider.loadRSEDOM(profileName, null);
if (dom != null) {
SystemProfileManager.getDefault().setRestoring(true);
profile = _importer.restoreProfile(dom);
profile.setPersistenceProvider(provider);
cleanTree(profile);
SystemProfileManager.getDefault().setRestoring(false);
}
_currentState = STATE_NONE;
}
return profile;
}
/**
* Restore a connection of a given name from disk...
*/
protected IHost restoreHost(ISystemHostPool hostPool, String connectionName) throws Exception {
/*
* FIXME //System.out.println("in SystemConnectionPoolImpl#restore for
* connection " + connectionName); String fileName =
* getRootSaveFileName(connectionName);
* //System.out.println(".......fileName = " + fileName);
* //System.out.println(".......folderName = " +
* getConnectionFolder(connectionName).getName()); java.util.List ext =
* getMOFHelpers().restore(getConnectionFolder(connectionName),fileName);
* // should be exactly one profile... Iterator iList = ext.iterator();
* SystemConnection connection = (SystemConnection)iList.next(); if
* (connection != null) { if
* (!connection.getAliasName().equalsIgnoreCase(connectionName)) {
* RSEUIPlugin.logDebugMessage(this.getClass().getName(),"Incorrect
* alias name found in connections.xmi file for " + connectionName+".
* Name was reset"); connection.setAliasName(connectionName); // just in
* case! } internalAddConnection(connection); } return connection;
*/
return null;
}
/**
* Restore a profile of a given name from disk...
*/
protected ISystemProfile restoreProfile(ISystemProfileManager mgr, String name) throws Exception {
/*
* FIXME String fileName = mgr.getRootSaveFileName(name); java.util.List
* ext = null;//FIXME
* getMOFHelpers().restore(SystemResourceManager.getProfileFolder(name),fileName);
* // should be exactly one profile... Iterator iList = ext.iterator();
* SystemProfile profile = (SystemProfile)iList.next();
* mgr.initialize(profile, name); return profile;
*/
return null;
}
/**
* Writes the RSE model to a DOM and schedules writing of that DOM to disk.
* Writes a profile to a DOM and schedules writing of that DOM to disk.
* May, in fact, update an existing DOM instead of creating a new one.
* If in the process of importing, skip writing.
* @return true if the profile is written to a DOM
*/
private boolean save(ISystemProfile profile, boolean force) {
boolean result = false;
boolean acquiredLock = false;
synchronized(this) {
if (!isImporting()) {
setState(STATE_EXPORTING);
acquiredLock = true;
private synchronized boolean save(ISystemProfile profile, boolean force) {
if (_currentState == STATE_NONE) {
_currentState = STATE_SAVING;
IRSEPersistenceProvider provider = profile.getPersistenceProvider();
if (provider == null) {
provider = getDefaultPersistenceProvider();
profile.setPersistenceProvider(provider);
}
}
if (acquiredLock) {
try {
RSEDOM dom = exportRSEDOM(profile, true); // DWD should do merge, but does not handle deletes properly yet
result = true;
if (dom.needsSave()) {
Job job = dom.getSaveJob();
if (job == null) {
job = new SaveRSEDOMJob(dom, getRSEPersistenceProvider());
dom.setSaveJob(job);
}
job.schedule(3000); // three second delay
RSEDOM dom = _exporter.createRSEDOM(profile, force);
cleanTree(profile);
if (dom.needsSave()) {
Job job = dom.getSaveJob();
if (job == null) {
job = new SaveRSEDOMJob(dom, getDefaultPersistenceProvider());
dom.setSaveJob(job);
}
} finally {
setState(STATE_NONE);
job.schedule(3000); // three second delay
}
_currentState = STATE_NONE;
}
return result;
return true;
}
private synchronized void setState(int state) {
_currentState = state;
private void cleanTree(IRSEPersistableContainer node) {
node.setWasRestored(true);
node.setTainted(false);
node.setDirty(false);
IRSEPersistableContainer[] children = node.getPersistableChildren();
for (int i = 0; i < children.length; i++) {
IRSEPersistableContainer child = children[i];
cleanTree(child);
}
}
}

View file

@ -31,7 +31,6 @@ import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IPropertyType;
import org.eclipse.rse.core.model.IRSEModelObject;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.IDelegatingConnectorService;
import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
@ -41,11 +40,10 @@ import org.eclipse.rse.persistence.dom.RSEDOM;
import org.eclipse.rse.persistence.dom.RSEDOMNode;
public class RSEDOMExporter implements IRSEDOMExporter {
private static RSEDOMExporter _instance = new RSEDOMExporter();
private Map _domMap;
// private ISystemRegistry _registry;
/**
* Constructor to create a new DOM exporter.
*/
@ -53,10 +51,6 @@ public class RSEDOMExporter implements IRSEDOMExporter {
_domMap = new HashMap();
}
public void setSystemRegistry(ISystemRegistry registry) {
// _registry = registry;
}
/**
* @return the singleton instance of this exporter
*/
@ -401,13 +395,13 @@ public class RSEDOMExporter implements IRSEDOMExporter {
*/
public RSEDOMNode createNode(RSEDOMNode parent, ISystemFilterPoolReference filterPoolReference, boolean clean) {
RSEDOMNode node = findOrCreateNode(parent, IRSEDOMConstants.TYPE_FILTER_POOL_REFERENCE, filterPoolReference, clean);
String name = filterPoolReference.getFullName();
node.setName(name); // filter pool references must write out the fully qualified name of their referenced filter pool
if (clean || node.isDirty()) {
ISystemFilterPool filterPool = filterPoolReference.getReferencedFilterPool();
String refId = (filterPool != null) ? filterPool.getId() : "unknown"; //$NON-NLS-1$
node.addAttribute(IRSEDOMConstants.ATTRIBUTE_REF_ID, refId);
}
createPropertySetNodes(node, filterPoolReference, clean);
node.setDirty(false);
return node;
@ -430,8 +424,7 @@ public class RSEDOMExporter implements IRSEDOMExporter {
node.setDirty(true);
}
}
boolean newNode = (node == null);
if (newNode) {
if (node == null) {
node = new RSEDOMNode(parent, type, name);
}
return node;

View file

@ -30,7 +30,6 @@ import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IPropertyType;
import org.eclipse.rse.core.model.IRSEModelObject;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.PropertyType;
import org.eclipse.rse.core.subsystems.IConnectorService;
@ -40,13 +39,14 @@ import org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.SubSystemFilterNamingPolicy;
import org.eclipse.rse.internal.core.filters.ISystemFilterConstants;
import org.eclipse.rse.internal.core.model.SystemProfile;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.persistence.dom.IRSEDOMConstants;
import org.eclipse.rse.persistence.dom.RSEDOM;
import org.eclipse.rse.persistence.dom.RSEDOMNode;
import org.eclipse.rse.persistence.dom.RSEDOMNodeAttribute;
public class RSEDOMImporter implements IRSEDOMImporter {
public class RSEDOMImporter {
private static RSEDOMImporter _instance = new RSEDOMImporter();
private ISystemRegistry _registry;
@ -63,20 +63,17 @@ public class RSEDOMImporter implements IRSEDOMImporter {
/**
* Restores the profile represented by dom
* @param profileManager
* @param dom
* @return the restored profile
*/
public ISystemProfile restoreProfile(ISystemProfileManager profileManager, RSEDOM dom) {
// create the profile
public ISystemProfile restoreProfile(RSEDOM dom) {
String profileName = dom.getName();
boolean defaultPrivate = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE).getValue());
boolean isActive = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE).getValue());
ISystemProfile profile = profileManager.createSystemProfile(profileName, isActive);
ISystemProfile profile = new SystemProfile(profileName, isActive);
if (profile != null) {
profile.setDefaultPrivate(defaultPrivate);
profileManager.makeSystemProfileActive(profile, isActive);
SystemProfileManager.getDefault().addSystemProfile(profile);
// restore the children for the profile
RSEDOMNode[] children = dom.getChildren();
for (int i = 0; i < children.length; i++) {
@ -130,7 +127,6 @@ public class RSEDOMImporter implements IRSEDOMImporter {
restorePropertySet(host, child);
}
}
return host;
}
@ -194,7 +190,7 @@ public class RSEDOMImporter implements IRSEDOMImporter {
}
public IServerLauncherProperties restoreServerLauncher(IConnectorService service, RSEDOMNode serverLauncherNode, IServerLauncherProperties sl) {
// restore all property sets
// restore all property sets
RSEDOMNode[] psChildren = serverLauncherNode.getChildren(IRSEDOMConstants.TYPE_PROPERTY_SET);
for (int p = 0; p < psChildren.length; p++) {
RSEDOMNode psChild = psChildren[p];
@ -232,7 +228,7 @@ public class RSEDOMImporter implements IRSEDOMImporter {
subSystem = existingSubSystems[0];
}
}
if (subSystem == null) {
// subSystem = factory.createSubSystemInternal(host);
ISubSystem[] createdSystems = _registry.createSubSystems(host, new ISubSystemConfiguration[]{factory});
@ -243,7 +239,6 @@ public class RSEDOMImporter implements IRSEDOMImporter {
subSystem.setSubSystemConfiguration(factory);
subSystem.setName(factory.getName());
subSystem.setConfigurationId(factory.getId());
subSystem.setWasRestored(true);
if (factory.supportsFilters()) {
ISystemFilterStartHere startHere = _registry.getSystemFilterStartHere();
@ -267,6 +262,7 @@ public class RSEDOMImporter implements IRSEDOMImporter {
restorePropertySet(subSystem, psChild);
}
}
subSystem.wasRestored();
return subSystem;
}
@ -304,10 +300,6 @@ public class RSEDOMImporter implements IRSEDOMImporter {
// create the filter
ISystemFilter filter = filterPool.createSystemFilter(name, filterStrings);
filter.setWasRestored(true);
// set filter attributes
filter.setSupportsNestedFilters(supportsNestedFilters);
filter.setRelativeOrder(relativeOrder);
filter.setDefault(isDefault);
@ -361,26 +353,21 @@ public class RSEDOMImporter implements IRSEDOMImporter {
filterPool = mgr.getSystemFilterPool(name);
}
if (filterPool == null) {
filterPool = _registry.getSystemFilterPool().createSystemFilterPool(name, supportsNestedFilters, isDeletable, ISystemFilterConstants.TRY_TO_RESTORE_NO);
if (filterPool != null) {
filterPool.setSystemFilterPoolManager(mgr);
// add to model
mgr.getPools().add(filterPool);
}
}
if (filterPool != null) {
filterPool.setType(type);
filterPool.setDefault(isDefault);
filterPool.setSupportsNestedFilters(supportsNestedFilters);
filterPool.setStringsCaseSensitive(isSetStringsCaseSensitive);
filterPool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings);
filterPool.setRelease(release);
filterPool.setSingleFilterStringOnly(isSetSingleFilterStringOnly);
filterPool.setOwningParentName(owningParentName);
filterPool.setNonRenamable(isNonRenamable);
filterPool.setWasRestored(true);
filterPool = mgr.createSystemFilterPool(name, isDeletable);
// filterPool = new SystemFilterPool(name, supportsNestedFilters, isDeletable);
// filterPool.setSystemFilterPoolManager(mgr);
// mgr.getPools().add(filterPool);
}
filterPool.setType(type);
filterPool.setDefault(isDefault);
filterPool.setSupportsNestedFilters(supportsNestedFilters);
filterPool.setStringsCaseSensitive(isSetStringsCaseSensitive);
filterPool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings);
filterPool.setRelease(release);
filterPool.setSingleFilterStringOnly(isSetSingleFilterStringOnly);
filterPool.setOwningParentName(owningParentName);
filterPool.setNonRenamable(isNonRenamable);
// filterPool.wasRestored();
}
} catch (Exception e) {
e.printStackTrace();
@ -407,26 +394,15 @@ public class RSEDOMImporter implements IRSEDOMImporter {
*/
public ISystemFilterPoolReference restoreFilterPoolReference(ISubSystem subsystem, RSEDOMNode node) {
ISystemFilterPoolReference filterPoolReference = null;
String subsystemName = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_REF_ID).getValue();
String filterPoolName = node.getName();
ISubSystemConfiguration configuration = getSubSystemConfiguration(subsystemName);
if (configuration != null) {
ISystemProfile profile = subsystem.getSystemProfile(); // DWD are there cases where this may be null?
ISystemFilterPoolManager filterPoolManager = configuration.getFilterPoolManager(profile);
ISystemFilterPool filterPool = filterPoolManager.getSystemFilterPool(filterPoolName);
ISystemFilterPoolReferenceManager referenceManager = subsystem.getFilterPoolReferenceManager();
/*
* DWD filterpool can be null when restoring since there can be forward references.
* A profile may be being restored that has references to a filter pool in a profile that doesn't yet exist.
* Need to create an "unresolved" reference instead of a null object and then patch them up on first access.
*/
// create reference to the filterpool
if (filterPool != null) {
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPool);
} else {
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolManager, filterPoolName);
}
String[] part = filterPoolName.split("___", 2); //$NON-NLS-1$
if (part.length == 1) { // name is unqualified and refers to a filter pool in the current profile, ensure it is qualified
ISystemProfile profile = subsystem.getSystemProfile();
String profileName = profile.getName();
filterPoolName = profileName + "___" + filterPoolName; //$NON-NLS-1$
}
ISystemFilterPoolReferenceManager referenceManager = subsystem.getFilterPoolReferenceManager();
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolName);
return filterPoolReference;
}

View file

@ -16,84 +16,89 @@
package org.eclipse.rse.persistence;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider;
import org.eclipse.rse.core.model.ISystemHostPool;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.logging.Logger;
public interface IRSEPersistenceManager {
public boolean commit(ISystemFilterPoolManager filterPoolManager);
/**
* Save all connections in the connection pool
* @param connectionPool
* Save a particular profile. If the profile has an existing persistence provider
* it is saved by that persistence provider. If the profile has no persistence provider
* then the default persistence provider is used.
* @param profile the profile to save
* @return true if successful
*/
public boolean commit(ISystemHostPool connectionPool);
public boolean commitProfile(ISystemProfile profile);
/**
* Save this profile
* @param profile
* Save all profiles.
* @return true if successful
*/
public boolean commit(ISystemProfile profile);
public boolean commitProfiles();
/**
* Save all profiles
* @param profileManager
* @return true if successful
* Restore all profiles
* @return an array of restored profiles.
*/
public boolean commit(ISystemProfileManager profileManager);
public ISystemProfile[] restoreProfiles();
/**
* Restore a profiles particular provider by name.
* @param provider a persistence provider
* @param profileName the name of the profile to restore
* @return the restored profile or null if no profile of that name is known to this provider.
*/
public ISystemProfile restoreProfile(IRSEPersistenceProvider provider, String profileName);
/**
* Delete the persistent form of a profile.
* @param persistenceProvider the persistence provider to use to delete the profile.
* If this is null the default persistence provider is used.
* @param profileName The name of the profile to delete
*/
public void deleteProfile(String profileName);
public boolean isExporting();
public boolean isImporting();
public void deleteProfile(IRSEPersistenceProvider persistenceProvider, String profileName);
/**
* Migrates a profile to a new persistence provider. It will delete the persistent form known to its previous
* persistence provider. If the new provider and the previous provider are the same this does nothing.
* @param profile the system profile to be migrated
* @param persistenceProvider the persistence provider to which this profile will be migrated.
*/
public void migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider);
/**
* Register the persistence provider to be used when saving and restoring RSE doms.
* The provider is registered under the provided id.
* If the id has already been registered, this provider replaces the previous provider
* with that id.
* @param id the provider id.
* @param provider the provider.
*/
public void registerRSEPersistenceProvider(String id, IRSEPersistenceProvider provider);
public void registerPersistenceProvider(String id, IRSEPersistenceProvider provider);
/**
* @return an array of persistence provider ids known to this workbench. These may have been
* provided by extension point or by registering them using
* {@link #registerPersistenceProvider(String, IRSEPersistenceProvider)}
*/
public String[] getPersistenceProviderIds();
/**
* Retrieves the persistence provider named by a particular id. It can return null if there
* is no provider known by that id. This may have the effect of activating the plugin that
* contains this provider.
* @param id the id of the persistence provider to locate
* @return the persistence provider or null
*/
public IRSEPersistenceProvider getPersistenceProvider(String id);
/**
* Restore all the filters for the filter pool
* @param filterPool
* @return true if sucessful
* @return true if this instance of the persistence manager is currently exporting a profile.
*/
public boolean restore(ISystemFilterPool filterPool);
public boolean isExporting();
/**
* Restore all connections in the connection pool
* @param connectionPool
* @return true if successful
* @return true if this instance of the persistence manager is currently importing a profile.
*/
public boolean restore(ISystemHostPool connectionPool);
public boolean isImporting();
/**
* Restore all profiles
* @param profileManager
* @return true if successful
*/
public boolean restore(ISystemProfileManager profileManager);
/**
* Restore the filter pool
* @param name
* @return the filter pool if successful
*/
public ISystemFilterPool restoreFilterPool(String name);
public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name);
}

View file

@ -21,10 +21,8 @@ import java.util.ArrayList;
import java.util.List;
public class RSEDOMNode implements Serializable {
/*
* Recommended for serializable objects. This should be updated if there is a schema change.
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L; // This should be updated if there is a schema change.
protected String _type;
protected String _name;
protected RSEDOMNode _parent;
@ -219,5 +217,13 @@ public class RSEDOMNode implements Serializable {
public void setRestoring(boolean restoring) {
this.restoring = restoring;
}
public void setName(String name) {
_name = name;
}
public void setType(String type) {
_type = type;
}
}

View file

@ -17,13 +17,12 @@
package org.eclipse.rse.internal.ui;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.validators.ISystemValidator;
import org.eclipse.rse.ui.validators.ValidatorFactory;
import org.eclipse.rse.ui.validators.ValidatorProfileName;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@ -79,10 +78,7 @@ public class SystemProfileForm
this.showVerbiage = showVerbiage;
callerInstanceOfWizardPage = (caller instanceof WizardPage);
callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog);
// FIXME cast to SystemProfileManager is temporary to get at api - need to use an adapter for getting validators
SystemProfileManager mgr = (SystemProfileManager)RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager();
nameValidator = mgr.getProfileNameValidator(profile);
nameValidator = ValidatorFactory.getProfileNameValidator(profile.getName());
}
/**

View file

@ -18,7 +18,7 @@ package org.eclipse.rse.internal.ui.actions;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
@ -38,7 +38,7 @@ public class SystemProfileNameSelectAction extends SystemBaseAction
{
super(profile.getName(),parent);
this.profile = profile;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager();
ISystemProfileManager mgr = SystemProfileManager.getDefault();
setChecked(mgr.isSystemProfileActive(profile.getName()));
setSelectionSensitive(false);

View file

@ -18,7 +18,6 @@ package org.eclipse.rse.internal.ui.dialogs;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.RSEUIPlugin;
@ -27,6 +26,7 @@ import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.dialogs.SystemSimpleContentElement;
import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.validators.ISystemValidator;
import org.eclipse.rse.ui.validators.ValidatorFactory;
import org.eclipse.rse.ui.validators.ValidatorProfileName;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@ -71,10 +71,7 @@ public class SystemCopyProfileDialog extends SystemPromptDialog
{
setInputObject(profile);
}
// FIXME cast to SystemProfileManager is temporary to get at api - need to use an adapter for getting validators
SystemProfileManager mgr = (SystemProfileManager)RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager();
nameValidator = mgr.getProfileNameValidator((String)null);
nameValidator = ValidatorFactory.getProfileNameValidator((String)null);
//pack();
setHelp(RSEUIPlugin.HELPPREFIX+"drnp0000"); //$NON-NLS-1$
}

View file

@ -531,7 +531,7 @@ public class SystemViewConnectionAdapter
IHost conn = (IHost)propertySourceInput;
if (name.equals(ISystemPropertyConstants.P_SYSTEMTYPE))
return conn.getSystemType().getName();
return conn.getSystemType().getLabel();
else if (name.equals(ISystemPropertyConstants.P_HOSTNAME))
return conn.getHostName();
else if (name.equals(ISystemPropertyConstants.P_DEFAULTUSERID))

View file

@ -25,6 +25,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider;
import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider;
import org.eclipse.rse.core.subsystems.ISubSystem;
@ -89,7 +90,7 @@ public class SystemViewFilterPoolReferenceAdapter
menu.add(menuGroup, action);
}
}
actions = adapter.getFilterPoolReferenceActions(menu, selection, shell, menuGroup, ssFactory, getFilterPoolReference(element));
actions = adapter.getFilterPoolReferenceActions(menu, selection, shell, menuGroup, ssFactory, (ISystemFilterPoolReference)element);
if (actions != null)
{
//menu.addSeparator();
@ -112,35 +113,35 @@ public class SystemViewFilterPoolReferenceAdapter
*/
public ISubSystem getSubSystem(Object element)
{
return ((ISubSystem)getFilterPoolReference(element).getProvider());
ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element;
return (ISubSystem)ref.getProvider();
}
/**
* Returns an image descriptor for the image. More efficient than getting the image.
* @param element The element for which an image is desired
*/
public ImageDescriptor getImageDescriptor(Object element)
{
ImageDescriptor poolImage = null;
ISystemFilterPool pool = getFilterPool(element);
if (pool.getProvider() != null)
{
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)pool.getProvider().getAdapter(ISubSystemConfigurationAdapter.class);
poolImage = adapter.getSystemFilterPoolImage(pool);
}
if (poolImage == null)
poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID);
return poolImage;
}
private ISystemFilterPoolReference getFilterPoolReference(Object element)
{
return (ISystemFilterPoolReference)element; // get referenced object
public ImageDescriptor getImageDescriptor(Object element) {
ImageDescriptor poolImage = null;
ISystemFilterPool pool = getFilterPool(element);
if (pool != null) {
ISystemFilterPoolManagerProvider provider = pool.getProvider();
if (provider != null) {
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) provider.getAdapter(ISubSystemConfigurationAdapter.class);
poolImage = adapter.getSystemFilterPoolImage(pool);
}
}
if (poolImage == null) {
poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID);
}
return poolImage;
}
private ISystemFilterPool getFilterPool(Object element)
{
return getFilterPoolReference(element).getReferencedFilterPool(); // get master object
ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element;
ISystemFilterPool pool = ref.getReferencedFilterPool();
return pool; // get master object
}
/**
@ -148,16 +149,11 @@ public class SystemViewFilterPoolReferenceAdapter
* @return the label for this filter pool reference.
*/
public String getText(Object element) {
String result = "unknown"; // $NON-NLS-1$ //$NON-NLS-1$
ISystemFilterPoolReference reference = (ISystemFilterPoolReference) element;
String result = reference.getName();
ISystemFilterPool pool = getFilterPool(element);
if (pool != null) {
result = pool.getName();
// the following looks like it was copied from the host adapter and not really needed here.
// boolean qualifyNames = RSEUIPlugin.getTheSystemRegistry().getQualifiedHostNames();
// if (qualifyNames) {
// String prefix = SubSystemHelpers.getParentSystemProfile(pool).getName();
// result = prefix + "." + result;
// }
}
return result;
}
@ -178,13 +174,14 @@ public class SystemViewFilterPoolReferenceAdapter
public String getAbsoluteName(Object element)
{
//TODO consider caching the absolute name in the FilterPoolReference to avoid unnecessary String operations - the name won't ever change
ISystemFilterPoolReference filterPoolRef = getFilterPoolReference(element);
ISystemFilterPoolReference filterPoolRef = (ISystemFilterPoolReference)element;
ISystemFilterPoolReferenceManagerProvider subSystem = filterPoolRef.getProvider();
ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(subSystem);
String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(subSystem) : ""; //$NON-NLS-1$
return parentAbsoluteName + "." + //$NON-NLS-1$
filterPoolRef.getReferencedFilterPool().getSystemFilterPoolManager().getName() + "." + //$NON-NLS-1$
filterPoolRef.getName();
String referenceName = filterPoolRef.getName();
String managerName = filterPoolRef.getReferencedFilterPoolManagerName();
String absoluteName = parentAbsoluteName + "." + managerName + "." + referenceName; //$NON-NLS-1$ //$NON-NLS-2$
return absoluteName;
}
/**
@ -202,7 +199,7 @@ public class SystemViewFilterPoolReferenceAdapter
*/
public Object getParent(Object element)
{
ISystemFilterPoolReference fpr = getFilterPoolReference(element);
ISystemFilterPoolReference fpr = (ISystemFilterPoolReference)element;
return SubSystemHelpers.getParentSubSystem(fpr);
}
@ -212,7 +209,7 @@ public class SystemViewFilterPoolReferenceAdapter
*/
public Object[] getChildren(IProgressMonitor monitor, IAdaptable element)
{
ISystemFilterPoolReference fpRef = getFilterPoolReference(element);
ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
ISubSystem ss = getSubSystem(element);
return fpRef.getSystemFilterReferences(ss);
}
@ -222,7 +219,7 @@ public class SystemViewFilterPoolReferenceAdapter
*/
public boolean hasChildren(IAdaptable element) {
int count = 0;
ISystemFilterPoolReference fpRef = getFilterPoolReference(element);
ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
if (fpRef != null) {
ISystemFilterPool filterPool = fpRef.getReferencedFilterPool();
if (filterPool != null) {

View file

@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants;
@ -61,7 +61,7 @@ public class SystemTeamViewActiveProfileAction extends SystemBaseAction
ISystemProfile profile = (ISystemProfile)getFirstSelection();
if (profile == null)
return false;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager();
ISystemProfileManager mgr = SystemProfileManager.getDefault();
// todo... we need to have two actions, one to make active, and one to make inactive.
while (profile != null)
{

View file

@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants;
@ -60,7 +60,7 @@ public class SystemTeamViewMakeActiveProfileAction extends SystemBaseAction
if (!(currsel instanceof ISystemProfile))
return false;
ISystemProfile profile = (ISystemProfile)currsel;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager();
ISystemProfileManager mgr = SystemProfileManager.getDefault();
boolean allActive = true;
while (profile != null)
{

View file

@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants;
@ -60,7 +60,7 @@ public class SystemTeamViewMakeInActiveProfileAction extends SystemBaseAction
if (!(currsel instanceof ISystemProfile))
return false;
ISystemProfile profile = (ISystemProfile)currsel;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager();
ISystemProfileManager mgr = SystemProfileManager.getDefault();
boolean allInActive = true;
while (profile != null)
{

View file

@ -16,11 +16,13 @@
package org.eclipse.rse.internal.ui.view.team;
import java.util.Hashtable;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.ui.SystemResources;
@ -371,7 +373,9 @@ public class SystemTeamViewProfileAdapter
*/
public ISystemValidator getNameValidator(Object element)
{
return new ValidatorProfileName(RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager().getSystemProfileNamesVector());
Vector names = RSECorePlugin.getDefault().getSystemRegistry().getSystemProfileManager().getSystemProfileNamesVector();
ISystemValidator validator = new ValidatorProfileName(names);
return validator;
}
/**
* Parent override.

View file

@ -44,9 +44,9 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.core.subsystems.SubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.subsystems.SubSystemConfigurationProxyComparator;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.RSESystemTypeAdapterFactory;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.actions.SystemDynamicPopupMenuExtensionManager;
@ -114,7 +114,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
if (systemType != null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
if (adapter != null && adapter.isEnabled(systemType)) {
ISystemProfileManager profileManager = SystemProfileManager.getSystemProfileManager();
ISystemProfileManager profileManager = SystemProfileManager.getDefault();
ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
String userName = System.getProperty("user.name"); //$NON-NLS-1$
registry.createLocalHost(profile, SystemResources.TERM_LOCAL, userName);
@ -761,7 +761,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
*/
public static ISystemProfileManager getTheSystemProfileManager()
{
return SystemProfileManager.getSystemProfileManager();
return SystemProfileManager.getDefault();
}
/**

View file

@ -23,7 +23,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.model.SystemRegistry;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
@ -87,7 +87,7 @@ public abstract class SystemBaseCopyAction extends SystemBaseDialogAction
: RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_MOVE_ID)),
parent);
this.mode = mode;
mgr = SystemProfileManager.getSystemProfileManager();
mgr = SystemProfileManager.getDefault();
sr = RSEUIPlugin.getTheSystemRegistry();
allowOnMultipleSelection(true);
setProcessAllSelections(true);

View file

@ -0,0 +1,27 @@
package org.eclipse.rse.ui.validators;
import java.util.Vector;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfileManager;
/**
* This class constructs validators for various bits of the user interface.
*/
public class ValidatorFactory {
/**
* Reusable method to return a name validator for renaming a profile.
* @param profileName the current profile name on updates. Can be null for new profiles. Used
* to remove from the existing name list the current connection.
* @return the validator
*/
public static ISystemValidator getProfileNameValidator(String profileName) {
ISystemProfileManager manager = RSECorePlugin.getDefault().getSystemRegistry().getSystemProfileManager();
Vector profileNames = manager.getSystemProfileNamesVector();
if (profileName != null) profileNames.remove(profileName);
ISystemValidator nameValidator = new ValidatorProfileName(profileNames);
return nameValidator;
}
}

View file

@ -124,21 +124,14 @@ public class ValidatorUniqueString
/**
* Reset the existing names list.
*/
public void setExistingNamesList(Vector existingList)
public void setExistingNamesList(Vector newList)
{
if (existingList == null)
this.existingList = null;
if (newList == null)
existingList = null;
else
{
String newList[] = new String[existingList.size()];
for (int idx=0; idx<existingList.size(); idx++)
{
if (!caseSensitive)
newList[idx] = existingList.elementAt(idx).toString().toLowerCase();
else
newList[idx] = existingList.elementAt(idx).toString();
}
init(newList, true); // don't redo the toLowerCase calls
existingList = new String[newList.size()];
newList.toArray(existingList);
}
}
/**

View file

@ -34,6 +34,7 @@ import org.eclipse.rse.core.model.ISystemHostPool;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.internal.core.model.RSEModelResources;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.RSESystemTypeAdapter;
@ -102,7 +103,7 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
*/
public ISystemProfile getSystemProfile()
{
return SystemProfileManager.getSystemProfileManager().getSystemProfile(getName());
return SystemProfileManager.getDefault().getSystemProfile(getName());
}
/**
@ -408,7 +409,7 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
conn.deletingHost(); // let connection do any necessary cleanup
getHostList().remove(conn);
setDirty(true);
RSECorePlugin.getThePersistenceManager().commit(conn.getSystemProfile());
conn.getSystemProfile().commit();
}
/**
@ -648,7 +649,9 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
*/
public boolean commit()
{
return RSECorePlugin.getThePersistenceManager().commit(this);
ISystemProfile profile = getSystemProfile();
boolean result = profile.commit();
return result;
}
/**

View file

@ -35,11 +35,9 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSEUserIdConstants;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.filters.ISystemFilter;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager;
import org.eclipse.rse.core.filters.ISystemFilterReference;
import org.eclipse.rse.core.filters.ISystemFilterStartHere;
@ -66,14 +64,13 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter;
import org.eclipse.rse.internal.core.filters.SystemFilterPool;
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.model.SystemHostPool;
import org.eclipse.rse.internal.model.SystemModelChangeEvent;
import org.eclipse.rse.internal.model.SystemModelChangeEventManager;
import org.eclipse.rse.internal.model.SystemPostableEventNotifier;
import org.eclipse.rse.internal.model.SystemPreferenceChangeManager;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.model.SystemRemoteChangeEventManager;
import org.eclipse.rse.internal.model.SystemResourceChangeManager;
import org.eclipse.rse.internal.model.SystemScratchpad;
@ -764,7 +761,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/
public ISystemProfileManager getSystemProfileManager()
{
return SystemProfileManager.getSystemProfileManager();
return SystemProfileManager.getDefault();
}
/**
@ -795,12 +792,14 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
{
return getSystemProfileManager().getSystemProfileNames();
}
/**
* Return all defined profile names as a vector
*/
public Vector getAllSystemProfileNamesVector()
{
return getSystemProfileManager().getSystemProfileNamesVector();
Vector v = getSystemProfileManager().getSystemProfileNamesVector();
return v;
}
/**
@ -2842,8 +2841,6 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/
public void disconnectAllSubSystems(IHost conn)
{
// FIXME - save profile
save();
ISubSystem[] subsystems = getSubSystemsLazily(conn);
if (subsystems == null)
@ -3346,8 +3343,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/
public boolean save()
{
ISystemProfileManager profileManager = getSystemProfileManager();
return RSEUIPlugin.getThePersistenceManager().commit(profileManager);
return RSEUIPlugin.getThePersistenceManager().commitProfiles();
}
/**
@ -3356,7 +3352,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/
public boolean saveHostPool(ISystemHostPool pool)
{
return RSEUIPlugin.getThePersistenceManager().commit(pool);
return pool.commit();
}
/**
@ -3414,9 +3410,4 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
return SystemFilterStartHere.getDefault();
}
public ISystemFilterPool getSystemFilterPool()
{
return SystemFilterPool.getDefault();
}
}//SystemRegistryImpl

View file

@ -21,7 +21,7 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.RSEUIPlugin;
@ -161,7 +161,7 @@ public class SystemStartHere
*/
public static ISystemProfileManager getSystemProfileManager()
{
return SystemProfileManager.getSystemProfileManager();
return SystemProfileManager.getDefault();
}
/**

View file

@ -20,6 +20,9 @@
package org.eclipse.rse.core.subsystems;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.resources.IResource;
@ -3249,8 +3252,14 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
}
public IRSEPersistableContainer[] getPersistableChildren() {
List children = new ArrayList(10);
ISystemFilterPoolReferenceManager manager = getSystemFilterPoolReferenceManager();
IRSEPersistableContainer[] result = manager.getReferencedSystemFilterPools();
if (manager != null) {
children.addAll(Arrays.asList(manager.getSystemFilterPoolReferences()));
}
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;
}

View file

@ -55,7 +55,7 @@ import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
import org.eclipse.rse.internal.core.filters.SystemFilterPoolWrapperInformation;
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemPropertyResources;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapter;
@ -773,7 +773,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
*/
public ISystemProfile getSystemProfile(String name)
{
return SystemProfileManager.getSystemProfileManager().getSystemProfile(name);
return SystemProfileManager.getDefault().getSystemProfile(name);
}
/**
@ -1001,8 +1001,8 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
}
if ((subsystems == null) || (subsystems.length != getSubSystemList().size()))
{
java.util.List alist = null;
if (SystemProfileManager.getSystemProfileManager().getSystemProfileNamesVector().size() > 0) // 42913
List alist = null;
if (SystemProfileManager.getDefault().getSize() > 0) // 42913
alist = getSubSystemList();
if (alist == null)
return new ISubSystem[0];
@ -1803,12 +1803,9 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
*/
protected boolean isUserPrivateProfile(ISystemFilterPoolManager mgr)
{
//System.out.println("mgr name = " + mgr.getName());
//String name = mgr.getName();
//return name.equalsIgnoreCase("private");
ISystemProfile profile = getSystemProfile(mgr);
//System.out.println("Testing for user private profile for mgr " + mgr.getName() + ": " + profile.isDefaultPrivate());;
return profile.isDefaultPrivate() || mgr.getName().equalsIgnoreCase("private"); //$NON-NLS-1$
ISystemProfile profile = mgr.getSystemProfile();
boolean result = profile.isDefaultPrivate() || mgr.getName().equalsIgnoreCase("private"); //$NON-NLS-1$
return result;
}
/**
@ -2538,7 +2535,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
public ISubSystem[] testForActiveReferences(ISystemProfile profile)
{
Vector v = new Vector();
ISystemProfileManager profileMgr = SystemProfileManager.getSystemProfileManager();
ISystemProfileManager profileMgr = SystemProfileManager.getDefault();
ISystemFilterPoolManager sfpm = getFilterPoolManager(profile);
String profileName = profile.getName();
if (sfpm != null)
@ -3022,7 +3019,6 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
if (filterPoolManagerList == null)
{
filterPoolManagerList = new ArrayList();
//FIXMEnew EObjectContainmenteList(SystemFilterPoolManager.class, this, SubsystemsPackage.SUB_SYSTEM_FACTORY__FILTER_POOL_MANAGER_LIST);
}
return filterPoolManagerList;
}
@ -3080,6 +3076,12 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
{
}
public void beginRestore() {
}
public void endRestore() {
}
/**
* Subsystem configurations are not persisted.
* @return null
@ -3088,12 +3090,6 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
return null;
}
public void beginRestore() {
}
public void endRestore() {
}
public IRSEPersistableContainer[] getPersistableChildren() {
return new IRSEPersistableContainer[0];
}