Skip to content

Commit

Permalink
Merge pull request #93 from rareddy/TEIID-2537
Browse files Browse the repository at this point in the history
TEIID-2537: reverting the earlier change, and correcting the logic in od...
  • Loading branch information
rareddy committed Jul 22, 2013
2 parents f09fccb + bf4d318 commit f274ac8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
package org.teiid.translator.odata;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
Expand All @@ -33,6 +35,7 @@
import java.util.List;
import java.util.Map;

import javax.activation.DataSource;
import javax.ws.rs.core.Response.Status;

import org.odata4j.core.ODataConstants;
Expand All @@ -53,6 +56,8 @@
import org.odata4j.stax2.XMLEvent2;
import org.odata4j.stax2.XMLEventReader2;
import org.odata4j.stax2.util.StaxUtil;
import org.teiid.core.types.BlobImpl;
import org.teiid.core.types.InputStreamFactory;
import org.teiid.language.Argument;
import org.teiid.language.Argument.Direction;
import org.teiid.language.Call;
Expand Down Expand Up @@ -206,7 +211,22 @@ protected BinaryWSProcedureExecution executeDirect(String method, String uri, St

Call call = this.translator.getLanguageFactory().createCall(ODataExecutionFactory.INVOKE_HTTP, parameters, null);

BinaryWSProcedureExecution execution = new BinaryWSProcedureExecution(call, this.metadata, this.executionContext, null, this.connection);
BinaryWSProcedureExecution execution = new BinaryWSProcedureExecution(call, this.metadata, this.executionContext, null, this.connection) {
@Override
public List<?> getOutputParameterValues() throws TranslatorException {
ArrayList params = new ArrayList(super.getOutputParameterValues());
final DataSource httpOut = (DataSource)params.get(0);
BlobImpl out = new BlobImpl(new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return httpOut.getInputStream();
}
}) ;
params.remove(0);
params.add(0, out);
return params;
}
};
execution.setUseResponseContext(true);
execution.setAlwaysAllowPayloads(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public List<?> next() throws TranslatorException, DataNotAvailableException {
@Override
public List<?> getOutputParameterValues() throws TranslatorException {
Object result = this.returnValue;
if (this.returnValue != null && this.procedure.getArguments().size() > 3 && Boolean.TRUE.equals(this.procedure.getArguments().get(3).getArgumentValue().getValue())) {
if (this.returnValue != null && this.procedure.getArguments().size() > 4 && Boolean.TRUE.equals(this.procedure.getArguments().get(3).getArgumentValue().getValue())) {
try {
result = new BlobType(new StreamingBlob(this.returnValue.getInputStream()));
} catch (IOException e) {
Expand Down

0 comments on commit f274ac8

Please sign in to comment.