Skip to content

Commit

Permalink
Fixed an issue with the LS serializer usage that triggered an Abstrac…
Browse files Browse the repository at this point in the history
…tMethodError at runtime under certain environments. The parsing is now done old-school.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@128 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Nov 3, 2008
1 parent 0919416 commit 3ee359a
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 22 deletions.
10 changes: 2 additions & 8 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,9 @@ void populate() throws OlapException {
</SOAP-ENV:Fault>
*/
// TODO: log doc to logfile
// 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: " + serializer.writeToString(fault));
"XMLA provider gave exception: " +
XmlaOlap4jUtil.prettyPrint(fault));
}
Element executeResponse =
findChild(body, XMLA_NS, "ExecuteResponse");
Expand Down
10 changes: 2 additions & 8 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,15 +659,9 @@ Element xxx(String request) throws OlapException {
</SOAP-ENV:Fault>
*/
// TODO: log doc to logfile
// 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: " + serializer.writeToString(fault)
"XMLA provider gave exception: " +
XmlaOlap4jUtil.prettyPrint(fault)
+ "\n Request was: \n" + request);
}
Element discoverResponse =
Expand Down
100 changes: 100 additions & 0 deletions src/org/olap4j/driver/xmla/XmlaOlap4jUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,106 @@ static String gatherText(Element element) {
return buf.toString();
}

static String prettyPrint(Element element) {
StringBuilder string = new StringBuilder();
prettyPrintLoop(element, string, "");
return string.toString();
}

private static void prettyPrintLoop(
NodeList nodes,
StringBuilder string,
String indentation)
{
for (int index = 0; index < nodes.getLength(); index++){
prettyPrintLoop(nodes.item(index), string, indentation);
}
}

private static void prettyPrintLoop(
Node node,
StringBuilder string,
String indentation)
{
if (node == null) {
return;
}

int type = node.getNodeType();

switch (type) {
case Node.DOCUMENT_NODE: {
string.append("\n");
prettyPrintLoop(node.getChildNodes(), string, indentation+"\t");
break;
}

case Node.ELEMENT_NODE: {
string.append(indentation);
string.append("<");
string.append(node.getNodeName());

int length = (node.getAttributes() != null) ?
node.getAttributes().getLength() : 0;
Attr attributes[] = new Attr[length];
for (int loopIndex = 0; loopIndex < length; loopIndex++) {
attributes[loopIndex] =
(Attr)node.getAttributes().item(loopIndex);
}

for (int loopIndex = 0; loopIndex < attributes.length;
loopIndex++)
{
Attr attribute = attributes[loopIndex];
string.append(" ");
string.append(attribute.getNodeName());
string.append("=\"");
string.append(attribute.getNodeValue());
string.append("\"");
}

string.append(">\n");

prettyPrintLoop(node.getChildNodes(), string, indentation+"\t");

string.append(indentation);
string.append("</");
string.append(node.getNodeName());
string.append(">\n");

break;
}

case Node.TEXT_NODE: {
string.append(indentation);
string.append(node.getNodeValue().trim()+"\n");
//prettyPrintLoop(node, string, indentation+"\t");
break;
}

case Node.PROCESSING_INSTRUCTION_NODE: {
string.append(indentation);
string.append("<?");
string.append(node.getNodeName());
String text = node.getNodeValue();
if (text != null && text.length() > 0) {
string.append(text);
}
string.append("?>\n");
break;
}

case Node.CDATA_SECTION_NODE: {
string.append(indentation);
string.append("<![CDATA[");
string.append(node.getNodeValue());
string.append("]]>");
break;
}
}
}


static Element findChild(Element element, String ns, String tag) {
final NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Expand Down
6 changes: 0 additions & 6 deletions testsrc/org/olap4j/XmlaConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,10 @@ public DoubleSubmissionTestProxy(
{
super(catalogNameUrls,urlString);
}
@Override
public byte[] get(URL url, String request) throws IOException {
this.checkup(request);
return super.get(url, request);
}
// @Override
// public Future<byte[]> submit(URL url, String request) {
// this.checkup(request);
// return super.submit(url, request);
// }
private void checkup(String request) {
String hash = Encoder.convertToHex(request.getBytes());
if ( request.indexOf("<RequestType>MDSCHEMA_CUBES</RequestType>") == -1 &&
Expand Down

0 comments on commit 3ee359a

Please sign in to comment.