static boolean importSettings()

in src/main/java/org/jetbrains/plugins/spotbugs/core/RuntimeSettingsImporter.java [48:92]


	static boolean importSettings(
			@NotNull final Project project,
			@NotNull final Module module,
			@NotNull final AbstractSettings settings,
			@NotNull final String filePath,
			@NotNull final String importFilePathKey
	) {

		final File file = new File(filePath);
		if (!file.exists()) {
			showImportPreferencesWarning(project, module, ResourcesLoader.getString("analysis.error.importSettings.notExists", filePath));
			return false;
		}
		if (!file.isFile()) {
			showImportPreferencesWarning(project, module, ResourcesLoader.getString("analysis.error.importSettings.noFile", filePath));
			return false;
		}
		if (!file.canRead()) {
			showImportPreferencesWarning(project, module, ResourcesLoader.getString("analysis.error.importSettings.notReadable", filePath));
			return false;
		}

		try {
			final FileInputStream input = new FileInputStream(file);
			try {
				final WorkspaceSettings workspaceSettings = WorkspaceSettings.getInstance(project);
				final Map<String, String> importFilePath = new HashMap<>(workspaceSettings.importFilePath);
				final boolean success = new SettingsImporter(project) {
					@Override
					protected void handleError(@NotNull final String title, @NotNull final String message) {
						showImportPreferencesWarning(project, module, title, message);
					}
				}.doImport(input, settings, importFilePathKey);
				workspaceSettings.importFilePath = importFilePath; // restore current
				return success;
			} finally {
				IoUtil.safeClose(input);
			}
		} catch (final Exception e) {
			final String msg = ResourcesLoader.getString("analysis.error.importSettings.fatal", filePath, e.getMessage());
			LOGGER.error(msg, e);
			showImportPreferencesWarning(project, module, msg);
			return false;
		}
	}