private List<EntityTypeRlsResponse> getEntityTypeDtos() { List<EntityType> entityTypes = getEntityTypes().filter(entityType -> !entityType.isAbstract()).collect(toList()); Collection<String> aclClasses = mutableAclClassService.getAclClassTypes(); entityTypes.sort(comparing(EntityType::getLabel)); return entityTypes .stream() .map( entityType -> { boolean rlsEnabled = aclClasses.contains(EntityIdentityUtils.toType(entityType)); boolean readOnly = systemEntityTypeRegistry.hasSystemEntityType(entityType.getId()); return new EntityTypeRlsResponse( entityType.getId(), entityType.getLabel(), rlsEnabled, readOnly); }) .collect(toList()); }
public void bootstrap() { LOGGER.trace("Failing JobExecutions that were left running..."); systemEntityTypeRegistry .getSystemEntityTypes() .filter(this::isJobExecution) .forEach(this::bootstrap); LOGGER.debug("Failed JobExecutions that were left running."); LOGGER.trace("Scheduling ScheduledJobs..."); jobScheduler.scheduleJobs(); LOGGER.debug("Scheduled ScheduledJobs."); LOGGER.trace("Upserting ScheduledJobTypes..."); upsertScheduledJobTypes(); LOGGER.debug("Upserted ScheduledJobTypes."); }
@PreAuthorize("hasAnyRole('ROLE_SU')") @Transactional @PostMapping("/update/entityclass/rls") @ResponseStatus(HttpStatus.OK) public void updateEntityClassRls(@Valid @RequestBody EntityTypeRlsRequest entityTypeRlsRequest) { String entityTypeId = entityTypeRlsRequest.getId(); if (systemEntityTypeRegistry.hasSystemEntityType(entityTypeId)) { throw new IllegalArgumentException("Updating system entity type not allowed"); } EntityType entityType = dataService.getEntityType(entityTypeId); String aclClassType = EntityIdentityUtils.toType(entityType); boolean hasAclClass = mutableAclClassService.hasAclClass(aclClassType); if (entityTypeRlsRequest.isRlsEnabled()) { if (!hasAclClass) { mutableAclClassService.createAclClass( aclClassType, EntityIdentityUtils.toIdType(entityType)); dataService .findAll(entityType.getId()) .forEach(entity -> mutableAclService.createAcl(new EntityIdentity(entity))); } } else { if (hasAclClass) { mutableAclClassService.deleteAclClass(aclClassType); } } }
/** * Validate that non-system entities are not assigned to a system package * * @param entityType entity type */ void validatePackage(EntityType entityType) { Package pack = entityType.getPackage(); if (pack != null && isSystemPackage(pack) && !systemEntityTypeRegistry.hasSystemEntityType(entityType.getId())) { throw new MolgenisValidationException( new ConstraintViolation( format( "Adding entity [%s] to system package [%s] is not allowed", entityType.getId(), entityType.getPackage().getId()))); } } }