Commit c89c1fd4585034a5ef1f217830046be7868e65ae

Authored by Andrew Shvayka
Committed by GitHub
2 parents 8be682d1 4a61616b

Merge pull request #1227 from ShvaykaD/master

Modify TbRestApiCallNode
@@ -118,16 +118,16 @@ public class TbRestApiCallNode implements TbNode { @@ -118,16 +118,16 @@ public class TbRestApiCallNode implements TbNode {
118 } 118 }
119 119
120 private TbMsg processResponse(TbContext ctx, TbMsg origMsg, ResponseEntity<String> response) { 120 private TbMsg processResponse(TbContext ctx, TbMsg origMsg, ResponseEntity<String> response) {
121 - TbMsgMetaData metaData = new TbMsgMetaData(); 121 + TbMsgMetaData metaData = origMsg.getMetaData();
122 metaData.putValue(STATUS, response.getStatusCode().name()); 122 metaData.putValue(STATUS, response.getStatusCode().name());
123 metaData.putValue(STATUS_CODE, response.getStatusCode().value()+""); 123 metaData.putValue(STATUS_CODE, response.getStatusCode().value()+"");
124 metaData.putValue(STATUS_REASON, response.getStatusCode().getReasonPhrase()); 124 metaData.putValue(STATUS_REASON, response.getStatusCode().getReasonPhrase());
125 - response.getHeaders().toSingleValueMap().forEach((k,v) -> metaData.putValue(k,v) ); 125 + response.getHeaders().toSingleValueMap().forEach(metaData::putValue);
126 return ctx.transformMsg(origMsg, origMsg.getType(), origMsg.getOriginator(), metaData, response.getBody()); 126 return ctx.transformMsg(origMsg, origMsg.getType(), origMsg.getOriginator(), metaData, response.getBody());
127 } 127 }
128 128
129 private TbMsg processFailureResponse(TbContext ctx, TbMsg origMsg, ResponseEntity<String> response) { 129 private TbMsg processFailureResponse(TbContext ctx, TbMsg origMsg, ResponseEntity<String> response) {
130 - TbMsgMetaData metaData = origMsg.getMetaData().copy(); 130 + TbMsgMetaData metaData = origMsg.getMetaData();
131 metaData.putValue(STATUS, response.getStatusCode().name()); 131 metaData.putValue(STATUS, response.getStatusCode().name());
132 metaData.putValue(STATUS_CODE, response.getStatusCode().value()+""); 132 metaData.putValue(STATUS_CODE, response.getStatusCode().value()+"");
133 metaData.putValue(STATUS_REASON, response.getStatusCode().getReasonPhrase()); 133 metaData.putValue(STATUS_REASON, response.getStatusCode().getReasonPhrase());
@@ -136,7 +136,7 @@ public class TbRestApiCallNode implements TbNode { @@ -136,7 +136,7 @@ public class TbRestApiCallNode implements TbNode {
136 } 136 }
137 137
138 private TbMsg processException(TbContext ctx, TbMsg origMsg, Throwable e) { 138 private TbMsg processException(TbContext ctx, TbMsg origMsg, Throwable e) {
139 - TbMsgMetaData metaData = origMsg.getMetaData().copy(); 139 + TbMsgMetaData metaData = origMsg.getMetaData();
140 metaData.putValue(ERROR, e.getClass() + ": " + e.getMessage()); 140 metaData.putValue(ERROR, e.getClass() + ": " + e.getMessage());
141 if (e instanceof HttpClientErrorException) { 141 if (e instanceof HttpClientErrorException) {
142 HttpClientErrorException httpClientErrorException = (HttpClientErrorException)e; 142 HttpClientErrorException httpClientErrorException = (HttpClientErrorException)e;