From d632005a4f43b177684793667b810109b32d37c4 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Wed, 25 Oct 2023 12:08:48 +0530 Subject: [PATCH] fix: pr comments --- .../multitenancy/TenantConfigSQLHelper.java | 19 +++---------------- .../storage/postgresql/utils/Utils.java | 9 +++++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java b/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java index 7a134e79..dc517467 100644 --- a/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java +++ b/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java @@ -24,6 +24,7 @@ import io.supertokens.pluginInterface.multitenancy.*; import io.supertokens.storage.postgresql.Start; import io.supertokens.storage.postgresql.queries.utils.JsonUtils; +import io.supertokens.storage.postgresql.utils.Utils; import java.sql.Connection; import java.sql.ResultSet; @@ -48,25 +49,11 @@ public static TenantConfigSQLHelper.TenantConfigRowMapper getInstance(ThirdParty return new TenantConfigSQLHelper.TenantConfigRowMapper(providers); } - private static String[] getStringArrayFromJsonString(String input) { - if (input == null) { - return new String[0]; - } - return new Gson().fromJson(input, String[].class); - } - - private static JsonArray getJsonArrayFromJsonString(String input) { - if (input == null) { - return new JsonArray(); - } - return new Gson().fromJson(input, JsonArray.class); - } - @Override public TenantConfig map(ResultSet result) throws StorageQueryException { try { - String[] firstFactors = getStringArrayFromJsonString(result.getString("first_factors")); - String[] defaultRequiredFactorIds = getStringArrayFromJsonString(result.getString("default_required_factors")); + String[] firstFactors = Utils.getStringArrayFromJsonString(result.getString("first_factors")); + String[] defaultRequiredFactorIds = Utils.getStringArrayFromJsonString(result.getString("default_required_factors")); return new TenantConfig( new TenantIdentifier(result.getString("connection_uri_domain"), result.getString("app_id"), result.getString("tenant_id")), diff --git a/src/main/java/io/supertokens/storage/postgresql/utils/Utils.java b/src/main/java/io/supertokens/storage/postgresql/utils/Utils.java index 91a58735..5f79f42c 100644 --- a/src/main/java/io/supertokens/storage/postgresql/utils/Utils.java +++ b/src/main/java/io/supertokens/storage/postgresql/utils/Utils.java @@ -17,6 +17,8 @@ package io.supertokens.storage.postgresql.utils; +import com.google.gson.Gson; + import java.io.ByteArrayOutputStream; import java.io.PrintStream; @@ -53,4 +55,11 @@ public static String generateCommaSeperatedQuestionMarks(int size) { } return builder.toString(); } + + public static String[] getStringArrayFromJsonString(String input) { + if (input == null) { + return null; + } + return new Gson().fromJson(input, String[].class); + } }