Fix credentials issue

This commit is contained in:
Andrii Shvaika 2022-06-02 15:34:59 +03:00
parent 63750ef8a0
commit 37da2a95ca
3 changed files with 24 additions and 3 deletions

View File

@ -404,8 +404,9 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont
return transformAsync(gitServiceQueue.getEntity(user.getTenantId(), versionId, externalId), return transformAsync(gitServiceQueue.getEntity(user.getTenantId(), versionId, externalId),
otherVersion -> { otherVersion -> {
EntityExportData<?> currentVersion = exportImportService.exportEntity(user, entityId, EntityExportSettings.builder() EntityExportData<?> currentVersion = exportImportService.exportEntity(user, entityId, EntityExportSettings.builder()
.exportRelations(otherVersion.getRelations() != null) .exportRelations(otherVersion.hasRelations())
.exportAttributes(otherVersion.getAttributes() != null) .exportAttributes(otherVersion.hasAttributes())
.exportCredentials(otherVersion.hasCredentials())
.build()); .build());
return transform(gitServiceQueue.getContentsDiff(user.getTenantId(), return transform(gitServiceQueue.getContentsDiff(user.getTenantId(),
JacksonUtil.toPrettyString(currentVersion.sort()), JacksonUtil.toPrettyString(currentVersion.sort()),
@ -417,7 +418,7 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont
@Override @Override
public ListenableFuture<EntityDataInfo> getEntityDataInfo(SecurityUser user, EntityId entityId, String versionId) { public ListenableFuture<EntityDataInfo> getEntityDataInfo(SecurityUser user, EntityId entityId, String versionId) {
return Futures.transform(gitServiceQueue.getEntity(user.getTenantId(), versionId, entityId), return Futures.transform(gitServiceQueue.getEntity(user.getTenantId(), versionId, entityId),
entity -> new EntityDataInfo(entity.getRelations() != null, entity.getAttributes() != null, false), MoreExecutors.directExecutor()); entity -> new EntityDataInfo(entity.hasRelations(), entity.hasAttributes(), entity.hasCredentials()), MoreExecutors.directExecutor());
} }

View File

@ -15,6 +15,7 @@
*/ */
package org.thingsboard.server.common.data.sync.ie; package org.thingsboard.server.common.data.sync.ie;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -30,4 +31,9 @@ public class DeviceExportData extends EntityExportData<Device> {
@JsonProperty(index = 3) @JsonProperty(index = 3)
private DeviceCredentials credentials; private DeviceCredentials credentials;
@JsonIgnore
@Override
public boolean hasCredentials() {
return credentials != null;
}
} }

View File

@ -81,4 +81,18 @@ public class EntityExportData<E extends ExportableEntity<? extends EntityId>> {
return entity.getExternalId() != null ? entity.getExternalId() : entity.getId(); return entity.getExternalId() != null ? entity.getExternalId() : entity.getId();
} }
@JsonIgnore
public boolean hasCredentials() {
return false;
}
@JsonIgnore
public boolean hasAttributes() {
return attributes != null;
}
@JsonIgnore
public boolean hasRelations() {
return relations != null;
}
} }