mondrian.tui
Class XmlaSupport

java.lang.Object
  extended by mondrian.tui.XmlaSupport

public class XmlaSupport
extends Object

This files provide support for making XMLA requests and looking at the responses.

Version:
$Id: //open/mondrian-release/3.0/src/main/mondrian/tui/XmlaSupport.java#2 $
Author:
Richard M. Emberson

Field Summary
static String CATALOG_NAME
           
static String DATASOURCE_DESCRIPTION
           
static String DATASOURCE_INFO
           
static String DATASOURCE_NAME
           
static Map<String,String> ENV
           
static String nl
           
static String ROW_SET_PREFIX
          This is the prefix used in xpath and transforms for the xmla rowset namespace "urn:schemas-microsoft-com:xml-analysis:rowset".
static String SOAP_PREFIX
           
 
Method Summary
static Document extractBodyFromSoap(Document doc)
           
static Node[] extractFaultNodesFromSoap(byte[] bytes)
           
static Node[] extractFaultNodesFromSoap(Document doc)
           
static Node[] extractHeaderAndBodyFromSoap(byte[] bytes)
           
static Node[] extractHeaderAndBodyFromSoap(Document doc)
           
static Node[] extractNodes(Node node, String xpath, String[][] nsArray)
          Given a Document and an xpath/namespace-array pair, extract and return the Nodes resulting from applying the xpath.
static Node[] extractNodesFromSoapXmla(byte[] bytes)
           
static Node[] extractNodesFromSoapXmla(Document doc)
           
static Node[] extractNodesFromXmla(byte[] bytes)
           
static Node[] extractNodesFromXmla(Document doc)
           
static CatalogLocator getCatalogLocator()
           
static DataSourcesConfig.DataSources getDataSources(String connectString, Map<String,String> catalogNameUrls)
           
static String getDataSourcesText(String connectString, Map<String,String> catalogNameUrls)
          With a connection string, generate the DataSource xml.
static String getSoapBodyXPath()
           
static String getSoapFaultXPath()
           
static String getSoapHeaderAndBodyXPath()
           
static String getSoapXmlaRootXPath(String xmlaPrefix)
           
static String getXmlaRootXPath(String xmlaPrefix)
           
static String getXmlaTransform(String xmlaPrefix)
          This is a parameterized XSLT.
static Servlet makeServlet(String connectString, Map<String,String> catalogNameUrls, String cbClassName)
           
static byte[] processSoapXmla(Document doc, Servlet servlet)
           
static byte[] processSoapXmla(Document doc, String connectString, Map<String,String> catalogNameUrls, String cbClassName)
           
static byte[] processSoapXmla(File file, Servlet servlet)
           
static byte[] processSoapXmla(File file, String connectString, Map<String,String> catalogNameUrls, String cbClassName)
          Process the given input file as a SOAP-XMLA request.
static byte[] processSoapXmla(String requestText, Servlet servlet)
           
static byte[] processSoapXmla(String requestText, String connectString, Map<String,String> catalogNameUrls, String cbClassName)
           
static byte[] processXmla(Document requestDoc, String connectString, Map<String,String> catalogNameUrls)
           
static byte[] processXmla(Document requestDoc, String connectString, Map<String,String> catalogNameUrls, Role role)
           
static byte[] processXmla(Element requestElem, String connectString, Map<String,String> catalogNameUrls)
           
static byte[] processXmla(Element requestElem, String connectString, Map<String,String> catalogNameUrls, Role role)
           
static byte[] processXmla(File file, String connectString, Map<String,String> catalogNameUrls)
          Processes the given input file as an XMLA request (no SOAP elements).
static byte[] processXmla(File file, String connectString, Map<String,String> catalogNameUrls, Role role)
           
static byte[] processXmla(String requestText, String connectString, Map<String,String> catalogNameUrls)
           
static byte[] processXmla(String requestText, String connectString, Map<String,String> catalogNameUrls, Role role)
           
static String readFile(File file)
          Reads a file line by line, adds a '\n' after each line and returns in a String.
static Document transformSoapXmla(Document doc, String[][] namevalueParameters, String ns)
           
static boolean validateEmbeddedSchema(byte[] bytes, String schemaTransform, String dataTransform)
          See next method for JavaDoc validateEmbeddedSchema(org.w3c.dom.Document, String, String).
