View | Details | Raw Unified | Return to bug 202416 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java (-48 / +63 lines)
Lines 15-26 Link Here
15
 * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
15
 * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
16
 * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
16
 * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
17
 * Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
17
 * Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
18
 * Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
18
 ********************************************************************************/
19
 ********************************************************************************/
19
20
20
package org.eclipse.rse.internal.persistence.dom;
21
package org.eclipse.rse.internal.persistence.dom;
21
22
22
import java.util.Vector;
23
import java.util.Vector;
23
24
25
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.Status;
24
import org.eclipse.rse.core.IRSECoreRegistry;
27
import org.eclipse.rse.core.IRSECoreRegistry;
25
import org.eclipse.rse.core.IRSESystemType;
28
import org.eclipse.rse.core.IRSESystemType;
26
import org.eclipse.rse.core.RSECorePlugin;
29
import org.eclipse.rse.core.RSECorePlugin;
Lines 74-81 Link Here
74
	 */
77
	 */
75
	public ISystemProfile restoreProfile(RSEDOM dom) {
78
	public ISystemProfile restoreProfile(RSEDOM dom) {
76
		String profileName = dom.getName();
79
		String profileName = dom.getName();
77
		boolean defaultPrivate = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE).getValue());
80
		boolean defaultPrivate = getBooleanValue(dom, IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE);
78
		boolean isActive = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE).getValue());
81
		boolean isActive = getBooleanValue(dom, IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE);
79
		ISystemProfile profile = new SystemProfile(profileName, isActive);
82
		ISystemProfile profile = new SystemProfile(profileName, isActive);
80
		if (profile != null) {
83
		if (profile != null) {
81
			profile.setDefaultPrivate(defaultPrivate);
84
			profile.setDefaultPrivate(defaultPrivate);
Lines 85-95 Link Here
85
			for (int i = 0; i < children.length; i++) {
88
			for (int i = 0; i < children.length; i++) {
86
				RSEDOMNode child = children[i];
89
				RSEDOMNode child = children[i];
87
				String type = child.getType();
90
				String type = child.getType();
88
				if (type.equals(IRSEDOMConstants.TYPE_HOST)) {
91
				if (IRSEDOMConstants.TYPE_HOST.equals(type)) {
89
					restoreHost(profile, child);
92
					restoreHost(profile, child);
90
				} else if (type.equals(IRSEDOMConstants.TYPE_FILTER_POOL)) {
93
				} else if (IRSEDOMConstants.TYPE_FILTER_POOL.equals(type)) {
91
					restoreFilterPool(profile, child);
94
					restoreFilterPool(profile, child);
92
				} else if (type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) {
95
				} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(type)) {
93
					restorePropertySet(profile, child);
96
					restorePropertySet(profile, child);
94
				}
97
				}
95
			}
98
			}
Lines 109-116 Link Here
109
		String systemTypeId = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE);
112
		String systemTypeId = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE);
110
		String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME);
113
		String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME);
111
		String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION);
114
		String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION);
112
		boolean isOffline = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE));
115
		boolean isOffline = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE);
113
		boolean isPromptable = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE));
116
		boolean isPromptable = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
114
117
115
		// create host and set it's attributes
118
		// create host and set it's attributes
116
		try {
119
		try {
Lines 127-133 Link Here
127
			host.setOffline(isOffline);
130
			host.setOffline(isOffline);
128
			host.setPromptable(isPromptable);
131
			host.setPromptable(isPromptable);
129
		} catch (Exception e) {
132
		} catch (Exception e) {
130
			e.printStackTrace();
133
			logException(e);
131
		}
134
		}
132
135
133
		// restore children of host
136
		// restore children of host
Lines 135-143 Link Here
135
		for (int i = 0; i < children.length; i++) {
138
		for (int i = 0; i < children.length; i++) {
136
			RSEDOMNode child = children[i];
139
			RSEDOMNode child = children[i];
137
			String type = child.getType();
140
			String type = child.getType();
138
			if (type.equals(IRSEDOMConstants.TYPE_CONNECTOR_SERVICE)) {
141
			if (IRSEDOMConstants.TYPE_CONNECTOR_SERVICE.equals(type)) {
139
				restoreConnectorService(host, child);
142
				restoreConnectorService(host, child);
140
			} else if (type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) {
143
			} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(type)) {
141
				restorePropertySet(host, child);
144
				restorePropertySet(host, child);
142
			}
145
			}
143
		}
146
		}
Lines 156-167 Link Here
156
		//		String name = connectorServiceNode.getName();
159
		//		String name = connectorServiceNode.getName();
157
		//		String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
160
		//		String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
158
		//		String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue();
161
		//		String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue();
159
		boolean useSSL = getBooleanValue(connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_USE_SSL).getValue());
162
		boolean useSSL = getBooleanValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_USE_SSL);
160
		RSEDOMNodeAttribute att = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_PORT);
163
		int port = getIntegerValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_PORT);
161
		int port = 0;
162
		if (att != null) {
163
			port = getIntegerValue(att.getValue());
164
		}
165
164
166
		// first restore subsystems (since right now we need subsystem to get at service
165
		// first restore subsystems (since right now we need subsystem to get at service
167
		RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM);
166
		RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM);
Lines 222-229 Link Here
222
		// in most cases (if not all) the subsystem already exists
221
		// in most cases (if not all) the subsystem already exists
223
		// since createHost() ends up recreating subsystems for each factory		
222
		// since createHost() ends up recreating subsystems for each factory		
224
		String name = subSystemNode.getName();
223
		String name = subSystemNode.getName();
225
		String type = subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
224
		String type = getAttributeValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
226
		boolean isHidden = getBooleanValue(subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_HIDDEN).getValue());
225
		boolean isHidden = getBooleanValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_HIDDEN);
227
		ISubSystem subSystem = null;
226
		ISubSystem subSystem = null;
228
		ISubSystemConfiguration factory = getSubSystemConfiguration(type);
227
		ISubSystemConfiguration factory = getSubSystemConfiguration(type);
229
		if (factory != null) {
228
		if (factory != null) {
Lines 288-305 Link Here
288
	public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) {
287
	public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) {
289
		// get the node attributes for a filter
288
		// get the node attributes for a filter
290
		String name = node.getName();
289
		String name = node.getName();
291
		boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue());
290
		boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS);
292
		int relativeOrder = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER).getValue());
291
		int relativeOrder = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER);
293
		boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue());
292
		boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT);
294
		boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue());
293
		boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE);
295
		boolean isPromptable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE).getValue());
294
		boolean isPromptable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
296
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue());
295
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS);
297
		boolean isNonDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE).getValue());
296
		boolean isNonDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE);
298
		boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue());
297
		boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE);
299
		boolean isNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE).getValue());
298
		boolean isNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE);
300
		boolean isStringsNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE).getValue());
299
		boolean isStringsNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE);
301
		int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue());
300
		int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE);
302
		boolean isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue());
301
		boolean isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY);
303
302
304
		Vector filterStrings = new Vector();
303
		Vector filterStrings = new Vector();
305
304
Lines 346-359 Link Here
346
345
347
		// get the node attributes for a filter pool
346
		// get the node attributes for a filter pool
348
		String name = node.getName();
347
		String name = node.getName();
349
		String type = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
348
		String type = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_TYPE);
350
		String id = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_ID).getValue();
349
		String id = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_ID);
351
		boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue());
350
		boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS);
352
		boolean isDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DELETABLE).getValue());
351
		boolean isDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DELETABLE);
353
		boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue());
352
		boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT);
354
		boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue());
353
		boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE);
355
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue());
354
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS);
356
		int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue());
355
		int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE);
357
		
356
		
358
		// Since old profiles won't have an "singleFilterStringOnlyESet" attribute
357
		// Since old profiles won't have an "singleFilterStringOnlyESet" attribute
359
		// we must give it a default value.
358
		// we must give it a default value.
Lines 366-376 Link Here
366
		RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$
365
		RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$
367
		if (attribute != null) {
366
		if (attribute != null) {
368
			isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue());
367
			isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue());
