implemented audit logs for the firmware and resource
This commit is contained in:
parent
ce24a87bed
commit
a5656009d2
@ -75,7 +75,6 @@ import javax.annotation.Nullable;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.thingsboard.server.controller.EdgeController.EDGE_ID;
|
import static org.thingsboard.server.controller.EdgeController.EDGE_ID;
|
||||||
@ -120,12 +119,12 @@ public class DeviceController extends BaseController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Device saveDevice(@RequestBody Device device,
|
public Device saveDevice(@RequestBody Device device,
|
||||||
@RequestParam(name = "accessToken", required = false) String accessToken) throws ThingsboardException {
|
@RequestParam(name = "accessToken", required = false) String accessToken) throws ThingsboardException {
|
||||||
|
boolean created = device.getId() == null;
|
||||||
try {
|
try {
|
||||||
device.setTenantId(getCurrentUser().getTenantId());
|
device.setTenantId(getCurrentUser().getTenantId());
|
||||||
|
|
||||||
checkEntity(device.getId(), device, Resource.DEVICE);
|
checkEntity(device.getId(), device, Resource.DEVICE);
|
||||||
|
|
||||||
boolean created = device.getId() == null;
|
|
||||||
Device oldDevice;
|
Device oldDevice;
|
||||||
if (!created) {
|
if (!created) {
|
||||||
oldDevice = deviceService.findDeviceById(getTenantId(), device.getId());
|
oldDevice = deviceService.findDeviceById(getTenantId(), device.getId());
|
||||||
@ -146,7 +145,7 @@ public class DeviceController extends BaseController {
|
|||||||
|
|
||||||
logEntityAction(savedDevice.getId(), savedDevice,
|
logEntityAction(savedDevice.getId(), savedDevice,
|
||||||
savedDevice.getCustomerId(),
|
savedDevice.getCustomerId(),
|
||||||
device.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
|
created ? ActionType.ADDED : ActionType.UPDATED, null);
|
||||||
|
|
||||||
if (device.getId() == null) {
|
if (device.getId() == null) {
|
||||||
deviceStateService.onDeviceAdded(savedDevice);
|
deviceStateService.onDeviceAdded(savedDevice);
|
||||||
@ -157,10 +156,9 @@ public class DeviceController extends BaseController {
|
|||||||
firmwareStateService.update(savedDevice, oldDevice);
|
firmwareStateService.update(savedDevice, oldDevice);
|
||||||
|
|
||||||
return savedDevice;
|
return savedDevice;
|
||||||
} catch (
|
} catch (Exception e) {
|
||||||
Exception e) {
|
|
||||||
logEntityAction(emptyId(EntityType.DEVICE), device,
|
logEntityAction(emptyId(EntityType.DEVICE), device,
|
||||||
null, device.getId() == null ? ActionType.ADDED : ActionType.UPDATED, e);
|
null, created ? ActionType.ADDED : ActionType.UPDATED, e);
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,8 +30,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.common.data.Firmware;
|
import org.thingsboard.server.common.data.Firmware;
|
||||||
import org.thingsboard.server.common.data.FirmwareInfo;
|
import org.thingsboard.server.common.data.FirmwareInfo;
|
||||||
|
import org.thingsboard.server.common.data.audit.ActionType;
|
||||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||||
import org.thingsboard.server.common.data.id.FirmwareId;
|
import org.thingsboard.server.common.data.id.FirmwareId;
|
||||||
import org.thingsboard.server.common.data.page.PageData;
|
import org.thingsboard.server.common.data.page.PageData;
|
||||||
@ -101,11 +103,17 @@ public class FirmwareController extends BaseController {
|
|||||||
@RequestMapping(value = "/firmware", method = RequestMethod.POST)
|
@RequestMapping(value = "/firmware", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public FirmwareInfo saveFirmwareInfo(@RequestBody FirmwareInfo firmwareInfo) throws ThingsboardException {
|
public FirmwareInfo saveFirmwareInfo(@RequestBody FirmwareInfo firmwareInfo) throws ThingsboardException {
|
||||||
|
boolean created = firmwareInfo.getId() == null;
|
||||||
|
try {
|
||||||
firmwareInfo.setTenantId(getTenantId());
|
firmwareInfo.setTenantId(getTenantId());
|
||||||
checkEntity(firmwareInfo.getId(), firmwareInfo, Resource.FIRMWARE);
|
checkEntity(firmwareInfo.getId(), firmwareInfo, Resource.FIRMWARE);
|
||||||
try {
|
FirmwareInfo savedFirmwareInfo = firmwareService.saveFirmwareInfo(firmwareInfo);
|
||||||
return firmwareService.saveFirmwareInfo(firmwareInfo);
|
logEntityAction(savedFirmwareInfo.getId(), savedFirmwareInfo,
|
||||||
|
null, created ? ActionType.ADDED : ActionType.UPDATED, null);
|
||||||
|
return savedFirmwareInfo;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logEntityAction(emptyId(EntityType.FIRMWARE), firmwareInfo,
|
||||||
|
null, created ? ActionType.ADDED : ActionType.UPDATED, e);
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,8 +149,11 @@ public class FirmwareController extends BaseController {
|
|||||||
firmware.setContentType(file.getContentType());
|
firmware.setContentType(file.getContentType());
|
||||||
firmware.setData(ByteBuffer.wrap(data));
|
firmware.setData(ByteBuffer.wrap(data));
|
||||||
firmware.setDataSize((long) data.length);
|
firmware.setDataSize((long) data.length);
|
||||||
return firmwareService.saveFirmware(firmware);
|
Firmware savedFirmware = firmwareService.saveFirmware(firmware);
|
||||||
|
logEntityAction(savedFirmware.getId(), savedFirmware, null, ActionType.UPDATED, null);
|
||||||
|
return savedFirmware;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logEntityAction(emptyId(EntityType.FIRMWARE), null, null, ActionType.UPDATED, e, strFirmwareId);
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,13 +194,15 @@ public class FirmwareController extends BaseController {
|
|||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/firmware/{firmwareId}", method = RequestMethod.DELETE)
|
@RequestMapping(value = "/firmware/{firmwareId}", method = RequestMethod.DELETE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void deleteResource(@PathVariable("firmwareId") String strFirmwareId) throws ThingsboardException {
|
public void deleteFirmware(@PathVariable("firmwareId") String strFirmwareId) throws ThingsboardException {
|
||||||
checkParameter(FIRMWARE_ID, strFirmwareId);
|
checkParameter(FIRMWARE_ID, strFirmwareId);
|
||||||
try {
|
try {
|
||||||
FirmwareId firmwareId = new FirmwareId(toUUID(strFirmwareId));
|
FirmwareId firmwareId = new FirmwareId(toUUID(strFirmwareId));
|
||||||
checkFirmwareInfoId(firmwareId, Operation.DELETE);
|
FirmwareInfo info = checkFirmwareInfoId(firmwareId, Operation.DELETE);
|
||||||
firmwareService.deleteFirmware(getTenantId(), firmwareId);
|
firmwareService.deleteFirmware(getTenantId(), firmwareId);
|
||||||
|
logEntityAction(firmwareId, info, null, ActionType.DELETED, null, strFirmwareId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logEntityAction(emptyId(EntityType.FIRMWARE), null, null, ActionType.DELETED, e, strFirmwareId);
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,8 +28,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.common.data.TbResource;
|
import org.thingsboard.server.common.data.TbResource;
|
||||||
import org.thingsboard.server.common.data.TbResourceInfo;
|
import org.thingsboard.server.common.data.TbResourceInfo;
|
||||||
|
import org.thingsboard.server.common.data.audit.ActionType;
|
||||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||||
import org.thingsboard.server.common.data.id.TbResourceId;
|
import org.thingsboard.server.common.data.id.TbResourceId;
|
||||||
import org.thingsboard.server.common.data.lwm2m.LwM2mObject;
|
import org.thingsboard.server.common.data.lwm2m.LwM2mObject;
|
||||||
@ -37,7 +39,6 @@ import org.thingsboard.server.common.data.page.PageData;
|
|||||||
import org.thingsboard.server.common.data.page.PageLink;
|
import org.thingsboard.server.common.data.page.PageLink;
|
||||||
import org.thingsboard.server.common.data.security.Authority;
|
import org.thingsboard.server.common.data.security.Authority;
|
||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.resource.TbResourceService;
|
|
||||||
import org.thingsboard.server.service.security.permission.Operation;
|
import org.thingsboard.server.service.security.permission.Operation;
|
||||||
import org.thingsboard.server.service.security.permission.Resource;
|
import org.thingsboard.server.service.security.permission.Resource;
|
||||||
|
|
||||||
@ -103,12 +104,18 @@ public class TbResourceController extends BaseController {
|
|||||||
@RequestMapping(value = "/resource", method = RequestMethod.POST)
|
@RequestMapping(value = "/resource", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TbResource saveResource(@RequestBody TbResource resource) throws ThingsboardException {
|
public TbResource saveResource(@RequestBody TbResource resource) throws ThingsboardException {
|
||||||
|
boolean created = resource.getId() == null;
|
||||||
try {
|
try {
|
||||||
resource.setTenantId(getTenantId());
|
resource.setTenantId(getTenantId());
|
||||||
checkEntity(resource.getId(), resource, Resource.TB_RESOURCE);
|
checkEntity(resource.getId(), resource, Resource.TB_RESOURCE);
|
||||||
return addResource(resource);
|
TbResource savedResource = checkNotNull(resourceService.saveResource(resource));
|
||||||
}
|
tbClusterService.onResourceChange(savedResource, null);
|
||||||
catch (Exception e) {
|
logEntityAction(savedResource.getId(), savedResource,
|
||||||
|
null, created ? ActionType.ADDED : ActionType.UPDATED, null);
|
||||||
|
return savedResource;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logEntityAction(emptyId(EntityType.TB_RESOURCE), resource,
|
||||||
|
null, created ? ActionType.ADDED : ActionType.UPDATED, e);
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,15 +179,11 @@ public class TbResourceController extends BaseController {
|
|||||||
TbResource tbResource = checkResourceId(resourceId, Operation.DELETE);
|
TbResource tbResource = checkResourceId(resourceId, Operation.DELETE);
|
||||||
resourceService.deleteResource(getTenantId(), resourceId);
|
resourceService.deleteResource(getTenantId(), resourceId);
|
||||||
tbClusterService.onResourceDeleted(tbResource, null);
|
tbClusterService.onResourceDeleted(tbResource, null);
|
||||||
|
logEntityAction(resourceId, tbResource, null, ActionType.DELETED, null, strResourceId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logEntityAction(emptyId(EntityType.TB_RESOURCE), null, null, ActionType.DELETED, e, strResourceId);
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TbResource addResource(TbResource resource) throws Exception {
|
|
||||||
checkEntity(resource.getId(), resource, Resource.TB_RESOURCE);
|
|
||||||
TbResource savedResource = checkNotNull(resourceService.saveResource(resource));
|
|
||||||
tbClusterService.onResourceChange(savedResource, null);
|
|
||||||
return savedResource;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -496,6 +496,8 @@ audit-log:
|
|||||||
"entity_view": "${AUDIT_LOG_MASK_ENTITY_VIEW:W}"
|
"entity_view": "${AUDIT_LOG_MASK_ENTITY_VIEW:W}"
|
||||||
"device_profile": "${AUDIT_LOG_MASK_DEVICE_PROFILE:W}"
|
"device_profile": "${AUDIT_LOG_MASK_DEVICE_PROFILE:W}"
|
||||||
"edge": "${AUDIT_LOG_MASK_EDGE:W}"
|
"edge": "${AUDIT_LOG_MASK_EDGE:W}"
|
||||||
|
"tb_resource": "${AUDIT_LOG_MASK_RESOURCE:W}"
|
||||||
|
"firmware": "${AUDIT_LOG_MASK_FIRMWARE:W}"
|
||||||
sink:
|
sink:
|
||||||
# Type of external sink. possible options: none, elasticsearch
|
# Type of external sink. possible options: none, elasticsearch
|
||||||
type: "${AUDIT_LOG_SINK_TYPE:none}"
|
type: "${AUDIT_LOG_SINK_TYPE:none}"
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.dao.firmware;
|
package org.thingsboard.server.dao.firmware;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import org.thingsboard.server.common.data.Firmware;
|
import org.thingsboard.server.common.data.Firmware;
|
||||||
import org.thingsboard.server.common.data.FirmwareInfo;
|
import org.thingsboard.server.common.data.FirmwareInfo;
|
||||||
import org.thingsboard.server.common.data.id.FirmwareId;
|
import org.thingsboard.server.common.data.id.FirmwareId;
|
||||||
@ -32,6 +33,8 @@ public interface FirmwareService {
|
|||||||
|
|
||||||
FirmwareInfo findFirmwareInfoById(TenantId tenantId, FirmwareId firmwareId);
|
FirmwareInfo findFirmwareInfoById(TenantId tenantId, FirmwareId firmwareId);
|
||||||
|
|
||||||
|
ListenableFuture<FirmwareInfo> findFirmwareInfoByIdAsync(TenantId tenantId, FirmwareId firmwareId);
|
||||||
|
|
||||||
PageData<FirmwareInfo> findTenantFirmwaresByTenantId(TenantId tenantId, PageLink pageLink);
|
PageData<FirmwareInfo> findTenantFirmwaresByTenantId(TenantId tenantId, PageLink pageLink);
|
||||||
|
|
||||||
PageData<FirmwareInfo> findTenantFirmwaresByTenantIdAndHasData(TenantId tenantId, boolean hasData, PageLink pageLink);
|
PageData<FirmwareInfo> findTenantFirmwaresByTenantIdAndHasData(TenantId tenantId, boolean hasData, PageLink pageLink);
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.dao.resource;
|
package org.thingsboard.server.dao.resource;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import org.thingsboard.server.common.data.ResourceType;
|
import org.thingsboard.server.common.data.ResourceType;
|
||||||
import org.thingsboard.server.common.data.TbResource;
|
import org.thingsboard.server.common.data.TbResource;
|
||||||
import org.thingsboard.server.common.data.TbResourceInfo;
|
import org.thingsboard.server.common.data.TbResourceInfo;
|
||||||
@ -34,6 +35,8 @@ public interface ResourceService {
|
|||||||
|
|
||||||
TbResourceInfo findResourceInfoById(TenantId tenantId, TbResourceId resourceId);
|
TbResourceInfo findResourceInfoById(TenantId tenantId, TbResourceId resourceId);
|
||||||
|
|
||||||
|
ListenableFuture<TbResourceInfo> findResourceInfoByIdAsync(TenantId tenantId, TbResourceId resourceId);
|
||||||
|
|
||||||
PageData<TbResourceInfo> findAllTenantResourcesByTenantId(TenantId tenantId, PageLink pageLink);
|
PageData<TbResourceInfo> findAllTenantResourcesByTenantId(TenantId tenantId, PageLink pageLink);
|
||||||
|
|
||||||
PageData<TbResourceInfo> findTenantResourcesByTenantId(TenantId tenantId, PageLink pageLink);
|
PageData<TbResourceInfo> findTenantResourcesByTenantId(TenantId tenantId, PageLink pageLink);
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.common.data;
|
package org.thingsboard.server.common.data;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -24,7 +25,7 @@ import org.thingsboard.server.common.data.id.TenantId;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class FirmwareInfo extends SearchTextBasedWithAdditionalInfo<FirmwareId> implements HasTenantId {
|
public class FirmwareInfo extends SearchTextBasedWithAdditionalInfo<FirmwareId> implements HasName, HasTenantId {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3168391583570815419L;
|
private static final long serialVersionUID = 3168391583570815419L;
|
||||||
|
|
||||||
@ -64,4 +65,10 @@ public class FirmwareInfo extends SearchTextBasedWithAdditionalInfo<FirmwareId>
|
|||||||
public String getSearchText() {
|
public String getSearchText() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String getName() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.common.data;
|
package org.thingsboard.server.common.data;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -25,7 +26,7 @@ import org.thingsboard.server.common.data.validation.NoXss;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class TbResourceInfo extends SearchTextBased<TbResourceId> implements HasTenantId {
|
public class TbResourceInfo extends SearchTextBased<TbResourceId> implements HasName, HasTenantId {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7282664529021651736L;
|
private static final long serialVersionUID = 7282664529021651736L;
|
||||||
|
|
||||||
@ -53,6 +54,12 @@ public class TbResourceInfo extends SearchTextBased<TbResourceId> implements Has
|
|||||||
this.searchText = resourceInfo.getSearchText();
|
this.searchText = resourceInfo.getSearchText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String getName() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSearchText() {
|
public String getSearchText() {
|
||||||
return searchText != null ? searchText : title;
|
return searchText != null ? searchText : title;
|
||||||
|
|||||||
@ -31,7 +31,9 @@ import org.thingsboard.server.common.data.id.DeviceId;
|
|||||||
import org.thingsboard.server.common.data.id.EdgeId;
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||||
|
import org.thingsboard.server.common.data.id.FirmwareId;
|
||||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||||
|
import org.thingsboard.server.common.data.id.TbResourceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.id.UserId;
|
import org.thingsboard.server.common.data.id.UserId;
|
||||||
import org.thingsboard.server.common.data.page.PageData;
|
import org.thingsboard.server.common.data.page.PageData;
|
||||||
@ -46,6 +48,8 @@ import org.thingsboard.server.dao.dashboard.DashboardService;
|
|||||||
import org.thingsboard.server.dao.device.DeviceService;
|
import org.thingsboard.server.dao.device.DeviceService;
|
||||||
import org.thingsboard.server.dao.entityview.EntityViewService;
|
import org.thingsboard.server.dao.entityview.EntityViewService;
|
||||||
import org.thingsboard.server.dao.exception.IncorrectParameterException;
|
import org.thingsboard.server.dao.exception.IncorrectParameterException;
|
||||||
|
import org.thingsboard.server.dao.firmware.FirmwareService;
|
||||||
|
import org.thingsboard.server.dao.resource.ResourceService;
|
||||||
import org.thingsboard.server.dao.rule.RuleChainService;
|
import org.thingsboard.server.dao.rule.RuleChainService;
|
||||||
import org.thingsboard.server.dao.tenant.TenantService;
|
import org.thingsboard.server.dao.tenant.TenantService;
|
||||||
import org.thingsboard.server.dao.user.UserService;
|
import org.thingsboard.server.dao.user.UserService;
|
||||||
@ -92,6 +96,12 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EntityQueryDao entityQueryDao;
|
private EntityQueryDao entityQueryDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceService resourceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FirmwareService firmwareService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteEntityRelations(TenantId tenantId, EntityId entityId) {
|
public void deleteEntityRelations(TenantId tenantId, EntityId entityId) {
|
||||||
super.deleteEntityRelations(tenantId, entityId);
|
super.deleteEntityRelations(tenantId, entityId);
|
||||||
@ -152,6 +162,12 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
|
|||||||
case EDGE:
|
case EDGE:
|
||||||
hasName = edgeService.findEdgeByIdAsync(tenantId, new EdgeId(entityId.getId()));
|
hasName = edgeService.findEdgeByIdAsync(tenantId, new EdgeId(entityId.getId()));
|
||||||
break;
|
break;
|
||||||
|
case TB_RESOURCE:
|
||||||
|
hasName = resourceService.findResourceInfoByIdAsync(tenantId, new TbResourceId(entityId.getId()));
|
||||||
|
break;
|
||||||
|
case FIRMWARE:
|
||||||
|
hasName = firmwareService.findFirmwareInfoByIdAsync(tenantId, new FirmwareId(entityId.getId()));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Not Implemented!");
|
throw new IllegalStateException("Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ package org.thingsboard.server.dao.firmware;
|
|||||||
|
|
||||||
import com.google.common.hash.HashFunction;
|
import com.google.common.hash.HashFunction;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.exception.ConstraintViolationException;
|
import org.hibernate.exception.ConstraintViolationException;
|
||||||
@ -115,6 +116,12 @@ public class BaseFirmwareService implements FirmwareService {
|
|||||||
return firmwareInfoDao.findById(tenantId, firmwareId.getId());
|
return firmwareInfoDao.findById(tenantId, firmwareId.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<FirmwareInfo> findFirmwareInfoByIdAsync(TenantId tenantId, FirmwareId firmwareId) {
|
||||||
|
log.trace("Executing findFirmwareInfoByIdAsync [{}]", firmwareId);
|
||||||
|
validateId(firmwareId, INCORRECT_FIRMWARE_ID + firmwareId);
|
||||||
|
return firmwareInfoDao.findByIdAsync(tenantId, firmwareId.getId()); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageData<FirmwareInfo> findTenantFirmwaresByTenantId(TenantId tenantId, PageLink pageLink) {
|
public PageData<FirmwareInfo> findTenantFirmwaresByTenantId(TenantId tenantId, PageLink pageLink) {
|
||||||
log.trace("Executing findTenantFirmwaresByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink);
|
log.trace("Executing findTenantFirmwaresByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink);
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.dao.resource;
|
package org.thingsboard.server.dao.resource;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.exception.ConstraintViolationException;
|
import org.hibernate.exception.ConstraintViolationException;
|
||||||
@ -93,6 +94,13 @@ public class BaseResourceService implements ResourceService {
|
|||||||
return resourceInfoDao.findById(tenantId, resourceId.getId());
|
return resourceInfoDao.findById(tenantId, resourceId.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<TbResourceInfo> findResourceInfoByIdAsync(TenantId tenantId, TbResourceId resourceId) {
|
||||||
|
log.trace("Executing findResourceInfoById [{}] [{}]", tenantId, resourceId);
|
||||||
|
Validator.validateId(resourceId, INCORRECT_RESOURCE_ID + resourceId);
|
||||||
|
return resourceInfoDao.findByIdAsync(tenantId, resourceId.getId());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteResource(TenantId tenantId, TbResourceId resourceId) {
|
public void deleteResource(TenantId tenantId, TbResourceId resourceId) {
|
||||||
log.trace("Executing deleteResource [{}] [{}]", tenantId, resourceId);
|
log.trace("Executing deleteResource [{}] [{}]", tenantId, resourceId);
|
||||||
|
|||||||
@ -287,6 +287,7 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
|
|||||||
[
|
[
|
||||||
EntityType.TB_RESOURCE,
|
EntityType.TB_RESOURCE,
|
||||||
{
|
{
|
||||||
|
type: 'entity.type-tb-resource',
|
||||||
details: 'resource.resource-library-details',
|
details: 'resource.resource-library-details',
|
||||||
add: 'resource.add',
|
add: 'resource.add',
|
||||||
noEntities: 'resource.no-resource-text',
|
noEntities: 'resource.no-resource-text',
|
||||||
@ -297,6 +298,7 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
|
|||||||
[
|
[
|
||||||
EntityType.FIRMWARE,
|
EntityType.FIRMWARE,
|
||||||
{
|
{
|
||||||
|
type: 'entity.type-firmware',
|
||||||
details: 'firmware.firmware-details',
|
details: 'firmware.firmware-details',
|
||||||
add: 'firmware.add',
|
add: 'firmware.add',
|
||||||
noEntities: 'firmware.no-firmware-text',
|
noEntities: 'firmware.no-firmware-text',
|
||||||
|
|||||||
@ -1493,7 +1493,9 @@
|
|||||||
"type-edge": "Edge",
|
"type-edge": "Edge",
|
||||||
"type-edges": "Edges",
|
"type-edges": "Edges",
|
||||||
"list-of-edges": "{ count, plural, 1 {One edge} other {List of # edges} }",
|
"list-of-edges": "{ count, plural, 1 {One edge} other {List of # edges} }",
|
||||||
"edge-name-starts-with": "Edges whose names start with '{{prefix}}'"
|
"edge-name-starts-with": "Edges whose names start with '{{prefix}}'",
|
||||||
|
"type-tb-resource": "Resource",
|
||||||
|
"type-firmware": "Firmware"
|
||||||
},
|
},
|
||||||
"entity-field": {
|
"entity-field": {
|
||||||
"created-time": "Created time",
|
"created-time": "Created time",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user