static boolean validateEmbeddedSchema(Document doc, String schemaTransform, String dataTransform)
          A given Document has both content and an embedded schema (where the schema has a single root node and the content has a single root node - they are not interwoven).
static boolean validateNodes(Node[] nodes)
          Validate Nodes with throws an error if validation was attempted but failed, returns true if validation was successful and false if validation was not tried.
static boolean validateSchemaSoapXmla(byte[] bytes)
          Check is a byte array containing a SOAP-XMLA response method is valid.
static boolean validateSchemaXmla(byte[] bytes)
          Check is a byte array containing a XMLA response method is valid.
static boolean validateSoapXmlaUsingXpath(byte[] bytes)
          This validates a SOAP-XMLA response using xpaths to extract the schema and data parts.
static boolean validateXmlaUsingXpath(byte[] bytes)
          This validates a XMLA response using xpaths to extract the schema and data parts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nl

public static final String nl

SOAP_PREFIX

public static final String SOAP_PREFIX
See Also:
Constant Field Values

CATALOG_NAME

public static final String CATALOG_NAME
See Also:
Constant Field Values

DATASOURCE_NAME

public static final String DATASOURCE_NAME
See Also:
Constant Field Values

DATASOURCE_DESCRIPTION

public static final String DATASOURCE_DESCRIPTION
See Also:
Constant Field Values

DATASOURCE_INFO

public static final String DATASOURCE_INFO
See Also:
Constant Field Values

ENV

public static final Map<String,String> ENV

ROW_SET_PREFIX

public static final String ROW_SET_PREFIX
This is the prefix used in xpath and transforms for the xmla rowset namespace "urn:schemas-microsoft-com:xml-analysis:rowset".

See Also:
Constant Field Values
Method Detail

getXmlaTransform

public static String getXmlaTransform(String xmlaPrefix)
This is a parameterized XSLT. The parameters are: "soap" with values "none" or empty "content" with values "schemadata", "schema", "data" or empty With these setting one can extract from an XMLA SOAP message the soap wrapper plus body or simply the body; the complete body (schema and data), only the schema of the body, only the data of the body or none of the body


getCatalogLocator

public static CatalogLocator getCatalogLocator()

getDataSources

public static DataSourcesConfig.DataSources getDataSources(String connectString,
                                                           Map<String,String> catalogNameUrls)
                                                    throws XOMException
Throws:
XOMException

getDataSourcesText

public static String getDataSourcesText(String connectString,
                                        Map<String,String> catalogNameUrls)
With a connection string, generate the DataSource xml. Since this is used by directly, same process, communicating with XMLA Mondrian, the fact that the URL contains "localhost" is not important.

Parameters:
connectString - Connect string
catalogNameUrls - array of catalog names, catalog url pairs

getSoapFaultXPath

public static String getSoapFaultXPath()

getSoapHeaderAndBodyXPath

public static String getSoapHeaderAndBodyXPath()

getSoapBodyXPath

public static String getSoapBodyXPath()

getSoapXmlaRootXPath

public static String getSoapXmlaRootXPath(String xmlaPrefix)

getXmlaRootXPath

public static String getXmlaRootXPath(String xmlaPrefix)

extractNodesFromSoapXmla

public static Node[] extractNodesFromSoapXmla(byte[] bytes)
                                       throws SAXException,
                                              IOException
Throws:
SAXException
IOException

extractNodesFromSoapXmla

public static Node[] extractNodesFromSoapXmla(Document doc)
                                       throws SAXException,
                                              IOException
Throws:
SAXException
IOException

extractNodesFromXmla

public static Node[] extractNodesFromXmla(byte[] bytes)
                                   throws SAXException,
                                          IOException
Throws:
SAXException
IOException

extractNodesFromXmla

public static Node[] extractNodesFromXmla(Document doc)
                                   throws SAXException,
                                          IOException
Throws:
SAXException
IOException

extractFaultNodesFromSoap

public static Node[] extractFaultNodesFromSoap(byte[] bytes)
                                        throws SAXException,
                                               IOException
Throws:
SAXException
IOException

extractFaultNodesFromSoap

public static Node[] extractFaultNodesFromSoap(Document doc)
                                        throws SAXException,
                                               IOException
Throws:
SAXException
IOException

extractHeaderAndBodyFromSoap

public static Node[] extractHeaderAndBodyFromSoap(byte[] bytes)
                                           throws SAXException,
                                                  IOException
Throws:
SAXException
IOException

extractHeaderAndBodyFromSoap

public static Node[] extractHeaderAndBodyFromSoap(Document doc)
                                           throws SAXException,
                                                  IOException
Throws:
SAXException
IOException

extractBodyFromSoap

public static Document extractBodyFromSoap(Document doc)
                                    throws SAXException,
                                           IOException
Throws:
SAXException
IOException

extractNodes

public static Node[] extractNodes(Node node,
                                  String xpath,
                                  String[][] nsArray)
                           throws SAXException,
                                  IOException
Given a Document and an xpath/namespace-array pair, extract and return the Nodes resulting from applying the xpath.

Throws:
SAXException
IOException

processSoapXmla

public static byte[] processSoapXmla(File file,
                                     String connectString,
                                     Map<String,String> catalogNameUrls,
                                     String cbClassName)
                              throws IOException,
                                     ServletException,
                                     SAXException
Process the given input file as a SOAP-XMLA request.

Throws:
IOException
ServletException
SAXException

processSoapXmla

public static byte[] processSoapXmla(Document doc,
                                     String connectString,
                                     Map<String,String> catalogNameUrls,
                                     String cbClassName)
                              throws IOException,
                                     ServletException,
                                     SAXException
Throws:
IOException
ServletException
SAXException

processSoapXmla

public static byte[] processSoapXmla(String requestText,
                                     String connectString,
                                     Map<String,String> catalogNameUrls,
                                     String cbClassName)
                              throws IOException,
                                     ServletException,
                                     SAXException
Throws:
IOException
ServletException
SAXException

makeServlet

public static Servlet makeServlet(String connectString,
                                  Map<String,String> catalogNameUrls,
                                  String cbClassName)
                           throws IOException,
                                  ServletException,
                                  SAXException
Throws:
IOException
ServletException
SAXException

processSoapXmla

public static byte[] processSoapXmla(File file,
                                     Servlet servlet)
                              throws IOException,
                                     ServletException,
                                     SAXException
Throws:
IOException
ServletException
SAXException

processSoapXmla

public static byte[] processSoapXmla(Document doc,
                                     Servlet servlet)
                              throws IOException,
                                     ServletException,
                                     SAXException
Throws:
IOException
ServletException
SAXException

processSoapXmla

public static byte[] processSoapXmla(String requestText,
                                     Servlet servlet)
                              throws IOException,
                                     ServletException,
                                     SAXException
Throws:
IOException
ServletException
SAXException

validateSchemaSoapXmla

public static boolean validateSchemaSoapXmla(byte[] bytes)
                                      throws SAXException,
                                             IOException,
                                             ParserConfigurationException,
                                             TransformerException
Check is a byte array containing a SOAP-XMLA response method is valid. Schema validation occurs if the XMLA response contains both a content and schmema section. This includes both the SOAP elements and the SOAP body content, the XMLA response.

Throws:
SAXException
IOException
ParserConfigurationException
TransformerException

processXmla

public static byte[] processXmla(File file,
                                 String connectString,
                                 Map<String,String> catalogNameUrls)
                          throws IOException,
                                 SAXException,
                                 XOMException
Processes the given input file as an XMLA request (no SOAP elements).

Throws:
IOException
SAXException
XOMException

processXmla

public static byte[] processXmla(File file,
                                 String connectString,
                                 Map<String,String> catalogNameUrls,
                                 Role role)
                          throws IOException,
                                 SAXException,
                                 XOMException
Throws:
IOException
SAXException
XOMException

processXmla

public static byte[] processXmla(String requestText,
                                 String connectString,
                                 Map<String,String> catalogNameUrls)
                          throws IOException,
                                 SAXException,
                                 XOMException
Throws:
IOException
SAXException
XOMException

processXmla

public static byte[] processXmla(String requestText,
                                 String connectString,
                                 Map<String,String> catalogNameUrls,
                                 Role role)
                          throws IOException,
                                 SAXException,
                                 XOMException
Throws:
IOException
SAXException
XOMException

processXmla

public static byte[] processXmla(Document requestDoc,
                                 String connectString,
                                 Map<String,String> catalogNameUrls)
                          throws IOException,
                                 XOMException
Throws:
IOException
XOMException

processXmla

public static byte[] processXmla(Document requestDoc,
                                 String connectString,
                                 Map<String,String> catalogNameUrls,
                                 Role role)
                          throws IOException,
                                 XOMException
Throws:
IOException
XOMException

processXmla

public static byte[] processXmla(Element requestElem,
                                 String connectString,
                                 Map<String,String> catalogNameUrls)
                          throws IOException,
                                 XOMException
Throws:
IOException
XOMException

processXmla

public static byte[] processXmla(Element requestElem,
                                 String connectString,
                                 Map<String,String> catalogNameUrls,
                                 Role role)
                          throws IOException,
                                 XOMException
Throws:
IOException
XOMException

validateSchemaXmla

public static boolean validateSchemaXmla(byte[] bytes)
                                  throws SAXException,
                                         IOException,
                                         ParserConfigurationException,
                                         TransformerException
Check is a byte array containing a XMLA response method is valid. Schema validation occurs if the XMLA response contains both a content and schmema section. This should not be used when the byte array contains both the SOAP elements and content, but only for the content.

Throws:
SAXException
IOException
ParserConfigurationException
TransformerException

validateSoapXmlaUsingXpath

public static boolean validateSoapXmlaUsingXpath(byte[] bytes)
                                          throws SAXException,
                                                 IOException
This validates a SOAP-XMLA response using xpaths to extract the schema and data parts. In addition, it does a little surgery on the DOMs removing the schema nodes from the XMLA root node.

Throws:
SAXException
IOException

validateXmlaUsingXpath

public static boolean validateXmlaUsingXpath(byte[] bytes)
                                      throws SAXException,
                                             IOException
This validates a XMLA response using xpaths to extract the schema and data parts. In addition, it does a little surgery on the DOMs removing the schema nodes from the XMLA root node.

Throws:
SAXException
IOException

validateNodes

public static boolean validateNodes(Node[] nodes)
                             throws SAXException,
                                    IOException
Validate Nodes with throws an error if validation was attempted but failed, returns true if validation was successful and false if validation was not tried.

Returns:
true if validation succeeded, false if validation was not tried
Throws:
SAXException
IOException

validateEmbeddedSchema

public static boolean validateEmbeddedSchema(byte[] bytes,
                                             String schemaTransform,
                                             String dataTransform)
                                      throws SAXException,
                                             IOException,
                                             ParserConfigurationException,
                                             TransformerException,
                                             TransformerConfigurationException
See next method for JavaDoc validateEmbeddedSchema(org.w3c.dom.Document, String, String).

Throws:
SAXException
IOException
ParserConfigurationException
TransformerException
TransformerConfigurationException

validateEmbeddedSchema

public static boolean validateEmbeddedSchema(Document doc,
                                             String schemaTransform,
                                             String dataTransform)
                                      throws SAXException,
                                             IOException,
                                             ParserConfigurationException,
                                             TransformerException,
                                             TransformerConfigurationException
A given Document has both content and an embedded schema (where the schema has a single root node and the content has a single root node - they are not interwoven). A single xsl transform is provided to extract the schema part of the Document and another xsl transform is provided to extract the content part and then the content is validated against the schema.

If the content is valid, then nothing happens, but if the content is not valid an execption is thrown (currently a RuntimeException).

When Mondrian moves to Java 5 or includes the JAXP 1.3 jar, then there is a utility in JAXP that does something like this (but allows for multiple schema/content parts).

Throws:
SAXException
IOException
ParserConfigurationException
TransformerException
TransformerConfigurationException

transformSoapXmla

public static Document transformSoapXmla(Document doc,
                                         String[][] namevalueParameters,
                                         String ns)
                                  throws SAXException,
                                         IOException,
                                         ParserConfigurationException,
                                         TransformerException
Throws:
SAXException
IOException
ParserConfigurationException
TransformerException

readFile

public static String readFile(File file)
                       throws IOException
Reads a file line by line, adds a '\n' after each line and returns in a String.

Throws:
IOException

SourceForge.net_Logo