Skip to content

Commit

Permalink
MONDRIAN
Browse files Browse the repository at this point in the history
       Fix Xmla so that in the datasources.xml file each DataSource
       element can have one or more catalogs. This allows Mondrian
       to work with Xmla clients that expect only a single datasource
       but one or more catalogs as well as clients that allow multiple
       datasources each of which may have one or more catalogs.
       Also, some of the Xmla "output" files had text format which caused
       junit errors.

[git-p4: depot-paths = "//open/mondrian/": change = 6652]
  • Loading branch information
Richard Emberson committed May 22, 2006
1 parent 3d1d37f commit 60c8ed0
Show file tree
Hide file tree
Showing 19 changed files with 1,117 additions and 752 deletions.
2 changes: 1 addition & 1 deletion doc/install.html
Expand Up @@ -410,7 +410,7 @@ <h3><a name="1._Describe_the_data_sources_in_datasources.xml">1. Describe the da
&nbsp;&nbsp;&nbsp;
&lt;URL&gt;http://localhost:8080/mondrian/xmla&lt;/URL&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;DataSourceInfo&gt;Provider=mondrian;
Jdbc=jdbc:postgresql://localhost/olap; Catalog=;
Jdbc=jdbc:postgresql://localhost/olap;
JdbcDrivers=org.postgresql.Driver; JdbcUser=pgsql;
JdbcPassword=pgsql&lt;/DataSourceInfo&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;Catalogs&gt;<br>
Expand Down
15 changes: 13 additions & 2 deletions src/main/mondrian/tui/CmdRunner.java
Expand Up @@ -1152,8 +1152,14 @@ else if (addToBuf) {
*/
protected void processSoapXmla(File file, int validateXmlaResponce)
throws Exception {
String catalogURL = CmdRunner.getCatalogURLProperty();
String[][] catalogNameUrls = new String[][] {
{ "CMD_RUNNER_CATALOG", catalogURL }
};
byte[] bytes = XmlaSupport.processSoapXmla(file,
getConnectString(), null);
getConnectString(),
catalogNameUrls,
null);

String response = new String(bytes);
System.out.println(response);
Expand Down Expand Up @@ -1182,8 +1188,13 @@ protected void processSoapXmla(File file, int validateXmlaResponce)
protected void processXmla(File file, int validateXmlaResponce)
throws Exception {

String catalogURL = CmdRunner.getCatalogURLProperty();
String[][] catalogNameUrls = new String[][] {
{ "CMD_RUNNER_CATALOG", catalogURL }
};
byte[] bytes = XmlaSupport.processXmla(file,
getConnectString());
getConnectString(),
catalogNameUrls);

String response = new String(bytes);
System.out.println(response);
Expand Down
82 changes: 58 additions & 24 deletions src/main/mondrian/tui/XmlaSupport.java
Expand Up @@ -257,10 +257,11 @@ public static CatalogLocator getCatalogLocator() {
return CATALOG_LOCATOR;
}
public static DataSourcesConfig.DataSources getDataSources(
String connectString)
String connectString,
String[][] catalogNameUrls)
throws XOMException {

String str = getDataSourcesText(connectString);
String str = getDataSourcesText(connectString, catalogNameUrls);
StringReader dsConfigReader = new StringReader(str);

final Parser xmlParser = XOMUtil.createDefaultParser();
Expand All @@ -279,9 +280,11 @@ public static DataSourcesConfig.DataSources getDataSources(
* important.
*
* @param connectString
* @param catalogNameUrls array of catalog names, catalog url pairs
* @return
*/
public static String getDataSourcesText(String connectString) {
public static String getDataSourcesText(String connectString,
String[][] catalogNameUrls) {
StringBuffer buf = new StringBuffer(500);
buf.append("<?xml version=\"1.0\"?>");
buf.append(nl);
Expand All @@ -303,6 +306,21 @@ public static String getDataSourcesText(String connectString) {
buf.append(connectString);
buf.append("]]></DataSourceInfo>");
buf.append(nl);
buf.append(" <Catalogs>");
buf.append(nl);
for (int i = 0; i < catalogNameUrls.length; i++) {
String[] catalogNameUrl = catalogNameUrls[i];
String name = catalogNameUrl[0];
String url = catalogNameUrl[1];
buf.append(" <Catalog name='");
buf.append(name);
buf.append("'><![CDATA[");
buf.append(url);
buf.append("]]></Catalog>");
}
buf.append(" </Catalogs>");
buf.append(nl);

buf.append(" <ProviderName>Mondrian</ProviderName>");
buf.append(nl);
buf.append(" <ProviderType>MDP</ProviderType>");
Expand Down Expand Up @@ -560,21 +578,27 @@ public static Node[] extractNodes(
* @throws SAXException
*/
public static byte[] processSoapXmla(File file,
String connectString, String cbClassName)
throws IOException, ServletException, SAXException {
String connectString,
String[][] catalogNameUrls,
String cbClassName)
throws IOException, ServletException, SAXException {

String requestText = XmlaSupport.readFile(file);
return processSoapXmla(requestText, connectString, cbClassName);
return processSoapXmla(requestText, connectString, catalogNameUrls, cbClassName);
}
public static byte[] processSoapXmla(Document doc,
String connectString, String cbClassName)
throws IOException, ServletException, SAXException {
String connectString,
String[][] catalogNameUrls,
String cbClassName)
throws IOException, ServletException, SAXException {

String requestText = XmlUtil.toString(doc, false);
return processSoapXmla(requestText, connectString, cbClassName);
return processSoapXmla(requestText, connectString, catalogNameUrls, cbClassName);
}
public static byte[] processSoapXmla(String requestText,
String connectString, String cbClassName)
String connectString,
String[][] catalogNameUrls,
String cbClassName)
throws IOException, ServletException, SAXException {

// read soap file
Expand All @@ -585,7 +609,7 @@ public static byte[] processSoapXmla(String requestText,
// Create datasource file and put datasource xml into it.
// Mark it as delete on exit.
String dataSourceText =
XmlaSupport.getDataSourcesText(connectString);
XmlaSupport.getDataSourcesText(connectString, catalogNameUrls);

dsFile = File.createTempFile("datasources.xml", null);

Expand Down Expand Up @@ -625,13 +649,15 @@ public static byte[] processSoapXmla(String requestText,
}
}

public static Servlet makeServlet(String connectString, String cbClassName)
public static Servlet makeServlet(String connectString,
String[][] catalogNameUrls,
String cbClassName)
throws IOException, ServletException, SAXException {

// Create datasource file and put datasource xml into it.
// Mark it as delete on exit.
String dataSourceText =
XmlaSupport.getDataSourcesText(connectString);
XmlaSupport.getDataSourcesText(connectString, catalogNameUrls);

File dsFile = File.createTempFile("datasources.xml", null);

Expand Down Expand Up @@ -729,30 +755,38 @@ public static boolean validateSchemaSoapXmla(byte[] bytes)
* @throws IOException
* @throws XOMException
*/
public static byte[] processXmla(File file, String connectString)
public static byte[] processXmla(File file,
String connectString,
String[][] catalogNameUrls)
throws IOException, SAXException, XOMException {

String requestText = XmlaSupport.readFile(file);
return processXmla(requestText, connectString);
return processXmla(requestText, connectString, catalogNameUrls);
}
public static byte[] processXmla(String requestText, String connectString)
throws IOException, SAXException, XOMException {
public static byte[] processXmla(String requestText,
String connectString,
String[][] catalogNameUrls)
throws IOException, SAXException, XOMException {

Document requestDoc = XmlUtil.parseString(requestText);
return processXmla(requestDoc, connectString);
return processXmla(requestDoc, connectString, catalogNameUrls);
}
public static byte[] processXmla(Document requestDoc, String connectString)
throws IOException, XOMException {
public static byte[] processXmla(Document requestDoc,
String connectString,
String[][] catalogNameUrls)
throws IOException, XOMException {

Element requestElem = requestDoc.getDocumentElement();
return processXmla(requestElem, connectString);
return processXmla(requestElem, connectString, catalogNameUrls);
}
public static byte[] processXmla(Element requestElem, String connectString)
throws IOException, XOMException {
public static byte[] processXmla(Element requestElem,
String connectString,
String[][] catalogNameUrls)
throws IOException, XOMException {
// make request
CatalogLocator cl = getCatalogLocator();
DataSourcesConfig.DataSources dataSources =
getDataSources(connectString);
getDataSources(connectString, catalogNameUrls);
XmlaHandler handler = new XmlaHandler(dataSources, cl);
XmlaRequest request = new DefaultXmlaRequest(requestElem, null);

Expand Down
145 changes: 86 additions & 59 deletions src/main/mondrian/xmla/DataSourcesConfig.xml
Expand Up @@ -22,7 +22,7 @@ This is the XML model for XMLA DataSources Configuration.
Revision is $Id$
</Doc>

<!-- DataSources ====================================================== -->
<Element type="DataSources">
<Doc>
Expand All @@ -35,92 +35,119 @@ Revision is $Id$
</Array>
</Element>

<!-- DataSource ============================================================ -->
<!-- DataSource ======================================================= -->
<Element type="DataSource">
<Doc>
Definition of a data source.
</Doc>
<Object name="name" type="DataSourceName" required="true">
<Doc>
Name.
Name.
</Doc>
</Object>
<Object name="description" type="DataSourceDescription" required="true">
<Object name="description" type="DataSourceDescription" required="true">
<Doc>
Description.
Description.
</Doc>
</Object>
<Object name="url" type="URL" required="true">
<Object name="url" type="URL" required="true">
<Doc>
URL of Web Services invocation.
URL of Web Services invocation.
</Doc>
</Object>
<Object name="dataSourceInfo" type="DataSourceInfo" required="true">
<Object name="dataSourceInfo" type="DataSourceInfo" required="true">
<Doc>
ConnectString of Mondrian.
ConnectString of Mondrian (minus the catalog entry).
</Doc>
</Object>
<Object name="providerName" type="ProviderName" required="true">
<Object name="catalogs" type="Catalogs" required="true">
<Doc>
Customized Service Provider Name.
One or more Catalogs.
</Doc>
</Object>
<Object name="providerType" type="ProviderType" required="true">
<Object name="providerName" type="ProviderName" required="true">
<Doc>
Ignored. Only return &quot;MDP&quot; for DISCOVER_DATASOURCES.
Customized Service Provider Name.
</Doc>
</Object>
<Object name="authenticationMode" type="AuthenticationMode" required="true">
<Object name="providerType" type="ProviderType" required="true">
<Doc>
Ignored. Only return &quot;Unauthenticated&quot; for DISCOVER_DATASOURCES.
Ignored. Only return &quot;MDP&quot; for DISCOVER_DATASOURCES.
</Doc>
</Object>
<Code><![CDATA[
public static final String PROVIDER_TYPE_TDP = "TDP";
public static final String PROVIDER_TYPE_MDP = "MDP";
public static final String PROVIDER_TYPE_DMP = "DMP";
public static final String AUTH_MODE_UNAUTHENTICATED = "Unauthenticated";
public static final String AUTH_MODE_AUTHENTICATED = "Authenticated";
public static final String AUTH_MODE_INTEGRATED = "Integrated";
public String getDataSourceName() {
return name;
}
public String getDataSourceDescription() {
return description;
}
public String getURL() {
return url;
}
public String getDataSourceInfo() {
return dataSourceInfo;
}
public String getProviderName() {
return providerName;
}
public String[] getProviderType() {
return new String[] {PROVIDER_TYPE_MDP};
}
public String getAuthenticationMode() {
return authenticationMode;
}
]]>
</Code>
<Object name="authenticationMode" type="AuthenticationMode" required="true">
<Doc>
Ignored. Only return &quot;Unauthenticated&quot; for DISCOVER_DATASOURCES.
</Doc>
</Object>
<Code><![CDATA[
public static final String PROVIDER_TYPE_TDP = "TDP";
public static final String PROVIDER_TYPE_MDP = "MDP";
public static final String PROVIDER_TYPE_DMP = "DMP";
public static final String AUTH_MODE_UNAUTHENTICATED = "Unauthenticated";
public static final String AUTH_MODE_AUTHENTICATED = "Authenticated";
public static final String AUTH_MODE_INTEGRATED = "Integrated";
public String getDataSourceName() {
return name;
}
public String getDataSourceDescription() {
return description;
}
public String getURL() {
return url;
}
public String getDataSourceInfo() {
return dataSourceInfo;
}
public String getProviderName() {
return providerName;
}
public String[] getProviderType() {
return new String[] {PROVIDER_TYPE_MDP};
}
public String getAuthenticationMode() {
return authenticationMode;
}
]]>
</Code>
</Element>

<StringElement type="DataSourceName"/>
<StringElement type="DataSourceDescription"/>
<StringElement type="URL"/>
<StringElement type="DataSourceInfo"/>
<StringElement type="ProviderName"/>
<StringElement type="ProviderType"/>
<StringElement type="AuthenticationMode"/>

<!-- Catalogs ========================================================= -->
<Element type="Catalogs">
<Doc>
<p>The list of catalogs associated with a data source.</p>
</Doc>
<Array name="catalogs" type="Catalog" required="true">
<Doc>
The list of catalogs.
</Doc>
</Array>
</Element>

<StringElement type="DataSourceName"/>
<StringElement type="DataSourceDescription"/>
<StringElement type="URL"/>
<StringElement type="DataSourceInfo"/>
<StringElement type="ProviderName"/>
<StringElement type="ProviderType"/>
<StringElement type="AuthenticationMode"/>
<!-- Catalog ========================================================== -->
<Element type="Catalog">
<Attribute name="name" required="true">
<Doc>
Name of the catalog.
</Doc>
</Attribute>
<CData/>
</Element>

</Model>

Expand Down

0 comments on commit 60c8ed0

Please sign in to comment.