Merge branch 'master' of github.com:thingsboard/thingsboard
This commit is contained in:
commit
f90e483d57
@ -37,7 +37,7 @@ public class RabbitMqPluginAction extends AbstractTemplatePluginAction<RabbitMqP
|
|||||||
builder.sync(configuration.isSync());
|
builder.sync(configuration.isSync());
|
||||||
builder.exchange(configuration.getExchange());
|
builder.exchange(configuration.getExchange());
|
||||||
builder.queueName(configuration.getQueueName());
|
builder.queueName(configuration.getQueueName());
|
||||||
builder.messageProperties(configuration.getMessageProperties()[0]);
|
builder.messageProperties(configuration.getMessageProperties());
|
||||||
builder.msgType(payload.getMsgType());
|
builder.msgType(payload.getMsgType());
|
||||||
builder.requestId(payload.getRequestId());
|
builder.requestId(payload.getRequestId());
|
||||||
builder.payload(getMsgBody(ctx, msg));
|
builder.payload(getMsgBody(ctx, msg));
|
||||||
|
|||||||
@ -27,6 +27,6 @@ public class RabbitMqPluginActionConfiguration implements TemplateActionConfigur
|
|||||||
private boolean sync;
|
private boolean sync;
|
||||||
private String exchange;
|
private String exchange;
|
||||||
private String queueName;
|
private String queueName;
|
||||||
private String[] messageProperties;
|
private String messageProperties;
|
||||||
private String template;
|
private String template;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,35 +18,7 @@
|
|||||||
},
|
},
|
||||||
"messageProperties": {
|
"messageProperties": {
|
||||||
"title": "Message properties",
|
"title": "Message properties",
|
||||||
"type": "array",
|
"type": "string"
|
||||||
"minItems" : 1,
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"value": "BASIC",
|
|
||||||
"label": "BASIC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "MINIMAL_BASIC",
|
|
||||||
"label": "MINIMAL_BASIC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "MINIMAL_PERSISTENT_BASIC",
|
|
||||||
"label": "MINIMAL_PERSISTENT_BASIC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "PERSISTENT_BASIC",
|
|
||||||
"label": "PERSISTENT_BASIC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "PERSISTENT_TEXT_PLAIN",
|
|
||||||
"label": "PERSISTENT_TEXT_PLAIN"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "TEXT_PLAIN",
|
|
||||||
"label": "TEXT_PLAIN"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"uniqueItems": true
|
|
||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
"title": "Body Template",
|
"title": "Body Template",
|
||||||
@ -67,8 +39,35 @@
|
|||||||
{
|
{
|
||||||
"key": "messageProperties",
|
"key": "messageProperties",
|
||||||
"type": "rc-select",
|
"type": "rc-select",
|
||||||
"multiple": false
|
"multiple": false,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"value": "BASIC",
|
||||||
|
"label": "BASIC"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "MINIMAL_BASIC",
|
||||||
|
"label": "MINIMAL_BASIC"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "MINIMAL_PERSISTENT_BASIC",
|
||||||
|
"label": "MINIMAL_PERSISTENT_BASIC"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "PERSISTENT_BASIC",
|
||||||
|
"label": "PERSISTENT_BASIC"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "PERSISTENT_TEXT_PLAIN",
|
||||||
|
"label": "PERSISTENT_TEXT_PLAIN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "TEXT_PLAIN",
|
||||||
|
"label": "TEXT_PLAIN"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"key": "template",
|
"key": "template",
|
||||||
"type": "textarea",
|
"type": "textarea",
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* @author Andrew Shvayka
|
* @author Andrew Shvayka
|
||||||
*/
|
*/
|
||||||
public class DemoClient {
|
public class RabbitMqDemoClient {
|
||||||
|
|
||||||
private static final String HOST = "localhost";
|
private static final String HOST = "localhost";
|
||||||
private static final String USERNAME = "guest";
|
private static final String USERNAME = "guest";
|
||||||
@ -16,23 +16,14 @@
|
|||||||
package org.thingsboard.server.extensions.rest.action;
|
package org.thingsboard.server.extensions.rest.action;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.velocity.Template;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
import org.apache.velocity.runtime.parser.ParseException;
|
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.thingsboard.server.common.msg.device.ToDeviceActorMsg;
|
import org.thingsboard.server.common.msg.device.ToDeviceActorMsg;
|
||||||
import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg;
|
import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg;
|
||||||
import org.thingsboard.server.common.msg.session.ToDeviceMsg;
|
|
||||||
import org.thingsboard.server.extensions.api.component.Action;
|
import org.thingsboard.server.extensions.api.component.Action;
|
||||||
import org.thingsboard.server.extensions.api.plugins.PluginAction;
|
|
||||||
import org.thingsboard.server.extensions.api.plugins.msg.PluginToRuleMsg;
|
|
||||||
import org.thingsboard.server.extensions.api.plugins.msg.ResponsePluginToRuleMsg;
|
|
||||||
import org.thingsboard.server.extensions.api.plugins.msg.RuleToPluginMsg;
|
import org.thingsboard.server.extensions.api.plugins.msg.RuleToPluginMsg;
|
||||||
import org.thingsboard.server.extensions.api.rules.RuleContext;
|
import org.thingsboard.server.extensions.api.rules.RuleContext;
|
||||||
import org.thingsboard.server.extensions.api.rules.RuleProcessingMetaData;
|
|
||||||
import org.thingsboard.server.extensions.core.action.template.AbstractTemplatePluginAction;
|
import org.thingsboard.server.extensions.core.action.template.AbstractTemplatePluginAction;
|
||||||
import org.thingsboard.server.extensions.core.utils.VelocityUtils;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -48,7 +39,7 @@ public class RestApiCallPluginAction extends AbstractTemplatePluginAction<RestAp
|
|||||||
builder.requestId(payload.getRequestId());
|
builder.requestId(payload.getRequestId());
|
||||||
builder.sync(configuration.isSync());
|
builder.sync(configuration.isSync());
|
||||||
builder.actionPath(configuration.getActionPath());
|
builder.actionPath(configuration.getActionPath());
|
||||||
builder.httpMethod(HttpMethod.valueOf(configuration.getRequestMethod()[0]));
|
builder.httpMethod(HttpMethod.valueOf(configuration.getRequestMethod()));
|
||||||
builder.expectedResultCode(HttpStatus.valueOf(configuration.getExpectedResultCode()));
|
builder.expectedResultCode(HttpStatus.valueOf(configuration.getExpectedResultCode()));
|
||||||
builder.msgBody(getMsgBody(ctx, msg));
|
builder.msgBody(getMsgBody(ctx, msg));
|
||||||
return Optional.of(new RestApiCallActionMsg(msg.getTenantId(),
|
return Optional.of(new RestApiCallActionMsg(msg.getTenantId(),
|
||||||
|
|||||||
@ -24,5 +24,5 @@ public class RestApiCallPluginActionConfiguration implements TemplateActionConfi
|
|||||||
private String template;
|
private String template;
|
||||||
private String actionPath;
|
private String actionPath;
|
||||||
private int expectedResultCode;
|
private int expectedResultCode;
|
||||||
private String[] requestMethod;
|
private String requestMethod;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class RestApiCallPlugin extends AbstractPlugin<RestApiCallPluginConfigura
|
|||||||
configuration.getPort(),
|
configuration.getPort(),
|
||||||
configuration.getBasePath());
|
configuration.getBasePath());
|
||||||
|
|
||||||
if (configuration.getAuthMethod()[0].equals(BASIC_AUTH_METHOD)) {
|
if (configuration.getAuthMethod().equals(BASIC_AUTH_METHOD)) {
|
||||||
String userName = configuration.getUserName();
|
String userName = configuration.getUserName();
|
||||||
String password = configuration.getPassword();
|
String password = configuration.getPassword();
|
||||||
String credentials = String.format(CREDENTIALS_TEMPLATE, userName, password);
|
String credentials = String.format(CREDENTIALS_TEMPLATE, userName, password);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public class RestApiCallPluginConfiguration {
|
|||||||
private int port;
|
private int port;
|
||||||
private String basePath;
|
private String basePath;
|
||||||
|
|
||||||
private String[] authMethod;
|
private String authMethod;
|
||||||
|
|
||||||
private String userName;
|
private String userName;
|
||||||
private String password;
|
private String password;
|
||||||
|
|||||||
@ -18,19 +18,7 @@
|
|||||||
},
|
},
|
||||||
"requestMethod": {
|
"requestMethod": {
|
||||||
"title": "Request method",
|
"title": "Request method",
|
||||||
"type": "array",
|
"type": "string"
|
||||||
"minItems" : 1,
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"value": "POST",
|
|
||||||
"label": "POST"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "PUT",
|
|
||||||
"label": "PUT"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"uniqueItems": true
|
|
||||||
},
|
},
|
||||||
"expectedResultCode": {
|
"expectedResultCode": {
|
||||||
"title": "Expected Result Code",
|
"title": "Expected Result Code",
|
||||||
@ -56,7 +44,17 @@
|
|||||||
{
|
{
|
||||||
"key": "requestMethod",
|
"key": "requestMethod",
|
||||||
"type": "rc-select",
|
"type": "rc-select",
|
||||||
"multiple": false
|
"multiple": false,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"value": "POST",
|
||||||
|
"label": "POST"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "PUT",
|
||||||
|
"label": "PUT"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"expectedResultCode"
|
"expectedResultCode"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -21,19 +21,7 @@
|
|||||||
},
|
},
|
||||||
"authMethod": {
|
"authMethod": {
|
||||||
"title": "Authentication method",
|
"title": "Authentication method",
|
||||||
"type": "array",
|
"type": "string"
|
||||||
"minItems" : 1,
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"value": "NO_AUTH",
|
|
||||||
"label": "No authentication"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "BASIC_AUTH",
|
|
||||||
"label": "Basic authentication"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"uniqueItems": true
|
|
||||||
},
|
},
|
||||||
"userName": {
|
"userName": {
|
||||||
"title": "Username",
|
"title": "Username",
|
||||||
@ -58,7 +46,17 @@
|
|||||||
{
|
{
|
||||||
"key": "authMethod",
|
"key": "authMethod",
|
||||||
"type": "rc-select",
|
"type": "rc-select",
|
||||||
"multiple": false
|
"multiple": false,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"value": "NO_AUTH",
|
||||||
|
"label": "No authentication"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "BASIC_AUTH",
|
||||||
|
"label": "Basic authentication"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"userName",
|
"userName",
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user