Browse Source

Removed CREDENTIALS type. Use action instead

pull/2436/head
Volodymyr Babak 6 years ago
parent
commit
a5d75e3800
  1. 4
      application/src/main/java/org/thingsboard/server/controller/AuthController.java
  2. 11
      application/src/main/java/org/thingsboard/server/controller/UserController.java
  3. 1
      application/src/main/java/org/thingsboard/server/service/edge/DefaultEdgeNotificationService.java
  4. 262
      application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java
  5. 4
      application/src/main/java/org/thingsboard/server/service/edge/rpc/init/DefaultSyncEdgeService.java
  6. 2
      common/data/src/main/java/org/thingsboard/server/common/data/edge/EdgeEventType.java

4
application/src/main/java/org/thingsboard/server/controller/AuthController.java

@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.thingsboard.rule.engine.api.MailService;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.audit.ActionType;
import org.thingsboard.server.common.data.edge.EdgeEventType;
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
import org.thingsboard.server.common.data.exception.ThingsboardException;
import org.thingsboard.server.common.data.id.TenantId;
@ -124,6 +125,9 @@ public class AuthController extends BaseController {
}
userCredentials.setPassword(passwordEncoder.encode(newPassword));
userService.replaceUserCredentials(securityUser.getTenantId(), userCredentials);
sendNotificationMsgToEdgeService(getTenantId(), null, userCredentials.getUserId(), EdgeEventType.USER, ActionType.CREDENTIALS_UPDATED);
} catch (Exception e) {
throw handleException(e);
}

11
application/src/main/java/org/thingsboard/server/controller/UserController.java

