From a20965746d48c66d68e84f0cfbf690e5c8e677af Mon Sep 17 00:00:00 2001 From: Deepanjan Bhattacharyya Date: Tue, 17 Sep 2019 17:24:15 -0400 Subject: [PATCH 1/3] Update primary key Check if userPoolArn is null and if so output blank. If userpool client's id is null use the name. --- src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java b/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java index 8c1ba1bbb..95d020b4e 100644 --- a/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java +++ b/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java @@ -130,7 +130,10 @@ public void setUserPoolDomain(UserPoolDomainResource userPoolDomain) { } public String primaryKey() { - return String.format("%s/%s/%s", getUserPoolArn(), getUserPoolClient().getId(), getUserPoolDomain().getDomain()); + return String.format("%s %s %s", + getUserPoolArn() != null ? getUserPoolArn() : "", + getUserPoolClient().getId() != null ? getUserPoolClient().getId() : getUserPoolClient().getName(), + getUserPoolDomain().getDomain()); } @Override From 175f089b899b7409c75ac57fe545f5d8d936b899 Mon Sep 17 00:00:00 2001 From: Deepanjan Bhattacharyya Date: Wed, 18 Sep 2019 11:14:21 -0400 Subject: [PATCH 2/3] Reformat primary key to avoid extra space when user pool arn not present. --- src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java b/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java index 95d020b4e..20fc77598 100644 --- a/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java +++ b/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java @@ -130,8 +130,8 @@ public void setUserPoolDomain(UserPoolDomainResource userPoolDomain) { } public String primaryKey() { - return String.format("%s %s %s", - getUserPoolArn() != null ? getUserPoolArn() : "", + return String.format("%s%s %s", + getUserPoolArn() != null ? getUserPoolArn() + " " : "", getUserPoolClient().getId() != null ? getUserPoolClient().getId() : getUserPoolClient().getName(), getUserPoolDomain().getDomain()); } From 90096f6da80689417eed3faf3af92906f551fb31 Mon Sep 17 00:00:00 2001 From: Deepanjan Bhattacharyya Date: Wed, 18 Sep 2019 12:00:51 -0400 Subject: [PATCH 3/3] Rplace String format with string builder for a cleaner conditional primary key generation. --- .../aws/elbv2/AuthenticateCognitoAction.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java b/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java index 20fc77598..0c1a2bb07 100644 --- a/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java +++ b/src/main/java/gyro/aws/elbv2/AuthenticateCognitoAction.java @@ -130,10 +130,20 @@ public void setUserPoolDomain(UserPoolDomainResource userPoolDomain) { } public String primaryKey() { - return String.format("%s%s %s", - getUserPoolArn() != null ? getUserPoolArn() + " " : "", - getUserPoolClient().getId() != null ? getUserPoolClient().getId() : getUserPoolClient().getName(), - getUserPoolDomain().getDomain()); + StringBuilder sb = new StringBuilder(); + if (getUserPoolArn() != null) { + sb.append(getUserPoolArn()).append(" "); + } + + if (getUserPoolClient().getId() != null) { + sb.append(getUserPoolClient().getId()); + } else { + sb.append(getUserPoolClient().getName()); + } + + sb.append(" ").append(getUserPoolDomain().getDomain()); + + return sb.toString(); } @Override