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

Collapse All | Expand All

(-)src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java (-3 / +8 lines)
Lines 16-21 Link Here
16
 * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
16
 * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
17
 * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
17
 * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
18
 * Martin Oberhuber (Wind River) - [196919] Fix deadlock with workspace operations
18
 * Martin Oberhuber (Wind River) - [196919] Fix deadlock with workspace operations
19
 * Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
19
 ********************************************************************************/
20
 ********************************************************************************/
20
21
21
package org.eclipse.rse.internal.persistence;
22
package org.eclipse.rse.internal.persistence;
Lines 371-377 Link Here
371
		for (int i = 0; i < profileNames.length; i++) {
372
		for (int i = 0; i < profileNames.length; i++) {
372
			String profileName = profileNames[i];
373
			String profileName = profileNames[i];
373
			ISystemProfile profile = load(persistenceProvider, profileName, timeout);
374
			ISystemProfile profile = load(persistenceProvider, profileName, timeout);
374
			profiles.add(profile);
375
			if (profile!=null) {
376
				profiles.add(profile);
377
			}
375
		}
378
		}
376
		return profiles;
379
		return profiles;
377
	}
380
	}
Lines 391-398 Link Here
391
				if (dom != null) {
394
				if (dom != null) {
392
					SystemProfileManager.getDefault().setRestoring(true);
395
					SystemProfileManager.getDefault().setRestoring(true);
393
					profile = _importer.restoreProfile(dom);
396
					profile = _importer.restoreProfile(dom);
394
					profile.setPersistenceProvider(provider);
397
					if (profile!=null) {
395
					cleanTree(profile);
398
						profile.setPersistenceProvider(provider);
399
						cleanTree(profile);
400
					}
396
					SystemProfileManager.getDefault().setRestoring(false);
401
					SystemProfileManager.getDefault().setRestoring(false);
397
				}
402
				}
398
			} finally {
403
			} finally {
(-)src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java (-72 / +130 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 73-98 Link Here
73
	 * @return the restored profile
76
	 * @return the restored profile
74
	 */
77
	 */
75
	public ISystemProfile restoreProfile(RSEDOM dom) {
78
	public ISystemProfile restoreProfile(RSEDOM dom) {
79
		ISystemProfile profile = null;
76
		String profileName = dom.getName();
80
		String profileName = dom.getName();
77
		boolean defaultPrivate = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE).getValue());
81
		if (profileName != null) {
78
		boolean isActive = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE).getValue());
82
			boolean defaultPrivate = getBooleanValue(dom, IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE);
79
		ISystemProfile profile = new SystemProfile(profileName, isActive);
83
			boolean isActive = getBooleanValue(dom, IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE);
80
		if (profile != null) {
84
			profile = new SystemProfile(profileName, isActive);
81
			profile.setDefaultPrivate(defaultPrivate);
85
			profile.setDefaultPrivate(defaultPrivate);
82
			SystemProfileManager.getDefault().addSystemProfile(profile);
86
			SystemProfileManager.getDefault().addSystemProfile(profile);
83
			// restore the children for the profile
87
			// restore the children for the profile
84
			RSEDOMNode[] children = dom.getChildren();
88
			RSEDOMNode[] children = dom.getChildren();
85
			for (int i = 0; i < children.length; i++) {
89
			for (int i = 0; i < children.length; i++) {
86
				RSEDOMNode child = children[i];
90
				try {
87
				String type = child.getType();
91
					RSEDOMNode child = children[i];
88
				if (type.equals(IRSEDOMConstants.TYPE_HOST)) {
92
					String type = child.getType();
89
					restoreHost(profile, child);
93
					if (IRSEDOMConstants.TYPE_HOST.equals(type)) {
90
				} else if (type.equals(IRSEDOMConstants.TYPE_FILTER_POOL)) {
94
						restoreHost(profile, child);
91
					restoreFilterPool(profile, child);
95
					} else if (IRSEDOMConstants.TYPE_FILTER_POOL.equals(type)) {
92
				} else if (type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) {
96
						restoreFilterPool(profile, child);
93
					restorePropertySet(profile, child);
97
					} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(type)) {
98
						restorePropertySet(profile, child);
99
					}
100
				} catch(Exception e) {
101
					logException(e);
94
				}
102
				}
95
			}
103
			}
104
		} else {
105
			logNullAttribute(dom, "name"); //$NON-NLS-1$
96
		}
