private void createAcl(Plugin plugin) { try { mutableAclService.createAcl(new PluginIdentity(plugin.getId())); } catch (AlreadyExistsException e) { throw new EntityAlreadyExistsException(plugin, e); } }
/** * {@inheritDoc} */ public ExtendedMutableAcl getAclFor(ObjectIdentity oid) { try { return ExtendedMutableAcl.castAndCreate(mutableAclService.readAclById(oid)); } catch (NotFoundException nfe) { return ExtendedMutableAcl.castAndCreate(mutableAclService.createAcl(oid)); } }
@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); } } }
acl = (MutableAcl) aclService.readAclById(identity); } catch (NotFoundException ex) { acl = aclService.createAcl(identity);