From 2bfb3ccad26055d70f14833d347b1ab2426faf45 Mon Sep 17 00:00:00 2001 From: David Dykstal Date: Mon, 7 May 2007 17:05:07 +0000 Subject: [PATCH] [185752] use systemTypeId instead of systemTypeName when persisting profiles. --- .../persistence/dom/RSEDOMExporter.java | 7 +--- .../persistence/dom/RSEDOMImporter.java | 37 ++++++++++++++----- .../rse/persistence/dom/IRSEDOMConstants.java | 1 + 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java index 7fdc5959db5..773dc2eb8d1 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java @@ -287,6 +287,7 @@ public class RSEDOMExporter implements IRSEDOMExporter { if (clean || node.isDirty()) { node.addAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE, host.getSystemType().getName()); + node.addAttribute(IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE, host.getSystemType().getId()); node.addAttribute(IRSEDOMConstants.ATTRIBUTE_OFFLINE, getBooleanString(host.isOffline())); node.addAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE, getBooleanString(host.isPromptable())); node.addAttribute(IRSEDOMConstants.ATTRIBUTE_HOSTNAME, host.getHostName()); @@ -317,11 +318,7 @@ public class RSEDOMExporter implements IRSEDOMExporter { public RSEDOMNode createNode(RSEDOMNode parent, IConnectorService connectorService, boolean clean) { RSEDOMNode node = findOrCreateNode(parent, IRSEDOMConstants.TYPE_CONNECTOR_SERVICE, connectorService, clean); if (clean || node.isDirty()) { - // store it's attributes - IRSESystemType systemType = connectorService.getHost().getSystemType(); - node.addAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE, systemType.getName()); - - // can't do this til connector service owns the properties (right now it's still subsystem) + // can't do this until connector service owns the properties (right now it's still subsystem) node.addAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP, connectorService.getName()); node.addAttribute(IRSEDOMConstants.ATTRIBUTE_USE_SSL, getBooleanString(connectorService.isUsingSSL())); node.addAttribute(IRSEDOMConstants.ATTRIBUTE_PORT, Integer.toString(connectorService.getPort())); diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java index 6541ccb4f90..7bb9b86d314 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java @@ -18,6 +18,7 @@ package org.eclipse.rse.internal.persistence.dom; import java.util.Vector; +import org.eclipse.rse.core.IRSECoreRegistry; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.filters.ISystemFilter; @@ -101,17 +102,24 @@ public class RSEDOMImporter { // get host node attributes String connectionName = hostNode.getName(); - String systemTypeName = hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); - String hostName = hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_HOSTNAME).getValue(); - String description = hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_DESCRIPTION).getValue(); - boolean isOffline = getBooleanValue(hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_OFFLINE).getValue()); - boolean isPromptable = getBooleanValue(hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE).getValue()); + String systemTypeName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE); + String systemTypeId = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE); + String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME); + String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION); + boolean isOffline = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE)); + boolean isPromptable = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE)); // create host and set it's attributes try { // NOTE create host effectively recreates the subsystems // so instead of creating subsystems on restore, we should be updating their properties - IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeName); + IRSECoreRegistry registry = RSECorePlugin.getDefault().getRegistry(); + IRSESystemType systemType = null; + if (systemTypeId != null) { + systemType = registry.getSystemTypeById(systemTypeId); + } else if (systemTypeName != null) { + systemType = registry.getSystemType(systemTypeName); + } host = profile.createHost(systemType, connectionName, hostName, description); host.setOffline(isOffline); host.setPromptable(isPromptable); @@ -158,11 +166,11 @@ public class RSEDOMImporter { RSEDOMNode ssChild = ssChildren[s]; ISubSystem subSystem = restoreSubSystem(host, ssChild); if (subSystem != null && service == null) { - ISubSystemConfiguration factory = subSystem.getSubSystemConfiguration(); - service = factory.getConnectorService(host); + ISubSystemConfiguration subsystemConfiguration = subSystem.getSubSystemConfiguration(); + service = subsystemConfiguration.getConnectorService(host); if (service != null) { - if (factory.supportsServerLaunchProperties(host)) { - IServerLauncherProperties sl = factory.createServerLauncher(service); + if (subsystemConfiguration.supportsServerLaunchProperties(host)) { + IServerLauncherProperties sl = subsystemConfiguration.createServerLauncher(service); if (sl != null) { // get server launcher properties // right now we just set them for subsystem, but later that will change @@ -470,4 +478,13 @@ public class RSEDOMImporter { private ISubSystemConfiguration getSubSystemConfiguration(String subsystemName) { return _registry.getSubSystemConfiguration(subsystemName); } + + private String getAttributeValue(RSEDOMNode node, String attributeName) { + String result = null; + RSEDOMNodeAttribute attribute = node.getAttribute(attributeName); + if (attribute != null) { + result = attribute.getValue(); + } + return result; + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java index 34eac0c9a86..50bad12ee28 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java @@ -47,6 +47,7 @@ public interface IRSEDOMConstants { public static final String ATTRIBUTE_HOSTNAME = "hostname"; //$NON-NLS-1$ public static final String ATTRIBUTE_OFFLINE = "offline"; //$NON-NLS-1$ public static final String ATTRIBUTE_DESCRIPTION = "description"; //$NON-NLS-1$ + public static final String ATTRIBUTE_SYSTEM_TYPE = "systemType"; //$NON-NLS-1$ // ConnectorService attributes public static final String ATTRIBUTE_GROUP = "group"; //$NON-NLS-1$