Commit 049a6af1 authored by Raigo Ukkivi's avatar Raigo Ukkivi
Browse files

TEIS-343. Allow processing of already deleted groups in delete group service.

parent c6b5aab1
......@@ -141,11 +141,14 @@ public class OfficialsGroupService {
@Transactional
public void delete(UUID groupId, RequestMetaDTO requestMetaDTO) {
OfficialsGroupEntity group = findCurrentGroupById(groupId);
group.setObjectStatus(ObjectStatus.DELETED);
repository.save(group);
userService.removeDeletedGroupFromUsers(groupId, requestMetaDTO);
officialsGroupNotifyService.notifyUpdate(mapper.toDomainDto(group), requestMetaDTO);
OfficialsGroupEntity group = repository.findById(groupId)
.orElseThrow(() -> new TeisResourceNotFoundException(OFFICIALS_GROUP_NOT_FOUND_MESSAGE, List.of(groupId)));
if (group.getObjectStatus() == CURRENT) {
group.setObjectStatus(ObjectStatus.DELETED);
repository.save(group);
userService.removeDeletedGroupFromUsers(groupId, requestMetaDTO);
officialsGroupNotifyService.notifyUpdate(mapper.toDomainDto(group), requestMetaDTO);
}
}
public OfficialsGroupEntity findCurrentGroupById(UUID id) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment