Skip to content

Commit

Permalink
SHIBUI-1997
Browse files Browse the repository at this point in the history
correctting the backendreporting delete successful when it was not
  • Loading branch information
chasegawa committed Jul 23, 2021
1 parent 6ee29be commit 9bece3f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public ResponseEntity<?> create(@RequestBody Group group) throws GroupExistsConf
}

@Secured("ROLE_ADMIN")
@PutMapping
@DeleteMapping("/{resourceId}")
@Transactional
public ResponseEntity<?> update(@RequestBody Group group) throws EntityNotFoundException {
Group result = groupService.updateGroup(group);
return ResponseEntity.ok(result);
public ResponseEntity<?> delete(@PathVariable String resourceId) throws EntityNotFoundException, GroupDeleteException {
groupService.deleteDefinition(resourceId);
return ResponseEntity.noContent().build();
}

@GetMapping
Expand All @@ -62,10 +62,10 @@ public ResponseEntity<?> getOne(@PathVariable String resourceId) throws EntityNo
}

@Secured("ROLE_ADMIN")
@DeleteMapping("/{resourceId}")
@PutMapping
@Transactional
public ResponseEntity<?> delete(@PathVariable String resourceId) throws EntityNotFoundException, GroupDeleteException {
groupService.deleteDefinition(resourceId);
return ResponseEntity.noContent().build();
public ResponseEntity<?> update(@RequestBody Group group) throws EntityNotFoundException {
Group result = groupService.updateGroup(group);
return ResponseEntity.ok(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public interface UserGroupRepository extends JpaRepository<UserGroup, UserGroupK

List<UserGroup> findAllByUser(User user);

Optional<List<UserGroup>> findAllByGroup(Group group);
List<UserGroup> findAllByGroup(Group group);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public Group createGroup(Group group) throws GroupExistsConflictException {
@Transactional
public void deleteDefinition(String resourceId) throws EntityNotFoundException, GroupDeleteException {
Group g = find(resourceId);
Optional<List<UserGroup>> userGroups = userGroupRepo.findAllByGroup(g);
if (userGroups.isEmpty() || !g.getEntityDescriptors().isEmpty()) {
List<UserGroup> userGroups = userGroupRepo.findAllByGroup(g);
if (!userGroups.isEmpty() || !g.getEntityDescriptors().isEmpty()) {
throw new GroupDeleteException(String.format(
"Unable to delete group with resource id: [%s] - remove all users and entities from group first",
resourceId));
Expand Down

0 comments on commit 9bece3f

Please sign in to comment.