All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mosip.registration.jobs.impl.DeleteAuditLogsJob Maven / Gradle / Ivy

package io.mosip.registration.jobs.impl;

import io.mosip.kernel.core.util.DateUtils;
import io.mosip.registration.entity.Registration;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import io.mosip.kernel.core.exception.ExceptionUtils;
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.registration.audit.AuditManagerService;
import io.mosip.registration.config.AppConfig;
import io.mosip.registration.constants.LoggerConstants;
import io.mosip.registration.constants.RegistrationConstants;
import io.mosip.registration.dto.ResponseDTO;
import io.mosip.registration.exception.RegBaseUncheckedException;
import io.mosip.registration.jobs.BaseJob;

import java.sql.Timestamp;

/**
 * The {@code DeleteAuditLogsJob} is a job to delete audit logs which extends
 * {@code BaseJob}
 * 
 * 

* The Audit logs deletion was dependent on audit_deletion_configured_days. * configuration parameter, and Audit logs deletion was internally deletes the * registration packets in local and {@link Registration} in database. *

* *

* If audit_deletion_configured_days=10, then all audit logs before 10 days from * now where eligible to delete, and it has a internal check as the registration * associated with audit has to be processed, then delete. *

* *

* This Job will be automatically triggered based on sync_frequency which has in * local DB. *

* *

* If Sync_frequency = "0 0 11 * * ?" this job will be triggered everyday 11:00 * AM, if it was missed on 11:00 AM, trigger on immediate application launch. *

* * * @author Yaswanth S * @since 1.0.0 * */ @Component(value = "deleteAuditLogsJob") public class DeleteAuditLogsJob extends BaseJob { /** * The RegPacketStatusServiceImpl */ @Autowired private AuditManagerService auditService; /** * LOGGER for logging */ private static final Logger LOGGER = AppConfig.getLogger(DeleteAuditLogsJob.class); /* * (non-Javadoc) * * @see org.springframework.scheduling.quartz.QuartzJobBean#executeInternal(org. * quartz.JobExecutionContext) */ @Async @Override public void executeInternal(JobExecutionContext context) { LOGGER.debug(LoggerConstants.DELETE_AUDIT_LOGS_JOB, RegistrationConstants.APPLICATION_NAME, RegistrationConstants.APPLICATION_ID, "job execute internal started"); this.responseDTO = new ResponseDTO(); try { this.jobId = loadContext(context); auditService = applicationContext.getBean(AuditManagerService.class); // Execute Parent Job this.responseDTO = executeParentJob(jobId); // Execute Current Job if (responseDTO.getSuccessResponseDTO() != null) { this.responseDTO = auditService.deleteAuditLogs(); } syncTransactionUpdate(responseDTO, triggerPoint, jobId, Timestamp.valueOf(DateUtils.getUTCCurrentDateTime())); } catch (RegBaseUncheckedException baseUncheckedException) { LOGGER.error(LoggerConstants.DELETE_AUDIT_LOGS_JOB, RegistrationConstants.APPLICATION_NAME, RegistrationConstants.APPLICATION_ID, baseUncheckedException.getMessage() + ExceptionUtils.getStackTrace(baseUncheckedException)); throw baseUncheckedException; } LOGGER.debug(LoggerConstants.DELETE_AUDIT_LOGS_JOB, RegistrationConstants.APPLICATION_NAME, RegistrationConstants.APPLICATION_ID, "job execute internal Ended"); } /* * (non-Javadoc) * * @see io.mosip.registration.jobs.BaseJob#executeJob(java.lang.String, * java.lang.String) */ @Override public ResponseDTO executeJob(String triggerPoint, String jobId) { LOGGER.debug(LoggerConstants.DELETE_AUDIT_LOGS_JOB, RegistrationConstants.APPLICATION_NAME, RegistrationConstants.APPLICATION_ID, "execute Job started"); // Execute Parent Job this.responseDTO = executeParentJob(jobId); // Execute Current Job if (responseDTO.getSuccessResponseDTO() != null) { this.responseDTO = auditService.deleteAuditLogs(); } syncTransactionUpdate(responseDTO, triggerPoint, jobId, Timestamp.valueOf(DateUtils.getUTCCurrentDateTime())); LOGGER.debug(LoggerConstants.DELETE_AUDIT_LOGS_JOB, RegistrationConstants.APPLICATION_NAME, RegistrationConstants.APPLICATION_ID, "execute job ended"); return responseDTO; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy