Store preferred download scheme as arbitrary strings

Although plugins can register download schemes with arbitrary names,
the getter/setter in AccountGeneralPreferences were allowing only a
specific enum type corresponding to the core download schemes. Get rid
of that enum type, and store arbitrary strings in the database. To
avoid a schema upgrade (which would be an annoying multi-step process
for a zero-downtime upgrade), convert to/from the old enum-string
values in AccountGeneralPreferences. Everywhere else, use the key from
the scheme map, e.g. "anonymous http" instead of "ANON_HTTP". This
eliminates the special-case code when sending RPCs from the client,
and avoids weird undocumented behavior in the set preferences REST API
call.

Change-Id: I3e2397d8dfa15d20329cc83e1e3fe069c8e021c4
This commit is contained in:
Dave Borowitz
2015-09-03 15:27:19 -04:00
parent ae8f44a50a
commit 0a741dd21c
12 changed files with 140 additions and 113 deletions

View File

@@ -21,7 +21,6 @@ import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.TimeFormat;
import com.google.gwt.core.client.JavaScriptObject;
@@ -73,11 +72,7 @@ public class AccountPreferencesInfo extends JavaScriptObject {
public final native boolean useFlashClipboard()
/*-{ return this.use_flash_clipboard || false }-*/;
public final DownloadScheme downloadScheme() {
String s = downloadSchemeRaw();
return s != null ? DownloadScheme.valueOf(s) : null;
}
private final native String downloadSchemeRaw()
public final native String downloadScheme()
/*-{ return this.download_scheme }-*/;
public final DownloadCommand downloadCommand() {
@@ -142,10 +137,7 @@ public class AccountPreferencesInfo extends JavaScriptObject {
public final native void useFlashClipboard(boolean u)
/*-{ this.use_flash_clipboard = u }-*/;
public final void downloadScheme(DownloadScheme d) {
downloadSchemeRaw(d != null ? d.toString() : null);
}
private final native void downloadSchemeRaw(String d)
public final native void downloadScheme(String d)
/*-{ this.download_scheme = d }-*/;
public final void downloadCommand(DownloadCommand d) {