AI node: fixed resources validation
This commit is contained in:
parent
395f262573
commit
ad6ab9cc53
@ -1063,18 +1063,16 @@ public class DefaultTbContext implements TbContext {
|
|||||||
@Override
|
@Override
|
||||||
public void checkTenantEntity(EntityId entityId) throws TbNodeException {
|
public void checkTenantEntity(EntityId entityId) throws TbNodeException {
|
||||||
TenantId actualTenantId = TenantIdLoader.findTenantId(this, entityId);
|
TenantId actualTenantId = TenantIdLoader.findTenantId(this, entityId);
|
||||||
assertSameTenantId(actualTenantId, entityId);
|
if (!getTenantId().equals(actualTenantId)) {
|
||||||
|
throw new TbNodeException("Entity with id: '" + entityId + "' specified in the configuration doesn't belong to the current tenant.", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E extends HasId<I> & HasTenantId, I extends EntityId> void checkTenantEntity(E entity) throws TbNodeException {
|
public <E extends HasId<I> & HasTenantId, I extends EntityId> void checkTenantOrSystemEntity(E entity) throws TbNodeException {
|
||||||
TenantId actualTenantId = entity.getTenantId();
|
TenantId actualTenantId = entity.getTenantId();
|
||||||
assertSameTenantId(actualTenantId, entity.getId());
|
if (!getTenantId().equals(actualTenantId) && !actualTenantId.isSysTenantId()) {
|
||||||
}
|
throw new TbNodeException("Entity with id: '" + entity.getId() + "' specified in the configuration doesn't belong to the current or system tenant.", true);
|
||||||
|
|
||||||
private void assertSameTenantId(TenantId tenantId, EntityId entityId) throws TbNodeException {
|
|
||||||
if (!getTenantId().equals(tenantId)) {
|
|
||||||
throw new TbNodeException("Entity with id: '" + entityId + "' specified in the configuration doesn't belong to the current tenant.", true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -255,7 +255,7 @@ public interface TbContext {
|
|||||||
|
|
||||||
void checkTenantEntity(EntityId entityId) throws TbNodeException;
|
void checkTenantEntity(EntityId entityId) throws TbNodeException;
|
||||||
|
|
||||||
<E extends HasId<I> & HasTenantId, I extends EntityId> void checkTenantEntity(E entity) throws TbNodeException;
|
<E extends HasId<I> & HasTenantId, I extends EntityId> void checkTenantOrSystemEntity(E entity) throws TbNodeException;
|
||||||
|
|
||||||
boolean isLocalEntity(EntityId entityId);
|
boolean isLocalEntity(EntityId entityId);
|
||||||
|
|
||||||
|
|||||||
@ -261,7 +261,7 @@ public final class TbAiNode extends TbAbstractExternalNode implements TbNode {
|
|||||||
if (!ResourceType.GENERAL.equals(resource.getResourceType())) {
|
if (!ResourceType.GENERAL.equals(resource.getResourceType())) {
|
||||||
throw new TbNodeException("[" + ctx.getTenantId() + "] Resource with ID: [" + tbResourceId + "] has unsupported resource type: " + resource.getResourceType(), true);
|
throw new TbNodeException("[" + ctx.getTenantId() + "] Resource with ID: [" + tbResourceId + "] has unsupported resource type: " + resource.getResourceType(), true);
|
||||||
}
|
}
|
||||||
ctx.checkTenantEntity(resource);
|
ctx.checkTenantOrSystemEntity(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListenableFuture<List<TbResourceDataInfo>> loadResources(TbContext ctx) {
|
private ListenableFuture<List<TbResourceDataInfo>> loadResources(TbContext ctx) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user