Skip to content

Commit

Permalink
Senders using message (frankframework#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanbrakel authored Mar 11, 2020
1 parent d631352 commit e12e15c
Show file tree
Hide file tree
Showing 186 changed files with 2,228 additions and 2,359 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import nl.nn.adapterframework.http.HttpResponseHandler;
import nl.nn.adapterframework.http.HttpSenderBase;
import nl.nn.adapterframework.parameters.ParameterList;
import nl.nn.adapterframework.parameters.ParameterResolutionContext;
import nl.nn.adapterframework.parameters.ParameterValueList;
import nl.nn.adapterframework.stream.Message;
import nl.nn.adapterframework.util.CredentialFactory;
import nl.nn.adapterframework.util.LogUtil;
import nl.nn.adapterframework.util.Misc;
Expand Down Expand Up @@ -153,13 +153,13 @@ private URIBuilder buildUri(String path) throws SenderException {
}

@Override
public String sendMessage(String correlationID, String path, ParameterResolutionContext prc) throws SenderException, TimeOutException {
public Message sendMessage(Message path, IPipeLineSession session) throws SenderException, TimeOutException, IOException {

//The input of this sender is the path where to send or retrieve info from.
staticUri = buildUri(path); // TODO: this is not thread safe!
staticUri = buildUri(path.asString()); // TODO: this is not thread safe!

//We don't need to send any message to the HttpSenderBase
return super.sendMessage(correlationID, "", prc);
return super.sendMessage(new Message(""), session);
}

@Override
Expand Down Expand Up @@ -240,12 +240,12 @@ else if (getMethodType().equals("POST")) {
}

@Override
public String extractResult(HttpResponseHandler responseHandler, ParameterResolutionContext prc) throws SenderException, IOException {
public String extractResult(HttpResponseHandler responseHandler, IPipeLineSession session) throws SenderException, IOException {
int statusCode = responseHandler.getStatusLine().getStatusCode();

boolean ok = false;
if (StringUtils.isNotEmpty(getResultStatusCodeSessionKey())) {
prc.getSession().put(getResultStatusCodeSessionKey(), Integer.toString(statusCode));
session.put(getResultStatusCodeSessionKey(), Integer.toString(statusCode));
ok = true;
} else {
if (statusCode==HttpServletResponse.SC_OK) {
Expand All @@ -266,7 +266,7 @@ public String extractResult(HttpResponseHandler responseHandler, ParameterResolu

XmlBuilder result = new XmlBuilder("result");

HttpServletResponse response = (HttpServletResponse) prc.getSession().get(IPipeLineSession.HTTP_RESPONSE_KEY);
HttpServletResponse response = (HttpServletResponse) session.get(IPipeLineSession.HTTP_RESPONSE_KEY);
if(response == null) {
XmlBuilder statuscode = new XmlBuilder("statuscode");
statuscode.setValue(statusCode + "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import nl.nn.adapterframework.core.TimeOutException;
import nl.nn.adapterframework.http.HttpResponseHandler;
import nl.nn.adapterframework.http.HttpSenderBase;
import nl.nn.adapterframework.parameters.ParameterResolutionContext;
import nl.nn.adapterframework.parameters.ParameterValueList;

public class CmisHttpSender extends HttpSenderBase {
Expand Down Expand Up @@ -138,7 +137,7 @@ else if (methodType.equals("DELETE")) {
}

@Override
public String extractResult(HttpResponseHandler responseHandler, ParameterResolutionContext prc) throws SenderException, IOException {
public String extractResult(HttpResponseHandler responseHandler, IPipeLineSession session) throws SenderException, IOException {
int responseCode = -1;
try {
StatusLine statusline = responseHandler.getStatusLine();
Expand All @@ -154,7 +153,7 @@ public String extractResult(HttpResponseHandler responseHandler, ParameterResolu
errorStream = responseHandler.getResponse();
}
Response response = new Response(responseCode, statusline.toString(), headerFields, responseStream, errorStream);
prc.getSession().put("response", response);
session.put("response", response);
}
catch(Exception e) {
throw new CmisConnectionException(getUrl(), responseCode, e);
Expand All @@ -174,9 +173,8 @@ public Response invoke(String method, String url, Map<String, String> headers, O
pls.put("method", method);
pls.put("headers", headers);

ParameterResolutionContext prc = new ParameterResolutionContext("", pls);
try {
sendMessage(null, null, prc);
sendMessage(null, pls);
return (Response) pls.get("response");
}
catch(Exception e) {
Expand Down
Loading

0 comments on commit e12e15c

Please sign in to comment.