Skip to content

Commit

Permalink
try to use old form data params
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobasco99 committed Aug 14, 2024
1 parent a5f14d1 commit 61770ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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;
Expand Down Expand Up @@ -462,7 +463,8 @@ public ResponseEntity<String> getAnalyzedText(@PathVariable("label1") String lab
*
* @param label1 the first label (user text)
* @param label2 the second label (expert or second user text)
* @param file the InputStream containing the text to compare
* @param textInputStream the InputStream containing the text to compare
* @param textFileDetail the file details of the text file
* @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
Expand All @@ -476,9 +478,7 @@ public ResponseEntity<String> 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<String> compareText(@RequestParam("label1") String label1, @RequestParam("label2") String label2,
@FormDataParam("file") MultipartFile file,
// @FormDataParam("file") FormDataContentDisposition textFileDetail,
public ResponseEntity<String> compareText(@RequestParam("label1") String label1, @RequestParam("label2") String label2, @FormDataParam("file") InputStream textInputStream, @FormDataParam("file") FormDataContentDisposition textFileDetail,
@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)) {
Expand All @@ -500,7 +500,6 @@ public ResponseEntity<String> compareText(@RequestParam("label1") String label1,

String topic = service.getTaskNameByIds(courseId, Integer.parseInt(label2));

InputStream textInputStream = file.getInputStream();
String encodedByteString = service.convertInputStreamToBase64(textInputStream);
TmitocarText tmitoBody = new TmitocarText();
tmitoBody.setTopic(topic);
Expand All @@ -510,7 +509,7 @@ public ResponseEntity<String> compareText(@RequestParam("label1") String label1,
tmitoBody.setText(encodedByteString);
tmitoBody.setUuid(email);
byte[] bytes = Base64.getDecoder().decode(encodedByteString);
String fname = file.getOriginalFilename();
String fname = textFileDetail.getFileName();
String fileEnding = "txt";
int dotIndex = fname.lastIndexOf('.');
if (dotIndex > 0 && dotIndex < fname.length() - 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,6 @@ private void uploadToTmitocar(String label1, String fileName, String wordspec)
if (!Files.exists(filePath)) {
throw new IOException("File not found: " + filePath);
}
byte[] fileContent = Files.readAllBytes(filePath);
String fileTextContent = new String(fileContent);

System.out.println("File content: " + fileTextContent);

ProcessBuilder pb;
if (wordspec != null && wordspec.length() > 2) {
Expand Down

0 comments on commit 61770ec

Please sign in to comment.