369
			isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue());
368
			isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY);
370
		}
369
		}
371
		
370
		
372
		String owningParentName = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME).getValue();
371
		String owningParentName = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME);
373
		boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue());
372
		boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE);
374
373
375
		// create the filter pool and set it's attributes
374
		// create the filter pool and set it's attributes
376
		try {
375
		try {
Lines 409-415 Link Here
409
//				filterPool.wasRestored();
408
//				filterPool.wasRestored();
410
			}
409
			}
411
		} catch (Exception e) {
410
		} catch (Exception e) {
412
			e.printStackTrace();
411
			logException(e);
413
		}
412
		}
414
413
415
		// restore children
414
		// restore children
Lines 417-427 Link Here
417
		for (int i = 0; i < children.length; i++) {
416
		for (int i = 0; i < children.length; i++) {
418
			RSEDOMNode child = children[i];
417
			RSEDOMNode child = children[i];
419
			String ctype = child.getType();
418
			String ctype = child.getType();
420
			if (ctype.equals(IRSEDOMConstants.TYPE_FILTER)) {
419
			if (IRSEDOMConstants.TYPE_FILTER.equals(ctype)) {
421
				if (filterPool != null) {
420
				if (filterPool != null) {
422
					restoreFilter(filterPool, child);
421
					restoreFilter(filterPool, child);
423
				}
422
				}
424
			} else if (ctype.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) {
423
			} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(ctype)) {
425
				restorePropertySet(filterPool, child);
424
				restorePropertySet(filterPool, child);
426
			}
425
			}
427
		}
426
		}
Lines 466-472 Link Here
466
		RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes();
465
		RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes();
467
		for (int i = 0; i < attributes.length; i++) {
466
		for (int i = 0; i < attributes.length; i++) {
468
			RSEDOMNodeAttribute attribute = attributes[i];
467
			RSEDOMNodeAttribute attribute = attributes[i];
469
			if (attribute.getKey().equals(IRSEDOMConstants.ATTRIBUTE_DESCRIPTION)) { // descriptions really are stored as attributes
468
			if (IRSEDOMConstants.ATTRIBUTE_DESCRIPTION.equals(attribute.getKey())) { // descriptions really are stored as attributes
470
				set.setDescription(attribute.getValue());
469
				set.setDescription(attribute.getValue());
471
			} else {
470
			} else {
472
				String typeStr = attribute.getType();
471
				String typeStr = attribute.getType();
Lines 479-488 Link Here
479
		for (int i = 0; i < children.length; i++) {
478
		for (int i = 0; i < children.length; i++) {
480
			RSEDOMNode child = children[i];
479
			RSEDOMNode child = children[i];
481
			String propertyName = child.getName();
480
			String propertyName = child.getName();
482
			String propertyValue = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_VALUE).getValue();
481
			String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE);
483
			String propertyTypeName = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
482
			String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE);
484
			IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
483
			IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
485
			if (propertyName.equals(IPropertySet.DESCRIPTION_KEY)) { // any descriptions found as properties should be set directly
484
			if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly
486
				set.setDescription(propertyValue);
485
				set.setDescription(propertyValue);
487
			} else {
486
			} else {
488
				set.addProperty(propertyName, propertyValue, propertyType);
487
				set.addProperty(propertyName, propertyValue, propertyType);
Lines 523-526 Link Here
523
		}
522
		}
524
		return result;
523
		return result;
525
	}
524
	}
525
526
	private boolean getBooleanValue(RSEDOMNode node, String attributeName) {
527
		String booleanStr = getAttributeValue(node, attributeName);
528
		return getBooleanValue(booleanStr);
529
	}
530
531
	private int getIntegerValue(RSEDOMNode node, String attributeName) {
532
		String intStr = getAttributeValue(node, attributeName);
533
		return getIntegerValue(intStr);
534
	}
535
	
536
	private void logException(Exception e) {
537
		RSECorePlugin.getDefault().getLog().log(
538
				new Status(IStatus.ERROR, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, e.getMessage(), e));
539
	}
540
526
}
541
}

Return to bug 202416