SUPPORT-9339: Fix
This commit is contained in:
parent
accc88da08
commit
2b5df5129d
2 changed files with 28 additions and 12 deletions
|
|
@ -0,0 +1,7 @@
|
|||
package ervu.model.fileupload;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
*/
|
||||
public record FileStatusResponse(UploadOrgInfo orgInfo, FileInfo[] filesInfo, FileStatus packInfo) {
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ import ervu.model.fileupload.EmployeeInfoFileFormType;
|
|||
import ervu.model.fileupload.EmployeeInfoKafkaMessage;
|
||||
import ervu.model.fileupload.FileInfo;
|
||||
import ervu.model.fileupload.FileStatus;
|
||||
import ervu.model.fileupload.FileStatusResponse;
|
||||
import ervu.model.fileupload.UploadOrgInfo;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
|
|
@ -428,18 +429,16 @@ public class EmployeeInfoFileUploadService {
|
|||
@KafkaListener(id = "${av.kafka.group.id}", topics = "${ervu.kafka.download.response}",
|
||||
containerFactory = "fileContainerFactory")
|
||||
public void listenKafka(String kafkaMessage) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
DownloadResponse downloadResponse = mapper.readValue(kafkaMessage, DownloadResponse.class);
|
||||
FileInfo fileInfo = Arrays.stream(downloadResponse.filesInfo())
|
||||
FileStatusResponse fileStatusResponse = objectMapper.readValue(kafkaMessage, FileStatusResponse.class);
|
||||
FileInfo fileInfo = Arrays.stream(fileStatusResponse.filesInfo())
|
||||
.filter(fileInfo1 -> fileInfo1.getType().equals(DOCUMENT))
|
||||
.findFirst()
|
||||
.get();
|
||||
String statusCode = fileInfo.getFileStatus().getCode();
|
||||
String statusCode = fileStatusResponse.packInfo().getCode();
|
||||
|
||||
if (FILE_ACCEPTED.getCode().equals(statusCode)) {
|
||||
interactionService.delete(fileInfo.getFileId(), downloadResponse.orgInfo().getOrgId());
|
||||
interactionService.delete(fileInfo.getFileId(), fileStatusResponse.orgInfo().getOrgId());
|
||||
}
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
|
|
@ -465,14 +464,24 @@ public class EmployeeInfoFileUploadService {
|
|||
if (statusCode == 401) {
|
||||
throw new LocalizedException("file_sign_validate", MESSAGE_SOURCE);
|
||||
}
|
||||
String errorCode = objectMapper.readTree(body)
|
||||
.get("error_code")
|
||||
.asText();
|
||||
if (errorCode.equals("CERT_TRUST_REVOCATION_STATUS_UNKNOWN")) {
|
||||
throw new LocalizedException("crl_certificate_expired", MESSAGE_SOURCE);
|
||||
if (statusCode == 500) {
|
||||
try {
|
||||
String errorCode = objectMapper.readTree(body)
|
||||
.get("error_code")
|
||||
.asText();
|
||||
if (errorCode.equals("CERT_TRUST_REVOCATION_STATUS_UNKNOWN")) {
|
||||
throw new LocalizedException("crl_certificate_expired", MESSAGE_SOURCE);
|
||||
}
|
||||
else {
|
||||
throw new FileUploadException("Unknown 500 error in verify module. Error code " + errorCode);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new FileUploadException("Unknown 500 error in verify module. Response body " + body, e);
|
||||
}
|
||||
}
|
||||
if (statusCode != 200) {
|
||||
throw new FileUploadException("Unknown error in verify module. Error code " + errorCode);
|
||||
throw new FileUploadException("Unknown error in verify module. StatusCode " + statusCode + " .Response body " + body);
|
||||
}
|
||||
return objectMapper.readValue(body, VerifyDocumentSignResponse.class);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue