Skip to content
Merged
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 @@ -26,23 +26,14 @@
*/
public class InternalConsentUpdateRequestDTO {

private String consentID;
private String receipt;
private String status;
private int consentFrequency;
private long validityPeriod;
private boolean recurringIndicator;
private Integer consentFrequency;
private Long validityPeriod;
private Boolean recurringIndicator;
private Map<String, String> consentAttributes;
private List<Authorization> authorizationResources;

public String getConsentID() {
return consentID;
}

public void setConsentID(String consentID) {
this.consentID = consentID;
}

public String getReceipt() {
return receipt;
}
Expand All @@ -59,27 +50,27 @@ public void setStatus(String status) {
this.status = status;
}

public int getConsentFrequency() {
public Integer getConsentFrequency() {
return consentFrequency;
}

public void setConsentFrequency(int consentFrequency) {
public void setConsentFrequency(Integer consentFrequency) {
this.consentFrequency = consentFrequency;
}

public long getValidityPeriod() {
public Long getValidityPeriod() {
return validityPeriod;
}

public void setValidityPeriod(long validityPeriod) {
public void setValidityPeriod(Long validityPeriod) {
this.validityPeriod = validityPeriod;
}

public boolean isRecurringIndicator() {
public Boolean isRecurringIndicator() {
return recurringIndicator;
}

public void setRecurringIndicator(boolean recurringIndicator) {
public void setRecurringIndicator(Boolean recurringIndicator) {
this.recurringIndicator = recurringIndicator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,24 @@ public static DetailedConsentResource constructDetailedConsentResourceFromUpdate
InternalConsentUpdateRequestDTO updateRequestDTO = objectMapper.readValue(requestPayload.toString(),
InternalConsentUpdateRequestDTO.class);

ArrayList<AuthorizationResource> authorizationResources = new ArrayList<>();
ArrayList<ConsentMappingResource> consentMappingResources = new ArrayList<>();
String receipt = updateRequestDTO.getReceipt() != null ? updateRequestDTO.getReceipt()
: storedConsent.getReceipt();
String status = updateRequestDTO.getStatus() != null ? updateRequestDTO.getStatus()
Comment on lines +333 to +335
Copy link
Contributor

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 1

Suggested change
String receipt = updateRequestDTO.getReceipt() != null ? updateRequestDTO.getReceipt()
: storedConsent.getReceipt();
String status = updateRequestDTO.getStatus() != null ? updateRequestDTO.getStatus()
String receipt = updateRequestDTO.getReceipt() != null ? updateRequestDTO.getReceipt()
: storedConsent.getReceipt();
log.debug("Processing consent update for consentId: {}", consentId);

: storedConsent.getCurrentStatus();
int frequency = updateRequestDTO.getConsentFrequency() != null ?
updateRequestDTO.getConsentFrequency() : storedConsent.getConsentFrequency();
long validityPeriod = updateRequestDTO.getValidityPeriod() != null ?
updateRequestDTO.getValidityPeriod() : storedConsent.getValidityPeriod();
boolean recurringIndicator = updateRequestDTO.isRecurringIndicator() != null ?
updateRequestDTO.isRecurringIndicator() : storedConsent.isRecurringIndicator();
Map<String, String> consentAttributes = updateRequestDTO.getConsentAttributes() != null ?
updateRequestDTO.getConsentAttributes() : null;

ArrayList<AuthorizationResource> authorizationResources = null;
ArrayList<ConsentMappingResource> consentMappingResources = null;
if (updateRequestDTO.getAuthorizationResources() != null) {
authorizationResources = new ArrayList<>();
Comment on lines +347 to +349
Copy link
Contributor

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 2

Suggested change
ArrayList<ConsentMappingResource> consentMappingResources = null;
if (updateRequestDTO.getAuthorizationResources() != null) {
authorizationResources = new ArrayList<>();
if (updateRequestDTO.getAuthorizationResources() != null) {
log.debug("Updating authorization resources for consentId: {}", consentId);
authorizationResources = new ArrayList<>();

consentMappingResources = new ArrayList<>();
for (InternalConsentUpdateRequestDTO.Authorization authorization:
updateRequestDTO.getAuthorizationResources()) {
String authId = authorization.getAuthorizationID() != null ? authorization.getAuthorizationID() :
Expand All @@ -354,19 +369,12 @@ public static DetailedConsentResource constructDetailedConsentResourceFromUpdate
}
}
}
} else {
// If the request doesn't contain authorization resources, use the existing authorization resources
// of the consent
authorizationResources = storedConsent.getAuthorizationResources();
consentMappingResources = storedConsent.getConsentMappingResources();
}

return new DetailedConsentResource(consentId,
storedConsent.getClientID(), updateRequestDTO.getReceipt(), storedConsent.getConsentType(),
updateRequestDTO.getStatus(), updateRequestDTO.getConsentFrequency(),
updateRequestDTO.getValidityPeriod(), storedConsent.getCreatedTime(), 0L,
updateRequestDTO.isRecurringIndicator(), updateRequestDTO.getConsentAttributes(),
authorizationResources, consentMappingResources);
return new DetailedConsentResource(consentId, storedConsent.getClientID(), receipt,
storedConsent.getConsentType(), status, frequency, validityPeriod, storedConsent.getCreatedTime(),
0L, recurringIndicator, consentAttributes, authorizationResources,
consentMappingResources);

} catch (JsonProcessingException e) {
log.error(String.format("Failed to parse update consent request payload for consentId: %s. Error: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ public class TestConstants {
"}";

public static final String CONSENT_UPDATE_PAYLOAD = "{\n" +
" \"consentID\": \"" + SAMPLE_CONSENT_ID + "\",\n" +
" \"status\": \"authorised\",\n" +
" \"validityPeriod\": 0,\n" +
" \"recurringIndicator\": true,\n" +
Expand Down
Loading