mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
[233876] [Persistence] Lose of Filters after restart
https://bugs.eclipse.org/bugs/show_bug.cgi?id=233876
This commit is contained in:
parent
b15c28c5fc
commit
c5774fd9f1
5 changed files with 135 additions and 29 deletions
|
@ -0,0 +1,62 @@
|
||||||
|
/*********************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Corporation. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* David Dykstal (IBM) - initial contribution.
|
||||||
|
* David Dykstal (IBM) - [233876] filters lost after restart
|
||||||
|
*********************************************************************************/
|
||||||
|
package org.eclipse.rse.internal.core.filters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a utility class used for manipulating host-owned filter pool names.
|
||||||
|
*/
|
||||||
|
public class HostOwnedFilterPoolPattern {
|
||||||
|
|
||||||
|
final private static String prefix = "CN-"; //$NON-NLS-1$
|
||||||
|
final private static int start = prefix.length();
|
||||||
|
private String suffix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a pattern given a subsystem configuration id
|
||||||
|
* @param configurationId the id from which to construct the pattern.
|
||||||
|
*/
|
||||||
|
public HostOwnedFilterPoolPattern(String configurationId) {
|
||||||
|
suffix = "-" + configurationId; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test a filter pool name to see if it matches this pattern
|
||||||
|
* @param filterPoolName The filter pool name to test.
|
||||||
|
* @return true if the pattern matches this name, false otherwise.
|
||||||
|
*/
|
||||||
|
public boolean matches(String filterPoolName) {
|
||||||
|
return (filterPoolName.startsWith(prefix) && filterPoolName.endsWith(suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the host name from the filter pool name
|
||||||
|
* @param filterPoolName the name of the filter pool
|
||||||
|
* @return the associated host name
|
||||||
|
*/
|
||||||
|
public String extract(String filterPoolName) {
|
||||||
|
String result = null;
|
||||||
|
if (matches(filterPoolName)) {
|
||||||
|
int length = filterPoolName.length() - (prefix.length() + suffix.length());
|
||||||
|
result = filterPoolName.substring(start, start + length);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a filter pool name from the host name
|
||||||
|
* @param hostName the host name to use as a base
|
||||||
|
* @return the associated filter pool name
|
||||||
|
*/
|
||||||
|
public String make(String hostName) {
|
||||||
|
return prefix + hostName + suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
* David Dykstal (IBM) - initial contribution.
|
* David Dykstal (IBM) - initial contribution.
|
||||||
* David Dykstal (IBM) - [189274] provide import and export operations for profiles
|
* David Dykstal (IBM) - [189274] provide import and export operations for profiles
|
||||||
* David Dykstal (IBM) - [216858] Need the ability to Import/Export RSE connections for sharing
|
* David Dykstal (IBM) - [216858] Need the ability to Import/Export RSE connections for sharing
|
||||||
|
* David Dykstal (IBM) - [233876] Filters lost after restart
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.persistence;
|
package org.eclipse.rse.internal.persistence;
|
||||||
|
@ -49,6 +50,7 @@ import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||||
import org.eclipse.rse.internal.core.RSECoreMessages;
|
import org.eclipse.rse.internal.core.RSECoreMessages;
|
||||||
|
import org.eclipse.rse.internal.core.filters.HostOwnedFilterPoolPattern;
|
||||||
import org.eclipse.rse.internal.persistence.dom.RSEDOMExporter;
|
import org.eclipse.rse.internal.persistence.dom.RSEDOMExporter;
|
||||||
import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter;
|
import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter;
|
||||||
import org.eclipse.rse.persistence.IRSEPersistenceManager;
|
import org.eclipse.rse.persistence.IRSEPersistenceManager;
|
||||||
|
@ -255,9 +257,11 @@ public class RSEEnvelope {
|
||||||
// create the filter pools
|
// create the filter pools
|
||||||
for (Iterator z = filterPoolNodes.iterator(); z.hasNext();) {
|
for (Iterator z = filterPoolNodes.iterator(); z.hasNext();) {
|
||||||
RSEDOMNode filterPoolNode = (RSEDOMNode) z.next();
|
RSEDOMNode filterPoolNode = (RSEDOMNode) z.next();
|
||||||
String name = filterPoolNode.getName();
|
String filterPoolName = filterPoolNode.getName();
|
||||||
if (name.startsWith("CN-")) { //$NON-NLS-1$
|
String configurationId = filterPoolNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_ID).getValue();
|
||||||
String hostName = name.substring(3);
|
HostOwnedFilterPoolPattern pattern = new HostOwnedFilterPoolPattern(configurationId);
|
||||||
|
String hostName = pattern.extract(filterPoolName);
|
||||||
|
if (hostName != null) {
|
||||||
IHost host = (IHost) hostMap.get(hostName);
|
IHost host = (IHost) hostMap.get(hostName);
|
||||||
if (host != null) {
|
if (host != null) {
|
||||||
mergeHostFilterPool(profile, host, filterPoolNode);
|
mergeHostFilterPool(profile, host, filterPoolNode);
|
||||||
|
@ -291,12 +295,16 @@ public class RSEEnvelope {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeHostFilterPool(ISystemProfile profile, IHost host, RSEDOMNode filterPoolNode) {
|
private void mergeHostFilterPool(ISystemProfile profile, IHost host, RSEDOMNode filterPoolNode) {
|
||||||
|
String configurationId = filterPoolNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_ID).getValue();
|
||||||
|
HostOwnedFilterPoolPattern pattern = new HostOwnedFilterPoolPattern(configurationId);
|
||||||
String hostName = host.getAliasName();
|
String hostName = host.getAliasName();
|
||||||
String filterPoolName = "CN-" + hostName; //$NON-NLS-1$
|
String filterPoolName = pattern.make(hostName);
|
||||||
filterPoolNode.setName(filterPoolName);
|
filterPoolNode.setName(filterPoolName);
|
||||||
mergeFilterPool(profile, filterPoolNode);
|
RSEDOMImporter importer = RSEDOMImporter.getInstance();
|
||||||
|
ISystemFilterPool filterPool = importer.restoreFilterPool(profile, filterPoolNode);
|
||||||
|
filterPool.setOwningParentName(hostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISystemFilterPool mergeFilterPool(ISystemProfile profile, RSEDOMNode filterPoolNode) {
|
private ISystemFilterPool mergeFilterPool(ISystemProfile profile, RSEDOMNode filterPoolNode) {
|
||||||
ISystemFilterPool filterPool = getMatchingFilterPool(profile, filterPoolNode);
|
ISystemFilterPool filterPool = getMatchingFilterPool(profile, filterPoolNode);
|
||||||
if (filterPool != null) {
|
if (filterPool != null) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* David Dykstal (IBM) - [217556] remove service subsystem types
|
* David Dykstal (IBM) - [217556] remove service subsystem types
|
||||||
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
|
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
|
||||||
* David Dykstal (IBM) - [232126] retrieve persisted filter type attribute
|
* David Dykstal (IBM) - [232126] retrieve persisted filter type attribute
|
||||||
|
* David Dykstal (IBM) - [233876] filters lost after restart
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.persistence.dom;
|
package org.eclipse.rse.internal.persistence.dom;
|
||||||
|
@ -49,6 +50,7 @@ import org.eclipse.rse.core.subsystems.IConnectorService;
|
||||||
import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
|
import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||||
|
import org.eclipse.rse.internal.core.filters.HostOwnedFilterPoolPattern;
|
||||||
import org.eclipse.rse.internal.core.model.SystemProfile;
|
import org.eclipse.rse.internal.core.model.SystemProfile;
|
||||||
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
||||||
import org.eclipse.rse.persistence.dom.IRSEDOMConstants;
|
import org.eclipse.rse.persistence.dom.IRSEDOMConstants;
|
||||||
|
@ -463,17 +465,28 @@ public class RSEDOMImporter {
|
||||||
public ISystemFilterPoolReference restoreFilterPoolReference(ISubSystem subsystem, RSEDOMNode node) {
|
public ISystemFilterPoolReference restoreFilterPoolReference(ISubSystem subsystem, RSEDOMNode node) {
|
||||||
ISystemFilterPoolReference filterPoolReference = null;
|
ISystemFilterPoolReference filterPoolReference = null;
|
||||||
String filterPoolName = node.getName();
|
String filterPoolName = node.getName();
|
||||||
|
ISystemProfile profile = subsystem.getSystemProfile();
|
||||||
|
String profileName = profile.getName();
|
||||||
|
String baseFilterPoolName = filterPoolName;
|
||||||
String[] part = filterPoolName.split("___", 2); //$NON-NLS-1$
|
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
|
if (part.length == 2) { // name is qualified and refers to a filter pool in a specific profile
|
||||||
ISystemProfile profile = subsystem.getSystemProfile();
|
profileName = part[0];
|
||||||
String profileName = profile.getName();
|
baseFilterPoolName = part[1];
|
||||||
filterPoolName = profileName + "___" + filterPoolName; //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
// special processing for host owned pool references
|
||||||
|
String configurationId = subsystem.getConfigurationId();
|
||||||
|
HostOwnedFilterPoolPattern pattern = new HostOwnedFilterPoolPattern(configurationId);
|
||||||
|
if (pattern.matches(baseFilterPoolName)) { // if this is a host owned pool then fix up this reference
|
||||||
|
String hostName = subsystem.getHostAliasName();
|
||||||
|
baseFilterPoolName = pattern.make(hostName);
|
||||||
|
}
|
||||||
|
// qualify the name and construct the reference
|
||||||
|
filterPoolName = profileName + "___" + baseFilterPoolName; //$NON-NLS-1$
|
||||||
ISystemFilterPoolReferenceManager referenceManager = subsystem.getFilterPoolReferenceManager();
|
ISystemFilterPoolReferenceManager referenceManager = subsystem.getFilterPoolReferenceManager();
|
||||||
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolName);
|
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolName);
|
||||||
return filterPoolReference;
|
return filterPoolReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISystemFilterString restoreFilterString(ISystemFilter filter, RSEDOMNode node) {
|
public ISystemFilterString restoreFilterString(ISystemFilter filter, RSEDOMNode node) {
|
||||||
/*
|
/*
|
||||||
String string = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING).getValue();
|
String string = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING).getValue();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David Dykstal (IBM) - [216858] provide ability to import and export connections
|
* David Dykstal (IBM) - [216858] provide ability to import and export connections
|
||||||
|
* David Dykstal (IBM) - [233876] filters lost after restart
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui.actions;
|
package org.eclipse.rse.internal.ui.actions;
|
||||||
|
@ -26,6 +27,8 @@ import org.eclipse.rse.core.model.IHost;
|
||||||
import org.eclipse.rse.core.model.ISystemProfile;
|
import org.eclipse.rse.core.model.ISystemProfile;
|
||||||
import org.eclipse.rse.core.model.ISystemProfileManager;
|
import org.eclipse.rse.core.model.ISystemProfileManager;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
|
import org.eclipse.rse.internal.core.model.ISystemProfileOperation;
|
||||||
|
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
||||||
import org.eclipse.rse.internal.persistence.RSEEnvelope;
|
import org.eclipse.rse.internal.persistence.RSEEnvelope;
|
||||||
import org.eclipse.rse.internal.ui.SystemResources;
|
import org.eclipse.rse.internal.ui.SystemResources;
|
||||||
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||||
|
@ -56,24 +59,33 @@ public class SystemImportConnectionAction extends SystemBaseAction {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(final IProgressMonitor monitor) {
|
||||||
IStatus status = Status.OK_STATUS;
|
IStatus status = Status.OK_STATUS;
|
||||||
RSEEnvelope envelope = new RSEEnvelope();
|
|
||||||
try {
|
try {
|
||||||
FileInputStream in = new FileInputStream(inFile);
|
final FileInputStream in = new FileInputStream(inFile);
|
||||||
envelope.get(in, monitor);
|
// run inside an ISystemProfileOperation to ensure that the changes are committed
|
||||||
envelope.mergeWith(profile);
|
status = SystemProfileManager.run(new ISystemProfileOperation() {
|
||||||
|
public IStatus run() {
|
||||||
|
IStatus operationStatus = Status.OK_STATUS;
|
||||||
|
try {
|
||||||
|
final RSEEnvelope envelope = new RSEEnvelope();
|
||||||
|
envelope.get(in, monitor);
|
||||||
|
envelope.mergeWith(profile);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// log the exception and return the status code
|
||||||
|
operationStatus = e.getStatus();
|
||||||
|
String message = operationStatus.getMessage();
|
||||||
|
if (message == null) {
|
||||||
|
message = SystemResources.SystemImportConnectionAction_CoreExceptionFound;
|
||||||
|
}
|
||||||
|
SystemBasePlugin.logError(message, e);
|
||||||
|
}
|
||||||
|
return operationStatus;
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// should not happen, log as unexpected
|
// should not happen, log as unexpected
|
||||||
SystemBasePlugin.logError(SystemResources.SystemImportConnectionAction_UnexpectedException, e);
|
SystemBasePlugin.logError(SystemResources.SystemImportConnectionAction_UnexpectedException, e);
|
||||||
} catch (CoreException e) {
|
|
||||||
// log the exception and return the status code
|
|
||||||
status = e.getStatus();
|
|
||||||
String message = status.getMessage();
|
|
||||||
if (message == null) {
|
|
||||||
message = SystemResources.SystemImportConnectionAction_CoreExceptionFound;
|
|
||||||
}
|
|
||||||
SystemBasePlugin.logError(message, e);
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [190231] Prepare API for UI/Non-UI Splitting
|
* Martin Oberhuber (Wind River) - [190231] Prepare API for UI/Non-UI Splitting
|
||||||
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
|
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
|
||||||
* David McKnight (IBM) - [233435] SubSystem.resolveFilterStrings(*) does not prompt for a connection when the subsystem is not connected
|
* David McKnight (IBM) - [233435] SubSystem.resolveFilterStrings(*) does not prompt for a connection when the subsystem is not connected
|
||||||
|
* David Dykstal (IBM) - [233876] filters lost after restart
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.core.subsystems;
|
package org.eclipse.rse.core.subsystems;
|
||||||
|
@ -89,6 +90,7 @@ import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
import org.eclipse.rse.core.model.RSEModelObject;
|
import org.eclipse.rse.core.model.RSEModelObject;
|
||||||
import org.eclipse.rse.internal.core.RSECoreMessages;
|
import org.eclipse.rse.internal.core.RSECoreMessages;
|
||||||
import org.eclipse.rse.internal.core.SystemResourceConstants;
|
import org.eclipse.rse.internal.core.SystemResourceConstants;
|
||||||
|
import org.eclipse.rse.internal.core.filters.HostOwnedFilterPoolPattern;
|
||||||
import org.eclipse.rse.internal.core.model.ISystemProfileOperation;
|
import org.eclipse.rse.internal.core.model.ISystemProfileOperation;
|
||||||
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
|
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
|
||||||
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
||||||
|
@ -680,9 +682,17 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider
|
||||||
String hostName = host.getAliasName();
|
String hostName = host.getAliasName();
|
||||||
if (allPoolsInProfile != null) {
|
if (allPoolsInProfile != null) {
|
||||||
for (int idx = 0; idx < allPoolsInProfile.length; idx++) {
|
for (int idx = 0; idx < allPoolsInProfile.length; idx++) {
|
||||||
String poolOwnerName = allPoolsInProfile[idx].getOwningParentName();
|
ISystemFilterPool currentPool = allPoolsInProfile[idx];
|
||||||
if ((poolOwnerName != null) && (poolOwnerName.equals(hostName))) {
|
String poolOwnerName = currentPool.getOwningParentName();
|
||||||
pool = allPoolsInProfile[idx];
|
if (poolOwnerName == null) {
|
||||||
|
HostOwnedFilterPoolPattern pattern = new HostOwnedFilterPoolPattern(config.getId());
|
||||||
|
if (pattern.matches(currentPool.getName())) {
|
||||||
|
currentPool.setOwningParentName(hostName); // TODO these pools should have been created with the owner set properly
|
||||||
|
poolOwnerName = hostName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hostName.equals(poolOwnerName)) {
|
||||||
|
pool = currentPool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,10 +728,11 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider
|
||||||
* since it names a team sharable resource. Not qualified by the profile
|
* since it names a team sharable resource. Not qualified by the profile
|
||||||
* name since that is implicit by being in a profile.
|
* name since that is implicit by being in a profile.
|
||||||
*/
|
*/
|
||||||
String name = "CN-" + connectionName; //$NON-NLS-1$
|
HostOwnedFilterPoolPattern pattern = new HostOwnedFilterPoolPattern(getConfigurationId());
|
||||||
|
String name = pattern.make(connectionName);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------
|
// -------------------------
|
||||||
// Filter Testing Methods...
|
// Filter Testing Methods...
|
||||||
// -------------------------
|
// -------------------------
|
||||||
|
|
Loading…
Add table
Reference in a new issue