Skip to content

Commit

Permalink
fix: PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anku255 committed Feb 28, 2024
1 parent d81681b commit 29345b1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void addBulkImportUsers(AppIdentifier appIdentifier, List<BulkImportUser> users)
/**
* Get users from the bulk_import_users table
*/
List<BulkImportUser> getBulkImportUsers(AppIdentifier appIdentifier, @Nonnull Integer limit, @Nullable BulkImportUserStatus status,
List<BulkImportUser> getBulkImportUsers(AppIdentifier appIdentifier, @Nonnull Integer limit, @Nullable BULK_IMPORT_USER_STATUS status,
@Nullable String bulkImportUserId, @Nullable Long createdAt) throws StorageQueryException;

/**
Expand All @@ -49,7 +49,7 @@ List<BulkImportUser> getBulkImportUsers(AppIdentifier appIdentifier, @Nonnull In
// ArrayList<String> bulkImportUserIds)
// throws StorageQueryException;

public enum BulkImportUserStatus {
public enum BULK_IMPORT_USER_STATUS {
NEW, PROCESSING, FAILED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.google.gson.Gson;
import com.google.gson.JsonObject;

import io.supertokens.pluginInterface.bulkimport.BulkImportStorage.BulkImportUserStatus;
import io.supertokens.pluginInterface.bulkimport.BulkImportStorage.BULK_IMPORT_USER_STATUS;

public class BulkImportUser {
public String id;
Expand All @@ -32,7 +32,7 @@ public class BulkImportUser {
public List<LoginMethod> loginMethods;

// Following fields come from the DB Record.
public BulkImportUserStatus status;
public BULK_IMPORT_USER_STATUS status;
public Long createdAt;
public Long updatedAt;

Expand All @@ -50,21 +50,27 @@ public static BulkImportUser fromJson(JsonObject jsonObject) {
return new Gson().fromJson(jsonObject, BulkImportUser.class);
}

public String toString() {
return new Gson().toJson(this);
}

// This method returns a JSON object string representation, excluding 'status', 'createdAt', and 'updatedAt'. Useful for test comparisons.
public String toRawData() {
JsonObject jsonObject = new Gson().fromJson(this.toString(), JsonObject.class);
// This method returns a JSON object string representation, excluding 'status', 'createdAt', and 'updatedAt'.
// It is used for inserting the user into the database or during testing.
public String toRawDataForDbStorage() {
JsonObject jsonObject = new Gson().fromJson(new Gson().toJson(this), JsonObject.class);
jsonObject.remove("status");
jsonObject.remove("createdAt");
jsonObject.remove("updatedAt");
return jsonObject.toString();
}

public static BulkImportUser fromRawDataFromDbStorage(String id, String rawData, BULK_IMPORT_USER_STATUS status, long createdAt, long updatedAt) {
BulkImportUser user = new Gson().fromJson(rawData, BulkImportUser.class);
user.id = id;
user.status = status;
user.createdAt = createdAt;
user.updatedAt = updatedAt;
return user;
}

public JsonObject toJsonObject() {
return new Gson().fromJson(this.toString(), JsonObject.class);
return new Gson().fromJson(new Gson().toJson(this), JsonObject.class);
}

public static class TotpDevice {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ public interface BulkImportSQLStorage extends BulkImportStorage, SQLStorage {
* Update the status of the users in the bulk_import_users table
*/
void updateBulkImportUserStatus_Transaction(AppIdentifier appIdentifier,
TransactionConnection con, @Nonnull String[] bulkImportUserIds, @Nonnull BulkImportUserStatus status) throws StorageQueryException;
TransactionConnection con, @Nonnull String[] bulkImportUserIds, @Nonnull BULK_IMPORT_USER_STATUS status) throws StorageQueryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.supertokens.pluginInterface.STORAGE_TYPE;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.authRecipe.AuthRecipeStorage;
import io.supertokens.pluginInterface.bulkimport.BulkImportStorage;
import io.supertokens.pluginInterface.bulkimport.sqlStorage.BulkImportSQLStorage;
import io.supertokens.pluginInterface.dashboard.sqlStorage.DashboardSQLStorage;
import io.supertokens.pluginInterface.emailpassword.sqlStorage.EmailPasswordSQLStorage;
import io.supertokens.pluginInterface.emailverification.sqlStorage.EmailVerificationSQLStorage;
Expand Down Expand Up @@ -161,11 +161,11 @@ public ActiveUsersSQLStorage getActiveUsersStorage() {
return (ActiveUsersSQLStorage) this.storage;
}

public BulkImportStorage getBulkImportStorage() {
public BulkImportSQLStorage getBulkImportStorage() {
if (this.storage.getType() != STORAGE_TYPE.SQL) {
// we only support SQL for now
throw new UnsupportedOperationException("");
}
return (BulkImportStorage) this.storage;
return (BulkImportSQLStorage) this.storage;
}
}

0 comments on commit 29345b1

Please sign in to comment.