Skip to content

Commit

Permalink
Made the fault string parsing more efficient and standard with the Ce…
Browse files Browse the repository at this point in the history
…llSet implementation way of doing it.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@121 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Oct 29, 2008
1 parent 7f766f2 commit 7b3729c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import org.olap4j.mdx.parser.*;
import org.olap4j.mdx.parser.impl.DefaultMdxParserImpl;
import org.olap4j.metadata.*;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;
import org.xml.sax.SAXException;

import java.io.*;
Expand Down Expand Up @@ -662,17 +665,16 @@ Element xxx(String request) throws OlapException {
</SOAP-ENV:Fault>
*/
// TODO: log doc to logfile
StringWriter writer = new StringWriter();
writer.append("The SOAP service end-point returned an error message.");
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(findChild(fault, null, "faultstring")), new StreamResult(writer));
} catch (TransformerException e) {
//The error message cannot be parsed... weird.
}
// A message must include the fault XML content. This is the right
// and efficient way to do it, according to
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6181019
// They changed the node.getString() in java... ....
DOMImplementation impl = fault.getOwnerDocument().getImplementation();
DOMImplementationLS factory = (DOMImplementationLS) impl.getFeature("LS", "3.0");
LSSerializer serializer = factory.createLSSerializer();
throw OlapExceptionHelper.createException(
"XMLA provider gave exception: \n" + writer.getBuffer()
+ "\n Request was: \n" + request);
"XMLA provider gave exception: " + serializer.writeToString(fault)
+ "\n Request was: \n" + request);
}
Element discoverResponse =
findChild(body, XMLA_NS, "DiscoverResponse");
Expand Down

0 comments on commit 7b3729c

Please sign in to comment.