Done ticket GEPAFINBE-212 Fixed the filename decode issue for external doc upload API.
This commit is contained in:
@@ -37,6 +37,7 @@ import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
|||||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.HubRepository;
|
import net.gepafin.tendermanagement.repositories.HubRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||||
|
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.service.CompanyService;
|
import net.gepafin.tendermanagement.service.CompanyService;
|
||||||
import net.gepafin.tendermanagement.service.feignClient.AppointmentApiService;
|
import net.gepafin.tendermanagement.service.feignClient.AppointmentApiService;
|
||||||
@@ -141,6 +142,9 @@ public class AppointmentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationServiceImpl applicationEvaluationService;
|
private ApplicationEvaluationServiceImpl applicationEvaluationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3Service amazonS3Service;
|
||||||
|
|
||||||
private final Map<Long, ExecutorService> executorMap = new ConcurrentHashMap<>();
|
private final Map<Long, ExecutorService> executorMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, ExecutorService> threadForDocumentMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, ExecutorService> threadForDocumentMap = new ConcurrentHashMap<>();
|
||||||
@@ -720,9 +724,11 @@ public class AppointmentDao {
|
|||||||
// Build the appointment request body
|
// Build the appointment request body
|
||||||
AppointmentCreationRequest appointmentCreationRequest = buildAppointmentCreationRequest(applicationId, createAppointmentRequest, appointmentTemplateId,
|
AppointmentCreationRequest appointmentCreationRequest = buildAppointmentCreationRequest(applicationId, createAppointmentRequest, appointmentTemplateId,
|
||||||
templateRichiestaData);
|
templateRichiestaData);
|
||||||
|
log.info("AppointmentCreationRequest {}", appointmentCreationRequest);
|
||||||
String appointmentRequestBody = Utils.convertObjectToJson(appointmentCreationRequest);
|
String appointmentRequestBody = Utils.convertObjectToJson(appointmentCreationRequest);
|
||||||
|
|
||||||
// Make API call to create the appointment
|
// Make API call to create the appointment
|
||||||
|
log.info("Context:{}, Authorization Token {}, RequestBody {}", context, authorizationToken, appointmentRequestBody);
|
||||||
ResponseEntity<Object> appointmentResponse = appointmentApiService.createAppointment(authorizationToken, context, appointmentRequestBody);
|
ResponseEntity<Object> appointmentResponse = appointmentApiService.createAppointment(authorizationToken, context, appointmentRequestBody);
|
||||||
String appointmentId = extractAppointmentIdFromResponse(appointmentResponse);
|
String appointmentId = extractAppointmentIdFromResponse(appointmentResponse);
|
||||||
|
|
||||||
@@ -751,6 +757,7 @@ public class AppointmentDao {
|
|||||||
private String extractAppointmentIdFromResponse(ResponseEntity<Object> appointmentResponse) {
|
private String extractAppointmentIdFromResponse(ResponseEntity<Object> appointmentResponse) {
|
||||||
|
|
||||||
if (appointmentResponse.getBody() != null) {
|
if (appointmentResponse.getBody() != null) {
|
||||||
|
log.info("Appointment API Response {}", appointmentResponse.getBody());
|
||||||
Map<String, Object> responseBody = (Map<String, Object>) appointmentResponse.getBody();
|
Map<String, Object> responseBody = (Map<String, Object>) appointmentResponse.getBody();
|
||||||
if (responseBody.containsKey(GepafinConstant.DATA_STRING)) {
|
if (responseBody.containsKey(GepafinConstant.DATA_STRING)) {
|
||||||
Map<String, Object> data = (Map<String, Object>) responseBody.get(GepafinConstant.DATA_STRING);
|
Map<String, Object> data = (Map<String, Object>) responseBody.get(GepafinConstant.DATA_STRING);
|
||||||
@@ -979,12 +986,12 @@ public class AppointmentDao {
|
|||||||
|
|
||||||
private File downloadFileFromS3(String fileUrl) throws Exception {
|
private File downloadFileFromS3(String fileUrl) throws Exception {
|
||||||
|
|
||||||
String key = extractS3KeyFromUrl(fileUrl);
|
String key = amazonS3Service.extractS3KeyFromUrl(fileUrl);
|
||||||
File localFile = new File(GepafinConstant.TEMP_FILE_PATH + extractFileName(key));
|
String fileName = extractFileName(key);
|
||||||
|
String folderPath = key.substring(0, key.lastIndexOf("/"));
|
||||||
|
File localFile = new File(GepafinConstant.TEMP_FILE_PATH + fileName);
|
||||||
|
|
||||||
GetObjectRequest getObjectRequest = new GetObjectRequest(OLD_BUCKET, key);
|
try (InputStream s3Stream = amazonS3Service.getFile(folderPath, key); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
||||||
|
|
||||||
try (InputStream s3Stream = s3Client.getObject(getObjectRequest).getObjectContent(); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
|
||||||
s3Stream.transferTo(outputStream);
|
s3Stream.transferTo(outputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -992,11 +999,6 @@ public class AppointmentDao {
|
|||||||
return localFile;
|
return localFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractS3KeyFromUrl(String url) {
|
|
||||||
|
|
||||||
return url.replace(s3Url, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String extractFileName(String filePath) {
|
private String extractFileName(String filePath) {
|
||||||
|
|
||||||
String[] parts = filePath.split("/");
|
String[] parts = filePath.split("/");
|
||||||
|
|||||||
@@ -21,4 +21,5 @@ AmazonS3Service {
|
|||||||
|
|
||||||
UploadFileOnAmazonS3Response copyFile(String fileName, String oldS3Path, String newS3Path);
|
UploadFileOnAmazonS3Response copyFile(String fileName, String oldS3Path, String newS3Path);
|
||||||
|
|
||||||
|
String extractS3KeyFromUrl(String url);
|
||||||
}
|
}
|
||||||
@@ -217,4 +217,9 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String extractS3KeyFromUrl(String url) {
|
||||||
|
|
||||||
|
return url.replace(s3Url, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user