mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Fix code smells
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
|||||||
import org.springframework.security.oauth2.core.OAuth2RefreshToken;
|
import org.springframework.security.oauth2.core.OAuth2RefreshToken;
|
||||||
|
|
||||||
public class SQLiteOAuth2AuthorizedClientService implements OAuth2AuthorizedClientService {
|
public class SQLiteOAuth2AuthorizedClientService implements OAuth2AuthorizedClientService {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(SQLiteOAuth2AuthorizedClientService.class);
|
||||||
private static final String TABLE_NAME = "oauth2_authorized_client";
|
private static final String TABLE_NAME = "oauth2_authorized_client";
|
||||||
|
|
||||||
private final JdbcOperations jdbcOperations;
|
private final JdbcOperations jdbcOperations;
|
||||||
@@ -72,7 +73,7 @@ public class SQLiteOAuth2AuthorizedClientService implements OAuth2AuthorizedClie
|
|||||||
@Override
|
@Override
|
||||||
public void saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal) {
|
public void saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal) {
|
||||||
try {
|
try {
|
||||||
int updated = jdbcOperations.update("""
|
jdbcOperations.update("""
|
||||||
INSERT INTO oauth2_authorized_client (
|
INSERT INTO oauth2_authorized_client (
|
||||||
client_registration_id, principal_name,
|
client_registration_id, principal_name,
|
||||||
access_token_value, access_token_issued_at, access_token_expires_at, access_token_scopes,
|
access_token_value, access_token_issued_at, access_token_expires_at, access_token_scopes,
|
||||||
@@ -102,7 +103,9 @@ public class SQLiteOAuth2AuthorizedClientService implements OAuth2AuthorizedClie
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (DataAccessException ex) {
|
} catch (DataAccessException ex) {
|
||||||
throw ex;
|
LOG.error("Failed to save authorized client for registration ID '{}' and principal '{}'",
|
||||||
|
authorizedClient.getClientRegistration().getRegistrationId(),
|
||||||
|
principal.getName(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,15 +79,16 @@ public class SchemaMigration implements ApplicationRunner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
addColumnIfMissing("assets", columns, "speed", "REAL", "1.0");
|
String table = "assets";
|
||||||
addColumnIfMissing("assets", columns, "muted", "BOOLEAN", "0");
|
addColumnIfMissing(table, columns, "speed", "REAL", "1.0");
|
||||||
addColumnIfMissing("assets", columns, "media_type", "TEXT", "'application/octet-stream'");
|
addColumnIfMissing(table, columns, "muted", "BOOLEAN", "0");
|
||||||
addColumnIfMissing("assets", columns, "audio_loop", "BOOLEAN", "0");
|
addColumnIfMissing(table, columns, "media_type", "TEXT", "'application/octet-stream'");
|
||||||
addColumnIfMissing("assets", columns, "audio_delay_millis", "INTEGER", "0");
|
addColumnIfMissing(table, columns, "audio_loop", "BOOLEAN", "0");
|
||||||
addColumnIfMissing("assets", columns, "audio_speed", "REAL", "1.0");
|
addColumnIfMissing(table, columns, "audio_delay_millis", "INTEGER", "0");
|
||||||
addColumnIfMissing("assets", columns, "audio_pitch", "REAL", "1.0");
|
addColumnIfMissing(table, columns, "audio_speed", "REAL", "1.0");
|
||||||
addColumnIfMissing("assets", columns, "audio_volume", "REAL", "1.0");
|
addColumnIfMissing(table, columns, "audio_pitch", "REAL", "1.0");
|
||||||
addColumnIfMissing("assets", columns, "preview", "TEXT", "NULL");
|
addColumnIfMissing(table, columns, "audio_volume", "REAL", "1.0");
|
||||||
|
addColumnIfMissing(table, columns, "preview", "TEXT", "NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addColumnIfMissing(String tableName, List<String> existingColumns, String columnName, String dataType, String defaultValue) {
|
private void addColumnIfMissing(String tableName, List<String> existingColumns, String columnName, String dataType, String defaultValue) {
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import org.springframework.util.StringUtils;
|
|||||||
import org.springframework.util.unit.DataSize;
|
import org.springframework.util.unit.DataSize;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SystemEnvironmentValidator {
|
public class SystemEnvironmentValidator {
|
||||||
private static final Logger log = LoggerFactory.getLogger(SystemEnvironmentValidator.class);
|
private static final Logger log = LoggerFactory.getLogger(SystemEnvironmentValidator.class);
|
||||||
@@ -61,7 +59,7 @@ public class SystemEnvironmentValidator {
|
|||||||
checkString(assetsPath, "IMGFLOAT_ASSETS_PATH", missing);
|
checkString(assetsPath, "IMGFLOAT_ASSETS_PATH", missing);
|
||||||
checkString(previewsPath, "IMGFLOAT_PREVIEWS_PATH", missing);
|
checkString(previewsPath, "IMGFLOAT_PREVIEWS_PATH", missing);
|
||||||
|
|
||||||
if (missing.length() > 0) {
|
if (!missing.isEmpty()) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Missing or invalid environment variables:\n" + missing
|
"Missing or invalid environment variables:\n" + missing
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user