-
Notifications
You must be signed in to change notification settings - Fork 98
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): Create new endpoint to download component template, attachment template, attachment information and release link sample in csv format. #2278
base: main
Are you sure you want to change the base?
Conversation
043523c
to
b363166
Compare
b363166
to
2bbf922
Compare
2bbf922
to
2ef2fe8
Compare
2ef2fe8
to
8fa91d9
Compare
8fa91d9
to
5ba7349
Compare
@rudra-superrr , Rest Docs issue resolved. |
@rudra-superrr , Already endpoint is there for Download license archive(under Admin tab -> license). |
Testing was successful and please look into Download Component CSV export button. |
0a3c8fe
to
30d42c9
Compare
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.
@nikkuma7 Please do update the review changes
} | ||
) | ||
@PreAuthorize("hasAuthority('WRITE')") | ||
@RequestMapping(value = IMPORTEXPORT_URL + "/downloadComponentTemplate", method = RequestMethod.GET) |
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.
Try to use specific variant like @GetMapping instead of generic representation of @RequestMapping in all the places.
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.
Exception need to be handled in all the places!
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.
Exception need to be handled in all the places!
public void getDownloadCsvComponentTemplate(User sw360User, HttpServletResponse response) throws TException, IOException { | ||
String fileConstant="ComponentsReleasesVendorsSample.csv"; | ||
if (!PermissionUtils.isUserAtLeast(UserGroup.ADMIN, sw360User)) { | ||
throw new RuntimeException("Unable to download CSV component template. User is not admin"); |
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.
throw a dedicated exception instead of using a generic one.
public void getDownloadAttachmentTemplate(User sw360User, HttpServletResponse response) throws TException, IOException { | ||
String fileConstant="AttachmentInfo_Sample.csv"; | ||
if (!PermissionUtils.isUserAtLeast(UserGroup.ADMIN, sw360User)) { | ||
throw new RuntimeException("Unable to download CSV attachment template. User is not admin"); |
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.
throw a dedicated exception instead of using a generic one
} | ||
|
||
public void getComponentDetailedExport(User sw360User, HttpServletResponse response) | ||
throws TException, IOException { |
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.
Remove the declaration of thrown exception 'TException', as it cannot be thrown from method's body.
|
||
} | ||
|
||
public void getDownloadAttachmentInfo(User sw360User, HttpServletResponse response) throws TException, IOException { |
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.
Remove unused throw exceptions.
} | ||
|
||
private Iface getThriftComponentClient() { | ||
ComponentService.Iface componentClient = new ThriftClients().makeComponentClient(); |
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.
Immediately return this expression instead of assigning it to the temporary variable "componentClient".
componentDetailedSummaryForExport = componentClient.getComponentDetailedSummaryForExport(); | ||
} catch (TException e) { | ||
log.error("Problem fetching components", e); | ||
return null; |
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.
Instead of null return, maybe its better to return emptyCollections.
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.
Please check the documentation once with latest main branch.
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.
@keerthi-bl , comment Addressed.
30d42c9
to
975e35e
Compare
c6e98f2
to
cb10ce4
Compare
… format. Signed-off-by: Nikesh kumar <kumar.nikesh@simens.com>
cb10ce4
to
d2de22f
Compare
Issue: #2277
Suggest Reviewer
How To Test?
http://localhost:8080/resource/api/importExport/downloadComponentTemplate
http://localhost:8080/resource/api/importExport/downloadAttachmentSample
http://localhost:8080/resource/api/importExport/downloadAttachmentInfo
http://localhost:8080/resource/api/importExport/downloadReleaseSample
Note : user should have admin access.
Checklist
Must: