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 |
} else { |
100 |
logNullAttribute(child, "type"); //$NON-NLS-1$ |
101 |
} |
102 |
} catch(Exception e) { |
103 |
logException(e); |
94 |
} |
104 |
} |
95 |
} |
105 |
} |
|
|
106 |
} else { |
107 |
logNullAttribute(dom, "name"); //$NON-NLS-1$ |
96 |
} |
108 |
} |
97 |
return profile; |
109 |
return profile; |
98 |
} |
110 |
} |
Lines 105-116
Link Here
|
105 |
|
117 |
|
106 |
// get host node attributes |
118 |
// get host node attributes |
107 |
String connectionName = hostNode.getName(); |
119 |
String connectionName = hostNode.getName(); |
108 |
String systemTypeName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE); |
120 |
// we changed from storing names to storing IDs, so these may be null |
109 |
String systemTypeId = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE); |
121 |
String systemTypeName = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE); |
|
|
122 |
String systemTypeId = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE); |
110 |
String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME); |
123 |
String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME); |
111 |
String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION); |
124 |
String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION); |
112 |
boolean isOffline = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE)); |
125 |
boolean isOffline = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE); |
113 |
boolean isPromptable = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE)); |
126 |
boolean isPromptable = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE); |
114 |
|
127 |
|
115 |
// create host and set it's attributes |
128 |
// create host and set it's attributes |
116 |
try { |
129 |
try { |
Lines 123-144
Link Here
|
123 |
} else if (systemTypeName != null) { |
136 |
} else if (systemTypeName != null) { |
124 |
systemType = registry.getSystemType(systemTypeName); |
137 |
systemType = registry.getSystemType(systemTypeName); |
125 |
} |
138 |
} |
126 |
host = profile.createHost(systemType, connectionName, hostName, description); |
139 |
//cannot create a host from a profile if we do not know the systemType |
127 |
host.setOffline(isOffline); |
140 |
if (systemType != null) { |
128 |
host.setPromptable(isPromptable); |
141 |
host = profile.createHost(systemType, connectionName, hostName, description); |
|
|
142 |
host.setOffline(isOffline); |
143 |
host.setPromptable(isPromptable); |
144 |
} else { |
145 |
StringBuffer msg = new StringBuffer(80); |
146 |
msg.append("unknown systemType \""); //$NON-NLS-1$ |
147 |
msg.append(systemTypeName); |
148 |
msg.append("\" ("); //$NON-NLS-1$ |
149 |
msg.append(systemTypeId); |
150 |
msg.append(") in "); //$NON-NLS-1$ |
151 |
msg.append(profile.getName()); |
152 |
msg.append(':'); |
153 |
msg.append(connectionName); |
154 |
logWarning(msg.toString()); |
155 |
} |
129 |
} catch (Exception e) { |
156 |
} catch (Exception e) { |
130 |
e.printStackTrace(); |
157 |
logException(e); |
131 |
} |
158 |
} |
132 |
|
159 |
|
133 |
// restore children of host |
160 |
// restore children of host |
134 |
RSEDOMNode[] children = hostNode.getChildren(); |
161 |
if (host!=null) { |
135 |
for (int i = 0; i < children.length; i++) { |
162 |
RSEDOMNode[] children = hostNode.getChildren(); |
136 |
RSEDOMNode child = children[i]; |
163 |
for (int i = 0; i < children.length; i++) { |
137 |
String type = child.getType(); |
164 |
RSEDOMNode child = children[i]; |
138 |
if (type.equals(IRSEDOMConstants.TYPE_CONNECTOR_SERVICE)) { |
165 |
String type = child.getType(); |
139 |
restoreConnectorService(host, child); |
166 |
if (IRSEDOMConstants.TYPE_CONNECTOR_SERVICE.equals(type)) { |
140 |
} else if (type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) { |
167 |
restoreConnectorService(host, child); |
141 |
restorePropertySet(host, child); |
168 |
} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(type)) { |
|
|
169 |
restorePropertySet(host, child); |
170 |
} else { |
171 |
logNullAttribute(child, "type"); //$NON-NLS-1$ |
172 |
} |
142 |
} |
173 |
} |
143 |
} |
174 |
} |
144 |
return host; |
175 |
return host; |
Lines 156-167
Link Here
|
156 |
// String name = connectorServiceNode.getName(); |
187 |
// String name = connectorServiceNode.getName(); |
157 |
// String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); |
188 |
// String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); |
158 |
// String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue(); |
189 |
// String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue(); |
159 |
boolean useSSL = getBooleanValue(connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_USE_SSL).getValue()); |
190 |
boolean useSSL = getBooleanValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_USE_SSL); |
160 |
RSEDOMNodeAttribute att = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_PORT); |
191 |
int port = getIntegerValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_PORT); |
161 |
int port = 0; |
|
|
162 |
if (att != null) { |
163 |
port = getIntegerValue(att.getValue()); |
164 |
} |
165 |
|
192 |
|
166 |
// first restore subsystems (since right now we need subsystem to get at service |
193 |
// first restore subsystems (since right now we need subsystem to get at service |
167 |
RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM); |
194 |
RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM); |
Lines 222-229
Link Here
|
222 |
// in most cases (if not all) the subsystem already exists |
249 |
// in most cases (if not all) the subsystem already exists |
223 |
// since createHost() ends up recreating subsystems for each factory |
250 |
// since createHost() ends up recreating subsystems for each factory |
224 |
String name = subSystemNode.getName(); |
251 |
String name = subSystemNode.getName(); |
225 |
String type = subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); |
252 |
String type = getAttributeValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_TYPE); |
226 |
boolean isHidden = getBooleanValue(subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_HIDDEN).getValue()); |
253 |
boolean isHidden = getBooleanValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_HIDDEN); |
227 |
ISubSystem subSystem = null; |
254 |
ISubSystem subSystem = null; |
228 |
ISubSystemConfiguration factory = getSubSystemConfiguration(type); |
255 |
ISubSystemConfiguration factory = getSubSystemConfiguration(type); |
229 |
if (factory != null) { |
256 |
if (factory != null) { |
Lines 288-305
Link Here
|
288 |
public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) { |
315 |
public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) { |
289 |
// get the node attributes for a filter |
316 |
// get the node attributes for a filter |
290 |
String name = node.getName(); |
317 |
String name = node.getName(); |
291 |
boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue()); |
318 |
boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS); |
292 |
int relativeOrder = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER).getValue()); |
319 |
int relativeOrder = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER); |
293 |
boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue()); |
320 |
boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT); |
294 |
boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue()); |
321 |
boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE); |
295 |
boolean isPromptable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE).getValue()); |
322 |
boolean isPromptable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE); |
296 |
boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue()); |
323 |
boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS); |
297 |
boolean isNonDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE).getValue()); |
324 |
boolean isNonDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE); |
298 |
boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue()); |
325 |
boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE); |
299 |
boolean isNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE).getValue()); |
326 |
boolean isNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE); |
300 |
boolean isStringsNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE).getValue()); |
327 |
boolean isStringsNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE); |
301 |
int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue()); |
328 |
int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE); |
302 |
boolean isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue()); |
329 |
boolean isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY); |
303 |
|
330 |
|
304 |
Vector filterStrings = new Vector(); |
331 |
Vector filterStrings = new Vector(); |
305 |
|
332 |
|
Lines 346-359
Link Here
|
346 |
|
373 |
|
347 |
// get the node attributes for a filter pool |
374 |
// get the node attributes for a filter pool |
348 |
String name = node.getName(); |
375 |
String name = node.getName(); |
349 |
String type = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); |
376 |
String type = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_TYPE); |
350 |
String id = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_ID).getValue(); |
377 |
String id = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_ID); |
351 |
boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue()); |
378 |
boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS); |
352 |
boolean isDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DELETABLE).getValue()); |
379 |
boolean isDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DELETABLE); |
353 |
boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue()); |
380 |
boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT); |
354 |
boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue()); |
381 |
boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE); |
355 |
boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue()); |
382 |
boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS); |
356 |
int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue()); |
383 |
int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE); |
357 |
|
384 |
|
358 |
// Since old profiles won't have an "singleFilterStringOnlyESet" attribute |
385 |
// Since old profiles won't have an "singleFilterStringOnlyESet" attribute |
359 |
// we must give it a default value. |
386 |
// we must give it a default value. |
Lines 366-376
Link Here
|
366 |
RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$ |
393 |
RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$ |
367 |
if (attribute != null) { |
394 |
if (attribute != null) { |
368 |
isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue()); |
395 |
isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue()); |
369 |
isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue()); |
396 |
isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY); |
370 |
} |
397 |
} |
371 |
|
398 |
|
372 |
String owningParentName = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME).getValue(); |
399 |
String owningParentName = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME); |
373 |
boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue()); |
400 |
boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE); |
374 |
|
401 |
|
375 |
// create the filter pool and set it's attributes |
402 |
// create the filter pool and set it's attributes |
376 |
try { |
403 |
try { |
Lines 409-428
Link Here
|
409 |
// filterPool.wasRestored(); |
436 |
// filterPool.wasRestored(); |
410 |
} |
437 |
} |
411 |
} catch (Exception e) { |
438 |
} catch (Exception e) { |
412 |
e.printStackTrace(); |
439 |
logException(e); |
413 |
} |
440 |
} |
414 |
|
441 |
|
415 |
// restore children |
442 |
// restore children |
416 |
RSEDOMNode[] children = node.getChildren(); |
443 |
if (filterPool != null) { |
417 |
for (int i = 0; i < children.length; i++) { |
444 |
RSEDOMNode[] children = node.getChildren(); |
418 |
RSEDOMNode child = children[i]; |
445 |
for (int i = 0; i < children.length; i++) { |
419 |
String ctype = child.getType(); |
446 |
RSEDOMNode child = children[i]; |
420 |
if (ctype.equals(IRSEDOMConstants.TYPE_FILTER)) { |
447 |
String ctype = child.getType(); |
421 |
if (filterPool != null) { |
448 |
if (IRSEDOMConstants.TYPE_FILTER.equals(ctype)) { |
422 |
restoreFilter(filterPool, child); |
449 |
restoreFilter(filterPool, child); |
|
|
450 |
} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(ctype)) { |
451 |
restorePropertySet(filterPool, child); |
452 |
} else { |
453 |
logNullAttribute(child, "type"); //$NON-NLS-1$ |
423 |
} |
454 |
} |
424 |
} else if (ctype.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) { |
|
|
425 |
restorePropertySet(filterPool, child); |
426 |
} |
455 |
} |
427 |
} |
456 |
} |
428 |
return filterPool; |
457 |
return filterPool; |
Lines 466-472
Link Here
|
466 |
RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes(); |
495 |
RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes(); |
467 |
for (int i = 0; i < attributes.length; i++) { |
496 |
for (int i = 0; i < attributes.length; i++) { |
468 |
RSEDOMNodeAttribute attribute = attributes[i]; |
497 |
RSEDOMNodeAttribute attribute = attributes[i]; |
469 |
if (attribute.getKey().equals(IRSEDOMConstants.ATTRIBUTE_DESCRIPTION)) { // descriptions really are stored as attributes |
498 |
if (IRSEDOMConstants.ATTRIBUTE_DESCRIPTION.equals(attribute.getKey())) { // descriptions really are stored as attributes |
470 |
set.setDescription(attribute.getValue()); |
499 |
set.setDescription(attribute.getValue()); |
471 |
} else { |
500 |
} else { |
472 |
String typeStr = attribute.getType(); |
501 |
String typeStr = attribute.getType(); |
Lines 479-488
Link Here
|
479 |
for (int i = 0; i < children.length; i++) { |
508 |
for (int i = 0; i < children.length; i++) { |
480 |
RSEDOMNode child = children[i]; |
509 |
RSEDOMNode child = children[i]; |
481 |
String propertyName = child.getName(); |
510 |
String propertyName = child.getName(); |
482 |
String propertyValue = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_VALUE).getValue(); |
511 |
String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE); |
483 |
String propertyTypeName = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); |
512 |
String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE); |
484 |
IPropertyType propertyType = PropertyType.fromString(propertyTypeName); |
513 |
IPropertyType propertyType = PropertyType.fromString(propertyTypeName); |
485 |
if (propertyName.equals(IPropertySet.DESCRIPTION_KEY)) { // any descriptions found as properties should be set directly |
514 |
if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly |
486 |
set.setDescription(propertyValue); |
515 |
set.setDescription(propertyValue); |
487 |
} else { |
516 |
} else { |
488 |
set.addProperty(propertyName, propertyValue, propertyType); |
517 |
set.addProperty(propertyName, propertyValue, propertyType); |
Lines 518-526
Link Here
|
518 |
private String getAttributeValue(RSEDOMNode node, String attributeName) { |
547 |
private String getAttributeValue(RSEDOMNode node, String attributeName) { |
519 |
String result = null; |
548 |
String result = null; |
520 |
RSEDOMNodeAttribute attribute = node.getAttribute(attributeName); |
549 |
RSEDOMNodeAttribute attribute = node.getAttribute(attributeName); |
|
|
550 |
if (attribute == null) { |
551 |
logNullAttribute(node, attributeName); |
552 |
} else { |
553 |
result = attribute.getValue(); |
554 |
} |
555 |
return result; |
556 |
} |
557 |
|
558 |
private String getAttributeValueMaybeNull(RSEDOMNode node, String attributeName) { |
559 |
String result = null; |
560 |
RSEDOMNodeAttribute attribute = node.getAttribute(attributeName); |
521 |
if (attribute != null) { |
561 |
if (attribute != null) { |
522 |
result = attribute.getValue(); |
562 |
result = attribute.getValue(); |
523 |
} |
563 |
} |
524 |
return result; |
564 |
return result; |
525 |
} |
565 |
} |
|
|
566 |
|
567 |
private boolean getBooleanValue(RSEDOMNode node, String attributeName) { |
568 |
String booleanStr = getAttributeValue(node, attributeName); |
569 |
if (booleanStr==null) logNullAttribute(node, attributeName); |
570 |
return getBooleanValue(booleanStr); |
571 |
} |
572 |
|
573 |
private int getIntegerValue(RSEDOMNode node, String attributeName) { |
574 |
String intStr = getAttributeValue(node, attributeName); |
575 |
if (intStr==null) logNullAttribute(node, attributeName); |
576 |
return getIntegerValue(intStr); |
577 |
} |
578 |
|
579 |
private void logException(Exception e) { |
580 |
RSECorePlugin.getDefault().getLog().log( |
581 |
new Status(IStatus.ERROR, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, e.getMessage(), e)); |
582 |
} |
583 |
|
584 |
private void logWarning(String msg) { |
585 |
RSECorePlugin.getDefault().getLog().log( |
586 |
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, "RSEDOMImporter: "+msg, null)); //$NON-NLS-1$ |
587 |
} |
588 |
|
589 |
private void logNullAttribute(RSEDOMNode node, String attributeName) { |
590 |
StringBuffer msg = new StringBuffer(80); |
591 |
msg.append("RSEDOMImporter: null attr \""); //$NON-NLS-1$ |
592 |
msg.append(attributeName==null ? "null" : attributeName); //$NON-NLS-1$ |
593 |
msg.append("\" in "); //$NON-NLS-1$ |
594 |
int len = msg.length(); |
595 |
RSEDOMNode parent = node.getParent(); |
596 |
while (parent!=null) { |
597 |
String parentName = parent.getName(); |
598 |
msg.insert(len, parentName==null ? "null/" : parentName+'/'); //$NON-NLS-1$ |
599 |
parent = parent.getParent(); |
600 |
} |
601 |
msg.append(node.getName()==null ? "null" : node.getName()); //$NON-NLS-1$ |
602 |
RSECorePlugin.getDefault().getLog().log( |
603 |
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, msg.toString(), null)); |
604 |
} |
605 |
|
526 |
} |
606 |
} |