diff --git a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java index e1e63880e2..4806f514b8 100644 --- a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java +++ b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java @@ -139,9 +139,6 @@ public void performInstall() { entityDatabaseSchemaService.createOrUpdateViewsAndFunctions(); entityDatabaseSchemaService.createOrUpdateDeviceInfoView(persistToTelemetry); - // edge specific - dataUpdateService.deleteAllWidgetBundlesAndTypes(); - log.info("Updating system data..."); // dataUpdateService.upgradeRuleNodes(); systemDataLoaderService.loadSystemWidgets(); diff --git a/application/src/main/java/org/thingsboard/server/service/cloud/rpc/processor/WidgetTypeCloudProcessor.java b/application/src/main/java/org/thingsboard/server/service/cloud/rpc/processor/WidgetTypeCloudProcessor.java index 54ff068e08..1013f0bbe9 100644 --- a/application/src/main/java/org/thingsboard/server/service/cloud/rpc/processor/WidgetTypeCloudProcessor.java +++ b/application/src/main/java/org/thingsboard/server/service/cloud/rpc/processor/WidgetTypeCloudProcessor.java @@ -22,18 +22,11 @@ import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.WidgetTypeId; -import org.thingsboard.server.common.data.page.PageData; -import org.thingsboard.server.common.data.page.PageLink; -import org.thingsboard.server.common.data.widget.DeprecatedFilter; import org.thingsboard.server.common.data.widget.WidgetType; import org.thingsboard.server.common.data.widget.WidgetTypeDetails; -import org.thingsboard.server.common.data.widget.WidgetTypeInfo; -import org.thingsboard.server.common.data.widget.WidgetsBundle; -import org.thingsboard.server.dao.exception.DataValidationException; import org.thingsboard.server.gen.edge.v1.WidgetTypeUpdateMsg; import org.thingsboard.server.service.edge.rpc.processor.BaseEdgeProcessor; -import java.util.List; import java.util.UUID; @Component @@ -57,17 +50,7 @@ public ListenableFuture processWidgetTypeMsgFromCloud(TenantId tenantId, W if (widgetTypeByTenantIdAndFqn != null && !widgetTypeByTenantIdAndFqn.getId().equals(widgetTypeDetails.getId())) { widgetTypeService.deleteWidgetType(widgetTypeByTenantIdAndFqn.getTenantId(), widgetTypeByTenantIdAndFqn.getId()); } - try { - widgetTypeService.saveWidgetType(widgetTypeDetails, false); - } catch (Exception e) { - if (e instanceof DataValidationException && e.getMessage().contains("fqn already exists")) { - deleteWidgetBundlesAndTypes(TenantId.SYS_TENANT_ID); - deleteWidgetBundlesAndTypes(tenantId); - widgetTypeService.saveWidgetType(widgetTypeDetails, false); - } else { - throw new RuntimeException(e); - } - } + widgetTypeService.saveWidgetType(widgetTypeDetails, false); } finally { widgetCreationLock.unlock(); } @@ -86,22 +69,4 @@ public ListenableFuture processWidgetTypeMsgFromCloud(TenantId tenantId, W } return Futures.immediateFuture(null); } - - private void deleteWidgetBundlesAndTypes(TenantId tenantId) { - List systemWidgetsBundles = widgetsBundleService.findSystemWidgetsBundles(tenantId); - for (WidgetsBundle systemWidgetsBundle : systemWidgetsBundles) { - if (systemWidgetsBundle != null) { - PageData widgetTypes; - var pageLink = new PageLink(1024); - do { - widgetTypes = widgetTypeService.findWidgetTypesInfosByWidgetsBundleId(tenantId, systemWidgetsBundle.getId(), false, DeprecatedFilter.ALL, null, pageLink); - for (var widgetType : widgetTypes.getData()) { - widgetTypeService.deleteWidgetType(tenantId, widgetType.getId()); - } - pageLink.nextPageLink(); - } while (widgetTypes.hasNext()); - widgetsBundleService.deleteWidgetsBundle(tenantId, systemWidgetsBundle.getId()); - } - } - } } diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DataUpdateService.java index 14fa10bff7..0920e21264 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DataUpdateService.java @@ -20,6 +20,4 @@ public interface DataUpdateService { void updateData(String fromVersion) throws Exception; void upgradeRuleNodes(); - - void deleteAllWidgetBundlesAndTypes(); } diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index c66e7dfed9..6d38593e9b 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -37,8 +37,6 @@ import org.thingsboard.server.common.data.page.PageLink; import org.thingsboard.server.common.data.query.DynamicValue; import org.thingsboard.server.common.data.query.FilterPredicateValue; -import org.thingsboard.server.common.data.widget.DeprecatedFilter; -import org.thingsboard.server.common.data.widget.WidgetTypeInfo; import org.thingsboard.server.common.data.widget.WidgetsBundle; import org.thingsboard.server.dao.alarm.AlarmDao; import org.thingsboard.server.dao.audit.AuditLogDao; @@ -52,7 +50,6 @@ import org.thingsboard.server.dao.tenant.TenantProfileService; import org.thingsboard.server.dao.tenant.TenantService; import org.thingsboard.server.dao.timeseries.TimeseriesService; -import org.thingsboard.server.dao.widget.WidgetTypeService; import org.thingsboard.server.dao.widget.WidgetsBundleService; import org.thingsboard.server.service.component.ComponentDiscoveryService; import org.thingsboard.server.service.component.RuleNodeClassInfo; @@ -88,9 +85,6 @@ public class DefaultDataUpdateService implements DataUpdateService { @Autowired private WidgetsBundleService widgetsBundleService; - @Autowired - private WidgetTypeService widgetTypeService; - @Autowired private CloudEventService cloudEventService; @@ -139,33 +133,6 @@ public void updateData(String fromVersion) throws Exception { } } - @Override - public void deleteAllWidgetBundlesAndTypes() { - PageData tenants = tenantService.findTenants(new PageLink(Integer.MAX_VALUE)); - for (Tenant tenant : tenants.getData()) { - deleteWidgetBundlesAndTypes(tenant.getId()); - } - deleteWidgetBundlesAndTypes(TenantId.SYS_TENANT_ID); - } - - private void deleteWidgetBundlesAndTypes(TenantId tenantId) { - List systemWidgetsBundles = widgetsBundleService.findSystemWidgetsBundles(tenantId); - for (WidgetsBundle systemWidgetsBundle : systemWidgetsBundles) { - if (systemWidgetsBundle != null) { - PageData widgetTypes; - var pageLink = new PageLink(1024); - do { - widgetTypes = widgetTypeService.findWidgetTypesInfosByWidgetsBundleId(tenantId, systemWidgetsBundle.getId(), false, DeprecatedFilter.ALL, null, pageLink); - for (var widgetType : widgetTypes.getData()) { - widgetTypeService.deleteWidgetType(tenantId, widgetType.getId()); - } - pageLink.nextPageLink(); - } while (widgetTypes.hasNext()); - widgetsBundleService.deleteWidgetsBundle(tenantId, systemWidgetsBundle.getId()); - } - } - } - private void migrateEdgeEvents(String logPrefix) { boolean skipEdgeEventsMigration = getEnv("TB_SKIP_EDGE_EVENTS_MIGRATION", false); if (!skipEdgeEventsMigration) {