SUPPORT-9345: return bad request for wrong extract formats
This commit is contained in:
parent
b477348fac
commit
dd13078cbb
2 changed files with 12 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ package ru.micord.ervu.controller;
|
|||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
|
@ -39,6 +40,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
*/
|
||||
@RestController
|
||||
public class ExtractController {
|
||||
private static final List<String> ALLOWED_FORMATS = List.of("1", "2");
|
||||
|
||||
private final PersonalDataService personalDataService;
|
||||
private final ReplyingKafkaService<Object, Bytes> replyingKafkaService;
|
||||
private final AuditService auditService;
|
||||
|
|
@ -64,6 +67,10 @@ public class ExtractController {
|
|||
|
||||
@GetMapping(value = "/extract/{formatRegistry}")
|
||||
public ResponseEntity<Resource> getExtract(HttpServletRequest servletRequest, @PathVariable String formatRegistry) {
|
||||
if (!ALLOWED_FORMATS.contains(formatRegistry)) {
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
|
||||
UserIdsPair userIdsPair = SecurityUtil.getUserIdsPair();
|
||||
String ervuId = userIdsPair.getErvuId();
|
||||
ConsumerRecord<String, Bytes> record;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ export class ExtractLoadService extends Behavior {
|
|||
observe: 'response'
|
||||
}).toPromise()
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
this.errorEvent.trigger();
|
||||
return;
|
||||
}
|
||||
|
||||
const data = window.URL.createObjectURL(response.body);
|
||||
const link = document.createElement("a");
|
||||
link.href = data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue