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

feat(rest): endpoint to update a vendor. #2606

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rudra-superrr
Copy link
Contributor

Issue: #2604

Description: endpoint to update a vendor.

@rudra-superrr rudra-superrr added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for labels Sep 10, 2024
@GMishx
Copy link
Contributor

GMishx commented Sep 11, 2024

@deo002 can you please test this PR?

@rudra-superrr rudra-superrr linked an issue Sep 12, 2024 that may be closed by this pull request
@deo002
Copy link

deo002 commented Sep 19, 2024

image
Cannot update url

@rudra-superrr
Copy link
Contributor Author

Hi @deo002 , can you try now.

@deo002
Copy link

deo002 commented Sep 19, 2024

Hi @deo002 , can you try now.

Thanks for quick response.
image
When I put null value for shortname, it gives 200 with message that Vendor has been updated successfully. When I do get request for that vendor, it is not updated. Ideally, it shouldn't be updated, but an error should be thrown instead of 200.

Signed-off-by: Rudra Chopra <prabhuchopra@gmail.com>
@deo002
Copy link

deo002 commented Sep 20, 2024

image
Issue still persists

@rudra-superrr
Copy link
Contributor Author

image Issue still persists

If user updates a single field, like shortName then the other two fields will be taken as null by default. Therefore in the above ss it will update shortname only and response will be 200 even if it says fullName is null because by default also fullName will be taken as null and it wont update the fullName field of the vendor. On the other hand if you enter a single field as null in body then it will give 400 status code because all the three fields will be considered as null.

@RequestBody Vendor vendor
) {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
if (vendor.getFullname() == null && vendor.getShortname() == null && vendor.getUrl() == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these conditions be || instead of && to prevent reading and updating null values for some fields?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs code review needs general test This is general testing, meaning that there is no org specific issue to check for
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Endpoint to update a vendor
3 participants