Skip to content

Commit

Permalink
Merge pull request #22 from covid-be-app/development
Browse files Browse the repository at this point in the history
Pre-release v1.2.2 to staging
  • Loading branch information
rik2803 authored Feb 23, 2021
2 parents 60f22d9 + 9c4e45a commit 3feae10
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthorizationCodeEntity> all = authorizationCodeRepository.findAll();

log.debug("AC Transfer - Found to copy ACs {}",all);

ResponseEntity<Void> 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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -44,6 +45,7 @@
* It is important to only generate 1 such signature for a test result to avoid having duplicates in the database.
* </p>
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class AuthorizationCodeService {
Expand All @@ -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());
Expand All @@ -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);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,6 +53,7 @@
@Accessors(chain = true)
@NoArgsConstructor
@RequiredArgsConstructor
@ToString
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "authorization_code")
Expand Down

0 comments on commit 3feae10

Please sign in to comment.