diff --git a/tmitocar-service/src/main/java/services/tmitocar/controller/TmitocarServiceController.java b/tmitocar-service/src/main/java/services/tmitocar/controller/TmitocarServiceController.java index 71d253b..0d95971 100644 --- a/tmitocar-service/src/main/java/services/tmitocar/controller/TmitocarServiceController.java +++ b/tmitocar-service/src/main/java/services/tmitocar/controller/TmitocarServiceController.java @@ -16,7 +16,6 @@ import java.nio.file.Files; import java.nio.file.Paths; -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import services.tmitocar.pojo.LrsCredentials; import services.tmitocar.pojo.TmitocarResponse; import services.tmitocar.pojo.TmitocarText; @@ -463,8 +462,7 @@ public ResponseEntity getAnalyzedText(@PathVariable("label1") String lab * * @param label1 the first label (user text) * @param label2 the second label (expert or second user text) - * @param textInputStream the InputStream containing the text to compare - * @param textFileDetail the file details of the text file + * @param file the InputStream containing the text to compare * @param type the type of text (text, pdf or docx) * @param template the template to use for the PDF report * @param wordSpec the word specification for the PDF report @@ -478,7 +476,7 @@ public ResponseEntity getAnalyzedText(@PathVariable("label1") String lab @ApiResponse(responseCode = "500", description = "Response failed.") }) @PostMapping(value = "/compareText" , consumes = MediaType.MULTIPART_FORM_DATA, produces = MediaType.APPLICATION_JSON) - public ResponseEntity compareText(@RequestParam("label1") String label1, @RequestParam("label2") String label2, @FormDataParam("file") InputStream textInputStream, @FormDataParam("file") FormDataContentDisposition textFileDetail, + public ResponseEntity compareText(@RequestParam("label1") String label1, @RequestParam("label2") String label2, @FormDataParam("file") MultipartFile file, @FormDataParam("type") String type, @FormDataParam("template") String template, @FormDataParam("wordSpec") String wordSpec,@FormDataParam("email") String email,@FormDataParam("courseId") int courseId, @FormDataParam("sbfmURL") String sbfmURL) throws ParseException, IOException { if (service.isActive.getOrDefault(label1, false)) { @@ -499,6 +497,7 @@ public ResponseEntity compareText(@RequestParam("label1") String label1, service.isActive.put(label1, true); String topic = service.getTaskNameByIds(courseId, Integer.parseInt(label2)); + InputStream textInputStream = file.getInputStream(); String encodedByteString = service.convertInputStreamToBase64(textInputStream); TmitocarText tmitoBody = new TmitocarText(); @@ -509,7 +508,7 @@ public ResponseEntity compareText(@RequestParam("label1") String label1, tmitoBody.setText(encodedByteString); tmitoBody.setUuid(email); byte[] bytes = Base64.getDecoder().decode(encodedByteString); - String fname = textFileDetail.getFileName(); + String fname = file.getOriginalFilename(); String fileEnding = "txt"; int dotIndex = fname.lastIndexOf('.'); if (dotIndex > 0 && dotIndex < fname.length() - 1) {