aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2013-01-17 15:27:26 (EST)
committerJohn Ross2013-01-23 09:39:37 (EST)
commit98ba80bbb423e570559c61f6eeb18ac43e7cfe9e (patch)
treef033ebb3eeec80ccefeffcd85d2d0b70e15e4deb
parent95025f60b123f3cff7003de1b252dc5bc3e0479c (diff)
downloadrt.equinox.bundles-98ba80bbb423e570559c61f6eeb18ac43e7cfe9e.zip
rt.equinox.bundles-98ba80bbb423e570559c61f6eeb18ac43e7cfe9e.tar.gz
rt.equinox.bundles-98ba80bbb423e570559c61f6eeb18ac43e7cfe9e.tar.bz2
Bug 395196 - [metatype] Unhelpful error message from metatype parserv20130123-143937
Added new log messages and additional information to existing log messages, particularly to aid in identifying the bundle containing bad metadata and location within the file. Added a new validation message indicating a non-numeric value for a numeric attribute definition type. Reduced the scope of a try/catch block in MetaTypeServiceImpl.getMetaTypeProvider() to make code clearer. Also fixed issue where a tracker could have been created but not registered in the map.
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/AttributeDefinitionImpl.java10
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java88
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ExternalMessages.properties51
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeMsg.java10
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeProviderImpl.java8
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java48
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ValueTokenizer.java19
7 files changed, 131 insertions, 103 deletions
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/AttributeDefinitionImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/AttributeDefinitionImpl.java
index afc0950..a0c2d9c 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/AttributeDefinitionImpl.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/AttributeDefinitionImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* 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
@@ -213,11 +213,11 @@ public class AttributeDefinitionImpl extends LocalizationElement implements Equi
*/
void setOption(Vector<String> labels, Vector<String> values, boolean needValidation) {
if ((labels == null) || (values == null)) {
- logger.log(LogService.LOG_ERROR, "AttributeDefinitionImpl.setOption(Vector, Vector, boolean) " + MetaTypeMsg.NULL_OPTIONS); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.NULL_OPTIONS, getID()));
return;
}
if (labels.size() != values.size()) {
- logger.log(LogService.LOG_ERROR, "AttributeDefinitionImpl.setOption(Vector, Vector, boolean) " + MetaTypeMsg.INCONSISTENT_OPTIONS); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.INCONSISTENT_OPTIONS, getID()));
return;
}
_labels = labels;
@@ -228,7 +228,7 @@ public class AttributeDefinitionImpl extends LocalizationElement implements Equi
_values.set(index, vt.getValuesAsString());
String reason = vt.validate(this);
if ((reason != null) && reason.length() > 0) {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.INVALID_OPTIONS, _values.get(index), reason));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.INVALID_OPTIONS, new Object[] {_values.get(index), getID(), reason}));
_labels.remove(index);
_values.remove(index);
index--; // Because this one has been removed.
@@ -254,7 +254,7 @@ public class AttributeDefinitionImpl extends LocalizationElement implements Equi
ValueTokenizer vt = new ValueTokenizer(defaults_str, logger);
String reason = vt.validate(this);
if ((reason != null) && reason.length() > 0) {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.INVALID_DEFAULTS, vt.getValuesAsString(), reason));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.INVALID_DEFAULTS, new Object[] {vt.getValuesAsString(), getID(), reason}));
return;
}
String[] defaults = vt.getValuesAsArray();
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java
index 295085b..850b78f 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* 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
@@ -158,12 +158,19 @@ public class DataParser {
protected ContentHandler _doc_handler;
protected boolean _isParsedDataValid = true;
protected Map<String, Map<String, String>> extensionAttributes = new HashMap<String, Map<String, String>>();
+ protected String elementId;
+ protected String elementName;
public AbstractHandler(ContentHandler parentHandler) {
this._doc_handler = parentHandler;
_dp_xmlReader.setContentHandler(this);
}
+ protected void init(String name, Attributes attributes) {
+ elementId = attributes.getValue(ID);
+ elementName = name;
+ }
+
public void endElement(String namespaceURI, String localName, String qName) {
finished();
// Let parent resume handling SAX events
@@ -171,13 +178,13 @@ public class DataParser {
}
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- throw new SAXException(NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, qName));
+ throw new SAXException(NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] {qName, attributes.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
public void characters(char[] buf, int start, int end) throws SAXException {
String s = new String(buf, start, end).trim();
if (s.length() > 0) {
- throw new SAXException(NLS.bind(MetaTypeMsg.UNEXPECTED_TEXT, s));
+ throw new SAXException(NLS.bind(MetaTypeMsg.UNEXPECTED_TEXT, new Object[] {s, elementName, elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
@@ -221,7 +228,7 @@ public class DataParser {
if (name.equalsIgnoreCase(METADATA)) {
new MetaDataHandler(this).init(name, attributes);
} else {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] {name, attributes.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
@@ -242,6 +249,7 @@ public class DataParser {
public void init(String name, Attributes attributes) {
logger.log(LogService.LOG_DEBUG, "Here is MetaDataHandler():init()"); //$NON-NLS-1$
+ super.init(name, attributes);
_dp_localization = attributes.getValue(LOCALIZATION);
if (_dp_localization == null) {
// Not a problem, because LOCALIZATION is an optional attribute.
@@ -265,7 +273,7 @@ public class DataParser {
OcdHandler ocdHandler = new OcdHandler(this);
ocdHandler.init(name, atts, _dp_OCDs);
} else {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] {name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
@@ -275,7 +283,7 @@ public class DataParser {
if (_dp_designateHandlers.size() == 0) {
// Schema defines at least one DESIGNATE is required.
_isParsedDataValid = false;
- logger.log(LogService.LOG_WARNING, "DataParser.finished() " + NLS.bind(MetaTypeMsg.MISSING_ELEMENT, DESIGNATE)); //$NON-NLS-1$
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.MISSING_ELEMENT, new Object[] {DESIGNATE, METADATA, elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
Enumeration<DesignateHandler> designateHandlerKeys = _dp_designateHandlers.elements();
@@ -286,7 +294,7 @@ public class DataParser {
if (ocd != null) {
designates.add(new Designate.Builder(ocd).bundle(dh._bundle_val).factoryPid(dh._factory_val).merge(dh._merge_val).pid(dh._pid_val).optional(dh._optional_val).build());
} else {
- logger.log(LogService.LOG_ERROR, "DataParser.finished() " + NLS.bind(MetaTypeMsg.OCD_ID_NOT_FOUND, dh._ocdref)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.OCD_REF_NOT_FOUND, new Object[] {dh._pid_val, dh._factory_val, dh._ocdref, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
@@ -313,12 +321,13 @@ public class DataParser {
public void init(String name, Attributes atts, Hashtable<String, ObjectClassDefinitionImpl> ocds_hashtable) {
logger.log(LogService.LOG_DEBUG, "Here is OcdHandler():init()"); //$NON-NLS-1$
+ super.init(name, atts);
_parent_OCDs_hashtable = ocds_hashtable;
collectExtensionAttributes(atts);
String ocd_name_val = atts.getValue(NAME);
if (ocd_name_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Hashtable) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, NAME, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {NAME, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
@@ -330,7 +339,7 @@ public class DataParser {
_refID = atts.getValue(ID);
if (_refID == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Hashtable) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, ID, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {ID, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
@@ -354,7 +363,7 @@ public class DataParser {
if (iconHandler._isParsedDataValid)
icons.add(iconHandler._icon);
} else {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] {name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
@@ -365,7 +374,7 @@ public class DataParser {
if (_ad_vector.size() == 0) {
// Schema defines at least one AD is required.
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.finished() " + NLS.bind(MetaTypeMsg.MISSING_ELEMENT, AD, _refID)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ELEMENT, new Object[] {AD, OCD, elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
// OCD gets all parsed ADs.
@@ -393,10 +402,11 @@ public class DataParser {
public void init(String name, Attributes atts) {
logger.log(LogService.LOG_DEBUG, "Here is IconHandler:init()"); //$NON-NLS-1$
+ super.init(name, atts);
String icon_resource_val = atts.getValue(RESOURCE);
if (icon_resource_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, RESOURCE, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {RESOURCE, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
@@ -424,6 +434,8 @@ public class DataParser {
Vector<String> _optionLabel_vector = new Vector<String>(7);
Vector<String> _optionValue_vector = new Vector<String>(7);
+ private String ad_defaults_str;
+
public AttributeDefinitionHandler(ContentHandler handler) {
super(handler);
}
@@ -431,6 +443,7 @@ public class DataParser {
public void init(String name, Attributes atts, Vector<AttributeDefinitionImpl> ad_vector) {
logger.log(LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler():init()"); //$NON-NLS-1$
+ super.init(name, atts);
_parent_ADs_vector = ad_vector;
collectExtensionAttributes(atts);
String ad_name_val = atts.getValue(NAME);
@@ -446,14 +459,14 @@ public class DataParser {
String ad_id_val = atts.getValue(ID);
if (ad_id_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, ID, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {ID, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
String ad_type_val = atts.getValue(TYPE);
if (ad_type_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, TYPE, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {TYPE, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
if (ad_type_val.equalsIgnoreCase(STRING)) {
@@ -478,7 +491,7 @@ public class DataParser {
_dataType = AttributeDefinition.PASSWORD;
} else {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.INVALID_TYPE, new Object[] {ad_type_val, _dp_url, _dp_bundle.getBundleId()})); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.INVALID_TYPE, new Object[] {ad_type_val, ad_id_val, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
@@ -501,7 +514,7 @@ public class DataParser {
// Not a problem, because MAX is an optional attribute.
}
- String ad_defaults_str = atts.getValue(DEFAULT);
+ ad_defaults_str = atts.getValue(DEFAULT);
if (ad_defaults_str == null) {
// Not a problem, because DEFAULT is an optional attribute.
}
@@ -514,10 +527,6 @@ public class DataParser {
}
_ad = new AttributeDefinitionImpl(ad_id_val, ad_name_val, ad_description_val, _dataType, ad_cardinality_val, convert(ad_min_val, _dataType), convert(ad_max_val, _dataType), Boolean.valueOf(ad_required_val).booleanValue(), _dp_localization, logger, extensionAttributes);
-
- if (ad_defaults_str != null) {
- _ad.setDefaultValue(ad_defaults_str, true);
- }
}
public void startElement(String uri, String localName, String qName, Attributes atts) {
@@ -537,7 +546,7 @@ public class DataParser {
_optionValue_vector.addElement(optionHandler._value_val);
}
} else {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] {name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
@@ -546,8 +555,20 @@ public class DataParser {
logger.log(LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler():finished()"); //$NON-NLS-1$
if (!_isParsedDataValid)
return;
-
+ int numOfValues = _optionValue_vector.size();
_ad.setOption(_optionLabel_vector, _optionValue_vector, true);
+ String[] values = _ad.getOptionValues();
+ if (values == null)
+ values = new String[0];
+ if (numOfValues != values.length)
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.INVALID_OPTIONS_XML, new Object[] {elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
+
+ if (ad_defaults_str != null) {
+ _ad.setDefaultValue(ad_defaults_str, true);
+ if (_ad.getDefaultValue() == null)
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.INVALID_DEFAULTS_XML, new Object[] {ad_defaults_str, elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
+ }
+
_parent_ADs_vector.addElement(_ad);
}
}
@@ -567,17 +588,18 @@ public class DataParser {
public void init(String name, Attributes atts) {
logger.log(LogService.LOG_DEBUG, "Here is OptionHandler:init()"); //$NON-NLS-1$
+ super.init(name, atts);
_label_val = atts.getValue(LABEL);
if (_label_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, LABEL, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {LABEL, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
_value_val = atts.getValue(VALUE);
if (_value_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, VALUE, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {VALUE, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
}
@@ -646,13 +668,13 @@ public class DataParser {
}
public void init(String name, Attributes atts) {
-
logger.log(LogService.LOG_DEBUG, "Here is DesignateHandler():init()"); //$NON-NLS-1$
+ super.init(name, atts);
_pid_val = atts.getValue(PID);
_factory_val = atts.getValue(FACTORY);
if (_pid_val == null && _factory_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, MetaTypeMsg.MISSING_DESIGNATE_PID_AND_FACTORYPID);
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_DESIGNATE_PID_AND_FACTORYPID, new Object[] {elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
@@ -695,7 +717,7 @@ public class DataParser {
_ocdref = objectHandler._ocdref;
}
} else {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] {name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
@@ -708,7 +730,7 @@ public class DataParser {
if (_ocdref == null) {
_isParsedDataValid = false;
// Schema defines at least one OBJECT is required.
- logger.log(LogService.LOG_ERROR, "DataParser.finished() " + NLS.bind(MetaTypeMsg.MISSING_ELEMENT, OBJECT, _pid_val)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ELEMENT, new Object[] {OBJECT, DESIGNATE, elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
@@ -729,10 +751,11 @@ public class DataParser {
public void init(String name, Attributes atts) {
logger.log(LogService.LOG_DEBUG, "Here is ObjectHandler():init()"); //$NON-NLS-1$
+ super.init(name, atts);
_ocdref = atts.getValue(OCDREF);
if (_ocdref == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, OCDREF, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {OCDREF, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
}
@@ -750,7 +773,7 @@ public class DataParser {
attributeHandler.init(name, atts);
// The ATTRIBUTE element is only used by RFC94, do nothing for it here.
} else {
- logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
+ logger.log(LogService.LOG_WARNING, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] {name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
}
}
}
@@ -772,17 +795,18 @@ public class DataParser {
public void init(String name, Attributes atts) {
logger.log(LogService.LOG_DEBUG, "Here is AttributeHandler():init()"); //$NON-NLS-1$
+ super.init(name, atts);
_adref_val = atts.getValue(ADREF);
if (_adref_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, ADREF, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {ADREF, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
_content_val = atts.getValue(CONTENT);
if (_content_val == null) {
_isParsedDataValid = false;
- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, CONTENT, name)); //$NON-NLS-1$
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] {CONTENT, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
return;
}
}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ExternalMessages.properties b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ExternalMessages.properties
index 820963a..2310541 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ExternalMessages.properties
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ExternalMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2011 IBM Corporation.
+# Copyright (c) 2005, 2013 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
@@ -9,29 +9,30 @@
# IBM Corporation - initial API and implementation
###############################################################################
#External Messages for EN locale
-SERVICE_DESCRIPTION=OSGi Metatype Service - IBM Implementation
-
-UNEXPECTED_ELEMENT=Unexpected element {0}.
-UNEXPECTED_TEXT=Unexpected text {0}.
-MISSING_ATTRIBUTE=Missing attribute {0} in tag {1}.
-INVALID_TYPE=Invalid attribute definition type {0} in metadata XML at {1} for bundle ID {2}.
-MISSING_DESIGNATE_PID_AND_FACTORYPID=A <Designate> element must specify either the 'pid' or 'factoryPid' attribute.
-OCD_ID_NOT_FOUND=Object Class Definition ID not found {0}.
-MISSING_ELEMENT=Missing element {0} (Reference ID = {1}.
-
-EXCEPTION_MESSAGE=Unexpected exception {0} with message {1}.
-NULL_IS_INVALID=Cannot validate a null.
-VALUE_OUT_OF_RANGE=Value {0} is out of range.
-VALUE_OUT_OF_OPTION=Value {0} is out of Option.
+ASK_INVALID_LOCALE=Object class definition with PID \"{0}\" does not support locale \"{1}\".
CARDINALITY_VIOLATION=Cardinality violation: \"{0}\" has {1} value(s) but must have between {2} and {3} value(s).
-NULL_OPTIONS=Cannot set Option labels or values as null.
-INCONSISTENT_OPTIONS=Labels and Values of Option have different sizes.
-INVALID_OPTIONS=Option value {0} is invalid because of {1}.
-INVALID_DEFAULTS=Dafaults value {0} is invalid because of {1}.
-
-METADATA_NOT_FOUND=Bundle(ID=\"{0}\", name=\"{1}\") has no MetaData file.
-ASK_INVALID_LOCALE=OCD(ID=\"{0}\") cannot support this locale \"{1}\".
+EXCEPTION_MESSAGE=An unexpected exception \"{0}\" with message \"{1}\" occurred while validating the attribute value.
+INCONSISTENT_OPTIONS=Attribute definition \"{0}\" does not have the same number of option values as labels.
+INVALID_DEFAULTS=Default value \"{0}\" for attribute definition \"{1}\" is invalid because \"{2}\".
+INVALID_DEFAULTS_XML=Invalid default value \"{0}\" for attribute definition \"{1}\" in metadata XML at \"{2}\" for bundle ID \"{3}\" with symbolic name \"{4}\".
+INVALID_OPTIONS=Option value \"{0}\" for attribute definition \"{1}\" is invalid because \"{2}\".
+INVALID_OPTIONS_XML=Invalid option value(s) for attribute definition \"{0}\" in metadata XML at \"{1}\" for bundle ID \"{2}\" with symbolic name \"{3}\".
+INVALID_PID_METATYPE_PROVIDER_IGNORED=Bundle \"{0}\" with ID \"{1}\" provided a MetaTypeProvider with an invalid property. Property \"{2}\" with value \"{3}\" was not of the expected type (String, String[], or Collection<String>) and will be ignored.
+INVALID_TYPE=Invalid type \"{0}\" for attribute definition with ID \"{1}\" in metadata XML at \"{2}\" for bundle ID \"{3}\" with symbolic name \"{4}\".
+METADATA_FILE_PARSE_ERROR=Unable to parse metadata XML at \"{0}\" for bundle ID \"{1}\" with symbolic name \"{2}\".
+METADATA_NOT_FOUND=Bundle \"{0}\" with ID \"{1}\" has no metadata files.
+METADATA_PARSE_ERROR=A general parser error occurred while attempting to parse the metadata of bundle ID \"{0}\" with symbolic name \"{1}\". The bundle will be treated as if it contained no metadata files.
+MISSING_ATTRIBUTE=Missing attribute \"{0}\" of element \"{1}\" with ID \"{2}\" in metadata XML at \"{3}\" for bundle ID \"{4}\" with symbolic name \"{5}\".
+MISSING_DESIGNATE_PID_AND_FACTORYPID=Missing "pid" or "factoryPid" attribute of element "Designate" with ID \"{0}\" in metadata XML at \"{1}\" for bundle ID \"{2}\" with symbolic name \"{3}\".
+MISSING_ELEMENT=Missing element \"{0}\" of parent element \"{1}\" with ID \"{2}\" in metadata XML at \"{3}\" for bundle ID \"{4}\" with symbolic name \"{5}\".
MISSING_REQUIRED_PARAMETER=Missing required parameter: {0}
-TOKENIZER_GOT_INVALID_DATA=The Tokenizer got invalid data.
-INVALID_PID_METATYPE_PROVIDER_IGNORED=Bundle {0} with ID {1} provided a MetaTypeProvider with an invalid property. Property {2} with value {3} was not of the expected type (String, String[], or Collection<String>) and will be ignored.
-METADATA_PARSE_ERROR=Unable to parse metadata XML at {0} for bundle ID {1}. \ No newline at end of file
+NULL_IS_INVALID=A null value is never valid.
+NULL_OPTIONS=Attribute definition \"{0}\" tried to set a null value for option labels or values.
+OCD_PID_NOT_FOUND=Object class definition with PID \"{0}\" does not exist.
+OCD_REF_NOT_FOUND=Designate with pid \"{0}\" and factoryPid \"{1}\" references missing OCD \"{2}\" in metadata XML at \"{3}\" for bundle ID \"{4}\" with symbolic name \"{5}\".
+SERVICE_DESCRIPTION=OSGi Metatype Service - IBM Implementation
+UNEXPECTED_ELEMENT=Unexpected element \"{0}\" with ID \"{1}\" in metadata XML at \"{2}\" for bundle ID \"{3}\" with symbolic name \"{4}\".
+UNEXPECTED_TEXT=Unexpected text \"{0}\" in element \"{1}\" with ID \"{2}\" in metadata XML at \"{3}\" for bundle ID \"{4}\" with symbolic name \"{5}\".
+VALUE_NOT_A_NUMBER=Value \"{0}\" is not a number.
+VALUE_OUT_OF_OPTION=Value \"{0}\" is not one of the options.
+VALUE_OUT_OF_RANGE=Value \"{0}\" is out of range.
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeMsg.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeMsg.java
index b5fb574..f915f5f 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeMsg.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeMsg.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation.
+ * Copyright (c) 2005, 2013 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
@@ -21,7 +21,8 @@ public class MetaTypeMsg extends NLS {
public static String MISSING_ATTRIBUTE;
public static String INVALID_TYPE;
public static String MISSING_DESIGNATE_PID_AND_FACTORYPID;
- public static String OCD_ID_NOT_FOUND;
+ public static String OCD_PID_NOT_FOUND;
+ public static String OCD_REF_NOT_FOUND;
public static String MISSING_ELEMENT;
public static String EXCEPTION_MESSAGE;
public static String NULL_IS_INVALID;
@@ -35,9 +36,12 @@ public class MetaTypeMsg extends NLS {
public static String METADATA_NOT_FOUND;
public static String ASK_INVALID_LOCALE;
public static String MISSING_REQUIRED_PARAMETER;
- public static String TOKENIZER_GOT_INVALID_DATA;
public static String INVALID_PID_METATYPE_PROVIDER_IGNORED;
+ public static String METADATA_FILE_PARSE_ERROR;
public static String METADATA_PARSE_ERROR;
+ public static String INVALID_DEFAULTS_XML;
+ public static String INVALID_OPTIONS_XML;
+ public static String VALUE_NOT_A_NUMBER;
static {
// initialize resource bundles
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeProviderImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeProviderImpl.java
index bf45a88..333b10a 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeProviderImpl.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeProviderImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* 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
@@ -59,7 +59,7 @@ public class MetaTypeProviderImpl implements MetaTypeProvider {
_isThereMeta = readMetaFiles(bundle, parser);
if (!_isThereMeta) {
- logger.log(LogService.LOG_DEBUG, NLS.bind(MetaTypeMsg.METADATA_NOT_FOUND, new Long(bundle.getBundleId()), bundle.getSymbolicName()));
+ logger.log(LogService.LOG_DEBUG, NLS.bind(MetaTypeMsg.METADATA_NOT_FOUND, bundle.getSymbolicName(), bundle.getBundleId()));
}
}
@@ -106,7 +106,7 @@ public class MetaTypeProviderImpl implements MetaTypeProvider {
}
}
} catch (Exception e) {
- logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.METADATA_PARSE_ERROR, new Object[] {entry, bundle.getBundleId()}), e);
+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.METADATA_FILE_PARSE_ERROR, new Object[] {entry, bundle.getBundleId(), bundle.getSymbolicName()}), e);
}
}
return result;
@@ -134,7 +134,7 @@ public class MetaTypeProviderImpl implements MetaTypeProvider {
ocd.setResourceBundle(locale, _bundle);
return ocd;
} else {
- throw new IllegalArgumentException(NLS.bind(MetaTypeMsg.OCD_ID_NOT_FOUND, pid));
+ throw new IllegalArgumentException(NLS.bind(MetaTypeMsg.OCD_PID_NOT_FOUND, pid));
}
}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java
index 28175be..93c2e75 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* 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
@@ -10,13 +10,12 @@
*******************************************************************************/
package org.eclipse.equinox.metatype.impl;
-import org.eclipse.equinox.metatype.EquinoxMetaTypeInformation;
-import org.eclipse.equinox.metatype.EquinoxMetaTypeService;
-
import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedAction;
import java.util.Hashtable;
import javax.xml.parsers.*;
+import org.eclipse.equinox.metatype.EquinoxMetaTypeInformation;
+import org.eclipse.equinox.metatype.EquinoxMetaTypeService;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.*;
import org.osgi.service.log.LogService;
@@ -56,29 +55,28 @@ public class MetaTypeServiceImpl implements EquinoxMetaTypeService, SynchronousB
* Internal Method - to get MetaTypeProvider object.
*/
private EquinoxMetaTypeInformation getMetaTypeProvider(final Bundle b) {
+ // Avoid synthetic accessor method warnings.
final LogService loggerTemp = this.logger;
final ServiceTracker<Object, Object> tracker = this.metaTypeProviderTracker;
- try {
- Long bID = new Long(b.getBundleId());
- synchronized (_mtps) {
- if (_mtps.containsKey(bID))
- return _mtps.get(bID);
- // Avoid synthetic accessor method warnings.
-
- EquinoxMetaTypeInformation mti = AccessController.doPrivileged(new PrivilegedExceptionAction<EquinoxMetaTypeInformation>() {
- public EquinoxMetaTypeInformation run() throws ParserConfigurationException, SAXException {
- MetaTypeInformationImpl impl = new MetaTypeInformationImpl(b, newParser(), loggerTemp);
- if (!impl._isThereMeta)
- return new MetaTypeProviderTracker(b, loggerTemp, tracker);
- return impl;
+ Long bID = new Long(b.getBundleId());
+ synchronized (_mtps) {
+ if (_mtps.containsKey(bID))
+ return _mtps.get(bID);
+ EquinoxMetaTypeInformation mti = AccessController.doPrivileged(new PrivilegedAction<EquinoxMetaTypeInformation>() {
+ public EquinoxMetaTypeInformation run() {
+ MetaTypeInformationImpl impl = null;
+ try {
+ impl = new MetaTypeInformationImpl(b, newParser(), loggerTemp);
+ } catch (Exception e) {
+ loggerTemp.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.METADATA_PARSE_ERROR, b.getBundleId(), b.getSymbolicName()), e);
}
- });
- _mtps.put(bID, mti);
- return mti;
- }
- } catch (Exception e) {
- logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.EXCEPTION_MESSAGE, e.getMessage()), e);
- return new MetaTypeProviderTracker(b, loggerTemp, tracker);
+ if (impl == null || !impl._isThereMeta)
+ return new MetaTypeProviderTracker(b, loggerTemp, tracker);
+ return impl;
+ }
+ });
+ _mtps.put(bID, mti);
+ return mti;
}
}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ValueTokenizer.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ValueTokenizer.java
index c0c5914..9e28978 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ValueTokenizer.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/ValueTokenizer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* 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
@@ -58,11 +58,9 @@ public class ValueTokenizer {
// at the end of the loop.
if (i + 1 < values_str.length()) {
buffer.append(values_str.charAt(++i));
- } else {
- // If the ESCAPE character occurs as the last character
- // of the string, log the error and ignore it.
- logger.log(LogService.LOG_ERROR, "ValueTokenizer.ValueTokenizer(String) " + MetaTypeMsg.TOKENIZER_GOT_INVALID_DATA); //$NON-NLS-1$
}
+ // If the ESCAPE character occurs as the last character
+ // of the string, ignore it.
break;
default :
// For all other characters, add them to the current token
@@ -149,6 +147,7 @@ public class ValueTokenizer {
if (values.isEmpty()) {
return MetaTypeMsg.NULL_IS_INVALID;
}
+ String s = null;
try {
// A value must match the cardinality.
int cardinality = Math.abs(ad.getCardinality());
@@ -164,7 +163,7 @@ public class ValueTokenizer {
}
// Now inspect each token.
for (Iterator<String> i = values.iterator(); i.hasNext();) {
- String s = i.next();
+ s = i.next();
// If options were declared and the value does not match one of them, the value is not valid.
if (!ad._values.isEmpty() && !ad._values.contains(s)) {
return NLS.bind(MetaTypeMsg.VALUE_OUT_OF_OPTION, s);
@@ -265,9 +264,11 @@ public class ValueTokenizer {
}
// No problems detected
return ""; //$NON-NLS-1$
- } catch (Throwable t) {
- String message = NLS.bind(MetaTypeMsg.EXCEPTION_MESSAGE, t.getClass().getName(), t.getMessage());
- logger.log(LogService.LOG_DEBUG, message, t);
+ } catch (NumberFormatException e) {
+ return NLS.bind(MetaTypeMsg.VALUE_NOT_A_NUMBER, s);
+ } catch (Exception e) {
+ String message = NLS.bind(MetaTypeMsg.EXCEPTION_MESSAGE, e.getClass().getName(), e.getMessage());
+ logger.log(LogService.LOG_DEBUG, message, e);
return message;
}
}