diff --git a/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeCopier.java b/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeCopier.java index 22467a7..60598ae 100644 --- a/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeCopier.java +++ b/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeCopier.java @@ -49,15 +49,21 @@ public class AuthorizationCodeCopier { @Scheduled(initialDelay = 2000, fixedDelayString = "${testresult.authorizationcode.transfer.rate}") @Transactional public void copyACs() { + log.debug("AC Transfer - Copying ACs"); List all = authorizationCodeRepository.findAll(); + log.debug("AC Transfer - Found to copy ACs {}",all); + ResponseEntity voidResponseEntity = submissionServerGateway.processAuthorizationCodes( AuthorizationCodeRequest.withAuthorizationCodes(all)); if (voidResponseEntity.getStatusCode().isError()) { - log.error("Error while processing authorization codes by submission server"); + log.debug("AC Transfer - Error while processing authorization codes by submission server"); } + authorizationCodeRepository.deleteAll(all); + + log.debug("AC Transfer - Done copying {} ACs",all.size()); } } diff --git a/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeService.java b/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeService.java index 4a0abd3..8f3e357 100644 --- a/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeService.java +++ b/src/main/java/app/coronawarn/testresult/authorizationcode/AuthorizationCodeService.java @@ -29,6 +29,7 @@ import java.security.PrivateKey; import java.security.Signature; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; /** @@ -44,6 +45,7 @@ * It is important to only generate 1 such signature for a test result to avoid having duplicates in the database. *

*/ +@Slf4j @Component @RequiredArgsConstructor public class AuthorizationCodeService { @@ -68,6 +70,8 @@ public void generateAndSaveAuthorizationCode(TestResultEntity testResultEntity) try { + log.debug("AC Generation - Start AC generation for {}",testResultEntity.getMobileTestId()); + AuthorizationCodeEntity authorizationCodeEntity = new AuthorizationCodeEntity(); PrivateKey privateKey = PemUtils.getPrivateKeyFromString(testResultConfig.getSignature().getPrivateKeyContent()); @@ -80,8 +84,11 @@ public void generateAndSaveAuthorizationCode(TestResultEntity testResultEntity) authorizationCodeRepository.save(authorizationCodeEntity); + log.debug("AC Generation - Generated and saved AC {}",authorizationCodeEntity); + } catch (Exception ex) { - throw new IllegalArgumentException("Unable to generate and save authorization code",ex); + log.error("AC Generation - Unable to generate and save authorization code",ex); + throw new IllegalArgumentException("AC Generation - Unable to generate and save authorization code",ex); } } diff --git a/src/main/java/app/coronawarn/testresult/entity/AuthorizationCodeEntity.java b/src/main/java/app/coronawarn/testresult/entity/AuthorizationCodeEntity.java index 23192ff..682bcb0 100644 --- a/src/main/java/app/coronawarn/testresult/entity/AuthorizationCodeEntity.java +++ b/src/main/java/app/coronawarn/testresult/entity/AuthorizationCodeEntity.java @@ -36,6 +36,7 @@ import lombok.NoArgsConstructor; import lombok.NonNull; import lombok.RequiredArgsConstructor; +import lombok.ToString; import lombok.experimental.Accessors; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; @@ -52,6 +53,7 @@ @Accessors(chain = true) @NoArgsConstructor @RequiredArgsConstructor +@ToString @Entity @EntityListeners(AuditingEntityListener.class) @Table(name = "authorization_code")