in taverna-scufl2-t2flow/src/main/java/org/apache/taverna/scufl2/translator/t2flow/t23activities/RESTActivityParser.java [82:157]
public Configuration parseConfiguration(T2FlowParser t2FlowParser,
ConfigBean configBean, ParserState parserState)
throws ReaderException {
RESTConfig restConfig = unmarshallConfig(t2FlowParser, configBean,
"xstream", RESTConfig.class);
Configuration configuration = new Configuration();
configuration.setParent(parserState.getCurrentProfile());
parserState.setCurrentConfiguration(configuration);
try {
ObjectNode json = (ObjectNode)configuration.getJson();
configuration.setType(ACTIVITY_URI.resolve("#Config"));
ObjectNode request = json.objectNode();
json.put("request", request);
String method = restConfig.getHttpMethod().toUpperCase();
request.put("httpMethod", method);
request.put("absoluteURITemplate", restConfig.getUrlSignature());
ArrayNode headers = json.arrayNode();
request.put("headers", headers);
if (restConfig.getAcceptsHeaderValue() != null && ! restConfig.getAcceptsHeaderValue().isEmpty()) {
ObjectNode accept = json.objectNode();
headers.add(accept);
accept.put("header", "Accept");
accept.put("value", restConfig.getAcceptsHeaderValue());
}
if (hasContent(method)) {
if (restConfig.getContentTypeForUpdates() != null && ! restConfig.getContentTypeForUpdates().isEmpty()) {
ObjectNode accept = json.objectNode();
headers.add(accept);
accept.put("header", "Content-Type");
accept.put("value", restConfig.getContentTypeForUpdates());
}
if (restConfig.isSendHTTPExpectRequestHeader()) {
ObjectNode accept = json.objectNode();
headers.add(accept);
accept.put("header", "Expect");
accept.put("value", "100-Continue");
}
}
if (restConfig.getOtherHTTPHeaders() != null
&& restConfig.getOtherHTTPHeaders().getList() != null)
for (HTTPHeaders.List list : restConfig.getOtherHTTPHeaders()
.getList()) {
String fieldName = list.getContent().get(0).getValue();
String fieldValue = list.getContent().get(1).getValue();
ObjectNode accept = json.objectNode();
headers.add(accept);
accept.put("header", fieldName);
accept.put("value", fieldValue);
}
if (restConfig.isShowActualUrlPort() != null)
json.put("showActualURLPort", restConfig.isShowActualUrlPort()
.booleanValue());
if (restConfig.isShowResponseHeadersPort() != null)
json.put("showResponseHeadersPort", restConfig
.isShowResponseHeadersPort().booleanValue());
if (restConfig.isShowRedirectionOutputPort())
json.put("showRedirectionOutputPort", true);
if (restConfig.isEscapeParameters() != null
&& !restConfig.isEscapeParameters())
json.put("escapeParameters", false);
if (restConfig.getOutgoingDataFormat() != null)
json.put("outgoingDataFormat",
restConfig.getOutgoingDataFormat());
return configuration;
} finally {
parserState.setCurrentConfiguration(null);
}
}