Forbid changes to 'TbServiceQueue' asset profile.
This commit is contained in:
parent
012c8e91de
commit
0717a56a69
@ -22,6 +22,7 @@ import org.thingsboard.server.common.data.EntityType;
|
|||||||
import org.thingsboard.server.common.data.User;
|
import org.thingsboard.server.common.data.User;
|
||||||
import org.thingsboard.server.common.data.asset.AssetProfile;
|
import org.thingsboard.server.common.data.asset.AssetProfile;
|
||||||
import org.thingsboard.server.common.data.audit.ActionType;
|
import org.thingsboard.server.common.data.audit.ActionType;
|
||||||
|
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
|
||||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||||
import org.thingsboard.server.common.data.id.AssetProfileId;
|
import org.thingsboard.server.common.data.id.AssetProfileId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -30,6 +31,8 @@ import org.thingsboard.server.dao.asset.AssetProfileService;
|
|||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.entitiy.AbstractTbEntityService;
|
import org.thingsboard.server.service.entitiy.AbstractTbEntityService;
|
||||||
|
|
||||||
|
import static org.thingsboard.server.dao.asset.BaseAssetService.TB_SERVICE_QUEUE;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@TbCoreComponent
|
@TbCoreComponent
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -43,6 +46,14 @@ public class DefaultTbAssetProfileService extends AbstractTbEntityService implem
|
|||||||
ActionType actionType = assetProfile.getId() == null ? ActionType.ADDED : ActionType.UPDATED;
|
ActionType actionType = assetProfile.getId() == null ? ActionType.ADDED : ActionType.UPDATED;
|
||||||
TenantId tenantId = assetProfile.getTenantId();
|
TenantId tenantId = assetProfile.getTenantId();
|
||||||
try {
|
try {
|
||||||
|
if (TB_SERVICE_QUEUE.equals(assetProfile.getName())) {
|
||||||
|
throw new ThingsboardException("Unable to save asset profile with name " + TB_SERVICE_QUEUE, ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||||
|
} else if (assetProfile.getId() != null) {
|
||||||
|
AssetProfile foundAssetProfile = assetProfileService.findAssetProfileById(tenantId, assetProfile.getId());
|
||||||
|
if (foundAssetProfile != null && TB_SERVICE_QUEUE.equals(foundAssetProfile.getName())) {
|
||||||
|
throw new ThingsboardException("Updating asset profile with name " + TB_SERVICE_QUEUE + " is prohibited!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||||
|
}
|
||||||
|
}
|
||||||
AssetProfile savedAssetProfile = checkNotNull(assetProfileService.saveAssetProfile(assetProfile));
|
AssetProfile savedAssetProfile = checkNotNull(assetProfileService.saveAssetProfile(assetProfile));
|
||||||
autoCommit(user, savedAssetProfile.getId());
|
autoCommit(user, savedAssetProfile.getId());
|
||||||
tbClusterService.broadcastEntityStateChangeEvent(tenantId, savedAssetProfile.getId(),
|
tbClusterService.broadcastEntityStateChangeEvent(tenantId, savedAssetProfile.getId(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user