@PostAuthorize( "hasRole('ROLE_ADMIN') || returnObject == null || returnObject.userId == principal.id") public Component createComponent(ComponentDTO dto) { Component component = new Component(); component.setUserId(SecurityHelper.getCurrentUserId()); ComponentMapper.copyDTOtoDomain(dto, component); return componentRepository.save(component); }
@PreAuthorize("hasRole('ROLE_ADMIN') || #existing.userId == principal.id") public void deleteComponent(Component component) { componentRepository.delete(component); }
@PreAuthorize("hasRole('ROLE_ADMIN') || #existing.userId == principal.id") public Component updateComponent(Component existing, ComponentDTO dto) { ComponentMapper.copyDTOtoDomain(dto, existing); return componentRepository.save(existing); }
@PostAuthorize( "hasRole('ROLE_ADMIN') || returnObject == null || returnObject.userId == principal.id") public Component getComponentById(Integer id) { return componentRepository.findOne(id); }
@PostFilter("hasRole('ROLE_ADMIN') || filterObject.userId == principal.id") public Iterable<Component> getComponentByType(ComponentType type) { Iterable<Component> components = componentRepository.findComponentByType(type); return components; }
@PostFilter("hasRole('ROLE_ADMIN') || filterObject.userId == principal.id") public Iterable<Component> getAllComponents() { Iterable<Component> components = componentRepository.findAll(); return components; }