@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 Component updateComponent(Component existing, ComponentDTO dto) { ComponentMapper.copyDTOtoDomain(dto, existing); return componentRepository.save(existing); }