Browse Source

Remove quotes if needed

pull/7858/head
Andrii Landiak 4 years ago
parent
commit
7e346894fb
  1. 15
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/rest/TbHttpClient.java
  2. 2
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/rest/TbRestApiCallNodeConfiguration.java

15
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/rest/TbHttpClient.java

@ -35,7 +35,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory;
import org.springframework.http.client.Netty4ClientHttpRequestFactory;
import org.thingsboard.server.common.data.StringUtils;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.client.AsyncRestTemplate;
@ -49,6 +48,7 @@ import org.thingsboard.rule.engine.api.util.TbNodeUtils;
import org.thingsboard.rule.engine.credentials.BasicCredentials;
import org.thingsboard.rule.engine.credentials.ClientCredentials;
import org.thingsboard.rule.engine.credentials.CredentialsType;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.msg.TbMsg;
import org.thingsboard.server.common.msg.TbMsgMetaData;
@ -192,7 +192,11 @@ public class TbHttpClient {
config.isIgnoreRequestBody()) {
entity = new HttpEntity<>(headers);
} else {
entity = new HttpEntity<>(msg.getData(), headers);
String data = msg.getData();
if (config.isTrimDoubleQuotes()) {
data = trimDoubleQuotes(data);
}
entity = new HttpEntity<>(data, headers);
}
URI uri = buildEncodedUri(endpointUrl);
@ -334,4 +338,11 @@ public class TbHttpClient {
}
}
private static String trimDoubleQuotes(String s) {
if (s.startsWith("\"") && s.endsWith("\"")) {
return s.substring(1, s.length() - 1);
}
return s;
}
}

2
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/rest/TbRestApiCallNodeConfiguration.java

@ -38,6 +38,7 @@ public class TbRestApiCallNodeConfiguration implements NodeConfiguration<TbRestA
private int maxParallelRequestsCount;
private boolean useRedisQueueForMsgPersistence;
private boolean trimQueue;
private boolean trimDoubleQuotes;
private int maxQueueSize;
private boolean enableProxy;
private boolean useSystemProxyProperties;
@ -60,6 +61,7 @@ public class TbRestApiCallNodeConfiguration implements NodeConfiguration<TbRestA
configuration.setMaxParallelRequestsCount(0);
configuration.setUseRedisQueueForMsgPersistence(false);
configuration.setTrimQueue(false);
configuration.setTrimDoubleQuotes(false);
configuration.setEnableProxy(false);
configuration.setCredentials(new AnonymousCredentials());
configuration.setIgnoreRequestBody(false);

Loading…
Cancel
Save