Resolved conflicts
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -9,12 +8,15 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@Component
|
||||
public interface AmazonS3Service {
|
||||
public interface
|
||||
AmazonS3Service {
|
||||
|
||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3(String s3Folder, MultipartFile file);
|
||||
|
||||
Boolean delete(String s3Folder, String filePath);
|
||||
|
||||
InputStream getFile(String s3Folder, String filePath) throws IOException;
|
||||
|
||||
|
||||
UploadFileOnAmazonS3Response moveFile(String fileName, String oldPath, String newPath);
|
||||
|
||||
}
|
||||
@@ -2,10 +2,12 @@ package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusForEvaluation;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ApplicationEvaluationService {
|
||||
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
|
||||
HttpServletRequest request,
|
||||
@@ -16,4 +18,7 @@ public interface ApplicationEvaluationService {
|
||||
|
||||
ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId);
|
||||
ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId);
|
||||
|
||||
ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.request.CreateAppointmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UploadDocToExternalSystemRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AppointmentCreationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentUploadResponse;
|
||||
import net.gepafin.tendermanagement.model.response.NdgResponse;
|
||||
|
||||
public interface AppointmentService {
|
||||
NdgResponse checkNdgForAppointment(HttpServletRequest request, Long applicationId);
|
||||
|
||||
AppointmentCreationResponse createAppointmentForApplication(HttpServletRequest request, Long applicationId, CreateAppointmentRequest createAppointmentRequest);
|
||||
|
||||
DocumentUploadResponse uploadDocToExternalSystem(HttpServletRequest request, Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.service;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,7 +16,7 @@ public interface AssignedApplicationsService {
|
||||
void deleteApplication(HttpServletRequest request, Long id);
|
||||
|
||||
List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId);
|
||||
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest assignedApplicationsRequest);
|
||||
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, UpdateAssignedApplicationRequest assignedApplicationsRequest);
|
||||
AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id);
|
||||
AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -26,21 +27,22 @@ public interface CompanyService {
|
||||
|
||||
List<CompanyResponse> getCompanyByUserId(HttpServletRequest request, Long userId);
|
||||
|
||||
Map<String, Object> checkVatNumber(HttpServletRequest request, String vatNumber);
|
||||
VatCheckResponseBean checkVatNumber(HttpServletRequest request, String vatNumber);
|
||||
|
||||
CompanyEntity validateCompany(Long companyId);
|
||||
|
||||
UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId);
|
||||
|
||||
|
||||
UserWithCompanyEntity getUserWithCompany(Long userId, Long companyId);
|
||||
|
||||
ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest);
|
||||
|
||||
CompanyDelegationResponse uploadCompanyDelegation(HttpServletRequest request, Long companyId, MultipartFile file);
|
||||
|
||||
CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId);
|
||||
CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId,Long applicationId);
|
||||
|
||||
void deleteCompanyDelegation(HttpServletRequest request, Long companyId);
|
||||
UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId);
|
||||
void removeCompanyFromList(HttpServletRequest request, Long companyId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
|
||||
public interface DocumentService {
|
||||
|
||||
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType);
|
||||
public List<DocumentResponseBean> uploadFile(HttpServletRequest request,List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType);
|
||||
|
||||
public void deleteFile(Long documentId);
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NotificationService {
|
||||
NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId);
|
||||
|
||||
public NotificationResponse getNotificationById(HttpServletRequest servletRequest, Long id);
|
||||
|
||||
public List<NotificationResponse> getNotificationByUserId(HttpServletRequest servletRequest, Long userId, Long companyId, List<NotificationEnum> statuses);
|
||||
|
||||
public NotificationResponse updateNotificationStatus(HttpServletRequest request, Long id, NotificationEnum status);
|
||||
|
||||
public void deleteNotification(HttpServletRequest request, Long id);
|
||||
|
||||
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses);
|
||||
|
||||
}
|
||||
@@ -45,6 +45,6 @@ public interface UserService {
|
||||
UserEntity getUserByBeneficiaryId(Long beneficiaryId);
|
||||
|
||||
public UserEntity getUserEntityById(Long userId);
|
||||
List<UserResponseBean> getAllUsers(HttpServletRequest request, Long roleId);
|
||||
List<UserResponseBean> getAllUsers(HttpServletRequest request, List<Long> roleIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.gepafin.tendermanagement.service.feignClient;
|
||||
|
||||
import net.gepafin.tendermanagement.constants.AppointmentApiConstant;
|
||||
import net.gepafin.tendermanagement.model.request.AppointmentNdgRequest;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(value = "appointment-api-service", url = "${appointment.base.url}")
|
||||
public interface AppointmentApiService {
|
||||
|
||||
@PostMapping(value = AppointmentApiConstant.ODESSA_LOGIN, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Object> loginWithOdessa(@RequestHeader("auth") String authToken, @RequestHeader("source") String source, @RequestHeader("context") String context,
|
||||
@RequestHeader("user") String user, @RequestHeader("password") String password, @RequestBody(required = false) Map<String, Object> body);
|
||||
|
||||
@PostMapping(value = AppointmentApiConstant.GET_NDG_BY_VAT_NUMBER, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Object> getNdgByVatNumber(@RequestBody AppointmentNdgRequest ndgRequest, @RequestHeader("Authorization") String token);
|
||||
|
||||
@PostMapping(value = AppointmentApiConstant.CREATE_VISURA, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Object> createVisura(@RequestBody String visuraRequest, @RequestHeader("Authorization") String token);
|
||||
|
||||
@GetMapping(value = AppointmentApiConstant.GET_VISURA_LIST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Object> getVisuraList(@RequestBody String visuraRequest, @RequestHeader("Authorization") String token);
|
||||
|
||||
@GetMapping(value = AppointmentApiConstant.GET_APPOINTMENT_TEMPLATE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Object> getAppointmentTemplateForTemplateCreation(@RequestHeader("Authorization") String token);
|
||||
|
||||
@PostMapping(value = AppointmentApiConstant.CREATE_APPOINTMENT_FROM_TEMPLATE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Object> createAppointment(@RequestHeader("Authorization") String token, @RequestHeader("context") String context, String appointmentCreationRequest);
|
||||
|
||||
@PostMapping(value = AppointmentApiConstant.UPLOAD_APOOINTMENT_DOCUMENT, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
ResponseEntity<Object> uploadDocumentToExternalSystemForAppointment(@RequestHeader("Authorization") String token, @RequestHeader("context") String context,
|
||||
@RequestPart("input") String uploadDocumentRequest, @RequestPart("file") MultipartFile file);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import com.amazonaws.AmazonServiceException;
|
||||
import com.amazonaws.SdkClientException;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.*;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.S3PathConfig;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.UploadFileOnAmazonS3Response;
|
||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
@@ -22,6 +29,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -45,6 +55,18 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
@Value("${aws.s3.url}")
|
||||
private String s3Url;
|
||||
|
||||
@Autowired
|
||||
private S3PathConfig s3ConfigBean;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3Client s3Client;
|
||||
|
||||
@Value("${aws.s3.region}")
|
||||
private String region;
|
||||
|
||||
@Autowired
|
||||
S3ReUploadMigrationService s3ReUploadMigrationService;
|
||||
|
||||
|
||||
private String upload(String fileName, String s3Folder,
|
||||
MultipartFile file) throws IOException {
|
||||
@@ -68,9 +90,11 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
if(Boolean.FALSE.equals(isTestProfileActivated())) {
|
||||
amazonS3.putObject(bucketName, path, inputStream, objectMetadata);
|
||||
}
|
||||
path =s3Url + s3Folder +"/"+ fileName;
|
||||
log.info("File '{}' uploaded successfully to Amazon S3 with URL: {}", fileName, path);
|
||||
return path;
|
||||
//getting actual encoded s3 file path
|
||||
URL amazonS3Url = amazonS3.getUrl(bucketName, path);
|
||||
String fileUrl = amazonS3Url.toString();
|
||||
log.info("File '{}' uploaded successfully to Amazon S3 with URL: {}", fileName, fileUrl);
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,12 +120,15 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
public InputStream getFile(String s3Folder, String filePath) {
|
||||
try {
|
||||
String fileName = Utils.extractFileName(filePath);
|
||||
String path = s3Folder + "/" + fileName;
|
||||
// Decode the file name to handle special characters like '+' correctly
|
||||
String decodedFileName = URLDecoder.decode(fileName, StandardCharsets.UTF_8.toString());
|
||||
|
||||
String path = s3Folder + "/" + decodedFileName;
|
||||
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, path);
|
||||
S3Object s3Object = amazonS3.getObject(getObjectRequest);
|
||||
log.info("File fetched successfully from Amazon S3: {}", fileName);
|
||||
return s3Object.getObjectContent();
|
||||
} catch (AmazonS3Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while getting file from Amazon S3: {}", e);
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.GET_ERROR_S3));
|
||||
@@ -125,4 +152,39 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadFileOnAmazonS3Response moveFile(String fileName, String oldPath, String newPath) {
|
||||
try {
|
||||
newPath = cleanNewPath(oldPath, newPath);
|
||||
oldPath = cleanOldPath(oldPath);
|
||||
log.info("Moving file from {} to {} in bucket {}", oldPath, newPath, bucketName);
|
||||
|
||||
CopyObjectRequest copyRequest = new CopyObjectRequest(bucketName, oldPath, bucketName, newPath);
|
||||
s3Client.copyObject(copyRequest);
|
||||
log.info("File copied successfully from {} to {}", oldPath, newPath);
|
||||
|
||||
s3Client.deleteObject(bucketName, oldPath);
|
||||
log.info("Original file deleted successfully: {}", oldPath);
|
||||
String filePath = s3Url + newPath;
|
||||
return UploadFileOnAmazonS3Response.builder().fileName(fileName).filePath(filePath).build();
|
||||
} catch (AmazonServiceException e) {
|
||||
log.error("AWS service error while moving file: {}", e.getErrorMessage(), e);
|
||||
throw e;
|
||||
} catch (SdkClientException e) {
|
||||
log.error("SDK client error while moving file: {}", e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected error while moving file: {}", e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private String cleanNewPath(String oldPath, String newPath) {
|
||||
return newPath + "/" + oldPath.substring(oldPath.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
private String cleanOldPath(String oldPath) {
|
||||
return oldPath.replace(s3Url, "");
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundExceptio
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -45,6 +46,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest) {
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
|
||||
entityOptional.ifPresent(applicationEvaluationEntity -> validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId()));
|
||||
@@ -52,6 +54,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) {
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
@@ -86,14 +89,8 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(id);
|
||||
|
||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||
validator.validatePreInstructor(request, amendment.getApplicationEvaluationEntity().getUserId());
|
||||
} else {
|
||||
validator.validateUserId(request, amendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||
}
|
||||
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
|
||||
}
|
||||
|
||||
@@ -110,6 +107,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationAmendmentRequestResponse closeAmendmentRequest(HttpServletRequest request, Long id, CloseAmendmentRequest closeAmendmentRequest) {
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
@@ -123,6 +121,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationAmendmentRequestResponse extendResponseDays(HttpServletRequest request, Long id, Long addedDays) {
|
||||
UserEntity user= validator.validateUser(request);
|
||||
return applicationAmendmentRequestDao.extendResponseDays(id, addedDays);
|
||||
@@ -132,6 +131,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
return applicationAmendmentRequestDao.getAmendmentByApplicationId(request,applicationId,statuses);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status) {
|
||||
return applicationAmendmentRequestDao.updateApplicationAmendmentStatus(applicationAmendmentId, status);
|
||||
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.ApplicationEvaluationDao;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusForEvaluation;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationService {
|
||||
@@ -36,6 +31,9 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
private AssignedApplicationsService assignedApplicationsService;
|
||||
@Autowired
|
||||
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
@Autowired
|
||||
private ApplicationEvaluationService applicationEvaluationService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
|
||||
@@ -54,31 +52,12 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
@Transactional(readOnly = true)
|
||||
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(
|
||||
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||
|
||||
if (applicationId == null && assignedApplicationId == null) {
|
||||
throw new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.EITHER_APPLICATION_OR_ASSIGNED_APPLICATION_ID_REQUIRED_MSG)
|
||||
);
|
||||
}
|
||||
UserEntity preInstructor = validator.validateUser(request);
|
||||
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
||||
assignedApplicationsRepository.findByApplicationIdOrIdAndIsDeletedFalse(applicationId,assignedApplicationId);
|
||||
|
||||
if (assignedApplicationId != null) {
|
||||
assignedApplicationsOptional = assignedApplicationsOptional.filter(a -> a.getId().equals(assignedApplicationId));
|
||||
}
|
||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsOptional
|
||||
.orElseThrow(() -> new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG)
|
||||
));
|
||||
validator.validatePreInstructor(request, assignedApplications.getUserId());
|
||||
|
||||
return applicationEvaluationDao.getApplicationEvaluationByApplicationId(
|
||||
request,
|
||||
preInstructor,
|
||||
assignedApplications.getApplication().getId(),
|
||||
assignedApplications.getId()
|
||||
applicationId,
|
||||
assignedApplicationId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,4 +72,10 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId) {
|
||||
return applicationEvaluationDao.validateApplicationEvaluation(applicationEvaluationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
|
||||
return applicationEvaluationDao.validateApplicationEvaluationByApplicationId(applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId,
|
||||
FormActionEnum action) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
return flowFormDao.getNextOrPreviousForm(applicationEntity, formId, action);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.AppointmentDao;
|
||||
import net.gepafin.tendermanagement.model.request.CreateAppointmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UploadDocToExternalSystemRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AppointmentCreationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentUploadResponse;
|
||||
import net.gepafin.tendermanagement.model.response.NdgResponse;
|
||||
import net.gepafin.tendermanagement.service.AppointmentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AppointmentServiceImpl implements AppointmentService {
|
||||
|
||||
@Autowired
|
||||
private AppointmentDao appointmentDao;
|
||||
|
||||
@Override
|
||||
public NdgResponse checkNdgForAppointment(HttpServletRequest request, Long applicationId) {
|
||||
|
||||
return appointmentDao.checkNdgForAppointment(applicationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppointmentCreationResponse createAppointmentForApplication(HttpServletRequest request, Long applicationId, CreateAppointmentRequest createAppointmentRequest) {
|
||||
|
||||
return appointmentDao.createAppointment(applicationId, createAppointmentRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentUploadResponse uploadDocToExternalSystem(HttpServletRequest request, Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest) {
|
||||
|
||||
return appointmentDao.uploadDocumentToExternalSystem(documentId, docToExternalSystemRequest);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.gepafin.tendermanagement.dao.AssignedApplicationsDao;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
@@ -45,7 +46,7 @@ public class AssignedApplicationsServiceImpl implements AssignedApplicationsServ
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest updatedAssignedApplicationRequest) {
|
||||
public AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, UpdateAssignedApplicationRequest updatedAssignedApplicationRequest) {
|
||||
return assignedApplicationsDao.updateAssignedApplication(request, id, updatedAssignedApplicationRequest);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +208,6 @@ public class AuthenticationService {
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response) {
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth != null) {
|
||||
String token = tokenProvider.extractTokenFromRequest(request);
|
||||
tokenProvider.invalidateToken(token);
|
||||
new SecurityContextLogoutHandler().logout(request, response, auth);
|
||||
}
|
||||
SecurityContextHolder.getContext().setAuthentication(null);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -78,7 +79,7 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Map<String, Object> checkVatNumber(HttpServletRequest request, String vatNumber) {
|
||||
public VatCheckResponseBean checkVatNumber(HttpServletRequest request, String vatNumber) {
|
||||
return vatCheckDao.checkVatNumber(vatNumber);
|
||||
}
|
||||
@Override
|
||||
@@ -90,7 +91,10 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
public UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId) {
|
||||
return companyDao.validateUserWithCompny(userId, companyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserWithCompanyEntity getUserWithCompany(Long userId, Long companyId) {
|
||||
return companyDao.getUserWithCompany(userId, companyId);
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
||||
@@ -107,9 +111,8 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId) {
|
||||
UserEntity userEntity =validator.validateUser(request);
|
||||
return delegationDao.getCompanyDelegation(userEntity, companyId);
|
||||
public CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId,Long applicationId) {
|
||||
return delegationDao.getCompanyDelegation(request, companyId,applicationId);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.DocumentDao;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.service.DocumentService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -22,9 +25,13 @@ public class DocumentServiceImpl implements DocumentService {
|
||||
@Autowired
|
||||
private DocumentDao documentDao;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
@Override
|
||||
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
||||
return documentDao.uploadFiles(files,sourceId,sourceType,fileType);
|
||||
public List<DocumentResponseBean> uploadFile(HttpServletRequest request,List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
||||
Map<String, Object> userInfo = validator.getUserInfoFromToken(request);
|
||||
Long userId = validator.getUserId(userInfo);
|
||||
return documentDao.uploadFiles(userId,files,sourceId,sourceType,fileType);
|
||||
}
|
||||
@Override
|
||||
public void deleteFile(Long documentId) {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.service.NotificationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class NotificationServiceImpl implements NotificationService {
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Override
|
||||
public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId) {
|
||||
|
||||
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
|
||||
notificationReq.setUserId(userId);
|
||||
notificationReq.setCompanyIds(listOf(companyId));
|
||||
return notificationDao.sendNotification(notificationReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationResponse getNotificationById(HttpServletRequest servletRequest, Long id) {
|
||||
|
||||
return notificationDao.getNotificationById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotificationResponse> getNotificationByUserId(HttpServletRequest servletRequest, Long userId, Long companyId, List<NotificationEnum> statuses) {
|
||||
|
||||
return notificationDao.getNotificationByUserId(userId, companyId, statuses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationResponse updateNotificationStatus(HttpServletRequest request, Long id, NotificationEnum status) {
|
||||
|
||||
return notificationDao.updateNotificationStatus(id, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNotification(HttpServletRequest request, Long id) {
|
||||
|
||||
notificationDao.deleteNotification(id);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses) {
|
||||
return notificationDao.getNotificationByCompanyIdAndUserId(userId, companyId, statuses);
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,14 @@ import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.GetObjectRequest;
|
||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.dao.DocumentDao;
|
||||
import net.gepafin.tendermanagement.dao.S3PathConfig;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationSignedDocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -50,13 +52,38 @@ public class S3ReUploadMigrationService {
|
||||
@Autowired
|
||||
private AmazonS3 amazonS3;
|
||||
|
||||
@Autowired
|
||||
ApplicationService applicationService;
|
||||
|
||||
@Value("${aws.s3.url}")
|
||||
private String s3Url;
|
||||
|
||||
@Autowired
|
||||
AmazonS3Service amazonS3Service;
|
||||
|
||||
@Value("${aws.s3.bucket.name}")
|
||||
private String bucketName;
|
||||
|
||||
@Value("${aws.s3.region}")
|
||||
private String region;
|
||||
|
||||
@Autowired
|
||||
private ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
@Autowired
|
||||
private DocumentDao documentDao;
|
||||
|
||||
|
||||
private boolean migrationCompleted = false;
|
||||
|
||||
public String reUploadAndMigrateDocuments(String providedKey) {
|
||||
|
||||
Long totalDocuments=0L;
|
||||
Long failedDocuments=0L;
|
||||
Long processDocuments=0L;
|
||||
if (migrationCompleted) {
|
||||
return "Migration already completed.";
|
||||
}
|
||||
@@ -66,26 +93,54 @@ public class S3ReUploadMigrationService {
|
||||
return "Invalid or missing migration key.";
|
||||
}
|
||||
|
||||
List<DocumentEntity> documents = documentRepository.findAllByIsDeleteFalse();
|
||||
List<DocumentEntity> documents = documentRepository.findAllByIsDeleteTrue();
|
||||
totalDocuments = Long.valueOf(documents.size());
|
||||
|
||||
if (documents.isEmpty()) {
|
||||
return "No documents found to migrate.";
|
||||
}
|
||||
|
||||
for (DocumentEntity document : documents) {
|
||||
String oldUrl = document.getFilePath(); // This should contain the full URL
|
||||
log.info("Processing {}", oldUrl);
|
||||
|
||||
log.info("Processing for the Document id and url:{} ",document.getId(),document.getFilePath());
|
||||
try {
|
||||
File localFile = downloadFileFromS3(oldUrl);
|
||||
String newKey = generateNewS3Path(document); // Make sure this generates the correct new path
|
||||
String uploadedPath = uploadFileToNewBucket(localFile, newKey);
|
||||
updateDocumentPathAndNameEntry(document, uploadedPath);
|
||||
|
||||
Long callId = null;
|
||||
Long applicationId = null;
|
||||
Long amendmentId = null;
|
||||
Long evaluationId = null;
|
||||
if (DocumentSourceTypeEnum.CALL.getValue().equalsIgnoreCase(document.getSource())) {
|
||||
callId = document.getSourceId();
|
||||
} else if (DocumentSourceTypeEnum.APPLICATION.getValue().equalsIgnoreCase(document.getSource())) {
|
||||
applicationId = document.getSourceId();
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||
callId = applicationEntity.getCall().getId();
|
||||
}
|
||||
else if(DocumentSourceTypeEnum.AMENDMENT.getValue().equalsIgnoreCase(document.getSource())){
|
||||
amendmentId = document.getSourceId();
|
||||
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
|
||||
applicationId = applicationEntity.getId();
|
||||
callId = applicationEntity.getCall().getId();
|
||||
} else if(DocumentSourceTypeEnum.EVALUATION.getValue().equalsIgnoreCase(document.getSource())){
|
||||
evaluationId = document.getSourceId();
|
||||
ApplicationEntity applicationEntity = applicationEvaluationRepository.findApplicationByEvaluationId(evaluationId);
|
||||
applicationId = applicationEntity.getId();
|
||||
callId = applicationEntity.getCall().getId();
|
||||
}
|
||||
|
||||
|
||||
documentDao.deleteFileFromS3(document,callId,applicationId,amendmentId);
|
||||
processDocuments++;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Error processing document {}: {}", document.getId(), e.getMessage());
|
||||
failedDocuments++;
|
||||
}
|
||||
}
|
||||
log.info("Total Documents Fetched ",totalDocuments);
|
||||
log.info("Total Process Documents :{}",processDocuments);
|
||||
log.info("Total Failed Documents :{}",failedDocuments);
|
||||
return "Migrated Successfully.";
|
||||
|
||||
}
|
||||
|
||||
private boolean isValidKey(String providedKey) {
|
||||
@@ -164,10 +219,10 @@ public class S3ReUploadMigrationService {
|
||||
Long callId;
|
||||
|
||||
if (sourceType.equals(DocumentSourceTypeEnum.CALL)) {
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L);
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L,0L);
|
||||
} else {
|
||||
callId = applicationRepository.findCallIdById(document.getSourceId());
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId());
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId(),0L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,13 +232,4 @@ public class S3ReUploadMigrationService {
|
||||
return parts[parts.length - 1];
|
||||
}
|
||||
|
||||
|
||||
private void updateDocumentPathAndNameEntry(DocumentEntity document, String newPath) {
|
||||
|
||||
String fileName = extractFileName(newPath);
|
||||
document.setFilePath(newPath);
|
||||
document.setFileName(fileName);
|
||||
documentRepository.save(document);
|
||||
log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<UserResponseBean> getAllUsers(HttpServletRequest request, Long roleId) {
|
||||
public List<UserResponseBean> getAllUsers(HttpServletRequest request, List<Long> roleIds) {
|
||||
UserEntity user=validator.validateUser(request);
|
||||
return userDao.getAllUsers(user, roleId);
|
||||
return userDao.getAllUsers(user, roleIds);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.GetObjectRequest;
|
||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.dao.DelegationDao;
|
||||
import net.gepafin.tendermanagement.dao.S3PathConfig;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationSignedDocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||
@@ -56,10 +57,16 @@ public class UserSignedAndDelegationServiceImpl {
|
||||
@Value("${aws.s3.url}")
|
||||
private String s3Url;
|
||||
|
||||
@Autowired
|
||||
private DelegationDao delegationDao;
|
||||
|
||||
private boolean migrationCompleted = false;
|
||||
|
||||
public String migrateUserDelegatedDocuments(String providedKey) {
|
||||
|
||||
Long totalDocuments=0L;
|
||||
Long failedDocuments=0L;
|
||||
Long processDocuments=0L;
|
||||
if (migrationCompleted) {
|
||||
return "Migration already completed.";
|
||||
}
|
||||
@@ -69,25 +76,27 @@ public class UserSignedAndDelegationServiceImpl {
|
||||
return "Invalid or missing migration key.";
|
||||
}
|
||||
|
||||
List<UserCompanyDelegationEntity> documents = userCompanyDelegationRepository.findAllByStatus("ACTIVE");
|
||||
|
||||
List<UserCompanyDelegationEntity> documents = userCompanyDelegationRepository.findAllByStatus("INACTIVE");
|
||||
totalDocuments = Long.valueOf(documents.size());
|
||||
if (documents.isEmpty()) {
|
||||
return "No documents found to migrate.";
|
||||
}
|
||||
|
||||
for (UserCompanyDelegationEntity document : documents) {
|
||||
String oldUrl = document.getFilePath();
|
||||
log.info("Processing user designated document: {}", oldUrl);
|
||||
log.info("Processing user designated document and old Url: {}", document.getId(),oldUrl);
|
||||
|
||||
try {
|
||||
File localFile = downloadFileFromS3(oldUrl);
|
||||
String newKey = generateNewS3PathForDelegationDoc();
|
||||
String uploadedPath = uploadFileToNewBucket(localFile, newKey);
|
||||
updateDelegatedDocumentPathAndNameEntry(document, uploadedPath);
|
||||
delegationDao.deleteDelegationFromS3(document);
|
||||
processDocuments++;
|
||||
} catch (Exception e) {
|
||||
log.error("Error processing user designated document {}: {}", document.getId(), e.getMessage());
|
||||
failedDocuments++;
|
||||
}
|
||||
}
|
||||
log.info("Total Documents Fetched:{} ",totalDocuments);
|
||||
log.info("Total Process Documents :{}",processDocuments);
|
||||
log.info("Total Failed Documents :{}",failedDocuments);
|
||||
return "Migrated";
|
||||
}
|
||||
|
||||
@@ -130,7 +139,7 @@ public class UserSignedAndDelegationServiceImpl {
|
||||
|
||||
private String generateNewS3PathForDelegationDoc() {
|
||||
|
||||
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L);
|
||||
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L);
|
||||
}
|
||||
|
||||
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {
|
||||
|
||||
Reference in New Issue
Block a user