Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 83712 Details for
Bug 207763
Exception when de-serializing nested Common Base Event XML fragments/documents.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Consolidated patch
207763_consolidated.txt (text/plain), 18.73 KB, created by
Rohit Shetty
on 2007-11-25 02:57:16 EST
(
hide
)
Description:
Consolidated patch
Filename:
MIME Type:
Creator:
Rohit Shetty
Created:
2007-11-25 02:57:16 EST
Size:
18.73 KB
patch
obsolete
>Index: src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java,v >retrieving revision 1.2 >diff -u -r1.2 EventFormatter.java >--- src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java 5 Oct 2006 21:07:44 -0000 1.2 >+++ src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java 25 Nov 2007 07:50:50 -0000 >@@ -2089,10 +2089,17 @@ > buffer.append("\t\t\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyData); >- } >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyData)) >+ { >+ buffer.append(anyData); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyData)); >+ } >+ } > > if (format) { > buffer.append(Constants.LINE_SEPARATOR); >@@ -2127,10 +2134,17 @@ > buffer.append("\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyElement); >- } >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyElement)) >+ { >+ buffer.append(anyElement); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyElement)); >+ } >+ } > } > > if (format) { >Index: src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 EventHandler.java >--- src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java 6 Sep 2006 17:54:15 -0000 1.1 >+++ src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java 25 Nov 2007 07:50:35 -0000 >@@ -25,7 +25,7 @@ > import org.xml.sax.helpers.DefaultHandler; > > /********************************************************************** >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2007 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 >@@ -356,7 +356,7 @@ > > String elementName = getLocalElementName(localName, qualifiedName); > >- if ((!elementName.equals("CommonBaseEvents")) && (!elementName.equals("TemplateEvent"))) { >+ if ((!elementName.equals("CommonBaseEvents")) && (!elementName.equals("TemplateEvent")) || anyElementNestingDepth > 0) { > > //The EMF class and object for this XML element: > EObject emfObj = null; >@@ -390,7 +390,7 @@ > > //This element is assumed to be an any element if no structural > // feature was found: >- if (objStructuralFeature == null) { >+ if (objStructuralFeature == null || anyElementNestingDepth > 0) { > > if ((containerName.equals(COMMON_BASE_EVENT_CLASS)) || (containerName.equals(OTHER_SITUATION_CLASS))) { > >@@ -473,7 +473,7 @@ > } > > //Fill instance attributes: >- if (emfObj != null) { >+ if (emfObj != null && emfObjClass != null) { > > HashMap featureSubMap = (HashMap) FEATURE_MAP.get(emfObjClass.getName()); > EAttribute feature = null; >@@ -542,7 +542,7 @@ > > String elementName = getLocalElementName(localName, qualifiedName); > >- if ((!elementName.equals("CommonBaseEvents")) && (!elementName.equals("TemplateEvent"))) { >+ if ((!elementName.equals("CommonBaseEvents")) && (!elementName.equals("TemplateEvent")) || anyElementNestingDepth > 0) { > > if (stack.isEmpty()) { > throw new SAXException(LoggingCoreResourceBundle.getString("LOG_EVENT_SAX_PARSER_UNEXPECTED_XML_ELEMENT_EXC_", elementName, String.valueOf(line), String.valueOf(column))); >@@ -597,7 +597,7 @@ > //Do not persist white space (e.g. formatting characters) > // between elements: > if (anyElementCharacters.trim().length() > 0) { >- ((CommonBaseEvent) (object)).addAny(XmlUtility.normalize(anyElementCharacters)); >+ ((CommonBaseEvent) (object)).addAny(anyElementCharacters.trim()); > } > > if(eventListener != null){ >@@ -619,10 +619,10 @@ > String currentAnyElement = otherSituation.getAny(); > > if ((currentAnyElement != null) && (currentAnyElement.trim().length() > 0)) { >- otherSituation.setAny(currentAnyElement.concat(XmlUtility.normalize(anyElementCharacters))); >+ otherSituation.setAny(currentAnyElement.concat(anyElementCharacters)); > } > else { >- otherSituation.setAny(XmlUtility.normalize(anyElementCharacters)); >+ otherSituation.setAny(anyElementCharacters.trim()); > } > } > } >Index: src/org/eclipse/hyades/logging/core/XmlUtility.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src/org/eclipse/hyades/logging/core/XmlUtility.java,v >retrieving revision 1.1 >diff -u -r1.1 XmlUtility.java >--- src/org/eclipse/hyades/logging/core/XmlUtility.java 6 Sep 2006 17:54:05 -0000 1.1 >+++ src/org/eclipse/hyades/logging/core/XmlUtility.java 25 Nov 2007 07:50:52 -0000 >@@ -15,6 +15,8 @@ > import java.nio.charset.Charset; > > import javax.xml.parsers.DocumentBuilderFactory; >+import javax.xml.parsers.SAXParser; >+import javax.xml.parsers.SAXParserFactory; > import javax.xml.transform.OutputKeys; > import javax.xml.transform.Transformer; > import javax.xml.transform.TransformerConfigurationException; >@@ -29,6 +31,7 @@ > import org.w3c.dom.DocumentType; > import org.w3c.dom.Node; > import org.xml.sax.InputSource; >+import org.xml.sax.helpers.DefaultHandler; > > /********************************************************************** > * Copyright (c) 2005, 2006 IBM Corporation and others. >@@ -1099,6 +1102,32 @@ > } > > /** >+ * >+ * Verifies if the specified XML fragment is valid wrt the syntax. >+ * >+ * @param string The string to be normalized. >+ * @return "true" is the specified string is a valid XML fragment, "false" otherwise. >+ */ >+ >+ public static boolean isValidXML(String xml) >+ { >+ StringReader xmlStream = new StringReader(xml); >+ SAXParserFactory factory = SAXParserFactory.newInstance(); >+ try { >+ SAXParser saxParser = factory.newSAXParser(); >+ InputSource source = new InputSource(xmlStream); >+ saxParser.parse(source, new DefaultHandler()); >+ } catch (Throwable t) { >+ return false; >+ } finally { >+ if (xmlStream != null) { >+ xmlStream.close(); >+ } >+ } >+ return true; >+ } >+ >+ /** > * Normalizes the parameter string according to the XML specification for > * attribute-value normalization > * (<a href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</a>) >Index: src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 EventHandler.java >--- src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java 6 Sep 2006 17:54:23 -0000 1.1 >+++ src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java 25 Nov 2007 07:50:44 -0000 >@@ -316,7 +316,7 @@ > } > > //CommonBaseEvents/TemplateEvent: 1 >- else if(parentElement == 1){ >+ else if(parentElement == 1 && anyElementNestingDepth == 0){ > > if(elementName.equals("CommonBaseEvent")){ > >@@ -453,7 +453,7 @@ > //CommonBaseEvent: 2 > else if(parentElement == 2){ > >- if(elementName.equals("contextDataElements")){ >+ if(elementName.equals("contextDataElements") && anyElementNestingDepth == 0){ > > ContextDataElement contextDataElement = EventFactory.eINSTANCE.createContextDataElement(); > >@@ -474,7 +474,7 @@ > > parentElement = 3; > } >- else if(elementName.equals("extendedDataElements")){ >+ else if(elementName.equals("extendedDataElements") && anyElementNestingDepth == 0){ > > ExtendedDataElement extendedDataElement = EventFactory.eINSTANCE.createExtendedDataElement(); > >@@ -495,7 +495,7 @@ > > parentElement = 4; > } >- else if(elementName.equals("associatedEvents")){ >+ else if(elementName.equals("associatedEvents") && anyElementNestingDepth == 0){ > > AssociatedEvent associatedEvent = EventFactory.eINSTANCE.createAssociatedEvent(); > >@@ -513,7 +513,7 @@ > > parentElement = 6; > } >- else if(elementName.equals("reporterComponentId")){ >+ else if(elementName.equals("reporterComponentId") && anyElementNestingDepth == 0){ > > ComponentIdentification reporterComponentId = EventFactory.eINSTANCE.createComponentIdentification(); > >@@ -559,7 +559,7 @@ > > ((CommonBaseEvent)(parsedElements.get(parsedElements.size() - 1))).setReporterComponentId(reporterComponentId); > } >- else if(elementName.equals("sourceComponentId")){ >+ else if(elementName.equals("sourceComponentId") && anyElementNestingDepth == 0){ > > ComponentIdentification sourceComponentId = EventFactory.eINSTANCE.createComponentIdentification(); > >@@ -605,7 +605,7 @@ > > ((CommonBaseEvent)(parsedElements.get(parsedElements.size() - 1))).setSourceComponentId(sourceComponentId); > } >- else if(elementName.equals("msgDataElement")){ >+ else if(elementName.equals("msgDataElement") && anyElementNestingDepth == 0){ > > MsgDataElement msgDataElement = EventFactory.eINSTANCE.createMsgDataElement(); > >@@ -623,7 +623,7 @@ > > parentElement = 7; > } >- else if(elementName.equals("situation")){ >+ else if(elementName.equals("situation") && anyElementNestingDepth == 0){ > > Situation situation = EventFactory.eINSTANCE.createSituation(); > >@@ -675,7 +675,7 @@ > > //extendedDataElements: 4 > //children: 5 >- else if((parentElement == 4) || (parentElement == 5)){ >+ else if((parentElement == 4) || (parentElement == 5) && anyElementNestingDepth == 0){ > > //Validate the remaining child elements when processing the ExtendedDataElements end element: > if(elementName.equals("children")){ >@@ -702,7 +702,7 @@ > } > > //associatedEvents: 6 >- else if(parentElement == 6){ >+ else if(parentElement == 6 && anyElementNestingDepth == 0){ > > //Validate the remaining child elements when processing the msgDataElement end element: > if(elementName.equals("associationEngineInfo")){ >@@ -730,7 +730,7 @@ > } > > //msgDataElement: 7 >- else if(parentElement == 7){ >+ else if(parentElement == 7 && anyElementNestingDepth == 0){ > > //Validate the remaining child elements when processing the msgDataElement end element: > if(elementName.equals("msgCatalogTokens")){ >@@ -752,7 +752,7 @@ > } > > //situation: 8 >- else if(parentElement == 8){ >+ else if(parentElement == 8 && anyElementNestingDepth == 0){ > > if(elementName.equals("situationType")){ > >@@ -1050,7 +1050,7 @@ > > //Validate the child elements of the following elements when processing their end element: > //-ContextDataElements >- else if(parentElement != 3){ >+ else if(parentElement != 3 && anyElementNestingDepth == 0){ > throw new SAXException(LoggingCoreResourceBundle.getString("LOG_EVENT_SAX_PARSER_UNEXPECTED_XML_ELEMENT_EXC_", elementName, String.valueOf(line), String.valueOf(column))); > } > >@@ -1074,13 +1074,13 @@ > //CommonBaseEvent: 2 > if(parentElement == 2){ > >- if(elementName.equals("CommonBaseEvent")){ >+ if(elementName.equals("CommonBaseEvent") && anyElementNestingDepth == 0){ > > CommonBaseEvent commonBaseEvent = ((CommonBaseEvent)(parsedElements.remove(parsedElements.size() - 1))); > > //Do not persist white space (e.g. formatting characters) between elements: > if (charactersBuffer.toString().trim().length() > 0) { >- commonBaseEvent.addAny(XmlUtility.normalize(charactersBuffer.toString())); >+ commonBaseEvent.addAny(charactersBuffer.toString().trim()); > } > > if(eventListener != null){ >@@ -1112,7 +1112,7 @@ > } > > //contextDataElements: 3 >- else if(parentElement == 3){ >+ else if(parentElement == 3 && anyElementNestingDepth == 0){ > > if(elementName.equals("contextValue")){ > ((ContextDataElement)(parsedElements.get(parsedElements.size() - 1))).setContextValue(charactersBuffer.toString()); >@@ -1135,7 +1135,7 @@ > > //extendedDataElements: 4 > //children: 5 >- else if((parentElement == 4) || (parentElement == 5)){ >+ else if((parentElement == 4) || (parentElement == 5) && anyElementNestingDepth == 0){ > > if(elementName.equals("values")){ > ((ExtendedDataElement)(parsedElements.get(parsedElements.size() - 1))).getValues().add(charactersBuffer.toString()); >@@ -1165,7 +1165,7 @@ > } > > //associatedEvents: 6 >- else if(parentElement == 6){ >+ else if(parentElement == 6 && anyElementNestingDepth == 0){ > > if(elementName.equals("associationEngine")){ > ((AssociatedEvent)(parsedElements.get(parsedElements.size() - 1))).setAssociationEngine(charactersBuffer.toString()); >@@ -1184,7 +1184,7 @@ > } > > //msgDataElement: 7 >- else if(parentElement == 7){ >+ else if(parentElement == 7 && anyElementNestingDepth == 0){ > > if(elementName.equals("msgId")){ > ((MsgDataElement)(parsedElements.get(parsedElements.size() - 1))).setMsgId(charactersBuffer.toString()); >@@ -1215,7 +1215,7 @@ > } > > //situation: 8 >- else if(parentElement == 8){ >+ else if(parentElement == 8 && anyElementNestingDepth == 0){ > > if(elementName.equals("situation")){ > >@@ -1233,7 +1233,7 @@ > //OtherSituation: 9 > else if(parentElement == 9){ > >- if(elementName.equals("situationType")){ >+ if(elementName.equals("situationType") && anyElementNestingDepth == 0){ > > OtherSituation otherSituation = ((OtherSituation)(parsedElements.remove(parsedElements.size() - 1))); > >@@ -1247,7 +1247,7 @@ > > //Do not persist white space (e.g. formatting characters) between elements: > if (charactersBuffer.toString().trim().length() > 0) { >- otherSituation.setAny(XmlUtility.normalize(charactersBuffer.toString())); >+ otherSituation.setAny(charactersBuffer.toString().trim()); > } > > ((Situation)(parsedElements.get(parsedElements.size() - 1))).setSituationType(otherSituation); >Index: src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java,v >retrieving revision 1.2 >diff -u -r1.2 EventFormatter.java >--- src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java 5 Oct 2006 21:07:44 -0000 1.2 >+++ src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java 25 Nov 2007 07:50:41 -0000 >@@ -2091,9 +2091,16 @@ > buffer.append("\t\t\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyData); >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyData)) >+ { >+ buffer.append(anyData); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyData)); >+ } > } > > if (format) { >@@ -2129,9 +2136,16 @@ > buffer.append("\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyElement); >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyElement)) >+ { >+ buffer.append(anyElement); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyElement)); >+ } > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 207763
:
83228
|
83306
| 83712 |
83713
|
84055
|
84635
|
89498