@WithMockUser(username = USERNAME) @Test void add() { String entityTypeId = "entityTypeId"; EntityType entityType = mock(EntityType.class); Package pack = mock(Package.class); MutableAcl mutableAcl = mock(MutableAcl.class); Acl acl = mock(Acl.class); when(pack.getId()).thenReturn("test"); when(entityType.getId()).thenReturn(entityTypeId); when(entityType.getPackage()).thenReturn(pack); when(userPermissionEvaluator.hasPermission( new PackageIdentity("test"), PackagePermission.ADD_ENTITY_TYPE)) .thenReturn(true); when(mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId()))) .thenReturn(mutableAcl); when(mutableAclService.readAclById(new PackageIdentity("test"))).thenReturn(acl); repo.add(entityType); verify(delegateRepository).add(entityType); verify(mutableAclService).createAcl(new EntityTypeIdentity(entityTypeId)); }
@Override public void createAcl(EntityType entityType) { MutableAcl acl; try { acl = mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId())); } catch (AlreadyExistsException e) { throw new EntityAlreadyExistsException(entityType, e); } Package pack = entityType.getPackage(); if (pack != null) { ObjectIdentity objectIdentity = new PackageIdentity(pack); acl.setParent(mutableAclService.readAclById(objectIdentity)); mutableAclService.updateAcl(acl); } }
EntityTypeRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<EntityType> { @Override public void createAcl(EntityType entityType) { MutableAcl acl; try { acl = mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId())); } catch (AlreadyExistsException e) { throw new EntityAlreadyExistsException(entityType, e); } Package pack = entityType.getPackage(); if (pack != null) { ObjectIdentity objectIdentity = new PackageIdentity(pack); acl.setParent(mutableAclService.readAclById(objectIdentity)); mutableAclService.updateAcl(acl); } } }
EntityTypeRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<EntityType> { @Override public void createAcl(EntityType entityType) { MutableAcl acl; try { acl = mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId())); } catch (AlreadyExistsException e) { throw new EntityAlreadyExistsException(entityType, e); } Package pack = entityType.getPackage(); if (pack != null) { ObjectIdentity objectIdentity = new PackageIdentity(pack); acl.setParent(mutableAclService.readAclById(objectIdentity)); mutableAclService.updateAcl(acl); } } EntityTypeRepositorySecurityDecorator(
      Repository<EntityType> delegateRepository,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      UserPermissionEvaluator userPermissionEvaluator,
      MutableAclService mutableAclService,
      MutableAclClassService mutableAclClassService,
      DataService dataService); }
EntityTypeRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<EntityType> { @Override public void createAcl(EntityType entityType) { MutableAcl acl; try { acl = mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId())); } catch (AlreadyExistsException e) { throw new EntityAlreadyExistsException(entityType, e); } Package pack = entityType.getPackage(); if (pack != null) { ObjectIdentity objectIdentity = new PackageIdentity(pack); acl.setParent(mutableAclService.readAclById(objectIdentity)); mutableAclService.updateAcl(acl); } } EntityTypeRepositorySecurityDecorator(
      Repository<EntityType> delegateRepository,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      UserPermissionEvaluator userPermissionEvaluator,
      MutableAclService mutableAclService,
      MutableAclClassService mutableAclClassService,
      DataService dataService); @Override boolean isActionPermitted(EntityType entityType, Action action); @Override boolean isActionPermitted(Object id, Action action); @Override void createAcl(EntityType entityType); @Override void deleteAcl(EntityType entityType); @Override void deleteAcl(Object entityTypeId); @Override void updateAcl(EntityType entityType); @Override void throwPermissionException(EntityType entityType, Action action); }
EntityTypeRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<EntityType> { @Override public void createAcl(EntityType entityType) { MutableAcl acl; try { acl = mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId())); } catch (AlreadyExistsException e) { throw new EntityAlreadyExistsException(entityType, e); } Package pack = entityType.getPackage(); if (pack != null) { ObjectIdentity objectIdentity = new PackageIdentity(pack); acl.setParent(mutableAclService.readAclById(objectIdentity)); mutableAclService.updateAcl(acl); } } EntityTypeRepositorySecurityDecorator(
      Repository<EntityType> delegateRepository,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      UserPermissionEvaluator userPermissionEvaluator,
      MutableAclService mutableAclService,
      MutableAclClassService mutableAclClassService,
      DataService dataService); @Override boolean isActionPermitted(EntityType entityType, Action action); @Override boolean isActionPermitted(Object id, Action action); @Override void createAcl(EntityType entityType); @Override void deleteAcl(EntityType entityType); @Override void deleteAcl(Object entityTypeId); @Override void updateAcl(EntityType entityType); @Override void throwPermissionException(EntityType entityType, Action action);  }