Showing
4 changed files
with
22 additions
and
3 deletions
@@ -565,6 +565,7 @@ public abstract class BaseController { | @@ -565,6 +565,7 @@ public abstract class BaseController { | ||
565 | } | 565 | } |
566 | if (e == null) { | 566 | if (e == null) { |
567 | pushEntityActionToRuleEngine(entityId, entity, user, customerId, actionType, additionalInfo); | 567 | pushEntityActionToRuleEngine(entityId, entity, user, customerId, actionType, additionalInfo); |
568 | + // TODO: voba - refactor to push events to edge queue directly, instead of the rule engine flow | ||
568 | } | 569 | } |
569 | auditLogService.logEntityAction(user.getTenantId(), customerId, user.getId(), user.getName(), entityId, entity, actionType, e, additionalInfo); | 570 | auditLogService.logEntityAction(user.getTenantId(), customerId, user.getId(), user.getName(), entityId, entity, actionType, e, additionalInfo); |
570 | } | 571 | } |
@@ -611,6 +612,10 @@ public abstract class BaseController { | @@ -611,6 +612,10 @@ public abstract class BaseController { | ||
611 | case UNASSIGNED_FROM_EDGE: | 612 | case UNASSIGNED_FROM_EDGE: |
612 | msgType = DataConstants.ENTITY_UNASSIGNED_FROM_EDGE; | 613 | msgType = DataConstants.ENTITY_UNASSIGNED_FROM_EDGE; |
613 | break; | 614 | break; |
615 | + case CREDENTIALS_UPDATED: | ||
616 | + //TODO: voba - this is not efficient way to do this. Refactor on later stages | ||
617 | + msgType = DataConstants.ENTITY_UPDATED; | ||
618 | + break; | ||
614 | } | 619 | } |
615 | if (!StringUtils.isEmpty(msgType)) { | 620 | if (!StringUtils.isEmpty(msgType)) { |
616 | try { | 621 | try { |
@@ -16,8 +16,11 @@ | @@ -16,8 +16,11 @@ | ||
16 | package org.thingsboard.server.service.edge.rpc.constructor; | 16 | package org.thingsboard.server.service.edge.rpc.constructor; |
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | +import org.springframework.beans.factory.annotation.Autowired; | ||
19 | import org.springframework.stereotype.Component; | 20 | import org.springframework.stereotype.Component; |
20 | import org.thingsboard.server.common.data.Device; | 21 | import org.thingsboard.server.common.data.Device; |
22 | +import org.thingsboard.server.common.data.security.DeviceCredentials; | ||
23 | +import org.thingsboard.server.dao.device.DeviceCredentialsService; | ||
21 | import org.thingsboard.server.gen.edge.DeviceUpdateMsg; | 24 | import org.thingsboard.server.gen.edge.DeviceUpdateMsg; |
22 | import org.thingsboard.server.gen.edge.UpdateMsgType; | 25 | import org.thingsboard.server.gen.edge.UpdateMsgType; |
23 | 26 | ||
@@ -25,11 +28,21 @@ import org.thingsboard.server.gen.edge.UpdateMsgType; | @@ -25,11 +28,21 @@ import org.thingsboard.server.gen.edge.UpdateMsgType; | ||
25 | @Slf4j | 28 | @Slf4j |
26 | public class DeviceUpdateMsgConstructor { | 29 | public class DeviceUpdateMsgConstructor { |
27 | 30 | ||
31 | + @Autowired | ||
32 | + private DeviceCredentialsService deviceCredentialsService; | ||
33 | + | ||
28 | public DeviceUpdateMsg constructDeviceUpdatedMsg(UpdateMsgType msgType, Device device) { | 34 | public DeviceUpdateMsg constructDeviceUpdatedMsg(UpdateMsgType msgType, Device device) { |
35 | + DeviceCredentials deviceCredentials | ||
36 | + = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getTenantId(), device.getId()); | ||
29 | DeviceUpdateMsg.Builder builder = DeviceUpdateMsg.newBuilder() | 37 | DeviceUpdateMsg.Builder builder = DeviceUpdateMsg.newBuilder() |
30 | .setMsgType(msgType) | 38 | .setMsgType(msgType) |
31 | .setName(device.getName()) | 39 | .setName(device.getName()) |
32 | - .setType(device.getType()); | 40 | + .setType(device.getType()) |
41 | + .setCredentialsType(deviceCredentials.getCredentialsType().name()) | ||
42 | + .setCredentialsId(deviceCredentials.getCredentialsId()); | ||
43 | + if (deviceCredentials.getCredentialsValue() != null) { | ||
44 | + builder.setCredentialsValue(deviceCredentials.getCredentialsValue()); | ||
45 | + } | ||
33 | return builder.build(); | 46 | return builder.build(); |
34 | } | 47 | } |
35 | } | 48 | } |
@@ -15,12 +15,10 @@ | @@ -15,12 +15,10 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.edge; | 16 | package org.thingsboard.server.dao.edge; |
17 | 17 | ||
18 | -import com.fasterxml.jackson.core.JsonProcessingException; | ||
19 | import com.google.common.util.concurrent.FutureCallback; | 18 | import com.google.common.util.concurrent.FutureCallback; |
20 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
21 | import org.thingsboard.server.common.data.EntitySubtype; | 20 | import org.thingsboard.server.common.data.EntitySubtype; |
22 | import org.thingsboard.server.common.data.Event; | 21 | import org.thingsboard.server.common.data.Event; |
23 | -import org.thingsboard.server.common.data.Tenant; | ||
24 | import org.thingsboard.server.common.data.edge.Edge; | 22 | import org.thingsboard.server.common.data.edge.Edge; |
25 | import org.thingsboard.server.common.data.edge.EdgeSearchQuery; | 23 | import org.thingsboard.server.common.data.edge.EdgeSearchQuery; |
26 | import org.thingsboard.server.common.data.id.CustomerId; | 24 | import org.thingsboard.server.common.data.id.CustomerId; |
@@ -160,6 +160,9 @@ message DeviceUpdateMsg { | @@ -160,6 +160,9 @@ message DeviceUpdateMsg { | ||
160 | UpdateMsgType msgType = 1; | 160 | UpdateMsgType msgType = 1; |
161 | string name = 2; | 161 | string name = 2; |
162 | string type = 3; | 162 | string type = 3; |
163 | + string credentialsType = 4; | ||
164 | + string credentialsId = 5; | ||
165 | + string credentialsValue = 6; | ||
163 | } | 166 | } |
164 | 167 | ||
165 | message AssetUpdateMsg { | 168 | message AssetUpdateMsg { |