106
		}
97
		return profile;
107
		return profile;
98
	}
108
	}
Lines 105-116 Link Here
105
115
106
		// get host node attributes
116
		// get host node attributes
107
		String connectionName = hostNode.getName();
117
		String connectionName = hostNode.getName();
108
		String systemTypeName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
118
		// we changed from storing names to storing IDs, so these may be null
109
		String systemTypeId = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE);
119
		String systemTypeName = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
120
		String systemTypeId = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE);
110
		String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME);
121
		String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME);
111
		String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION);
122
		String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION);
112
		boolean isOffline = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE));
123
		boolean isOffline = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE);
113
		boolean isPromptable = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE));
124
		boolean isPromptable = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
114
125
115
		// create host and set it's attributes
126
		// create host and set it's attributes
116
		try {
127
		try {
Lines 123-144 Link Here
123
			} else if (systemTypeName != null) {
134
			} else if (systemTypeName != null) {
124
				systemType = registry.getSystemType(systemTypeName);
135
				systemType = registry.getSystemType(systemTypeName);
125
			}
136
			}
126
			host = profile.createHost(systemType, connectionName, hostName, description);
137
			//cannot create a host from a profile if we do not know the systemType
127
			host.setOffline(isOffline);
138
			if (systemType != null) {
128
			host.setPromptable(isPromptable);
139
				host = profile.createHost(systemType, connectionName, hostName, description);
140
				host.setOffline(isOffline);
141
				host.setPromptable(isPromptable);
142
			}
129
		} catch (Exception e) {
143
		} catch (Exception e) {
130
			e.printStackTrace();
144
			logException(e);
131
		}
145
		}
132
146
133
		// restore children of host
147
		// restore children of host
134
		RSEDOMNode[] children = hostNode.getChildren();
148
		if (host!=null) {
135
		for (int i = 0; i < children.length; i++) {
149
			RSEDOMNode[] children = hostNode.getChildren();
136
			RSEDOMNode child = children[i];
150
			for (int i = 0; i < children.length; i++) {
137
			String type = child.getType();
151
				RSEDOMNode child = children[i];
138
			if (type.equals(IRSEDOMConstants.TYPE_CONNECTOR_SERVICE)) {
152
				String type = child.getType();
139
				restoreConnectorService(host, child);
153
				if (IRSEDOMConstants.TYPE_CONNECTOR_SERVICE.equals(type)) {
140
			} else if (type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) {
154
					restoreConnectorService(host, child);
141
				restorePropertySet(host, child);
155
				} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(type)) {
156
					restorePropertySet(host, child);
157
				}
142
			}
158
			}
143
		}
159
		}
144
		return host;
160
		return host;
Lines 156-167 Link Here
156
		//		String name = connectorServiceNode.getName();
172
		//		String name = connectorServiceNode.getName();
157
		//		String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
173
		//		String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
158
		//		String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue();
174
		//		String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue();
159
		boolean useSSL = getBooleanValue(connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_USE_SSL).getValue());
175
		boolean useSSL = getBooleanValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_USE_SSL);
160
		RSEDOMNodeAttribute att = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_PORT);
176
		int port = getIntegerValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_PORT);
161
		int port = 0;
162
		if (att != null) {
163
			port = getIntegerValue(att.getValue());
164
		}
165
177
166
		// first restore subsystems (since right now we need subsystem to get at service
178
		// first restore subsystems (since right now we need subsystem to get at service
167
		RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM);
179
		RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM);
Lines 222-229 Link Here
222
		// in most cases (if not all) the subsystem already exists
234
		// in most cases (if not all) the subsystem already exists
223
		// since createHost() ends up recreating subsystems for each factory		
235
		// since createHost() ends up recreating subsystems for each factory		
224
		String name = subSystemNode.getName();
236
		String name = subSystemNode.getName();
225
		String type = subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
237
		String type = getAttributeValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
226
		boolean isHidden = getBooleanValue(subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_HIDDEN).getValue());
238
		boolean isHidden = getBooleanValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_HIDDEN);
227
		ISubSystem subSystem = null;
239
		ISubSystem subSystem = null;
