Skip to content

Commit

Permalink
SHIBUI-2364
Browse files Browse the repository at this point in the history
code cleanup
  • Loading branch information
chasegawa committed Sep 9, 2022
1 parent 45b880f commit 13c512b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,20 @@ public void initRestTemplate() {
@PutMapping("/EntityDescriptor/{resourceId}")
@Transactional
public ResponseEntity<?> update(@RequestBody EntityDescriptorRepresentation edRepresentation, @PathVariable String resourceId)
throws ForbiddenException, ConcurrentModificationException, PersistentEntityNotFound,
InvalidPatternMatchException {
throws ForbiddenException, ConcurrentModificationException, PersistentEntityNotFound, InvalidPatternMatchException {
edRepresentation.setId(resourceId); // This should be the same already, but just to be safe...
EntityDescriptorRepresentation result = entityDescriptorService.update(edRepresentation);
return ResponseEntity.ok().body(result);
}

@PutMapping("/EntityDescriptor/{resourceId}/changeGroup/{groupId}")
@Transactional
public ResponseEntity<?> updateGroupForEntityDescriptor(@PathVariable String resourceId, String groupId)
throws ForbiddenException, ConcurrentModificationException, PersistentEntityNotFound, InvalidPatternMatchException {
EntityDescriptorRepresentation result = entityDescriptorService.updateGroupForEntityDescriptor(resourceId, groupId);
return ResponseEntity.ok().body(result);
}

@PostMapping(value = "/EntityDescriptor", consumes = "application/xml")
@Transactional
public ResponseEntity<?> upload(@RequestBody byte[] entityDescriptorXml, @RequestParam String spName) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,6 @@ EntityDescriptorRepresentation updateEntityDescriptorEnabledStatus(String resour
EntityDescriptorRepresentation createNewEntityDescriptorFromXMLOrigin(EntityDescriptor ed);

boolean entityExists(String entityID);

EntityDescriptorRepresentation updateGroupForEntityDescriptor(String resourceId, String groupId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ public boolean entityExists(String entityID) {
return entityDescriptorRepository.findByEntityID(entityID) != null ;
}

@Override
public EntityDescriptorRepresentation updateGroupForEntityDescriptor(String resourceId, String groupId) {
EntityDescriptor ed = entityDescriptorRepository.findByResourceId(resourceId);
ed.setIdOfOwner(groupId);
EntityDescriptor savedEntity = entityDescriptorRepository.save(ed);
return createRepresentationFromDescriptor(savedEntity);
}

@Override
public EntityDescriptorRepresentation createNew(EntityDescriptorRepresentation edRep)
throws ForbiddenException, ObjectIdExistsException, InvalidPatternMatchException {
Expand Down

0 comments on commit 13c512b

Please sign in to comment.