Skip to content

Commit

Permalink
Code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
slaurenz committed Jan 28, 2022
1 parent e8727fe commit 7b1a23e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

import lombok.Getter;

@Getter
public class RevocationBatchDownloadException extends RuntimeException {

@Getter
private int status = 500;

private final int status;

public RevocationBatchDownloadException(String message, Throwable inner) {
super(message, inner);
this.status = 500;
}

public RevocationBatchDownloadException(String message) {
super(message);
this.status = 500;
}

public RevocationBatchDownloadException(String message, Throwable inner, int status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import lombok.Getter;

@Getter
public class RevocationBatchGoneException extends RuntimeException {
@Getter
private String batchId;

private final String batchId;

public RevocationBatchGoneException(String message, String batchId) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import lombok.Getter;

@Getter
public class RevocationBatchParseException extends RuntimeException {
@Getter
private String batchId;

private final String batchId;

public RevocationBatchParseException(String message, String batchId) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

/**
* This class provides an Iterator for downloading the revocation List parts from the gateway.
*
*/

@ConditionalOnProperty("dgc.gateway.connector.enabled")
Expand All @@ -58,6 +57,7 @@ public class DgcGatewayRevocationListDownloadIterator implements Iterator<List<R
* Creates a new Iterator instance for downloading the revocation list from the dgc gateway.
* The If-Modified-Since Header is set to the default value and the download should start with the first
* part of the revocation list.
*
* @param dgcGatewayConnectorRestClient The rest client for the connection to the dgc gateway
*/

Expand All @@ -69,8 +69,9 @@ public DgcGatewayRevocationListDownloadIterator(DgcGatewayConnectorRestClient dg
* Creates a new Iterator instance for downloading the revocation list from the dgc gateway.
* The If-Modified-Since Header is set to the given value and only newer parts of the revocation list
* are downloaded.
*
* @param dgcGatewayConnectorRestClient The rest client for the connection to the dgc gateway
* @param ifModifiedSinceDate The value for the If-Modified-Since date
* @param ifModifiedSinceDate The value for the If-Modified-Since date
*/

public DgcGatewayRevocationListDownloadIterator(DgcGatewayConnectorRestClient dgcGatewayConnectorRestClient,
Expand All @@ -81,7 +82,8 @@ public DgcGatewayRevocationListDownloadIterator(DgcGatewayConnectorRestClient dg
}

/**
* Sets the If-Modified-Since date and downloads the next newer part of the revocation list from the dgc gateway.
* Sets the If-Modified-Since date and downloads the next newer part of the revocation list from the dgc gateway.
*
* @param dateTime The value for the If-Modified-Since date
*/
public void setIfModifiedSinceDate(ZonedDateTime dateTime) {
Expand Down Expand Up @@ -131,18 +133,20 @@ private void fetchNextRevocationListPart() {
responseEntity.getStatusCode());
return;
}
try {
if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT
|| responseEntity.getBody().getBatches().isEmpty()) {

if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT
|| responseEntity.getBody() == null
|| responseEntity.getBody().getBatches().isEmpty()) {
log.debug("No Content received for download with If-Modified-Since date: {}", toIsoO8601(lastUpdated));
return;
}

nextData = responseEntity.getBody().getBatches();
hasNext = true;
lastUpdated = nextData.get(nextData.size() - 1).getDate();
} catch (NullPointerException e) {
log.debug("No Content received for download with If-Modified-Since date: {}", toIsoO8601(lastUpdated));
return;
}

nextData = responseEntity.getBody().getBatches();
hasNext = true;
lastUpdated = nextData.get(nextData.size() - 1).getDate();
}

}

0 comments on commit 7b1a23e

Please sign in to comment.