228
		ISubSystemConfiguration factory = getSubSystemConfiguration(type);
240
		ISubSystemConfiguration factory = getSubSystemConfiguration(type);
229
		if (factory != null) {
241
		if (factory != null) {
Lines 288-305 Link Here
288
	public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) {
300
	public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) {
289
		// get the node attributes for a filter
301
		// get the node attributes for a filter
290
		String name = node.getName();
302
		String name = node.getName();
291
		boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue());
303
		boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS);
292
		int relativeOrder = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER).getValue());
304
		int relativeOrder = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER);
293
		boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue());
305
		boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT);
294
		boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue());
306
		boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE);
295
		boolean isPromptable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE).getValue());
307
		boolean isPromptable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
296
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue());
308
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS);
297
		boolean isNonDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE).getValue());
309
		boolean isNonDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE);
298
		boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue());
310
		boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE);
299
		boolean isNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE).getValue());
311
		boolean isNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE);
300
		boolean isStringsNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE).getValue());
312
		boolean isStringsNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE);
301
		int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue());
313
		int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE);
302
		boolean isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue());
314
		boolean isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY);
303
315
304
		Vector filterStrings = new Vector();
316
		Vector filterStrings = new Vector();
305
317
Lines 346-359 Link Here
346
358
347
		// get the node attributes for a filter pool
359
		// get the node attributes for a filter pool
348
		String name = node.getName();
360
		String name = node.getName();
349
		String type = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
361
		String type = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_TYPE);
350
		String id = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_ID).getValue();
362
		String id = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_ID);
351
		boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue());
363
		boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS);
352
		boolean isDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DELETABLE).getValue());
364
		boolean isDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DELETABLE);
353
		boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue());
365
		boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT);
354
		boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue());
366
		boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE);
355
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue());
367
		boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS);
356
		int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue());
368
		int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE);
357
		
369
		
358
		// Since old profiles won't have an "singleFilterStringOnlyESet" attribute
370
		// Since old profiles won't have an "singleFilterStringOnlyESet" attribute
359
		// we must give it a default value.
371
		// we must give it a default value.
Lines 366-376 Link Here
366
		RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$
378
		RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$
367
		if (attribute != null) {
379
		if (attribute != null) {
368
			isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue());
380
			isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue());
369
			isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue());
381
			isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY);
370
		}
382
		}
371
		
383
		
372
		String owningParentName = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME).getValue();
384
		String owningParentName = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME);
373
		boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue());
385
		boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE);
374
386
375
		// create the filter pool and set it's attributes
387
		// create the filter pool and set it's attributes
376
		try {
388
		try {
Lines 409-428 Link Here
409
//				filterPool.wasRestored();
421
//				filterPool.wasRestored();
410
			}
422
			}
411
		} catch (Exception e) {
423
		} catch (Exception e) {
412
			e.printStackTrace();
424
			logException(e);
413
		}
425
		}
414
426
415
		// restore children
427
		// restore children
416
		RSEDOMNode[] children = node.getChildren();
428
		if (filterPool != null) {
417
		for (int i = 0; i < children.length; i++) {
429
			RSEDOMNode[] children = node.getChildren();
418
			RSEDOMNode child = children[i];
430
			for (int i = 0; i < children.length; i++) {
419
			String ctype = child.getType();
431
				RSEDOMNode child = children[i];
420
			if (ctype.equals(IRSEDOMConstants.TYPE_FILTER)) {
432
				String ctype = child.getType();
421
				if (filterPool != null) {
433
				if (IRSEDOMConstants.TYPE_FILTER.equals(ctype)) {
422
					restoreFilter(filterPool, child);
434
					restoreFilter(filterPool, child);
435
				} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(ctype)) {
436
					restorePropertySet(filterPool, child);
423
				}
437
				}
424
			} else if (ctype.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) {
425
				restorePropertySet(filterPool, child);
426
			}
438
			}
427
		}
439
		}
428
		return filterPool;
440
		return filterPool;
Lines 466-472 Link Here
466
		RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes();
478
		RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes();
