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.thingsboard.common.util.JacksonUtil;
 | 
			
		||||
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.EntityType;
 | 
			
		||||
import org.thingsboard.server.common.data.HasName;
 | 
			
		||||
@ -127,20 +128,20 @@ public class EntityActionService {
 | 
			
		||||
                } else {
 | 
			
		||||
                    entityNode = JacksonUtil.newObjectNode();
 | 
			
		||||
                    if (actionType == ActionType.ATTRIBUTES_UPDATED) {
 | 
			
		||||
                        String scope = extractParameter(String.class, 0, additionalInfo);
 | 
			
		||||
                        AttributeScope scope = extractParameter(AttributeScope.class, 0, additionalInfo);
 | 
			
		||||
                        @SuppressWarnings("unchecked")
 | 
			
		||||
                        List<AttributeKvEntry> attributes = extractParameter(List.class, 1, additionalInfo);
 | 
			
		||||
                        metaData.putValue(DataConstants.SCOPE, scope);
 | 
			
		||||
                        metaData.putValue(DataConstants.SCOPE, scope.name());
 | 
			
		||||
                        if (attributes != null) {
 | 
			
		||||
                            for (AttributeKvEntry attr : attributes) {
 | 
			
		||||
                                JacksonUtil.addKvEntry(entityNode, attr);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    } else if (actionType == ActionType.ATTRIBUTES_DELETED) {
 | 
			
		||||
                        String scope = extractParameter(String.class, 0, additionalInfo);
 | 
			
		||||
                        AttributeScope scope = extractParameter(AttributeScope.class, 0, additionalInfo);
 | 
			
		||||
                        @SuppressWarnings("unchecked")
 | 
			
		||||
                        List<String> keys = extractParameter(List.class, 1, additionalInfo);
 | 
			
		||||
                        metaData.putValue(DataConstants.SCOPE, scope);
 | 
			
		||||
                        metaData.putValue(DataConstants.SCOPE, scope.name());
 | 
			
		||||
                        ArrayNode attrsArrayNode = entityNode.putArray("attributes");
 | 
			
		||||
                        if (keys != null) {
 | 
			
		||||
                            keys.forEach(attrsArrayNode::add);
 | 
			
		||||
 | 
			
		||||
@ -236,14 +236,14 @@ public abstract class AbstractBulkImportService<E extends HasId<? extends Entity
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onSuccess(Void unused) {
 | 
			
		||||
                    entityActionService.logEntityAction(user, (UUIDBased & EntityId) entityId, null,
 | 
			
		||||
                            null, ActionType.ATTRIBUTES_UPDATED, null, scope, attributes);
 | 
			
		||||
                            null, ActionType.ATTRIBUTES_UPDATED, null, AttributeScope.valueOf(scope), attributes);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onFailure(Throwable throwable) {
 | 
			
		||||
                    entityActionService.logEntityAction(user, (UUIDBased & EntityId) entityId, null,
 | 
			
		||||
                            null, ActionType.ATTRIBUTES_UPDATED, BaseController.toException(throwable),
 | 
			
		||||
                            scope, attributes);
 | 
			
		||||
                            AttributeScope.valueOf(scope), attributes);
 | 
			
		||||
                    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.stereotype.Service;
 | 
			
		||||
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.HasName;
 | 
			
		||||
import org.thingsboard.server.common.data.StringUtils;
 | 
			
		||||
@ -200,10 +201,10 @@ public class AuditLogServiceImpl implements AuditLogService {
 | 
			
		||||
                break;
 | 
			
		||||
            case ATTRIBUTES_UPDATED:
 | 
			
		||||
                actionData.put("entityId", entityId.toString());
 | 
			
		||||
                String scope = extractParameter(String.class, 0, additionalInfo);
 | 
			
		||||
                AttributeScope scope = extractParameter(AttributeScope.class, 0, additionalInfo);
 | 
			
		||||
                @SuppressWarnings("unchecked")
 | 
			
		||||
                List<AttributeKvEntry> attributes = extractParameter(List.class, 1, additionalInfo);
 | 
			
		||||
                actionData.put("scope", scope);
 | 
			
		||||
                actionData.put("scope", scope.name());
 | 
			
		||||
                ObjectNode attrsNode = JacksonUtil.newObjectNode();
 | 
			
		||||
                if (attributes != null) {
 | 
			
		||||
                    for (AttributeKvEntry attr : attributes) {
 | 
			
		||||
@ -215,8 +216,8 @@ public class AuditLogServiceImpl implements AuditLogService {
 | 
			
		||||
            case ATTRIBUTES_DELETED:
 | 
			
		||||
            case ATTRIBUTES_READ:
 | 
			
		||||
                actionData.put("entityId", entityId.toString());
 | 
			
		||||
                scope = extractParameter(String.class, 0, additionalInfo);
 | 
			
		||||
                actionData.put("scope", scope);
 | 
			
		||||
                scope = extractParameter(AttributeScope.class, 0, additionalInfo);
 | 
			
		||||
                actionData.put("scope", scope.name());
 | 
			
		||||
                @SuppressWarnings("unchecked")
 | 
			
		||||
                List<String> keys = extractParameter(List.class, 1, additionalInfo);
 | 
			
		||||
                ArrayNode attrsArrayNode = actionData.putArray("attributes");
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user