use of com.icthh.xm.ms.entity.config.XmEntityTenantConfigService.XmEntityTenantConfig in project xm-ms-entity by xm-online.
the class XmEntitySpecServiceUnitTest method disableDynamicPrivilegesGeneration.
private void disableDynamicPrivilegesGeneration() {
XmEntityTenantConfig config = new XmEntityTenantConfig();
config.setDisableDynamicPrivilegesGeneration(true);
when(tenantConfig.getXmEntityTenantConfig("TEST")).thenReturn(config);
}
use of com.icthh.xm.ms.entity.config.XmEntityTenantConfigService.XmEntityTenantConfig in project xm-ms-entity by xm-online.
the class XmEntitySpecServiceUnitTest method enableDynamicPermissionCheck.
private void enableDynamicPermissionCheck() {
XmEntityTenantConfig config = new XmEntityTenantConfig();
when(tenantConfig.getXmEntityTenantConfig("TEST")).thenReturn(config);
config.getEntityFunctions().setDynamicPermissionCheckEnabled(true);
}
use of com.icthh.xm.ms.entity.config.XmEntityTenantConfigService.XmEntityTenantConfig in project xm-ms-entity by xm-online.
the class FunctionServiceImplUnitTest method setUp.
@Before
public void setUp() {
xmEntitySpecService = Mockito.mock(XmEntitySpecService.class);
xmEntityService = Mockito.mock(XmEntityService.class);
functionExecutorService = Mockito.mock(FunctionExecutorService.class);
functionContextService = Mockito.mock(FunctionContextService.class);
dynamicPermissionCheckService = Mockito.mock(DynamicPermissionCheckService.class);
xmEntityTenantConfigService = Mockito.mock(XmEntityTenantConfigService.class);
jsonValidationService = spy(new JsonValidationService(new ObjectMapper()));
functionService = new FunctionServiceImpl(xmEntitySpecService, xmEntityService, functionExecutorService, functionContextService, dynamicPermissionCheckService, jsonValidationService, xmEntityTenantConfigService);
xmEntityTenantConfig = new XmEntityTenantConfig();
when(xmEntityTenantConfigService.getXmEntityTenantConfig()).thenReturn(xmEntityTenantConfig);
}
use of com.icthh.xm.ms.entity.config.XmEntityTenantConfigService.XmEntityTenantConfig in project xm-ms-entity by xm-online.
the class XmEntitySpecService method extendDataSpec.
@SneakyThrows
private void extendDataSpec(TypeSpec type, TypeSpec parentType, String tenant) {
XmEntityTenantConfig entityTenantConfig = this.tenantConfigService.getXmEntityTenantConfig(tenant);
Boolean isInheritanceEnabled = entityTenantConfig.getEntitySpec().getEnableDataSpecInheritance();
if (isFeatureEnabled(isInheritanceEnabled, type.getDataSpecInheritance()) && hasDataSpec(type, parentType)) {
ObjectMapper objectMapper = new ObjectMapper();
var target = objectMapper.readValue(type.getDataSpec(), Map.class);
var parent = objectMapper.readValue(parentType.getDataSpec(), Map.class);
if (parent.containsKey("additionalProperties")) {
parent.put("additionalProperties", true);
}
target.put(XM_ENTITY_DEFINITION, Map.of(parentType.getKey(), parent));
target.put("$ref", "#/" + XM_ENTITY_DEFINITION + "/" + parentType.getKey());
String mergedJson = objectMapper.writeValueAsString(target);
type.setDataSpec(mergedJson);
} else {
type.setDataSpec(type.getDataSpec() != null ? type.getDataSpec() : parentType.getDataSpec());
}
}
use of com.icthh.xm.ms.entity.config.XmEntityTenantConfigService.XmEntityTenantConfig in project xm-ms-entity by xm-online.
the class EntityCustomPrivilegeService method onEntitySpecUpdate.
@IgnoreLogginAspect
@Override
public void onEntitySpecUpdate(Map<String, TypeSpec> specs, String tenantKey) {
XmEntityTenantConfig xmEntityTenantConfig = tenantConfigService.getXmEntityTenantConfig(tenantKey);
Boolean disableDynamicPrivilegesGeneration = xmEntityTenantConfig.getDisableDynamicPrivilegesGeneration();
if (Boolean.TRUE.equals(disableDynamicPrivilegesGeneration)) {
log.warn("Dynamic privilege generation disabled.");
return;
}
String privilegesPath = resolvePathWithTenant(tenantKey, CUSTOMER_PRIVILEGES_PATH);
log.info("Get config from {}", privilegesPath);
List<String> paths = asList(privilegesPath);
Map<String, Configuration> configs = commonConfigRepository.getConfig(null, paths);
configs = configs == null ? new HashMap<>() : configs;
updateCustomPrivileges(specs, privilegesPath, configs.get(privilegesPath), tenantKey);
}
Aggregations