467
		for (int i = 0; i < attributes.length; i++) {
479
		for (int i = 0; i < attributes.length; i++) {
468
			RSEDOMNodeAttribute attribute = attributes[i];
480
			RSEDOMNodeAttribute attribute = attributes[i];
469
			if (attribute.getKey().equals(IRSEDOMConstants.ATTRIBUTE_DESCRIPTION)) { // descriptions really are stored as attributes
481
			if (IRSEDOMConstants.ATTRIBUTE_DESCRIPTION.equals(attribute.getKey())) { // descriptions really are stored as attributes
470
				set.setDescription(attribute.getValue());
482
				set.setDescription(attribute.getValue());
471
			} else {
483
			} else {
472
				String typeStr = attribute.getType();
484
				String typeStr = attribute.getType();
Lines 479-488 Link Here
479
		for (int i = 0; i < children.length; i++) {
491
		for (int i = 0; i < children.length; i++) {
480
			RSEDOMNode child = children[i];
492
			RSEDOMNode child = children[i];
481
			String propertyName = child.getName();
493
			String propertyName = child.getName();
482
			String propertyValue = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_VALUE).getValue();
494
			String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE);
483
			String propertyTypeName = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
495
			String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE);
484
			IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
496
			IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
485
			if (propertyName.equals(IPropertySet.DESCRIPTION_KEY)) { // any descriptions found as properties should be set directly
497
			if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly
486
				set.setDescription(propertyValue);
498
				set.setDescription(propertyValue);
487
			} else {
499
			} else {
488
				set.addProperty(propertyName, propertyValue, propertyType);
500
				set.addProperty(propertyName, propertyValue, propertyType);
Lines 518-526 Link Here
518
	private String getAttributeValue(RSEDOMNode node, String attributeName) {
530
	private String getAttributeValue(RSEDOMNode node, String attributeName) {
519
		String result = null;
531
		String result = null;
520
		RSEDOMNodeAttribute attribute = node.getAttribute(attributeName);
532
		RSEDOMNodeAttribute attribute = node.getAttribute(attributeName);
533
		if (attribute == null) {
534
			logNullAttribute(node, attributeName);
535
		} else {
536
			result = attribute.getValue();
537
		}
538
		return result;
539
	}
540
541
	private String getAttributeValueMaybeNull(RSEDOMNode node, String attributeName) {
542
		String result = null;
543
		RSEDOMNodeAttribute attribute = node.getAttribute(attributeName);
521
		if (attribute != null) {
544
		if (attribute != null) {
522
			result = attribute.getValue();
545
			result = attribute.getValue();
523
		}
546
		}
524
		return result;
547
		return result;
525
	}
548
	}
549
550
	private boolean getBooleanValue(RSEDOMNode node, String attributeName) {
551
		String booleanStr = getAttributeValue(node, attributeName);
552
		if (booleanStr==null) logNullAttribute(node, attributeName);
553
		return getBooleanValue(booleanStr);
554
	}
555
556
	private int getIntegerValue(RSEDOMNode node, String attributeName) {
557
		String intStr = getAttributeValue(node, attributeName);
558
		if (intStr==null) logNullAttribute(node, attributeName);
559
		return getIntegerValue(intStr);
560
	}
561
	
562
	private void logException(Exception e) {
563
		RSECorePlugin.getDefault().getLog().log(
564
				new Status(IStatus.ERROR, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, e.getMessage(), e));
565
	}
566
	
567
	private void logNullAttribute(RSEDOMNode node, String attributeName) {
568
		StringBuffer msg = new StringBuffer(80);
569
		msg.append("RSEDOMImporter: null attr \""); //$NON-NLS-1$
570
		msg.append(attributeName==null ? "null" : attributeName); //$NON-NLS-1$
571
		msg.append("\" in "); //$NON-NLS-1$
572
		int len = msg.length();
573
		RSEDOMNode parent = node.getParent();
574
		while (parent!=null) {
575
			String parentName = parent.getName();
576
			msg.insert(len, parentName==null ? "null/" : parentName+'/'); //$NON-NLS-1$
577
			parent = parent.getParent();
578
		}
579
		msg.append(node.getName()==null ? "null" : node.getName()); //$NON-NLS-1$
580
		RSECorePlugin.getDefault().getLog().log(
581
				new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, msg.toString(), null));
582
	}
583
526
}
584
}

Return to bug 202416