Fix import of public dashboard
This commit is contained in:
parent
468bc44d5d
commit
c51302eaa5
@ -24,6 +24,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||
import org.thingsboard.server.common.data.id.CustomerId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.sync.ie.EntityImportSettings;
|
||||
import org.thingsboard.server.dao.customer.CustomerDao;
|
||||
import org.thingsboard.server.dao.customer.CustomerService;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
@ -35,6 +36,7 @@ import org.thingsboard.server.common.data.sync.ie.EntityExportData;
|
||||
public class CustomerImportService extends BaseEntityImportService<CustomerId, Customer, EntityExportData<Customer>> {
|
||||
|
||||
private final CustomerService customerService;
|
||||
private final CustomerDao customerDao;
|
||||
|
||||
@Override
|
||||
protected void setOwner(TenantId tenantId, Customer customer, IdProvider idProvider) {
|
||||
@ -43,10 +45,12 @@ public class CustomerImportService extends BaseEntityImportService<CustomerId, C
|
||||
|
||||
@Override
|
||||
protected Customer prepareAndSave(TenantId tenantId, Customer customer, EntityExportData<Customer> exportData, IdProvider idProvider, EntityImportSettings importSettings) {
|
||||
if (customer.isPublic()) {
|
||||
return customerService.findOrCreatePublicCustomer(tenantId);
|
||||
} else {
|
||||
if (!customer.isPublic()) {
|
||||
return customerService.saveCustomer(customer);
|
||||
} else {
|
||||
Customer publicCustomer = customerService.findOrCreatePublicCustomer(tenantId);
|
||||
publicCustomer.setExternalId(customer.getExternalId());
|
||||
return customerDao.save(tenantId, publicCustomer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -340,7 +340,7 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont
|
||||
DaoUtil.processInBatches(pageLink -> {
|
||||
return exportableEntitiesService.findEntitiesByTenantId(user.getTenantId(), entityType, pageLink);
|
||||
}, 100, entity -> {
|
||||
if (!importedEntities.get(entityType).contains(entity.getId())) {
|
||||
if (importedEntities.get(entityType) == null || !importedEntities.get(entityType).contains(entity.getId())) {
|
||||
try {
|
||||
exportableEntitiesService.checkPermission(user, entity, entityType, Operation.DELETE);
|
||||
} catch (ThingsboardException e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user