From 3c3890e8f5a4cd7ec7b3e601949d785dd6ff4cb3 Mon Sep 17 00:00:00 2001 From: chasegawa Date: Mon, 13 Sep 2021 14:20:34 -0700 Subject: [PATCH] SHIBUI-2063 intermediate commit --- .../admin/ui/controller/AttributeBundleController.java | 6 ++++++ .../admin/ui/service/AttributeBundleService.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java index a9ac9160a..1dbe5e026 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java @@ -50,6 +50,12 @@ public ResponseEntity getAll() { return ResponseEntity.ok(attributeBundleService.findAll()); } + @GetMapping("/{resourceId}") + @Transactional(readOnly = true) + public ResponseEntity getOne(@PathVariable String resourceId) throws EntityNotFoundException { + return ResponseEntity.ok(attributeBundleService.findByResourceId(resourceId)); + } + @Secured("ROLE_ADMIN") @PutMapping @Transactional diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/AttributeBundleService.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/AttributeBundleService.java index f246c7d1b..916ea99b2 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/AttributeBundleService.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/AttributeBundleService.java @@ -43,4 +43,12 @@ public AttributeBundle updateBundle(AttributeBundle bundle) throws EntityNotFoun bundleToUpdate.setAttributes(bundle.getAttributes()); return attributeBundleRepository.save(bundleToUpdate); } + + public AttributeBundle findByResourceId(String resourceId) throws EntityNotFoundException { + Optional result = attributeBundleRepository.findByResourceId(resourceId); + if (result.isEmpty()) { + throw new EntityNotFoundException(String.format("Unable to find attribute bundle with resource id: [%s] for deletion", resourceId)); + } + return result.get(); + } } \ No newline at end of file