1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 13:05:22 +02:00

[202416] apply patch from Martin - tests for invalid DOM node attributes when importing a DOM

This commit is contained in:
David Dykstal 2007-09-11 01:51:17 +00:00
parent 19fb3c47e9
commit 0f964c8e73
2 changed files with 160 additions and 75 deletions

View file

@ -16,6 +16,7 @@
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
* Martin Oberhuber (Wind River) - [196919] Fix deadlock with workspace operations * Martin Oberhuber (Wind River) - [196919] Fix deadlock with workspace operations
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.persistence; package org.eclipse.rse.internal.persistence;
@ -371,7 +372,9 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
for (int i = 0; i < profileNames.length; i++) { for (int i = 0; i < profileNames.length; i++) {
String profileName = profileNames[i]; String profileName = profileNames[i];
ISystemProfile profile = load(persistenceProvider, profileName, timeout); ISystemProfile profile = load(persistenceProvider, profileName, timeout);
profiles.add(profile); if (profile!=null) {
profiles.add(profile);
}
} }
return profiles; return profiles;
} }
@ -391,8 +394,10 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
if (dom != null) { if (dom != null) {
SystemProfileManager.getDefault().setRestoring(true); SystemProfileManager.getDefault().setRestoring(true);
profile = _importer.restoreProfile(dom); profile = _importer.restoreProfile(dom);
profile.setPersistenceProvider(provider); if (profile!=null) {
cleanTree(profile); profile.setPersistenceProvider(provider);
cleanTree(profile);
}
SystemProfileManager.getDefault().setRestoring(false); SystemProfileManager.getDefault().setRestoring(false);
} }
} finally { } finally {

View file

@ -15,12 +15,15 @@
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
* Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled * Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.persistence.dom; package org.eclipse.rse.internal.persistence.dom;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.rse.core.IRSECoreRegistry; import org.eclipse.rse.core.IRSECoreRegistry;
import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
@ -73,26 +76,35 @@ public class RSEDOMImporter {
* @return the restored profile * @return the restored profile
*/ */
public ISystemProfile restoreProfile(RSEDOM dom) { public ISystemProfile restoreProfile(RSEDOM dom) {
ISystemProfile profile = null;
String profileName = dom.getName(); String profileName = dom.getName();
boolean defaultPrivate = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE).getValue()); if (profileName != null) {
boolean isActive = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE).getValue()); boolean defaultPrivate = getBooleanValue(dom, IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE);
ISystemProfile profile = new SystemProfile(profileName, isActive); boolean isActive = getBooleanValue(dom, IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE);
if (profile != null) { profile = new SystemProfile(profileName, isActive);
profile.setDefaultPrivate(defaultPrivate); profile.setDefaultPrivate(defaultPrivate);
SystemProfileManager.getDefault().addSystemProfile(profile); SystemProfileManager.getDefault().addSystemProfile(profile);
// restore the children for the profile // restore the children for the profile
RSEDOMNode[] children = dom.getChildren(); RSEDOMNode[] children = dom.getChildren();
for (int i = 0; i < children.length; i++) { for (int i = 0; i < children.length; i++) {
RSEDOMNode child = children[i]; try {
String type = child.getType(); RSEDOMNode child = children[i];
if (type.equals(IRSEDOMConstants.TYPE_HOST)) { String type = child.getType();
restoreHost(profile, child); if (IRSEDOMConstants.TYPE_HOST.equals(type)) {
} else if (type.equals(IRSEDOMConstants.TYPE_FILTER_POOL)) { restoreHost(profile, child);
restoreFilterPool(profile, child); } else if (IRSEDOMConstants.TYPE_FILTER_POOL.equals(type)) {
} else if (type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) { restoreFilterPool(profile, child);
restorePropertySet(profile, child); } else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(type)) {
restorePropertySet(profile, child);
} else {
logNullAttribute(child, "type"); //$NON-NLS-1$
}
} catch(Exception e) {
logException(e);
} }
} }
} else {
logNullAttribute(dom, "name"); //$NON-NLS-1$
} }
return profile; return profile;
} }
@ -105,12 +117,13 @@ public class RSEDOMImporter {
// get host node attributes // get host node attributes
String connectionName = hostNode.getName(); String connectionName = hostNode.getName();
String systemTypeName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE); // we changed from storing names to storing IDs, so these may be null
String systemTypeId = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE); String systemTypeName = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
String systemTypeId = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE);
String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME); String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME);
String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION); String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION);
boolean isOffline = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE)); boolean isOffline = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE);
boolean isPromptable = getBooleanValue(getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE)); boolean isPromptable = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
// create host and set it's attributes // create host and set it's attributes
try { try {
@ -123,22 +136,40 @@ public class RSEDOMImporter {
} else if (systemTypeName != null) { } else if (systemTypeName != null) {
systemType = registry.getSystemType(systemTypeName); systemType = registry.getSystemType(systemTypeName);
} }
host = profile.createHost(systemType, connectionName, hostName, description); //cannot create a host from a profile if we do not know the systemType
host.setOffline(isOffline); if (systemType != null) {
host.setPromptable(isPromptable); host = profile.createHost(systemType, connectionName, hostName, description);
host.setOffline(isOffline);
host.setPromptable(isPromptable);
} else {
StringBuffer msg = new StringBuffer(80);
msg.append("unknown systemType \""); //$NON-NLS-1$
msg.append(systemTypeName);
msg.append("\" ("); //$NON-NLS-1$
msg.append(systemTypeId);
msg.append(") in "); //$NON-NLS-1$
msg.append(profile.getName());
msg.append(':');
msg.append(connectionName);
logWarning(msg.toString());
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logException(e);
} }
// restore children of host // restore children of host
RSEDOMNode[] children = hostNode.getChildren(); if (host!=null) {
for (int i = 0; i < children.length; i++) { RSEDOMNode[] children = hostNode.getChildren();
RSEDOMNode child = children[i]; for (int i = 0; i < children.length; i++) {
String type = child.getType(); RSEDOMNode child = children[i];
if (type.equals(IRSEDOMConstants.TYPE_CONNECTOR_SERVICE)) { String type = child.getType();
restoreConnectorService(host, child); if (IRSEDOMConstants.TYPE_CONNECTOR_SERVICE.equals(type)) {
} else if (type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) { restoreConnectorService(host, child);
restorePropertySet(host, child); } else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(type)) {
restorePropertySet(host, child);
} else {
logNullAttribute(child, "type"); //$NON-NLS-1$
}
} }
} }
return host; return host;
@ -156,12 +187,8 @@ public class RSEDOMImporter {
// String name = connectorServiceNode.getName(); // String name = connectorServiceNode.getName();
// String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); // String type = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue();
// String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue(); // String group = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_GROUP).getValue();
boolean useSSL = getBooleanValue(connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_USE_SSL).getValue()); boolean useSSL = getBooleanValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_USE_SSL);
RSEDOMNodeAttribute att = connectorServiceNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_PORT); int port = getIntegerValue(connectorServiceNode, IRSEDOMConstants.ATTRIBUTE_PORT);
int port = 0;
if (att != null) {
port = getIntegerValue(att.getValue());
}
// first restore subsystems (since right now we need subsystem to get at service // first restore subsystems (since right now we need subsystem to get at service
RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM); RSEDOMNode[] ssChildren = connectorServiceNode.getChildren(IRSEDOMConstants.TYPE_SUBSYSTEM);
@ -222,8 +249,8 @@ public class RSEDOMImporter {
// in most cases (if not all) the subsystem already exists // in most cases (if not all) the subsystem already exists
// since createHost() ends up recreating subsystems for each factory // since createHost() ends up recreating subsystems for each factory
String name = subSystemNode.getName(); String name = subSystemNode.getName();
String type = subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); String type = getAttributeValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
boolean isHidden = getBooleanValue(subSystemNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_HIDDEN).getValue()); boolean isHidden = getBooleanValue(subSystemNode, IRSEDOMConstants.ATTRIBUTE_HIDDEN);
ISubSystem subSystem = null; ISubSystem subSystem = null;
ISubSystemConfiguration factory = getSubSystemConfiguration(type); ISubSystemConfiguration factory = getSubSystemConfiguration(type);
if (factory != null) { if (factory != null) {
@ -288,18 +315,18 @@ public class RSEDOMImporter {
public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) { public ISystemFilter restoreFilter(ISystemFilterPool filterPool, RSEDOMNode node) {
// get the node attributes for a filter // get the node attributes for a filter
String name = node.getName(); String name = node.getName();
boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue()); boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS);
int relativeOrder = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER).getValue()); int relativeOrder = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELATIVE_ORDER);
boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue()); boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT);
boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue()); boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE);
boolean isPromptable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE).getValue()); boolean isPromptable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue()); boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS);
boolean isNonDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE).getValue()); boolean isNonDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_DELETABLE);
boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue()); boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE);
boolean isNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE).getValue()); boolean isNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_CHANGEABLE);
boolean isStringsNonChangable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE).getValue()); boolean isStringsNonChangable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRINGS_NON_CHANGABLE);
int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue()); int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE);
boolean isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue()); boolean isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY);
Vector filterStrings = new Vector(); Vector filterStrings = new Vector();
@ -346,14 +373,14 @@ public class RSEDOMImporter {
// get the node attributes for a filter pool // get the node attributes for a filter pool
String name = node.getName(); String name = node.getName();
String type = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); String type = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_TYPE);
String id = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_ID).getValue(); String id = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_ID);
boolean supportsNestedFilters = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS).getValue()); boolean supportsNestedFilters = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_NESTED_FILTERS);
boolean isDeletable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DELETABLE).getValue()); boolean isDeletable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DELETABLE);
boolean isDefault = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT).getValue()); boolean isDefault = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_DEFAULT);
boolean isSetStringsCaseSensitive = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE).getValue()); boolean isSetStringsCaseSensitive = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_STRING_CASE_SENSITIVE);
boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS).getValue()); boolean isSetSupportsDuplicateFilterStrings = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SUPPORTS_DUPLICATE_FILTER_STRINGS);
int release = getIntegerValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_RELEASE).getValue()); int release = getIntegerValue(node, IRSEDOMConstants.ATTRIBUTE_RELEASE);
// Since old profiles won't have an "singleFilterStringOnlyESet" attribute // Since old profiles won't have an "singleFilterStringOnlyESet" attribute
// we must give it a default value. // we must give it a default value.
@ -366,11 +393,11 @@ public class RSEDOMImporter {
RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$ RSEDOMNodeAttribute attribute = node.getAttribute("singleFilterStringOnlyESet"); //$NON-NLS-1$
if (attribute != null) { if (attribute != null) {
isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue()); isSingleFilterStringOnlyESet = getBooleanValue(attribute.getValue());
isSetSingleFilterStringOnly = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY).getValue()); isSetSingleFilterStringOnly = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_SINGLE_FILTER_STRING_ONLY);
} }
String owningParentName = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME).getValue(); String owningParentName = getAttributeValue(node, IRSEDOMConstants.ATTRIBUTE_OWNING_PARENT_NAME);
boolean isNonRenamable = getBooleanValue(node.getAttribute(IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE).getValue()); boolean isNonRenamable = getBooleanValue(node, IRSEDOMConstants.ATTRIBUTE_NON_RENAMABLE);
// create the filter pool and set it's attributes // create the filter pool and set it's attributes
try { try {
@ -409,20 +436,22 @@ public class RSEDOMImporter {
// filterPool.wasRestored(); // filterPool.wasRestored();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logException(e);
} }
// restore children // restore children
RSEDOMNode[] children = node.getChildren(); if (filterPool != null) {
for (int i = 0; i < children.length; i++) { RSEDOMNode[] children = node.getChildren();
RSEDOMNode child = children[i]; for (int i = 0; i < children.length; i++) {
String ctype = child.getType(); RSEDOMNode child = children[i];
if (ctype.equals(IRSEDOMConstants.TYPE_FILTER)) { String ctype = child.getType();
if (filterPool != null) { if (IRSEDOMConstants.TYPE_FILTER.equals(ctype)) {
restoreFilter(filterPool, child); restoreFilter(filterPool, child);
} else if (IRSEDOMConstants.TYPE_PROPERTY_SET.equals(ctype)) {
restorePropertySet(filterPool, child);
} else {
logNullAttribute(child, "type"); //$NON-NLS-1$
} }
} else if (ctype.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)) {
restorePropertySet(filterPool, child);
} }
} }
return filterPool; return filterPool;
@ -466,7 +495,7 @@ public class RSEDOMImporter {
RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes(); RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes();
for (int i = 0; i < attributes.length; i++) { for (int i = 0; i < attributes.length; i++) {
RSEDOMNodeAttribute attribute = attributes[i]; RSEDOMNodeAttribute attribute = attributes[i];
if (attribute.getKey().equals(IRSEDOMConstants.ATTRIBUTE_DESCRIPTION)) { // descriptions really are stored as attributes if (IRSEDOMConstants.ATTRIBUTE_DESCRIPTION.equals(attribute.getKey())) { // descriptions really are stored as attributes
set.setDescription(attribute.getValue()); set.setDescription(attribute.getValue());
} else { } else {
String typeStr = attribute.getType(); String typeStr = attribute.getType();
@ -479,10 +508,10 @@ public class RSEDOMImporter {
for (int i = 0; i < children.length; i++) { for (int i = 0; i < children.length; i++) {
RSEDOMNode child = children[i]; RSEDOMNode child = children[i];
String propertyName = child.getName(); String propertyName = child.getName();
String propertyValue = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_VALUE).getValue(); String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE);
String propertyTypeName = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE);
IPropertyType propertyType = PropertyType.fromString(propertyTypeName); IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
if (propertyName.equals(IPropertySet.DESCRIPTION_KEY)) { // any descriptions found as properties should be set directly if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly
set.setDescription(propertyValue); set.setDescription(propertyValue);
} else { } else {
set.addProperty(propertyName, propertyValue, propertyType); set.addProperty(propertyName, propertyValue, propertyType);
@ -516,6 +545,17 @@ public class RSEDOMImporter {
} }
private String getAttributeValue(RSEDOMNode node, String attributeName) { private String getAttributeValue(RSEDOMNode node, String attributeName) {
String result = null;
RSEDOMNodeAttribute attribute = node.getAttribute(attributeName);
if (attribute == null) {
logNullAttribute(node, attributeName);
} else {
result = attribute.getValue();
}
return result;
}
private String getAttributeValueMaybeNull(RSEDOMNode node, String attributeName) {
String result = null; String result = null;
RSEDOMNodeAttribute attribute = node.getAttribute(attributeName); RSEDOMNodeAttribute attribute = node.getAttribute(attributeName);
if (attribute != null) { if (attribute != null) {
@ -523,4 +563,44 @@ public class RSEDOMImporter {
} }
return result; return result;
} }
private boolean getBooleanValue(RSEDOMNode node, String attributeName) {
String booleanStr = getAttributeValue(node, attributeName);
if (booleanStr==null) logNullAttribute(node, attributeName);
return getBooleanValue(booleanStr);
}
private int getIntegerValue(RSEDOMNode node, String attributeName) {
String intStr = getAttributeValue(node, attributeName);
if (intStr==null) logNullAttribute(node, attributeName);
return getIntegerValue(intStr);
}
private void logException(Exception e) {
RSECorePlugin.getDefault().getLog().log(
new Status(IStatus.ERROR, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, e.getMessage(), e));
}
private void logWarning(String msg) {
RSECorePlugin.getDefault().getLog().log(
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, "RSEDOMImporter: "+msg, null)); //$NON-NLS-1$
}
private void logNullAttribute(RSEDOMNode node, String attributeName) {
StringBuffer msg = new StringBuffer(80);
msg.append("RSEDOMImporter: null attr \""); //$NON-NLS-1$
msg.append(attributeName==null ? "null" : attributeName); //$NON-NLS-1$
msg.append("\" in "); //$NON-NLS-1$
int len = msg.length();
RSEDOMNode parent = node.getParent();
while (parent!=null) {
String parentName = parent.getName();
msg.insert(len, parentName==null ? "null/" : parentName+'/'); //$NON-NLS-1$
parent = parent.getParent();
}
msg.append(node.getName()==null ? "null" : node.getName()); //$NON-NLS-1$
RSECorePlugin.getDefault().getLog().log(
new Status(IStatus.WARNING, RSECorePlugin.getDefault().getBundle().getSymbolicName(), -1, msg.toString(), null));
}
} }