From 9bece3f70c15b42af375c8bd872eb560b37da00b Mon Sep 17 00:00:00 2001 From: chasegawa Date: Fri, 23 Jul 2021 16:19:11 -0700 Subject: [PATCH] SHIBUI-1997 correctting the backendreporting delete successful when it was not --- .../ui/security/controller/GroupController.java | 16 ++++++++-------- .../security/repository/UserGroupRepository.java | 2 +- .../ui/security/service/GroupServiceImpl.java | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/controller/GroupController.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/controller/GroupController.java index 9f7a2f5c9..c0fc0a8ea 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/controller/GroupController.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/controller/GroupController.java @@ -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 @@ -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); } } diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/repository/UserGroupRepository.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/repository/UserGroupRepository.java index aba60176c..3de20d7f6 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/repository/UserGroupRepository.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/repository/UserGroupRepository.java @@ -14,5 +14,5 @@ public interface UserGroupRepository extends JpaRepository findAllByUser(User user); - Optional> findAllByGroup(Group group); + List findAllByGroup(Group group); } diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java index 939cce661..c505c727a 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java @@ -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> userGroups = userGroupRepo.findAllByGroup(g); - if (userGroups.isEmpty() || !g.getEntityDescriptors().isEmpty()) { + List 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));