Skip to content
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

Merged
merged 3 commits into from
Jul 13, 2018
Merged

Fix source transfer #286

merged 3 commits into from
Jul 13, 2018

Conversation

nivemaham
Copy link
Collaborator

@nivemaham nivemaham commented Jul 12, 2018

  • Adds validation for source update and source transfer occasions.
  • A source cannot be transfered to another project if it is assigned
  • A source cannot be transfered to a project which doesn't have compatible source-type.

Fixes #239

Copy link
Contributor

@dennyverbeeck dennyverbeeck left a 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());

}
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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 😄

Copy link
Collaborator Author

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);

Copy link
Collaborator Author

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.

Copy link
Contributor

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.

@nivemaham nivemaham merged commit 2c7de29 into dev Jul 13, 2018
@nivemaham nivemaham mentioned this pull request Jul 17, 2018
@nivemaham nivemaham deleted the fix-source-transfer branch July 31, 2018 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants