Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package io.mosip.resident.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.mosip.kernel.biometrics.entities.BiometricRecord;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Map;

/**
*
Expand Down Expand Up @@ -44,5 +47,6 @@ public class ResidentUpdateDto implements Serializable {
private String proofOfIdentity;
private String proofOfRelationship;
private String proofOfDateOfBirth;
private Map<String, BiometricRecord> bios;

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class ResidentUpdateRequestDto {
private String otp;

private String identityJson;

private List<ResidentDocuments> documents;

private String individualBiometrics;

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class ResidentUpdateService {

@Autowired
private Utilities utilities;

@Autowired
AuditUtil audit;

Expand All @@ -105,16 +105,17 @@ public class ResidentUpdateService {
private static final String VALUE = "value";

public PacketGeneratorResDto createPacket(ResidentUpdateDto request) throws BaseCheckedException, IOException {
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.UIN.toString(),
request.getIdValue(), "ResidentUpdateServiceImpl::createPacket()");
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.UIN.toString(), request.getIdValue(),
"ResidentUpdateServiceImpl::createPacket()");
byte[] packetZipBytes = null;
audit.setAuditRequestDto(EventEnum.CREATE_PACKET);
PackerGeneratorFailureDto dto = new PackerGeneratorFailureDto();
if (validator.isValidCenter(request.getCenterId())
&& request.getIdType().equals(ResidentIndividialIDType.UIN)
? validator.isValidRegistrationTypeAndUin(RegistrationType.RES_UPDATE.toString(),
request.getIdValue())
: validator.isValidVid(request.getIdValue())) {
// if (validator.isValidCenter(request.getCenterId())
// && request.getIdType().equals(ResidentIndividialIDType.UIN)
// ? validator.isValidRegistrationTypeAndUin(RegistrationType.RES_UPDATE.toString(),
// request.getIdValue())
// : validator.isValidVid(request.getIdValue())) {
if (validator.isValidCenter(request.getCenterId())) {

logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.UIN.toString(),
request.getIdValue(),
Expand All @@ -130,7 +131,8 @@ public PacketGeneratorResDto createPacket(ResidentUpdateDto request) throws Base

fields.keySet().forEach(key -> {
try {
idMap.put(key, fields.get(key) != null ? JsonUtils.javaObjectToJsonString(fields.get(key)) : null);
idMap.put(key,
fields.get(key) != null ? JsonUtils.javaObjectToJsonString(fields.get(key)) : null);
} catch (JsonProcessingException e) {
throw new BaseUncheckedException(ResidentErrorCode.JSON_PROCESSING_EXCEPTION.getErrorCode(),
ResidentErrorCode.JSON_PROCESSING_EXCEPTION.getErrorMessage(), e);
Expand All @@ -144,56 +146,53 @@ public PacketGeneratorResDto createPacket(ResidentUpdateDto request) throws Base
if (request.getProofOfDateOfBirth() != null && !request.getProofOfDateOfBirth().isEmpty())
setDemographicDocuments(request.getProofOfAddress(), demoJsonObject, PROOF_OF_DOB, map);
if (request.getProofOfRelationship() != null && !request.getProofOfRelationship().isEmpty())
setDemographicDocuments(request.getProofOfAddress(), demoJsonObject, PROOF_OF_RELATIONSHIP,
map);
setDemographicDocuments(request.getProofOfAddress(), demoJsonObject, PROOF_OF_RELATIONSHIP, map);
if (request.getProofOfIdentity() != null && !request.getProofOfIdentity().isEmpty())
setDemographicDocuments(request.getProofOfAddress(), demoJsonObject, PROOF_OF_IDENTITY, map);

PacketDto packetDto = new PacketDto();
packetDto.setId(generateRegistrationId(request.getCenterId(), request.getMachineId()));
packetDto.setSource(utilities.getDefaultSource());
packetDto.setProcess(RegistrationType.RES_UPDATE.toString());
packetDto.setProcess(RegistrationType.NEW.toString());
packetDto.setSchemaVersion(idschemaVersion);
packetDto.setSchemaJson(idSchemaUtil.getIdSchema(Double.valueOf(idschemaVersion)));
packetDto.setFields(idMap);
packetDto.setDocuments(map);
packetDto.setMetaInfo(getRegistrationMetaData(request.getIdValue(),
request.getRequestType().toString(), request.getCenterId(), request.getMachineId()));
packetDto.setMetaInfo(getRegistrationMetaData(request.getIdValue(), request.getRequestType().toString(),
request.getCenterId(), request.getMachineId()));
packetDto.setAudits(utilities.generateAudit(packetDto.getId()));
packetDto.setOfflineMode(false);
packetDto.setRefId(request.getCenterId() + "_" + request.getMachineId());
packetDto.setBiometrics(request.getBios());
List<PacketInfo> packetInfos = packetWriter.createPacket(packetDto);

if (CollectionUtils.isEmpty(packetInfos) || packetInfos.iterator().next().getId() == null)
throw new PacketCreatorException(ResidentErrorCode.PACKET_CREATION_EXCEPTION.getErrorCode(), ResidentErrorCode.PACKET_CREATION_EXCEPTION.getErrorMessage());
throw new PacketCreatorException(ResidentErrorCode.PACKET_CREATION_EXCEPTION.getErrorCode(),
ResidentErrorCode.PACKET_CREATION_EXCEPTION.getErrorMessage());

file = new File(env.getProperty("object.store.base.location")
+ File.separator + env.getProperty("packet.manager.account.name")
+ File.separator + packetInfos.iterator().next().getId() + ".zip");
file = new File(env.getProperty("object.store.base.location") + File.separator
+ env.getProperty("packet.manager.account.name") + File.separator
+ packetInfos.iterator().next().getId() + ".zip");

FileInputStream fis = new FileInputStream(file);

packetZipBytes = IOUtils.toByteArray(fis);

String creationTime = DateUtils.formatToISOString(LocalDateTime.now());

logger.debug(LoggerFileConstant.SESSIONID.toString(),
LoggerFileConstant.REGISTRATIONID.toString(), packetDto.getId(),
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
packetDto.getId(),
"ResidentUpdateServiceImpl::createPacket()::packet created and sent for sync service");

PacketGeneratorResDto packerGeneratorResDto = syncUploadEncryptionService.uploadUinPacket(
packetDto.getId(), creationTime, request.getRequestType().toString(),
packetZipBytes);
packetDto.getId(), creationTime, request.getRequestType().toString(), packetZipBytes);

logger.debug(LoggerFileConstant.SESSIONID.toString(),
LoggerFileConstant.REGISTRATIONID.toString(), packetDto.getId(),
"ResidentUpdateServiceImpl::createPacket()::packet synched and uploaded");
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
packetDto.getId(), "ResidentUpdateServiceImpl::createPacket()::packet synched and uploaded");
return packerGeneratorResDto;
} catch (Exception e) {
logger.error(LoggerFileConstant.SESSIONID.toString(),
LoggerFileConstant.REGISTRATIONID.toString(),
ResidentErrorCode.BASE_EXCEPTION.getErrorMessage(),
ExceptionUtils.getStackTrace(e));
logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
ResidentErrorCode.BASE_EXCEPTION.getErrorMessage(), ExceptionUtils.getStackTrace(e));
if (e instanceof BaseCheckedException) {
throw (BaseCheckedException) e;
}
Expand Down Expand Up @@ -225,7 +224,7 @@ private void setDemographicDocuments(String documentBytes, JSONObject demoJsonOb
}

private Map<String, String> getRegistrationMetaData(String registrationType, String uin, String centerId,
String machineId) throws JsonProcessingException {
String machineId) throws JsonProcessingException {

Map<String, String> metadata = new HashMap<>();

Expand Down Expand Up @@ -263,22 +262,20 @@ private String generateRegistrationId(String centerId, String machineId) throws
JSONObject ridJson;
try {

logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
"", "PacketGeneratorServiceImpl::generateRegistrationId():: RIDgeneration Api call started");
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "",
"PacketGeneratorServiceImpl::generateRegistrationId():: RIDgeneration Api call started");
responseWrapper = (ResponseWrapper<?>) restClientService.getApi(ApiName.RIDGENERATION, pathsegments, "", "",
ResponseWrapper.class);
if (CollectionUtils.isEmpty(responseWrapper.getErrors())) {
ridJson = mapper.readValue(mapper.writeValueAsString(responseWrapper.getResponse()), JSONObject.class);
logger.debug(LoggerFileConstant.SESSIONID.toString(),
LoggerFileConstant.REGISTRATIONID.toString(), "",
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "",
"\"PacketGeneratorServiceImpl::generateRegistrationId():: RIDgeneration Api call ended with response data : "
+ JsonUtil.objectMapperObjectToJson(ridJson));
rid = (String) ridJson.get("rid");

} else {
List<ServiceError> error = responseWrapper.getErrors();
logger.debug(LoggerFileConstant.SESSIONID.toString(),
LoggerFileConstant.REGISTRATIONID.toString(), "",
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "",
"\"PacketGeneratorServiceImpl::generateRegistrationId():: RIDgeneration Api call ended with response data : "
+ error.get(0).getMessage());
throw new BaseCheckedException(ResidentErrorCode.BASE_EXCEPTION.getErrorCode(),
Expand Down
Loading