Browse Source

Fix credentials issue

pull/6641/head
Andrii Shvaika 4 years ago
parent
commit
37da2a95ca
  1. 7
      application/src/main/java/org/thingsboard/server/service/sync/vc/DefaultEntitiesVersionControlService.java
  2. 6
      common/data/src/main/java/org/thingsboard/server/common/data/sync/ie/DeviceExportData.java
  3. 14
      common/data/src/main/java/org/thingsboard/server/common/data/sync/ie/EntityExportData.java

7
application/src/main/java/org/thingsboard/server/service/sync/vc/DefaultEntitiesVersionControlService.java

@ -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());
} }

6
common/data/src/main/java/org/thingsboard/server/common/data/sync/ie/DeviceExportData.java

@ -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;
}
} }

14
common/data/src/main/java/org/thingsboard/server/common/data/sync/ie/EntityExportData.java

@ -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;
}
} }

Loading…
Cancel
Save