use of io.jmix.core.impl.serialization.EntityTokenException in project jmix by jmix-framework.
the class EntityImportExportImpl method assertToken.
protected void assertToken(Object entity, FetchPlan fetchPlan) {
if (coreProperties.isEntitySerializationTokenRequired()) {
SecurityState securityState = EntitySystemAccess.getSecurityState(entity);
if (securityState.getRestoreState() == SecurityState.RestoreState.RESTORED_FROM_NULL_TOKEN) {
MetaClass metaClass = metadata.getClass(entity.getClass());
for (MetaProperty metaProperty : metaClass.getProperties()) {
if (metaProperty.getRange().isClass() && metadataTools.isJpa(metaProperty) && fetchPlan.containsProperty(metaProperty.getName())) {
InMemoryCrudEntityContext inMemoryContext = new InMemoryCrudEntityContext(metaProperty.getRange().asClass(), applicationContext);
accessManager.applyRegisteredConstraints(inMemoryContext);
if (inMemoryContext.readPredicate() != null) {
throw new EntityTokenException(format("Could not read export/import token from entity %s.", entity));
}
}
}
}
}
}
Aggregations