Skip to content

Commit 49cc22f

Browse files
committed
Reduce duplication
1 parent fa206fe commit 49cc22f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

access-grant/src/main/java/com/inrupt/client/accessgrant/AccessGrantClient.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -754,11 +754,7 @@ static Map<String, Object> buildAccessDenialv1(
754754
consent.put(HAS_STATUS, "https://w3id.org/GConsent#ConsentStatusRefused");
755755
consent.put(FOR_PERSONAL_DATA, resources);
756756
consent.put(IS_PROVIDED_TO, agent);
757-
if (verifiedRequest) {
758-
consent.put(VERIFIED_REQUEST, accessRequest);
759-
} else {
760-
consent.put(REQUEST, accessRequest);
761-
}
757+
linkRequest(consent, accessRequest, verifiedRequest);
762758
if (!purposes.isEmpty()) {
763759
consent.put(FOR_PURPOSE, purposes);
764760
}
@@ -796,11 +792,7 @@ static Map<String, Object> buildAccessGrantv1(
796792
consent.put(HAS_STATUS, "https://w3id.org/GConsent#ConsentStatusExplicitlyGiven");
797793
consent.put(FOR_PERSONAL_DATA, resources);
798794
consent.put(IS_PROVIDED_TO, agent);
799-
if (verifiedRequest) {
800-
consent.put(VERIFIED_REQUEST, accessRequest);
801-
} else {
802-
consent.put(REQUEST, accessRequest);
803-
}
795+
linkRequest(consent, accessRequest, verifiedRequest);
804796
if (!purposes.isEmpty()) {
805797
consent.put(FOR_PURPOSE, purposes);
806798
}
@@ -906,4 +898,12 @@ static boolean isAccessDenial(final URI type) {
906898
return SOLID_ACCESS_DENIAL.equals(type.toString()) || QN_ACCESS_DENIAL.equals(type)
907899
|| FQ_ACCESS_DENIAL.equals(type);
908900
}
901+
902+
private static void linkRequest(final Map<String, Object> consent, final URI request, final boolean verifiedLink) {
903+
if (verifiedLink) {
904+
consent.put(VERIFIED_REQUEST, request);
905+
} else {
906+
consent.put(REQUEST, request);
907+
}
908+
}
909909
}

0 commit comments

Comments
 (0)