Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-29593 Record status comment for failed status #831

Open
wants to merge 1 commit into
base: 1.1.4.4
Choose a base branch
from
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
Expand Up @@ -7,10 +7,12 @@
import io.mosip.credential.request.generator.entity.CredentialEntity;
import io.mosip.credential.request.generator.exception.ApiNotAccessibleException;
import io.mosip.credential.request.generator.util.RestUtil;
import io.mosip.credential.request.generator.util.TrimExceptionMessage;
import io.mosip.idrepository.core.dto.CredentialIssueRequestDto;
import io.mosip.idrepository.core.dto.CredentialServiceRequestDto;
import io.mosip.idrepository.core.dto.CredentialServiceResponse;
import io.mosip.idrepository.core.dto.CredentialServiceResponseDto;
import io.mosip.idrepository.core.dto.ErrorDTO;
import io.mosip.idrepository.core.logger.IdRepoLogger;
import io.mosip.idrepository.core.security.IdRepoSecurityManager;
import io.mosip.kernel.core.exception.ExceptionUtils;
Expand Down Expand Up @@ -91,6 +93,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon

try {
forkJoinPool.submit(() -> credentialEntities.parallelStream().forEach(credential -> {
TrimExceptionMessage trimMessage = new TrimExceptionMessage();
try {
LOGGER.info(IdRepoSecurityManager.getUser(), CREDENTIAL_ITEM_PROCESSOR, "batchid = " + batchId,
"started processing item : " + credential.getRequestId());
Expand Down Expand Up @@ -122,8 +125,9 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon
responseObject.getErrors() != null && !responseObject.getErrors().isEmpty()) {
LOGGER.debug(IdRepoSecurityManager.getUser(), CREDENTIAL_ITEM_PROCESSOR, "batchid = " + batchId,
responseObject.toString());

ErrorDTO error = responseObject.getErrors().get(0);
credential.setStatusCode(CredentialStatusCode.FAILED.name());
credential.setStatusComment(error.getMessage());

} else {
CredentialServiceResponse credentialServiceResponse = responseObject.getResponse();
Expand All @@ -132,6 +136,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon
credential.setIssuanceDate(credentialServiceResponse.getIssuanceDate());
credential.setStatusCode(credentialServiceResponse.getStatus());
credential.setSignature(credentialServiceResponse.getSignature());
credential.setStatusComment("credentials issued to partner");

}
credential.setUpdatedBy(CREDENTIAL_USER);
Expand All @@ -143,20 +148,23 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon
LOGGER.error(IdRepoSecurityManager.getUser(), CREDENTIAL_ITEM_PROCESSOR, "batchid = " + batchId,
ExceptionUtils.getStackTrace(e));
credential.setStatusCode("FAILED");
credential.setStatusComment(trimMessage.trimExceptionMessage(e.getMessage()));
credential.setUpdateDateTime(DateUtils.getUTCCurrentDateTime());
credential.setUpdatedBy(CREDENTIAL_USER);
} catch (IOException e) {

LOGGER.error(IdRepoSecurityManager.getUser(), CREDENTIAL_ITEM_PROCESSOR, "batchid = " + batchId,
ExceptionUtils.getStackTrace(e));
credential.setStatusCode("FAILED");
credential.setStatusComment(trimMessage.trimExceptionMessage(e.getMessage()));
credential.setUpdateDateTime(DateUtils.getUTCCurrentDateTime());
credential.setUpdatedBy(CREDENTIAL_USER);
} catch (Exception e) {

LOGGER.error(IdRepoSecurityManager.getUser(), CREDENTIAL_ITEM_PROCESSOR, "batchid = " + batchId,
ExceptionUtils.getStackTrace(e));
credential.setStatusCode("FAILED");
credential.setStatusComment(trimMessage.trimExceptionMessage(e.getMessage()));
credential.setUpdateDateTime(DateUtils.getUTCCurrentDateTime());
credential.setUpdatedBy(CREDENTIAL_USER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public class CredentialEntity {
/** The deleted date time. */
@Column(name = "del_dtimes")
private LocalDateTime deletedDateTime;

@Column(name = "status_comment")
private String statusComment;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the default db schema of 1.1.4.4 we might not have this field, this change will cause consistence issue.


/**
* Gets the request id.
Expand Down Expand Up @@ -291,4 +294,12 @@ public void setSignature(String signature) {
this.signature = signature;
}

public String getStatusComment() {
return statusComment;
}

public void setStatusComment(String statusComment) {
this.statusComment = statusComment;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.mosip.credential.request.generator.util;

/**
* The Class TrimExceptionMessage.
*
* @author Neha
*/

public class TrimExceptionMessage {

private static final int MESSAGE_LENGTH = 400;

public String trimExceptionMessage(String exceptionMessage) {
return exceptionMessage.substring(0, Math.min(exceptionMessage.length(), MESSAGE_LENGTH));

}

}