package org.cryptomator.cryptofs.health.api;

import org.cryptomator.cryptofs.VaultConfig;
import org.cryptomator.cryptolib.api.Cryptor;
import org.cryptomator.cryptolib.api.Masterkey;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;

public interface DiagnosticResult {

	enum Severity {
		/**
		 * No complains
		 */
		GOOD,

		/**
		 * Unexpected, but nothing to worry about. May be worth logging
		 */
		INFO,

		/**
		 * Compromises vault structure, can and should be fixed.
		 */
		WARN,

		/**
		 * Irreversible damage, no automated way of fixing this issue.
		 */
		CRITICAL;
	}

	Severity getSeverity();

	/**
	 * @return A short, human-readable summary of the result.
	 */
	@Override
	String toString();

	default void fix(Path pathToVault, VaultConfig config, Masterkey masterkey, Cryptor cryptor) throws IOException {
		throw new UnsupportedOperationException("Fix for result" + this.getClass() + " not implemented");
	}

	/**
	 * Get more specific info about the result like names of affected resources.
	 *
	 * @return A map of strings containing result specific information
	 */
	default Map<String, String> details() {
		return Map.of();
	}
}

@@ -255,16 +255,43 @@
 til.Map;
+%0Aimport java.util.Optional;
 %0A%0Apublic
@@ -392,383 +392,1196 @@
 %09 * 
-Unexpected, but nothing to worry about. May be worth logging%0A%09%09 */%0A%09%09INFO,%0A%0A%09%09/**%0A%09%09 * Compromises vault structure, can and should be fixed.%0A%09%09 */%0A%09%09WARN,%0A%0A%09%09/**%0A%09%09 * Irreversible damage, no automated way of fixing this issue.%0A%09%09 */%0A%09%09CRITICAL;%0A%09%7D%0A%0A%09Severity getSeverity();%0A%0A%09/**%0A%09 * @return A short, human-readable summary of the result.%0A%09 */%0A%09@Override%0A%09String toString();%0A
+No impact on vault structure, no data lass, but noteworthy.%0A%09%09 * %3Cp%3E%0A%09%09 * If a fix is present, applying it is recommended.%0A%09%09 */%0A%09%09INFO,%0A%0A%09%09/**%0A%09%09 * Compromises vault structure, but no apparent data loss.%0A%09%09 * %3Cp%3E%0A%09%09 * If a fix is present, applying it is highly advised to prevent data loss.%0A%09%09 */%0A%09%09WARN,%0A%0A%09%09/**%0A%09%09 * Compromises vault structure, data loss happened.%0A%09%09 * %3Cp%3E%0A%09%09 * Restore from backups is advised.%0A%09%09 * If not possible and a fix present, applying it is recommended to restore vault structure.%0A%09%09 */%0A%09%09CRITICAL;%0A%09%7D%0A%0A%09Severity getSeverity();%0A%0A%09/**%0A%09 * @return A short, human-readable summary of the result.%0A%09 */%0A%09@Override%0A%09String toString();%0A%0A%09/**%0A%09 * A fix for the result.%0A%09 * %3Cp%3E%0A%09 * %22Fix%22 does not imply to restore lost data. It only implies, that the issue leading to this result is resolved.%0A%09 *%0A%09 * @param pathToVault path to the root directory of the vault%0A%09 * @param config the vault config%0A%09 * @param masterkey the masterkey of the vault%0A%09 * @param cryptor%0A%09 * @throws IOException%0A%09 * @throws UnsupportedOperationException if no fix is implemented for this result%0A%09 * @deprecated Use %7B@link #getFix(Path, VaultConfig, Masterkey, Cryptor)%7D instead%0A%09 */%0A%09@Deprecated
 %0A%09de
@@ -1796,16 +1796,155 @@
 %22);%0A%09%7D%0A%0A
+%09default Optional%3CFix%3E getFix(Path pathToVault, VaultConfig config, Masterkey masterkey, Cryptor cryptor) %7B%0A%09%09return Optional.empty();%0A%09%7D%0A%0A
 %09/**%0A%09 *
@@ -2157,11 +2157,89 @@
 of();%0A%09%7D
+%0A%0A%09@FunctionalInterface%0A%09interface Fix %7B%0A%09%09void apply() throws IOException;%0A%09%7D
 %0A%7D%0A

Change docs for Severity and add method to determine if fix is implemented or not.