Browse Source

Fix update existing widget type by fqn: check fqn is not empty.

pull/9294/head
Igor Kulikov 3 years ago
parent
commit
a1393e7e81
  1. 3
      application/src/main/java/org/thingsboard/server/service/entitiy/widgets/type/DefaultWidgetTypeService.java

3
application/src/main/java/org/thingsboard/server/service/entitiy/widgets/type/DefaultWidgetTypeService.java

@ -18,6 +18,7 @@ package org.thingsboard.server.service.entitiy.widgets.type;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.audit.ActionType;
import org.thingsboard.server.common.data.id.TenantId;
@ -42,7 +43,7 @@ public class DefaultWidgetTypeService extends AbstractTbEntityService implements
@Override
public WidgetTypeDetails save(WidgetTypeDetails widgetTypeDetails, boolean updateExistingByFqn, User user) throws Exception {
TenantId tenantId = widgetTypeDetails.getTenantId();
if (widgetTypeDetails.getId() == null && updateExistingByFqn) {
if (widgetTypeDetails.getId() == null && StringUtils.isNotEmpty(widgetTypeDetails.getFqn()) && updateExistingByFqn) {
WidgetType widgetType = widgetTypeService.findWidgetTypeByTenantIdAndFqn(tenantId, widgetTypeDetails.getFqn());
if (widgetType != null) {
widgetTypeDetails.setId(widgetType.getId());

Loading…
Cancel
Save