mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-27 03:21:29 +01:00
checkstyle corrections
Former-commit-id: a888649ce7d75b721e053d305a406ecddbdcdbc4
This commit is contained in:
@@ -704,12 +704,15 @@ public final class Settings {
|
|||||||
* @param dbVersionKey the settings key for the dbVersion
|
* @param dbVersionKey the settings key for the dbVersion
|
||||||
* @return the connection string
|
* @return the connection string
|
||||||
* @throws IOException thrown the data directory cannot be created
|
* @throws IOException thrown the data directory cannot be created
|
||||||
* @throws org.owasp.dependencycheck.utils.InvalidSettingException
|
* @throws InvalidSettingException thrown if there is an invalid setting
|
||||||
*/
|
*/
|
||||||
public static String getConnectionString(String connectionStringKey, String dbFileNameKey, String dbVersionKey) throws IOException, InvalidSettingException {
|
public static String getConnectionString(String connectionStringKey, String dbFileNameKey, String dbVersionKey)
|
||||||
|
throws IOException, InvalidSettingException {
|
||||||
final String connStr = Settings.getString(connectionStringKey);
|
final String connStr = Settings.getString(connectionStringKey);
|
||||||
if (connStr == null) {
|
if (connStr == null) {
|
||||||
throw new InvalidSettingException(String.format("Invalid properties file to get the connection string; '%s' must be defined.", connectionStringKey));
|
final String msg = String.format("Invalid properties file to get the connection string; '%s' must be defined.",
|
||||||
|
connectionStringKey);
|
||||||
|
throw new InvalidSettingException(msg);
|
||||||
}
|
}
|
||||||
if (connStr.contains("%s")) {
|
if (connStr.contains("%s")) {
|
||||||
final File directory = getDataDirectory();
|
final File directory = getDataDirectory();
|
||||||
@@ -718,7 +721,9 @@ public final class Settings {
|
|||||||
fileName = Settings.getString(dbFileNameKey);
|
fileName = Settings.getString(dbFileNameKey);
|
||||||
}
|
}
|
||||||
if (fileName == null) {
|
if (fileName == null) {
|
||||||
throw new InvalidSettingException(String.format("Invalid properties file to get a file based connection string; '%s' must be defined.", dbFileNameKey));
|
final String msg = String.format("Invalid properties file to get a file based connection string; '%s' must be defined.",
|
||||||
|
dbFileNameKey);
|
||||||
|
throw new InvalidSettingException(msg);
|
||||||
}
|
}
|
||||||
if (fileName.contains("%s")) {
|
if (fileName.contains("%s")) {
|
||||||
String version = null;
|
String version = null;
|
||||||
@@ -726,15 +731,15 @@ public final class Settings {
|
|||||||
version = Settings.getString(dbVersionKey);
|
version = Settings.getString(dbVersionKey);
|
||||||
}
|
}
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
throw new InvalidSettingException(String.format("Invalid properties file to get a file based connection string; '%s' must be defined.", dbFileNameKey));
|
final String msg = String.format("Invalid properties file to get a file based connection string; '%s' must be defined.",
|
||||||
|
dbFileNameKey);
|
||||||
|
throw new InvalidSettingException(msg);
|
||||||
}
|
}
|
||||||
fileName = String.format(fileName, version);
|
fileName = String.format(fileName, version);
|
||||||
}
|
}
|
||||||
if (connStr.startsWith("jdbc:h2:file:")) {
|
if (connStr.startsWith("jdbc:h2:file:") && fileName.endsWith(".h2.db")) {
|
||||||
if (fileName.endsWith(".h2.db")) {
|
|
||||||
fileName = fileName.substring(0, fileName.length() - 6);
|
fileName = fileName.substring(0, fileName.length() - 6);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// yes, for H2 this path won't actually exists - but this is sufficient to get the value needed
|
// yes, for H2 this path won't actually exists - but this is sufficient to get the value needed
|
||||||
final File dbFile = new File(directory, fileName);
|
final File dbFile = new File(directory, fileName);
|
||||||
final String cString = String.format(connStr, dbFile.getCanonicalPath());
|
final String cString = String.format(connStr, dbFile.getCanonicalPath());
|
||||||
@@ -753,11 +758,9 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public static File getDataDirectory() throws IOException {
|
public static File getDataDirectory() throws IOException {
|
||||||
final File path = Settings.getDataFile(Settings.KEYS.DATA_DIRECTORY);
|
final File path = Settings.getDataFile(Settings.KEYS.DATA_DIRECTORY);
|
||||||
if (!path.exists()) {
|
if (path.exists() || path.mkdirs()) {
|
||||||
if (!path.mkdirs()) {
|
return path;
|
||||||
|
}
|
||||||
throw new IOException(String.format("Unable to create the data directory '%s'", path.getAbsolutePath()));
|
throw new IOException(String.format("Unable to create the data directory '%s'", path.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user