attribute scope is prepared correctly for rule engine message metadata
This commit is contained in:
parent
a88b1ef349
commit
140f8dc489
@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.server.cluster.TbClusterService;
|
import org.thingsboard.server.cluster.TbClusterService;
|
||||||
|
import org.thingsboard.server.common.data.AttributeScope;
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.common.data.HasName;
|
import org.thingsboard.server.common.data.HasName;
|
||||||
@ -127,20 +128,20 @@ public class EntityActionService {
|
|||||||
} else {
|
} else {
|
||||||
entityNode = JacksonUtil.newObjectNode();
|
entityNode = JacksonUtil.newObjectNode();
|
||||||
if (actionType == ActionType.ATTRIBUTES_UPDATED) {
|
if (actionType == ActionType.ATTRIBUTES_UPDATED) {
|
||||||
String scope = extractParameter(String.class, 0, additionalInfo);
|
AttributeScope scope = extractParameter(AttributeScope.class, 0, additionalInfo);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<AttributeKvEntry> attributes = extractParameter(List.class, 1, additionalInfo);
|
List<AttributeKvEntry> attributes = extractParameter(List.class, 1, additionalInfo);
|
||||||
metaData.putValue(DataConstants.SCOPE, scope);
|
metaData.putValue(DataConstants.SCOPE, scope.name());
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
for (AttributeKvEntry attr : attributes) {
|
for (AttributeKvEntry attr : attributes) {
|
||||||
JacksonUtil.addKvEntry(entityNode, attr);
|
JacksonUtil.addKvEntry(entityNode, attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (actionType == ActionType.ATTRIBUTES_DELETED) {
|
} else if (actionType == ActionType.ATTRIBUTES_DELETED) {
|
||||||
String scope = extractParameter(String.class, 0, additionalInfo);
|
AttributeScope scope = extractParameter(AttributeScope.class, 0, additionalInfo);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> keys = extractParameter(List.class, 1, additionalInfo);
|
List<String> keys = extractParameter(List.class, 1, additionalInfo);
|
||||||
metaData.putValue(DataConstants.SCOPE, scope);
|
metaData.putValue(DataConstants.SCOPE, scope.name());
|
||||||
ArrayNode attrsArrayNode = entityNode.putArray("attributes");
|
ArrayNode attrsArrayNode = entityNode.putArray("attributes");
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
keys.forEach(attrsArrayNode::add);
|
keys.forEach(attrsArrayNode::add);
|
||||||
|
|||||||
@ -236,14 +236,14 @@ public abstract class AbstractBulkImportService<E extends HasId<? extends Entity
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void unused) {
|
public void onSuccess(Void unused) {
|
||||||
entityActionService.logEntityAction(user, (UUIDBased & EntityId) entityId, null,
|
entityActionService.logEntityAction(user, (UUIDBased & EntityId) entityId, null,
|
||||||
null, ActionType.ATTRIBUTES_UPDATED, null, scope, attributes);
|
null, ActionType.ATTRIBUTES_UPDATED, null, AttributeScope.valueOf(scope), attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable throwable) {
|
public void onFailure(Throwable throwable) {
|
||||||
entityActionService.logEntityAction(user, (UUIDBased & EntityId) entityId, null,
|
entityActionService.logEntityAction(user, (UUIDBased & EntityId) entityId, null,
|
||||||
null, ActionType.ATTRIBUTES_UPDATED, BaseController.toException(throwable),
|
null, ActionType.ATTRIBUTES_UPDATED, BaseController.toException(throwable),
|
||||||
scope, attributes);
|
AttributeScope.valueOf(scope), attributes);
|
||||||
throw new RuntimeException(throwable);
|
throw new RuntimeException(throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
|
import org.thingsboard.server.common.data.AttributeScope;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.common.data.HasName;
|
import org.thingsboard.server.common.data.HasName;
|
||||||
import org.thingsboard.server.common.data.StringUtils;
|
import org.thingsboard.server.common.data.StringUtils;
|
||||||
@ -200,10 +201,10 @@ public class AuditLogServiceImpl implements AuditLogService {
|
|||||||
break;
|
break;
|
||||||
case ATTRIBUTES_UPDATED:
|
case ATTRIBUTES_UPDATED:
|
||||||
actionData.put("entityId", entityId.toString());
|
actionData.put("entityId", entityId.toString());
|
||||||
String scope = extractParameter(String.class, 0, additionalInfo);
|
AttributeScope scope = extractParameter(AttributeScope.class, 0, additionalInfo);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<AttributeKvEntry> attributes = extractParameter(List.class, 1, additionalInfo);
|
List<AttributeKvEntry> attributes = extractParameter(List.class, 1, additionalInfo);
|
||||||
actionData.put("scope", scope);
|
actionData.put("scope", scope.name());
|
||||||
ObjectNode attrsNode = JacksonUtil.newObjectNode();
|
ObjectNode attrsNode = JacksonUtil.newObjectNode();
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
for (AttributeKvEntry attr : attributes) {
|
for (AttributeKvEntry attr : attributes) {
|
||||||
@ -215,8 +216,8 @@ public class AuditLogServiceImpl implements AuditLogService {
|
|||||||
case ATTRIBUTES_DELETED:
|
case ATTRIBUTES_DELETED:
|
||||||
case ATTRIBUTES_READ:
|
case ATTRIBUTES_READ:
|
||||||
actionData.put("entityId", entityId.toString());
|
actionData.put("entityId", entityId.toString());
|
||||||
scope = extractParameter(String.class, 0, additionalInfo);
|
scope = extractParameter(AttributeScope.class, 0, additionalInfo);
|
||||||
actionData.put("scope", scope);
|
actionData.put("scope", scope.name());
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> keys = extractParameter(List.class, 1, additionalInfo);
|
List<String> keys = extractParameter(List.class, 1, additionalInfo);
|
||||||
ArrayNode attrsArrayNode = actionData.putArray("attributes");
|
ArrayNode attrsArrayNode = actionData.putArray("attributes");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user