Showing
4 changed files
with
22 additions
and
3 deletions
... | ... | @@ -565,6 +565,7 @@ public abstract class BaseController { |
565 | 565 | } |
566 | 566 | if (e == null) { |
567 | 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 | 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 | 612 | case UNASSIGNED_FROM_EDGE: |
612 | 613 | msgType = DataConstants.ENTITY_UNASSIGNED_FROM_EDGE; |
613 | 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 | 620 | if (!StringUtils.isEmpty(msgType)) { |
616 | 621 | try { | ... | ... |
... | ... | @@ -16,8 +16,11 @@ |
16 | 16 | package org.thingsboard.server.service.edge.rpc.constructor; |
17 | 17 | |
18 | 18 | import lombok.extern.slf4j.Slf4j; |
19 | +import org.springframework.beans.factory.annotation.Autowired; | |
19 | 20 | import org.springframework.stereotype.Component; |
20 | 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 | 24 | import org.thingsboard.server.gen.edge.DeviceUpdateMsg; |
22 | 25 | import org.thingsboard.server.gen.edge.UpdateMsgType; |
23 | 26 | |
... | ... | @@ -25,11 +28,21 @@ import org.thingsboard.server.gen.edge.UpdateMsgType; |
25 | 28 | @Slf4j |
26 | 29 | public class DeviceUpdateMsgConstructor { |
27 | 30 | |
31 | + @Autowired | |
32 | + private DeviceCredentialsService deviceCredentialsService; | |
33 | + | |
28 | 34 | public DeviceUpdateMsg constructDeviceUpdatedMsg(UpdateMsgType msgType, Device device) { |
35 | + DeviceCredentials deviceCredentials | |
36 | + = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getTenantId(), device.getId()); | |
29 | 37 | DeviceUpdateMsg.Builder builder = DeviceUpdateMsg.newBuilder() |
30 | 38 | .setMsgType(msgType) |
31 | 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 | 46 | return builder.build(); |
34 | 47 | } |
35 | 48 | } | ... | ... |
... | ... | @@ -15,12 +15,10 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.dao.edge; |
17 | 17 | |
18 | -import com.fasterxml.jackson.core.JsonProcessingException; | |
19 | 18 | import com.google.common.util.concurrent.FutureCallback; |
20 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
21 | 20 | import org.thingsboard.server.common.data.EntitySubtype; |
22 | 21 | import org.thingsboard.server.common.data.Event; |
23 | -import org.thingsboard.server.common.data.Tenant; | |
24 | 22 | import org.thingsboard.server.common.data.edge.Edge; |
25 | 23 | import org.thingsboard.server.common.data.edge.EdgeSearchQuery; |
26 | 24 | import org.thingsboard.server.common.data.id.CustomerId; | ... | ... |