Author: shawkins
Date: 2010-05-18 13:06:12 -0400 (Tue, 18 May 2010)
New Revision: 2139
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLProcedureExecution.java
Log:
TEIID-1077: adding the connector-ws module, ensuring that logging is conditional for
debug, and removing the wrapping used in the rpc style invocation - this means that RPC
modeled procedures are no longer valid. The user must pass a document as the parameter to
the procedure call.
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java 2010-05-18
16:05:10 UTC (rev 2138)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java 2010-05-18
17:06:12 UTC (rev 2139)
@@ -127,14 +127,13 @@
return null;
}
- private List<String> getXPaths() {
+ private List<String> getXPaths() throws TranslatorException {
XPathSplitter splitter = new XPathSplitter();
try {
return splitter.split(this.executionInfo.getTableXPath());
} catch (InvalidPathException e) {
- e.printStackTrace();
+ throw new TranslatorException(e);
}
- return null;
}
private Document getDocumentStream(final File xmlFile, int fileNumber) {
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java 2010-05-18
16:05:10 UTC (rev 2138)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java 2010-05-18
17:06:12 UTC (rev 2139)
@@ -37,6 +37,9 @@
import org.teiid.language.Call;
import org.teiid.language.QueryExpression;
import org.teiid.language.Select;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
@@ -95,7 +98,7 @@
@TranslatorProperty(description="Log the XML request/response documents",
display="Log Request/Response Documents")
public boolean isLogRequestResponseDocs() {
- return logRequestResponseDocs;
+ return logRequestResponseDocs &&
LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL);
}
public void setLogRequestResponseDocs(Boolean logRequestResponseDocs) {
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLProcedureExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLProcedureExecution.java 2010-05-18
16:05:10 UTC (rev 2138)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLProcedureExecution.java 2010-05-18
17:06:12 UTC (rev 2139)
@@ -23,6 +23,7 @@
package org.teiid.translator.xml;
import java.io.StringReader;
+import java.sql.Clob;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.Arrays;
@@ -34,7 +35,6 @@
import org.teiid.language.Argument;
import org.teiid.language.Call;
-import org.teiid.language.Argument.Direction;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.AbstractMetadataRecord;
@@ -43,7 +43,6 @@
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.streaming.BaseStreamingExecution;
/**
* A soap call executor - handles all styles doc/literal, rpc/encoded etc.
@@ -61,7 +60,7 @@
/**
* @param env
*/
- public XMLProcedureExecution(Call procedure, RuntimeMetadata metadata,
ExecutionContext context, XMLExecutionFactory executionFactory, Dispatch dispatch) {
+ public XMLProcedureExecution(Call procedure, RuntimeMetadata metadata,
ExecutionContext context, XMLExecutionFactory executionFactory, Dispatch<Source>
dispatch) {
this.metadata = metadata;
this.context = context;
this.procedure = procedure;
@@ -81,7 +80,12 @@
}
// execute the request
- Source result = this.dispatch.invoke(buildRequest(procedureName,
procedure.getArguments()));
+ Source result;
+ try {
+ result = this.dispatch.invoke(buildRequest(procedure.getArguments()));
+ } catch (SQLException e1) {
+ throw new TranslatorException(e1);
+ }
this.returnValue = this.executionFactory.convertToXMLType(result);
if (executionFactory.isLogRequestResponseDocs()) {
try {
@@ -92,27 +96,24 @@
}
- Source buildRequest(String procedureName, List<Argument> args){
- StringBuilder sb = new StringBuilder();
- sb.append("<tns1:").append(procedureName);
- sb.append("
xmlns:tns1=\"").append(BaseStreamingExecution.DUMMY_NS_NAME).append("\">");
-
- for (Argument argument:args) {
- if (argument.getDirection() == Direction.IN ) {
- sb.append(argument.getArgumentValue().getValue());
- }
- else if (argument.getDirection() == Direction.INOUT) {
- sb.append(argument.getArgumentValue().getValue());
- }
+ Source buildRequest(List<Argument> args) throws SQLException,
TranslatorException{
+ if (args.size() != 1) {
+ throw new TranslatorException("Expected a single argument to the procedure
execution"); //$NON-NLS-1$
}
-
- sb.append("</tns1:").append(procedureName).append(">");
-
- return new StreamSource(new StringReader(sb.toString()));
+ Argument arg = args.get(0);
+ Object value = arg.getArgumentValue().getValue();
+ if (value instanceof SQLXML) {
+ return new StreamSource(((SQLXML)value).getCharacterStream());
+ } else if (value instanceof Clob) {
+ return new StreamSource(((Clob)value).getCharacterStream());
+ } else if (value != null) {
+ return new StreamSource(new StringReader(value.toString()));
+ } else {
+ //TODO: work around for JBoss native
+ return new StreamSource(new StringReader("<none/>"));
//$NON-NLS-1$
+ }
}
-
-
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
if (!returnedResult) {
Show replies by date