|
@@ -3,6 +3,7 @@ package es.uv.saic.web;
|
|
|
import es.uv.saic.extractor.ExtractionRequest;
|
|
import es.uv.saic.extractor.ExtractionRequest;
|
|
|
import es.uv.saic.service.EnhancementService;
|
|
import es.uv.saic.service.EnhancementService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -20,6 +21,7 @@ import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/enhancements")
|
|
@RequestMapping("/enhancements")
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
|
|
+@Slf4j
|
|
|
public class EnhancementController {
|
|
public class EnhancementController {
|
|
|
|
|
|
|
|
private final EnhancementService enhancementService;
|
|
private final EnhancementService enhancementService;
|
|
@@ -28,10 +30,13 @@ public class EnhancementController {
|
|
|
public String singleStepAnalysis(@RequestBody String html,
|
|
public String singleStepAnalysis(@RequestBody String html,
|
|
|
@RequestParam(value = "provider", required = false) String provider,
|
|
@RequestParam(value = "provider", required = false) String provider,
|
|
|
@RequestParam(value = "model", required = false) String model) {
|
|
@RequestParam(value = "model", required = false) String model) {
|
|
|
|
|
+ log.info("====== EnhancementController.singleStepAnalysis start ======");
|
|
|
try {
|
|
try {
|
|
|
return enhancementService.calculateScoreAndProduceCommentsWithSingleCall(ExtractionRequest.fromHtml(html), provider, model);
|
|
return enhancementService.calculateScoreAndProduceCommentsWithSingleCall(ExtractionRequest.fromHtml(html), provider, model);
|
|
|
} catch (IllegalArgumentException e) {
|
|
} catch (IllegalArgumentException e) {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ log.info("====== EnhancementController.singleStepAnalysis end ======");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -39,6 +44,8 @@ public class EnhancementController {
|
|
|
public String singleStepAnalysisFile(@RequestPart("file") MultipartFile file,
|
|
public String singleStepAnalysisFile(@RequestPart("file") MultipartFile file,
|
|
|
@RequestParam(value = "provider", required = false) String provider,
|
|
@RequestParam(value = "provider", required = false) String provider,
|
|
|
@RequestParam(value = "model", required = false) String model) {
|
|
@RequestParam(value = "model", required = false) String model) {
|
|
|
|
|
+ log.info("====== EnhancementController.singleStepAnalysisFile start ======");
|
|
|
|
|
+
|
|
|
if (file.isEmpty()) {
|
|
if (file.isEmpty()) {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, "Uploaded file is empty");
|
|
throw new ResponseStatusException(BAD_REQUEST, "Uploaded file is empty");
|
|
|
}
|
|
}
|
|
@@ -53,6 +60,8 @@ public class EnhancementController {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, "Unable to read uploaded file", e);
|
|
throw new ResponseStatusException(BAD_REQUEST, "Unable to read uploaded file", e);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ log.info("====== EnhancementController.singleStepAnalysisFile end ======");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -60,6 +69,8 @@ public class EnhancementController {
|
|
|
public String singleStepAnalysisCsvFile(@RequestPart("file") MultipartFile file,
|
|
public String singleStepAnalysisCsvFile(@RequestPart("file") MultipartFile file,
|
|
|
@RequestParam(value = "provider", required = false) String provider,
|
|
@RequestParam(value = "provider", required = false) String provider,
|
|
|
@RequestParam(value = "model", required = false) String model) {
|
|
@RequestParam(value = "model", required = false) String model) {
|
|
|
|
|
+ log.info("====== EnhancementController.singleStepAnalysisCsvFile start ======");
|
|
|
|
|
+
|
|
|
if (file.isEmpty()) {
|
|
if (file.isEmpty()) {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, "Uploaded file is empty");
|
|
throw new ResponseStatusException(BAD_REQUEST, "Uploaded file is empty");
|
|
|
}
|
|
}
|
|
@@ -71,6 +82,8 @@ public class EnhancementController {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, "Unable to read uploaded CSV file", e);
|
|
throw new ResponseStatusException(BAD_REQUEST, "Unable to read uploaded CSV file", e);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ log.info("====== EnhancementController.singleStepAnalysisCsvFile end ======");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|