Conversation
c74dd84 to
4088d20
Compare
| return HttpResponse.ok(response); | ||
| try { | ||
| List<SharedProgram> sharedPrograms = ontologyService.getSharedOntology(programId, shared); | ||
| List<org.breedinginsight.api.model.v1.response.metadata.Status> metadataStatus = new ArrayList<>(); |
There was a problem hiding this comment.
I think you can reduce the generic in List to just List<Status>
| Response<DataResponse<SharedProgram>> response = new Response(metadata, new DataResponse<>(sharedPrograms)); | ||
| return HttpResponse.ok(response); | ||
| try { | ||
| List<SharedProgram> sharedPrograms = ontologyService.getSharedOntology(programId, shared); |
There was a problem hiding this comment.
Could the name of both the class and this variable be changed to SharedOntology? SharedProgram doesn't make as much sense to me.
| ontologyService.unsubscribeOntology(programId, sharingProgramId); | ||
| return HttpResponse.ok(); | ||
| } catch (UnprocessableEntityException e) { | ||
| return HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage()); |
There was a problem hiding this comment.
Can you add an error log statement, please?
| SubscribedProgram shareRequest = ontologyService.subscribeOntology(programId, sharingProgramId); | ||
| Response<SubscribedProgram> response = new Response(shareRequest); | ||
| return HttpResponse.ok(response); | ||
| } catch (UnprocessableEntityException e) { |
There was a problem hiding this comment.
Can you add an error log statement, please?
|
|
||
| import javax.inject.Inject; | ||
| import javax.inject.Singleton; | ||
| import javax.swing.text.html.Option; |
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class SubscribedProgram { |
There was a problem hiding this comment.
Can this change to SubscribedOntology?
| // Check that shared program exists | ||
| Optional<ProgramSharedOntologyEntity> optionalSharedOntology = programOntologyDAO.getSharedOntologyById(sharingProgramId, programId); | ||
| if (optionalSharedOntology.isEmpty()) { | ||
| throw new DoesNotExistException("Shared ontology between specified programs was not found."); |
There was a problem hiding this comment.
Thoughts on this throwing more of an illegal state type of exception?
There was a problem hiding this comment.
Let's talk more about this over a slack huddle if that works for you? Did you have a specific status in mind? The only other one I can think of is UnprocessableEntityException but the DoesNotExistException seems to fit better since the user is requesting a specific resource and it doesn't exist.
The other UnprocessableEntityException errors are thrown when the shared record is found, but there is something else that is preventing the action.
There was a problem hiding this comment.
Talked with Chris, and I'm fine for it to stay as is
| // Check that shared program exists | ||
| Optional<ProgramSharedOntologyEntity> optionalSharedOntology = programOntologyDAO.getSharedOntologyById(sharingProgramId, programId); | ||
| if (optionalSharedOntology.isEmpty()) { | ||
| throw new DoesNotExistException("Shared ontology between specified programs was not found."); |
There was a problem hiding this comment.
Same as above...thoughts on this throwing some sort of illegal state type of exception?
| HttpResponse response = HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY).body(e.getErrors()); | ||
| return response; | ||
| } catch (UnprocessableEntityException e) { | ||
| log.error(e.getMessage()); |
There was a problem hiding this comment.
Sorry to be a pain, but for these error messages, can you change this to log.error(e.getMessage(), e);, please? That way the error stack gets printed to the logs too.
There was a problem hiding this comment.
Thanks for catching that! Added.
664ed2f to
dae5604
Compare
Description
Story: https://breedinginsight.atlassian.net/jira/software/c/projects/BI/boards/1?modal=detail&selectedIssue=BI-1366
Adds
subscribeendpoints to the backendOntologyController. See bi-web for the different check conditions.Includes tests for all scenarios.
Dependencies
biweb: BI-1366
Testing
See biweb.
Checklist: