Skip to content

Commit

Permalink
EPMRPP-81154 added xml to api description and added file size check (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rkukharenka authored Feb 27, 2023
1 parent 6b6d953 commit 7009281
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

@Service
public class ImportLaunchHandlerImpl implements ImportLaunchHandler {
private static final int MAX_FILE_SIZE = 32 * 1024 * 1024;

private ImportStrategyFactory importStrategyFactory;
private MessageBus messageBus;

Expand Down Expand Up @@ -81,6 +83,7 @@ private void validate(MultipartFile file) {
expect(file.getOriginalFilename(), it -> it.endsWith(ZIP_EXTENSION) || it.endsWith(XML_EXTENSION)).verify(INCORRECT_REQUEST,
"Should be a zip archive or an xml file " + file.getOriginalFilename()
);
expect(file.getSize(), size -> size <= MAX_FILE_SIZE).verify(INCORRECT_REQUEST, "File size is more than 32 Mb.");
}

private File transferToTempFile(MultipartFile file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public DeleteBulkRS deleteLaunches(@PathVariable String projectName, @RequestBod

@PostMapping(value = "/import", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
@ResponseStatus(OK)
@ApiOperation(value = "Import junit xml report", notes = "Only following formats are supported: zip.")
@ApiOperation(value = "Import junit xml report", notes = "Only following formats are supported: zip and xml.")
public OperationCompletionRS importLaunch(@PathVariable String projectName, @RequestParam("file") MultipartFile file,
@AuthenticationPrincipal ReportPortalUser user, HttpServletRequest request) {
return importLaunchHandler.importLaunch(projectExtractor.extractProjectDetails(user, normalizeId(projectName)),
Expand Down

0 comments on commit 7009281

Please sign in to comment.