@@ -1045,10 +1045,9 @@ public void signUpMultipleViaBulkImport_Transaction(TransactionConnection connec
10451045 try {
10461046 Connection sqlConnection = (Connection ) connection .getConnection ();
10471047 EmailPasswordQueries .signUpMultipleForBulkImport_Transaction (this , sqlConnection , users );
1048- } catch (StorageQueryException | SQLException | StorageTransactionLogicException e ) {
1048+ } catch (StorageQueryException | StorageTransactionLogicException e ) {
10491049 Throwable actual = e .getCause ();
1050- if (actual instanceof BatchUpdateException ) {
1051- BatchUpdateException batchUpdateException = (BatchUpdateException ) actual ;
1050+ if (actual instanceof BatchUpdateException batchUpdateException ) {
10521051 Map <String , Exception > errorByPosition = new HashMap <>();
10531052 SQLException nextException = batchUpdateException .getNextException ();
10541053 while (nextException != null ) {
@@ -1288,8 +1287,7 @@ public void updateMultipleIsEmailVerified_Transaction(AppIdentifier appIdentifie
12881287 EmailVerificationQueries .updateMultipleUsersIsEmailVerified_Transaction (this , sqlCon , appIdentifier ,
12891288 emailToUserId , isEmailVerified );
12901289 } catch (SQLException e ) {
1291- if (e instanceof BatchUpdateException ) {
1292- BatchUpdateException batchUpdateException = (BatchUpdateException ) e ;
1290+ if (e instanceof BatchUpdateException batchUpdateException ) {
12931291 SQLException nextException = batchUpdateException .getNextException ();
12941292 Map <String , Exception > errorByPosition = new HashMap <>();
12951293 while (nextException != null ) {
@@ -1520,9 +1518,7 @@ public void importThirdPartyUsers_Transaction(TransactionConnection con,
15201518 Connection sqlCon = (Connection ) con .getConnection ();
15211519 ThirdPartyQueries .importUser_Transaction (this , sqlCon , usersToImport );
15221520 } catch (SQLException e ) {
1523- Throwable actual = e .getCause ();
1524- if (actual instanceof BatchUpdateException ) {
1525- BatchUpdateException batchUpdateException = (BatchUpdateException ) actual ;
1521+ if (e instanceof BatchUpdateException batchUpdateException ) {
15261522 Map <String , Exception > errorByPosition = new HashMap <>();
15271523 SQLException nextException = batchUpdateException .getNextException ();
15281524 while (nextException != null ) {
@@ -2126,50 +2122,46 @@ public void importPasswordlessUsers_Transaction(TransactionConnection con,
21262122 Connection sqlCon = (Connection ) con .getConnection ();
21272123 PasswordlessQueries .importUsers_Transaction (sqlCon , this , users );
21282124 } catch (SQLException e ) {
2129- if (e instanceof BatchUpdateException ) {
2130- Throwable actual = e .getCause ();
2131- if (actual instanceof BatchUpdateException ) {
2132- BatchUpdateException batchUpdateException = (BatchUpdateException ) actual ;
2133- Map <String , Exception > errorByPosition = new HashMap <>();
2134- SQLException nextException = batchUpdateException .getNextException ();
2135- while (nextException != null ) {
2125+ if (e instanceof BatchUpdateException batchUpdateException ) {
2126+ Map <String , Exception > errorByPosition = new HashMap <>();
2127+ SQLException nextException = batchUpdateException .getNextException ();
2128+ while (nextException != null ) {
21362129
2137- if (nextException instanceof PSQLException ) {
2138- PostgreSQLConfig config = Config .getConfig (this );
2139- ServerErrorMessage serverMessage = ((PSQLException ) nextException ).getServerErrorMessage ();
2130+ if (nextException instanceof PSQLException ) {
2131+ PostgreSQLConfig config = Config .getConfig (this );
2132+ ServerErrorMessage serverMessage = ((PSQLException ) nextException ).getServerErrorMessage ();
21402133
2141- int position = getErroneousEntryPosition (batchUpdateException );
2134+ int position = getErroneousEntryPosition (batchUpdateException );
21422135
2143- if (isPrimaryKeyError (serverMessage , config .getPasswordlessUsersTable ())
2144- || isPrimaryKeyError (serverMessage , config .getUsersTable ())
2145- || isPrimaryKeyError (serverMessage , config .getPasswordlessUserToTenantTable ())
2146- || isPrimaryKeyError (serverMessage , config .getAppIdToUserIdTable ())) {
2147- errorByPosition .put (users .get (position ).userId , new DuplicateUserIdException ());
2148- }
2149- if (isUniqueConstraintError (serverMessage , config .getPasswordlessUserToTenantTable (),
2150- "email" )) {
2151- errorByPosition .put (users .get (position ).userId , new DuplicateEmailException ());
2136+ if (isPrimaryKeyError (serverMessage , config .getPasswordlessUsersTable ())
2137+ || isPrimaryKeyError (serverMessage , config .getUsersTable ())
2138+ || isPrimaryKeyError (serverMessage , config .getPasswordlessUserToTenantTable ())
2139+ || isPrimaryKeyError (serverMessage , config .getAppIdToUserIdTable ())) {
2140+ errorByPosition .put (users .get (position ).userId , new DuplicateUserIdException ());
2141+ }
2142+ if (isUniqueConstraintError (serverMessage , config .getPasswordlessUserToTenantTable (),
2143+ "email" )) {
2144+ errorByPosition .put (users .get (position ).userId , new DuplicateEmailException ());
21522145
2153- } else if (isUniqueConstraintError (serverMessage , config .getPasswordlessUserToTenantTable (),
2154- "phone_number" )) {
2155- errorByPosition .put (users .get (position ).userId , new DuplicatePhoneNumberException ());
2146+ } else if (isUniqueConstraintError (serverMessage , config .getPasswordlessUserToTenantTable (),
2147+ "phone_number" )) {
2148+ errorByPosition .put (users .get (position ).userId , new DuplicatePhoneNumberException ());
21562149
2157- } else if (isForeignKeyConstraintError (serverMessage , config .getAppIdToUserIdTable (),
2158- "app_id" )) {
2159- throw new TenantOrAppNotFoundException (users .get (position ).tenantIdentifier .toAppIdentifier ());
2150+ } else if (isForeignKeyConstraintError (serverMessage , config .getAppIdToUserIdTable (),
2151+ "app_id" )) {
2152+ throw new TenantOrAppNotFoundException (users .get (position ).tenantIdentifier .toAppIdentifier ());
21602153
2161- } else if (isForeignKeyConstraintError (serverMessage , config .getUsersTable (),
2162- "tenant_id" )) {
2163- throw new TenantOrAppNotFoundException (users .get (position ).tenantIdentifier .toAppIdentifier ());
2164- }
2154+ } else if (isForeignKeyConstraintError (serverMessage , config .getUsersTable (),
2155+ "tenant_id" )) {
2156+ throw new TenantOrAppNotFoundException (users .get (position ).tenantIdentifier .toAppIdentifier ());
21652157 }
2166- nextException = nextException .getNextException ();
21672158 }
2168- throw new StorageQueryException (
2169- new BulkImportBatchInsertException ("passwordless errors" , errorByPosition ));
2159+ nextException = nextException .getNextException ();
21702160 }
2171- throw new StorageQueryException (e );
2161+ throw new StorageQueryException (
2162+ new BulkImportBatchInsertException ("passwordless errors" , errorByPosition ));
21722163 }
2164+ throw new StorageQueryException (e );
21732165 }
21742166 }
21752167
@@ -3655,8 +3647,7 @@ public void addBulkImportUsers(AppIdentifier appIdentifier, List<BulkImportUser>
36553647 try {
36563648 BulkImportQueries .insertBulkImportUsers_Transaction (this , (Connection ) con .getConnection (), appIdentifier , users );
36573649 } catch (SQLException e ) {
3658- if (e instanceof BatchUpdateException ) {
3659- BatchUpdateException batchUpdateException = (BatchUpdateException ) e ;
3650+ if (e instanceof BatchUpdateException batchUpdateException ) {
36603651 SQLException nextException = batchUpdateException .getNextException ();
36613652 if (nextException instanceof PSQLException ){
36623653 ServerErrorMessage serverErrorMessage = ((PSQLException ) nextException ).getServerErrorMessage ();
@@ -3784,6 +3775,7 @@ public List<String> deleteBulkImportUsers(AppIdentifier appIdentifier, @Nonnull
37843775 try {
37853776 return BulkImportQueries .deleteBulkImportUsers (this , appIdentifier , bulkImportUserIds );
37863777 } catch (SQLException e ) {
3778+ Logging .error (this , "Error deleting bulk import users" , true , e );
37873779 throw new StorageQueryException (e );
37883780 }
37893781 }
0 commit comments