@Test void checkPermissionsThrowsException() { Exception exception = assertThrows( EntityTypePermissionDeniedException.class, () -> this.staticContentService.checkPermissions("home")); assertThat(exception.getMessage()) .containsPattern("permission:UPDATE_DATA entityTypeId:sys_StaticContent"); }
public void checkPermissions(String pluginId) { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, pluginId, StaticContent.class); if (staticContent == null) { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), UPDATE_DATA)) { throw new EntityTypePermissionDeniedException(UPDATE_DATA, STATIC_CONTENT); } } else { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), ADD_DATA)) { throw new EntityTypePermissionDeniedException(ADD_DATA, STATIC_CONTENT); } } }
StaticContentServiceImpl implements StaticContentService { public void checkPermissions(String pluginId) { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, pluginId, StaticContent.class); if (staticContent == null) { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), UPDATE_DATA)) { throw new EntityTypePermissionDeniedException(UPDATE_DATA, STATIC_CONTENT); } } else { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), ADD_DATA)) { throw new EntityTypePermissionDeniedException(ADD_DATA, STATIC_CONTENT); } } } }
StaticContentServiceImpl implements StaticContentService { public void checkPermissions(String pluginId) { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, pluginId, StaticContent.class); if (staticContent == null) { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), UPDATE_DATA)) { throw new EntityTypePermissionDeniedException(UPDATE_DATA, STATIC_CONTENT); } } else { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), ADD_DATA)) { throw new EntityTypePermissionDeniedException(ADD_DATA, STATIC_CONTENT); } } } StaticContentServiceImpl(
      DataService dataService,
      StaticContentFactory staticContentFactory,
      UserPermissionEvaluator permissionService); }
StaticContentServiceImpl implements StaticContentService { public void checkPermissions(String pluginId) { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, pluginId, StaticContent.class); if (staticContent == null) { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), UPDATE_DATA)) { throw new EntityTypePermissionDeniedException(UPDATE_DATA, STATIC_CONTENT); } } else { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), ADD_DATA)) { throw new EntityTypePermissionDeniedException(ADD_DATA, STATIC_CONTENT); } } } StaticContentServiceImpl(
      DataService dataService,
      StaticContentFactory staticContentFactory,
      UserPermissionEvaluator permissionService); @Override @Transactional boolean submitContent(String key, String content); @Transactional(readOnly = true) @Override boolean isCurrentUserCanEdit(String pluginId); @Transactional(readOnly = true) @Override String getContent(String key); void checkPermissions(String pluginId); }
StaticContentServiceImpl implements StaticContentService { public void checkPermissions(String pluginId) { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, pluginId, StaticContent.class); if (staticContent == null) { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), UPDATE_DATA)) { throw new EntityTypePermissionDeniedException(UPDATE_DATA, STATIC_CONTENT); } } else { if (!permissionService.hasPermission(new EntityTypeIdentity(STATIC_CONTENT), ADD_DATA)) { throw new EntityTypePermissionDeniedException(ADD_DATA, STATIC_CONTENT); } } } StaticContentServiceImpl(
      DataService dataService,
      StaticContentFactory staticContentFactory,
      UserPermissionEvaluator permissionService); @Override @Transactional boolean submitContent(String key, String content); @Transactional(readOnly = true) @Override boolean isCurrentUserCanEdit(String pluginId); @Transactional(readOnly = true) @Override String getContent(String key); void checkPermissions(String pluginId);  }