@ -35,17 +35,14 @@ import org.thingsboard.rule.engine.api.MailService;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.audit.ActionType;
import org.thingsboard.server.common.data.edge.Edge;
import org.thingsboard.server.common.data.edge.EdgeEventType;
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
import org.thingsboard.server.common.data.exception.ThingsboardException;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.EdgeId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.common.data.page.TextPageData;
import org.thingsboard.server.common.data.page.TextPageLink;
import org.thingsboard.server.common.data.page.TimePageData;
import org.thingsboard.server.common.data.page.TimePageLink;
import org.thingsboard.server.common.data.security.Authority;
import org.thingsboard.server.common.data.security.UserCredentials;
import org.thingsboard.server.queue.util.TbCoreComponent;
@ -60,8 +57,6 @@ import org.thingsboard.server.utils.MiscUtils;
import javax.servlet.http.HttpServletRequest;
import static org.thingsboard.server.controller.EdgeController.EDGE_ID;
@RestController
@TbCoreComponent
@RequestMapping("/api")
@ -167,6 +162,8 @@ public class UserController extends BaseController {
savedUser.getCustomerId(),
user.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
sendNotificationMsgToEdgeService(getTenantId(), null, user.getId(), EdgeEventType.USER, user.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
return savedUser;
} catch (Exception e) {
@ -242,6 +239,8 @@ public class UserController extends BaseController {
user.getCustomerId(),
ActionType.DELETED, null, strUserId);
sendNotificationMsgToEdgeService(getTenantId(), null, user.getId(), EdgeEventType.USER, ActionType.DELETED);
} catch (Exception e) {
logEntityAction(emptyId(EntityType.USER),
null,

1
application/src/main/java/org/thingsboard/server/service/edge/DefaultEdgeNotificationService.java

@ -174,6 +174,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
// TODO: voba - ADDED is not required for CE version ?
// case ADDED:
case UPDATED:
case CREDENTIALS_UPDATED:
ListenableFuture<List<EdgeId>> edgeIdsFuture = findRelatedEdgeIdsByEntityId(tenantId, entityId);
Futures.transform(edgeIdsFuture, edgeIds -> {
if (edgeIds != null && !edgeIds.isEmpty()) {

262
application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java

@ -28,9 +28,7 @@ import com.google.gson.JsonObject;
import io.grpc.stub.StreamObserver;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.springframework.util.StringUtils;
import org.thingsboard.server.common.data.Dashboard;
import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.Device;
@ -195,11 +193,23 @@ public final class EdgeGrpcSession implements Closeable {
for (EdgeEvent edgeEvent : pageData.getData()) {
log.trace("[{}] Processing edge event [{}]", this.sessionId, edgeEvent);
try {
UpdateMsgType msgType = getResponseMsgType(ActionType.valueOf(edgeEvent.getEdgeEventAction()));
if (msgType == null) {
processTelemetryMessage(edgeEvent);
} else {
processEntityCRUDMessage(edgeEvent, msgType);
ActionType edgeEventAction = ActionType.valueOf(edgeEvent.getEdgeEventAction());
switch (edgeEventAction) {
case UPDATED:
case ADDED:
case ASSIGNED_TO_EDGE:
case DELETED:
case UNASSIGNED_FROM_EDGE:
case ALARM_ACK:
case ALARM_CLEAR:
case CREDENTIALS_UPDATED:
processEntityMessage(edgeEvent, edgeEventAction);
break;
case ATTRIBUTES_UPDATED:
case ATTRIBUTES_DELETED:
case TIMESERIES_UPDATED:
processTelemetryMessage(edgeEvent);
break;
}
} catch (Exception e) {
log.error("Exception during processing records from queue", e);
@ -278,217 +288,212 @@ public final class EdgeGrpcSession implements Closeable {
}
}
private void processEntityCRUDMessage(EdgeEvent edgeEvent, UpdateMsgType msgType) {
log.trace("Executing processEntityCRUDMessage, edgeEvent [{}], msgType [{}]", edgeEvent, msgType);
private void processEntityMessage(EdgeEvent edgeEvent, ActionType edgeEventAction) {
UpdateMsgType msgType = getResponseMsgType(ActionType.valueOf(edgeEvent.getEdgeEventAction()));
log.trace("Executing processEntityCRUDMessage, edgeEvent [{}], edgeEventAction [{}], msgType [{}]", edgeEvent, edgeEventAction, msgType);
switch (edgeEvent.getEdgeEventType()) {
case EDGE:
// TODO: voba - add edge update logic
break;
case DEVICE:
processDeviceCRUD(edgeEvent, msgType);
break;
case DEVICE_CREDENTIALS:
processDeviceCredentialsCRUD(edgeEvent, msgType);
processDevice(edgeEvent, msgType, edgeEventAction);
break;
case ASSET:
processAssetCRUD(edgeEvent, msgType);
processAsset(edgeEvent, msgType, edgeEventAction);
break;
case ENTITY_VIEW:
processEntityViewCRUD(edgeEvent, msgType);
processEntityView(edgeEvent, msgType, edgeEventAction);
break;
case DASHBOARD:
processDashboardCRUD(edgeEvent, msgType);
processDashboard(edgeEvent, msgType, edgeEventAction);
break;
case RULE_CHAIN:
processRuleChainCRUD(edgeEvent, msgType);
processRuleChain(edgeEvent, msgType, edgeEventAction);
break;
case RULE_CHAIN_METADATA:
processRuleChainMetadataCRUD(edgeEvent, msgType);
processRuleChainMetadata(edgeEvent, msgType);
break;
case ALARM:
processAlarmCRUD(edgeEvent, msgType);
processAlarm(edgeEvent, msgType);
break;
case USER:
processUserCRUD(edgeEvent, msgType);
break;
case USER_CREDENTIALS:
processUserCredentialsCRUD(edgeEvent, msgType);
processUser(edgeEvent, msgType, edgeEventAction);
break;
case RELATION:
processRelationCRUD(edgeEvent, msgType);
processRelation(edgeEvent, msgType);
break;
}
}
private void processDeviceCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processDevice(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeActionType) {
DeviceId deviceId = new DeviceId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
case DEVICE_CONFLICT_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = null;
switch (edgeActionType) {
case ADDED:
case UPDATED:
case ASSIGNED_TO_EDGE:
Device device = ctx.getDeviceService().findDeviceById(edgeEvent.getTenantId(), deviceId);
if (device != null) {
DeviceUpdateMsg deviceUpdateMsg =
ctx.getDeviceUpdateMsgConstructor().constructDeviceUpdatedMsg(msgType, device);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setDeviceUpdateMsg(deviceUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
case ENTITY_DELETED_RPC_MESSAGE:
case DELETED:
case UNASSIGNED_FROM_EDGE:
DeviceUpdateMsg deviceUpdateMsg =
ctx.getDeviceUpdateMsgConstructor().constructDeviceDeleteMsg(deviceId);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setDeviceUpdateMsg(deviceUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
}
private void processDeviceCredentialsCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
DeviceId deviceId = new DeviceId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
break;
case CREDENTIALS_UPDATED:
DeviceCredentials deviceCredentials = ctx.getDeviceCredentialsService().findDeviceCredentialsByDeviceId(edge.getTenantId(), deviceId);
if (deviceCredentials != null) {
DeviceCredentialsUpdateMsg deviceCredentialsUpdateMsg =
ctx.getDeviceUpdateMsgConstructor().constructDeviceCredentialsUpdatedMsg(deviceCredentials);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setDeviceCredentialsUpdateMsg(deviceCredentialsUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
}
if (entityUpdateMsg != null) {
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
}
private void processAssetCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processAsset(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) {
AssetId assetId = new AssetId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = null;
switch (edgeEventAction) {
case ADDED:
case UPDATED:
case ASSIGNED_TO_EDGE:
Asset asset = ctx.getAssetService().findAssetById(edgeEvent.getTenantId(), assetId);
if (asset != null) {
AssetUpdateMsg assetUpdateMsg =
ctx.getAssetUpdateMsgConstructor().constructAssetUpdatedMsg(msgType, asset);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setAssetUpdateMsg(assetUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
case ENTITY_DELETED_RPC_MESSAGE:
case DELETED:
case UNASSIGNED_FROM_EDGE:
AssetUpdateMsg assetUpdateMsg =
ctx.getAssetUpdateMsgConstructor().constructAssetDeleteMsg(assetId);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setAssetUpdateMsg(assetUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
break;
}
if (entityUpdateMsg != null) {
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
}
private void processEntityViewCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processEntityView(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) {
EntityViewId entityViewId = new EntityViewId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = null;
switch (edgeEventAction) {
case ADDED:
case UPDATED:
case ASSIGNED_TO_EDGE:
EntityView entityView = ctx.getEntityViewService().findEntityViewById(edgeEvent.getTenantId(), entityViewId);
if (entityView != null) {
EntityViewUpdateMsg entityViewUpdateMsg =
ctx.getEntityViewUpdateMsgConstructor().constructEntityViewUpdatedMsg(msgType, entityView);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setEntityViewUpdateMsg(entityViewUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
case ENTITY_DELETED_RPC_MESSAGE:
case DELETED:
case UNASSIGNED_FROM_EDGE:
EntityViewUpdateMsg entityViewUpdateMsg =
ctx.getEntityViewUpdateMsgConstructor().constructEntityViewDeleteMsg(entityViewId);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setEntityViewUpdateMsg(entityViewUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
break;
}
if (entityUpdateMsg != null) {
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
}
private void processDashboardCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processDashboard(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) {
DashboardId dashboardId = new DashboardId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = null;
switch (edgeEventAction) {
case ADDED:
case UPDATED:
case ASSIGNED_TO_EDGE:
Dashboard dashboard = ctx.getDashboardService().findDashboardById(edgeEvent.getTenantId(), dashboardId);
if (dashboard != null) {
DashboardUpdateMsg dashboardUpdateMsg =
ctx.getDashboardUpdateMsgConstructor().constructDashboardUpdatedMsg(msgType, dashboard);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setDashboardUpdateMsg(dashboardUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
case ENTITY_DELETED_RPC_MESSAGE:
case DELETED:
case UNASSIGNED_FROM_EDGE:
DashboardUpdateMsg dashboardUpdateMsg =
ctx.getDashboardUpdateMsgConstructor().constructDashboardDeleteMsg(dashboardId);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setDashboardUpdateMsg(dashboardUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
break;
}
if (entityUpdateMsg != null) {
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
}
private void processRuleChainCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processRuleChain(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) {
RuleChainId ruleChainId = new RuleChainId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = null;
switch (edgeEventAction) {
case ADDED:
case UPDATED:
case ASSIGNED_TO_EDGE:
RuleChain ruleChain = ctx.getRuleChainService().findRuleChainById(edgeEvent.getTenantId(), ruleChainId);
if (ruleChain != null) {
RuleChainUpdateMsg ruleChainUpdateMsg =
ctx.getRuleChainUpdateMsgConstructor().constructRuleChainUpdatedMsg(edge.getRootRuleChainId(), msgType, ruleChain);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setRuleChainUpdateMsg(ruleChainUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
case ENTITY_DELETED_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
case DELETED:
case UNASSIGNED_FROM_EDGE:
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setRuleChainUpdateMsg(ctx.getRuleChainUpdateMsgConstructor().constructRuleChainDeleteMsg(ruleChainId))
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
break;
}
if (entityUpdateMsg != null) {
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
}
private void processRuleChainMetadataCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processRuleChainMetadata(EdgeEvent edgeEvent, UpdateMsgType msgType) {
RuleChainId ruleChainId = new RuleChainId(edgeEvent.getEntityId());
RuleChain ruleChain = ctx.getRuleChainService().findRuleChainById(edgeEvent.getTenantId(), ruleChainId);
if (ruleChain != null) {
@ -506,53 +511,44 @@ public final class EdgeGrpcSession implements Closeable {
}
}
private void processUserCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processUser(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeActionType) {
UserId userId = new UserId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = null;
switch (edgeActionType) {
case ADDED:
case UPDATED:
case ASSIGNED_TO_EDGE:
User user = ctx.getUserService().findUserById(edgeEvent.getTenantId(), userId);
if (user != null) {
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setUserUpdateMsg(ctx.getUserUpdateMsgConstructor().constructUserUpdatedMsg(msgType, user))
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
case ENTITY_DELETED_RPC_MESSAGE:
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
case DELETED:
case UNASSIGNED_FROM_EDGE:
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setUserUpdateMsg(ctx.getUserUpdateMsgConstructor().constructUserDeleteMsg(userId))
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
break;
}
}
private void processUserCredentialsCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
UserId userId = new UserId(edgeEvent.getEntityId());
switch (msgType) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
case CREDENTIALS_UPDATED:
UserCredentials userCredentialsByUserId = ctx.getUserService().findUserCredentialsByUserId(edge.getTenantId(), userId);
if (userCredentialsByUserId != null) {
UserCredentialsUpdateMsg userCredentialsUpdateMsg =
ctx.getUserUpdateMsgConstructor().constructUserCredentialsUpdatedMsg(userCredentialsByUserId);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setUserCredentialsUpdateMsg(userCredentialsUpdateMsg)
.build();
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
break;
}
if (entityUpdateMsg != null) {
outputStream.onNext(ResponseMsg.newBuilder()
.setEntityUpdateMsg(entityUpdateMsg)
.build());
}
}
private void processRelationCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processRelation(EdgeEvent edgeEvent, UpdateMsgType msgType) {
EntityRelation entityRelation = mapper.convertValue(edgeEvent.getEntityBody(), EntityRelation.class);
EntityUpdateMsg entityUpdateMsg = EntityUpdateMsg.newBuilder()
.setRelationUpdateMsg(ctx.getRelationUpdateMsgConstructor().constructRelationUpdatedMsg(msgType, entityRelation))
@ -562,7 +558,7 @@ public final class EdgeGrpcSession implements Closeable {
.build());
}
private void processAlarmCRUD(EdgeEvent edgeEvent, UpdateMsgType msgType) {
private void processAlarm(EdgeEvent edgeEvent, UpdateMsgType msgType) {
try {
AlarmId alarmId = new AlarmId(edgeEvent.getEntityId());
Alarm alarm = ctx.getAlarmService().findAlarmByIdAsync(edgeEvent.getTenantId(), alarmId).get();
@ -593,10 +589,6 @@ public final class EdgeGrpcSession implements Closeable {
return UpdateMsgType.ALARM_ACK_RPC_MESSAGE;
case ALARM_CLEAR:
return UpdateMsgType.ALARM_CLEAR_RPC_MESSAGE;
case ATTRIBUTES_UPDATED:
case ATTRIBUTES_DELETED:
case TIMESERIES_UPDATED:
return null;
default:
throw new RuntimeException("Unsupported actionType [" + actionType + "]");
}

4
application/src/main/java/org/thingsboard/server/service/edge/rpc/init/DefaultSyncEdgeService.java

@ -395,7 +395,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
public void processDeviceCredentialsRequestMsg(Edge edge, DeviceCredentialsRequestMsg deviceCredentialsRequestMsg) {
if (deviceCredentialsRequestMsg.getDeviceIdMSB() != 0 && deviceCredentialsRequestMsg.getDeviceIdLSB() != 0) {
DeviceId deviceId = new DeviceId(new UUID(deviceCredentialsRequestMsg.getDeviceIdMSB(), deviceCredentialsRequestMsg.getDeviceIdLSB()));
saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE_CREDENTIALS, ActionType.ADDED, deviceId, null);
saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE, ActionType.CREDENTIALS_UPDATED, deviceId, null);
}
}
@ -403,7 +403,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
public void processUserCredentialsRequestMsg(Edge edge, UserCredentialsRequestMsg userCredentialsRequestMsg) {
if (userCredentialsRequestMsg.getUserIdMSB() != 0 && userCredentialsRequestMsg.getUserIdLSB() != 0) {
UserId userId = new UserId(new UUID(userCredentialsRequestMsg.getUserIdMSB(), userCredentialsRequestMsg.getUserIdLSB()));
saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER_CREDENTIALS, ActionType.ADDED, userId, null);
saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, ActionType.CREDENTIALS_UPDATED, userId, null);
}
}

2
common/data/src/main/java/org/thingsboard/server/common/data/edge/EdgeEventType.java

@ -19,14 +19,12 @@ public enum EdgeEventType {
DASHBOARD,
ASSET,
DEVICE,
DEVICE_CREDENTIALS,
ENTITY_VIEW,
ALARM,
RULE_CHAIN,
RULE_CHAIN_METADATA,
EDGE,
USER,
USER_CREDENTIALS,
CUSTOMER,
RELATION
}

Loading…
Cancel
Save