Skip to content

Commit

Permalink
Merge pull request #501 from GSPrakash2662/develop
Browse files Browse the repository at this point in the history
Develop to release
  • Loading branch information
jainhitesh9998 authored Jan 21, 2025
2 parents 04b0cb5 + 269e4e6 commit d805124
Show file tree
Hide file tree
Showing 256 changed files with 3,236 additions and 1,281 deletions.
6 changes: 6 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@
android:name="flutterEmbedding"
android:value="2" />
</application>
<queries>
<!-- If your application checks for inAppBrowserView launch mode support -->
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ MachineDetailsApi getMachineDetailsApi(ClientCryptoManagerService clientCryptoMa
AuthenticationApi getAuthenticationApi(SyncRestService syncRestService,
SyncRestUtil syncRestFactory,
LoginService loginService,
AuditManagerService auditManagerService) {
AuditManagerService auditManagerService,GlobalParamRepository globalParamRepository) {
return new AuthenticationApi(appContext, syncRestService, syncRestFactory,
loginService, auditManagerService);
loginService, auditManagerService, globalParamRepository);
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import io.mosip.registration.clientmanager.BuildConfig;
import io.mosip.registration.clientmanager.constant.AuditEvent;
import io.mosip.registration.clientmanager.constant.Components;
import io.mosip.registration.clientmanager.dto.http.ResponseWrapper;
import io.mosip.registration.clientmanager.dto.http.ServiceError;
import io.mosip.registration.clientmanager.exception.InvalidMachineSpecIDException;
import io.mosip.registration.clientmanager.repository.GlobalParamRepository;
import io.mosip.registration.clientmanager.service.LoginService;
import io.mosip.registration.clientmanager.spi.AuditManagerService;
import io.mosip.registration.clientmanager.spi.SyncRestService;
Expand All @@ -48,6 +50,7 @@ public class AuthenticationApi implements AuthResponsePigeon.AuthResponseApi {
LoginService loginService;
AuditManagerService auditManagerService;
SharedPreferences sharedPreferences;
GlobalParamRepository globalParamRepository;
public static final String IS_OFFICER = "is_officer";
public static final String IS_SUPERVISOR = "is_supervisor";
public static final String IS_DEFAULT = "is_default";
Expand All @@ -59,12 +62,13 @@ public class AuthenticationApi implements AuthResponsePigeon.AuthResponseApi {

@Inject
public AuthenticationApi(Context context, SyncRestService syncRestService, SyncRestUtil syncRestFactory,
LoginService loginService, AuditManagerService auditManagerService) {
LoginService loginService, AuditManagerService auditManagerService, GlobalParamRepository globalParamRepository) {
this.context = context;
this.syncRestService = syncRestService;
this.syncRestFactory = syncRestFactory;
this.loginService = loginService;
this.auditManagerService = auditManagerService;
this.globalParamRepository = globalParamRepository;
sharedPreferences = this.context.
getSharedPreferences(
this.context.getString(R.string.app_name),
Expand Down Expand Up @@ -232,4 +236,10 @@ public void stopAlarmService(@NonNull AuthResponsePigeon.Result<String> result)
}
result.success(resultString);
}

@Override
public void forgotPasswordUrl(@NonNull AuthResponsePigeon.Result<String> result) {
String response = this.globalParamRepository.getCachedStringForgotPassword();
result.success(response);
}
}
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.ibotta:plugin:1.2.0"
//Jacoco Plugin
Expand All @@ -27,7 +27,7 @@ allprojects {
}

ext {
compileSdkVersion = 31
compileSdkVersion = 33
buildToolsVersion = "31.0.0"

minSdkVersion = 28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ TemplateService TemplateService(MasterDataService masterDataService, IdentitySch

@Provides
@Singleton
PreRegistrationDataSyncService PreRegistrationDataSyncService(PreRegistrationDataSyncDao preRegistrationDao, MasterDataService masterDataService, SyncRestService syncRestService, PreRegZipHandlingService preRegZipHandlingService, PreRegistrationList preRegistration, GlobalParamRepository globalParamRepository) {
return new PreRegistrationDataSyncServiceImpl(appContext, preRegistrationDao, masterDataService, syncRestService, preRegZipHandlingService, preRegistration, globalParamRepository);
PreRegistrationDataSyncService PreRegistrationDataSyncService(PreRegistrationDataSyncDao preRegistrationDao, MasterDataService masterDataService, SyncRestService syncRestService, PreRegZipHandlingService preRegZipHandlingService, PreRegistrationList preRegistration, GlobalParamRepository globalParamRepository, RegistrationService registrationService) {
return new PreRegistrationDataSyncServiceImpl(appContext, preRegistrationDao, masterDataService, syncRestService, preRegZipHandlingService, preRegistration, globalParamRepository, registrationService);
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ public class RegistrationConstants {
public static final String SELECTED_HANDLES = "mosip.registration.default-selected-handle-fields";
public static final String TEMPLATE_IMPORTANT_GUIDELINES = "mosip.registration.important_guidelines";
public static final String PRE_REG_PACKET_LOCATION = "mosip.registration.registration_pre_reg_packet_location";
public static final String FORGOT_PASSWORD_URL = "mosip.registration.reset_password_url";
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ public List<String> getSelectedHandles() {
.distinct()
.collect(Collectors.toList());
}

public String getCachedStringForgotPassword() {
return globalParamMap.get(RegistrationConstants.FORGOT_PASSWORD_URL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void syncGlobalParamsData(Runnable onFinish, boolean isManualSync) throws
Log.i(TAG, "config data sync is started");
String serverVersion = getServerVersionFromConfigs();

Call<ResponseWrapper<Map<String, Object>>> call = serverVersion.startsWith("1.1.5") ? syncRestService.getV1GlobalConfigs(
Call<ResponseWrapper<Map<String, Object>>> call = (serverVersion != null && serverVersion.startsWith("1.1.5")) ? syncRestService.getV1GlobalConfigs(
clientCryptoManagerService.getMachineName(), BuildConfig.CLIENT_VERSION) : syncRestService.getGlobalConfigs(
clientCryptoManagerService.getClientKeyIndex(), BuildConfig.CLIENT_VERSION);
call.enqueue(new Callback<ResponseWrapper<Map<String, Object>>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,21 @@ public void syncAllPacketStatus() {
String serverVersion = this.globalParamRepository.getCachedStringGlobalParam(RegistrationConstants.SERVER_VERSION);

PacketStatusRequest packetStatusRequest = new PacketStatusRequest();
packetStatusRequest.setId(serverVersion.startsWith("1.1.5") ? PACKET_STATUS_READER_ID : PACKET_EXTERNAL_STATUS_READER_ID);
packetStatusRequest.setId((serverVersion!=null && serverVersion.startsWith("1.1.5")) ? PACKET_STATUS_READER_ID : PACKET_EXTERNAL_STATUS_READER_ID);
packetStatusRequest.setVersion(PACKET_SYNC_VERSION);
packetStatusRequest.setRequesttime(DateUtils.formatToISOString(LocalDateTime.now(ZoneOffset.UTC)));
List<PacketIdDto> packets = new ArrayList<>();
for (Registration reg : registrations) {
PacketIdDto packet = new PacketIdDto();
if (serverVersion.startsWith("1.1.5")) {
if (serverVersion!=null && serverVersion.startsWith("1.1.5")) {
packet.setRegistrationId(reg.getPacketId());
} else {
packet.setPacketId(reg.getPacketId());
}
}
packetStatusRequest.setRequest(packets);

Call<PacketStatusResponse> call = serverVersion.startsWith("1.1.5") ? this.syncRestService.getV1PacketStatus(packetStatusRequest) : this.syncRestService.getPacketStatus(packetStatusRequest);
Call<PacketStatusResponse> call = (serverVersion!=null && serverVersion.startsWith("1.1.5")) ? this.syncRestService.getV1PacketStatus(packetStatusRequest) : this.syncRestService.getPacketStatus(packetStatusRequest);
call.enqueue(new Callback<PacketStatusResponse>() {
@Override
public void onResponse(Call<PacketStatusResponse> call, Response<PacketStatusResponse> response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.mosip.registration.clientmanager.spi.MasterDataService;
import io.mosip.registration.clientmanager.spi.PreRegistrationDataSyncService;
import io.mosip.registration.clientmanager.dto.registration.RegistrationDto;
import io.mosip.registration.clientmanager.spi.RegistrationService;
import io.mosip.registration.clientmanager.spi.SyncRestService;
import io.mosip.registration.clientmanager.util.SyncRestUtil;
import io.mosip.registration.packetmanager.util.DateUtils;
Expand Down Expand Up @@ -65,18 +66,20 @@ public class PreRegistrationDataSyncServiceImpl implements PreRegistrationDataSy
SharedPreferences sharedPreferences;
PreRegistrationList preRegistration;
GlobalParamRepository globalParamRepository;
RegistrationService registrationService;
private Context context;
private String result = "";
ExecutorService executorServiceForPreReg = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

public PreRegistrationDataSyncServiceImpl(Context context,PreRegistrationDataSyncDao preRegistrationDao,MasterDataService masterDataService,SyncRestService syncRestService,PreRegZipHandlingService preRegZipHandlingService,PreRegistrationList preRegistration,GlobalParamRepository globalParamRepository){
public PreRegistrationDataSyncServiceImpl(Context context,PreRegistrationDataSyncDao preRegistrationDao,MasterDataService masterDataService,SyncRestService syncRestService,PreRegZipHandlingService preRegZipHandlingService,PreRegistrationList preRegistration,GlobalParamRepository globalParamRepository,RegistrationService registrationService){
this.context = context;
this.preRegistrationDao = preRegistrationDao;
this.masterDataService = masterDataService;
this.syncRestService = syncRestService;
this.preRegZipHandlingService = preRegZipHandlingService;
this.preRegistration = preRegistration;
this.globalParamRepository = globalParamRepository;
this.registrationService = registrationService;
sharedPreferences = this.context.getSharedPreferences(
this.context.getString(R.string.app_name),
Context.MODE_PRIVATE);
Expand All @@ -87,7 +90,6 @@ public void fetchPreRegistrationIds(Runnable onFinish) {
Log.i(TAG,"Fetching Pre-Registration Id's started {}");

CenterMachineDto centerMachineDto = this.masterDataService.getRegistrationCenterMachineDetails();
Log.i(TAG,"Pre-Registration get center Id"+ centerMachineDto.getCenterId());
if (centerMachineDto == null) {
result = "application_id_sync_failed";
onFinish.run();
Expand Down Expand Up @@ -208,7 +210,7 @@ public Map<String, Object> getPreRegistration(@NonNull String preRegistrationId,
return attributeData;
}

private PreRegistrationList fetchPreRegistration(String preRegistrationId, String lastUpdatedTimeStamp) throws ClientCheckedException {
private PreRegistrationList fetchPreRegistration(String preRegistrationId, String lastUpdatedTimeStamp) throws Exception {
Log.i(TAG,"Fetching Pre-Registration started for {}"+ preRegistrationId);
// PreRegistrationList preRegistration;

Expand All @@ -220,17 +222,23 @@ private PreRegistrationList fetchPreRegistration(String preRegistrationId, Strin
try {
preRegistration = downloadAndSavePacket(preRegistrationId, lastUpdatedTimeStamp);
} catch (ExecutionException | InterruptedException e) {
this.registrationService.getRegistrationDto().getDocuments().clear();
this.registrationService.getRegistrationDto().getDemographics().clear();
throw new RuntimeException(e);
}
return preRegistration;
}

if(lastUpdatedTimeStamp == null /*||
preRegistration.getLastUpdatedPreRegTimeStamp().before(lastUpdatedTimeStamp)*/) {
Timestamp updatedPreRegTimeStamp = Timestamp.valueOf(preRegistration.getLastUpdatedPreRegTimeStamp());
Timestamp lastUpdatedTime = Timestamp.valueOf(lastUpdatedTimeStamp);
if(lastUpdatedTimeStamp == null ||
updatedPreRegTimeStamp.before(lastUpdatedTime)) {
Log.i(TAG,"Pre-Registration ID is not up-to-date downloading {}"+ preRegistrationId);
try {
return downloadAndSavePacket(preRegistrationId, lastUpdatedTimeStamp);
preRegistration = downloadAndSavePacket(preRegistrationId, lastUpdatedTimeStamp);
} catch (ExecutionException | InterruptedException e) {
this.registrationService.getRegistrationDto().getDocuments().clear();
this.registrationService.getRegistrationDto().getDemographics().clear();
throw new RuntimeException(e);
}
}
Expand All @@ -253,10 +261,9 @@ private Map<String, Object> setPacketToResponse(byte[] decryptedPacket, String p
}

private PreRegistrationList downloadAndSavePacket(@NonNull String preRegistrationId,
String lastUpdatedTimeStamp) throws ClientCheckedException, ExecutionException, InterruptedException {
String lastUpdatedTimeStamp) throws ClientCheckedException, ExecutionException, InterruptedException {

CenterMachineDto centerMachineDto = this.masterDataService.getRegistrationCenterMachineDetails();
Log.i(TAG,"Pre-Registration get center Id"+ centerMachineDto.getCenterId() + centerMachineDto.getMachineId());
if (centerMachineDto == null) {
throw new ClientCheckedException(context, R.string.err_001);
}
Expand Down Expand Up @@ -333,8 +340,10 @@ private String getToDate(Timestamp reqTime) {

Calendar cal = Calendar.getInstance();
cal.setTime(reqTime);
cal.add(Calendar.DATE,
Integer.parseInt(String.valueOf(this.globalParamRepository.getCachedStringGlobalParam(RegistrationConstants.PRE_REG_DAYS_LIMIT))));
if(this.globalParamRepository.getCachedStringGlobalParam(RegistrationConstants.PRE_REG_DAYS_LIMIT)!=null) {
cal.add(Calendar.DATE,
Integer.parseInt(String.valueOf(this.globalParamRepository.getCachedStringGlobalParam(RegistrationConstants.PRE_REG_DAYS_LIMIT))));
}

return formatDate(cal);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public void submitRegistrationDto(String makerName) throws Exception {

List<String> selectedHandles = this.globalParamRepository.getSelectedHandles();
if(selectedHandles != null) {
if (this.registrationDto.getFlowType().equals("NEW")) {
if (this.registrationDto.getFlowType().equals("NEW") ||
this.registrationDto.getFlowType().equals("Update")) {
this.registrationDto.getDemographics().put("selectedHandles", selectedHandles);
}
}
Expand Down Expand Up @@ -220,12 +221,12 @@ public void submitRegistrationDto(String makerName) throws Exception {
document.setType(entry.getValue().getType());
document.setFormat(entry.getValue().getFormat());
document.setRefNumber(entry.getValue().getRefNumber());
document.setDocument(convertImageToPDF(entry.getValue().getContent()));
document.setDocument(("pdf".equalsIgnoreCase(entry.getValue().getFormat()))?combineByteArray(entry.getValue().getContent()):convertImageToPDF(entry.getValue().getContent()));
Log.i(TAG, entry.getKey() + " >> PDF document size :" + document.getDocument().length);
packetWriterService.setDocument(this.registrationDto.getRId(), entry.getKey(), document);
});

if (serverVersion.startsWith("1.1.5")) {
if (serverVersion!=null && serverVersion.startsWith("1.1.5")) {
this.registrationDto.getBestBiometrics(individualBiometricsFieldId, Modality.EXCEPTION_PHOTO).forEach( b -> {
Document document = new Document();
document.setType("EOP");
Expand Down Expand Up @@ -305,6 +306,17 @@ private String getKey(RegistrationDto registrationDTO, String subType) throws Ex
return String.join(RegistrationConstants.COMMA, key);
}

private byte[] combineByteArray(List<byte[]> byteList) {
int totalLength = byteList.stream().mapToInt(byteArr -> byteArr.length).sum();
byte[] result = new byte[totalLength];
int currentPos = 0;
for (byte[] byteArr : byteList) {
System.arraycopy(byteArr, 0, result, currentPos, byteArr.length);
currentPos += byteArr.length;
}
return result;
}

private String getAdditionalInfo(Object fieldValue) {
if(fieldValue == null) { return null; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import java.util.List;

import io.mosip.registration.clientmanager.config.ClientDatabase;
import io.mosip.registration.clientmanager.dao.GlobalParamDao;
import io.mosip.registration.clientmanager.dao.IdentitySchemaDao;
import io.mosip.registration.clientmanager.dao.ProcessSpecDao;
import io.mosip.registration.clientmanager.dao.TemplateDao;
import io.mosip.registration.clientmanager.dto.http.IdSchemaResponse;
import io.mosip.registration.clientmanager.dto.uispec.FieldSpecDto;
import io.mosip.registration.clientmanager.dto.uispec.ProcessSpecDto;
Expand All @@ -41,7 +44,15 @@ public void setUp() {
.build();

IdentitySchemaDao identitySchemaDao = clientDatabase.identitySchemaDao();
identitySchemaRepository = new IdentitySchemaRepository(identitySchemaDao);
//template dao
TemplateDao templateDao = clientDatabase.templateDao();
TemplateRepository templateRepository = new TemplateRepository(templateDao);
//global param dao
GlobalParamDao globalParamDao = clientDatabase.globalParamDao();
GlobalParamRepository globalParamRepository = new GlobalParamRepository(globalParamDao);

ProcessSpecDao processSpecDao = clientDatabase.processSpecDao();
identitySchemaRepository = new IdentitySchemaRepository(templateRepository, globalParamRepository, identitySchemaDao,processSpecDao);

ProcessSpecDto processSpecDto = new ProcessSpecDto();
ScreenSpecDto screen = new ScreenSpecDto();
Expand Down
Loading

0 comments on commit d805124

Please sign in to comment.