-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix source transfer #286
Fix source transfer #286
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one request, otherwise looks great!
// set old source-type, ensures compatibility | ||
sourceDto.setSourceType(sourceToUpdate.getSourceType()); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move all this logic into SourceService
, including the call to save()
. This would make the code more re-usable, plus it would make the whole update transactional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. That was my preferred method. But the problem is mainly due to the inconsistent way of error handling. We have two ways of error handling. One is by throwing exception and have the ExceptionTranslator
to translate this into body. However, it deviates from the original method that was followed in the FrontEnd app. It expects headers with custom parameters to show proper messages to the user. So I decided to stick to responding with headers, because this action mainly involves user interaction and proper message on the front end seems essential. I didn't want to return ResponseEntity
from SourceService
either. It sounded far from SourceService
logics. So I chose this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, i thought the frontend could handle also error messages in the body, but i might be mistaken. If not we can modify the ExceptionTranslator
to set the headers, and use exceptions everywhere.
Ok let's keep it here for now and revisit the error handling later, but i would feel safer with at least the save()
being delegated to the service so it's transactional 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That is what I thought. So I will push the exceptionHandler changes too. I was thinking of doing it separately. But same PR doesn't hurt.
Save is done through SourceService
which is Transactional.
SourceDTO result = sourceService.save(sourceDto);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why we have specific annotations for some methods in classes which are Transactional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save is done through SourceService which is Transactional.
SourceDTO result = sourceService.save(sourceDto);
Sorry, of course, my bad!
I don't know why we have specific annotations for some methods in classes which are Transactional.
Indeed, the method-level annotations can go away if there is a class-level one.
Fixes #239