Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -786,15 +786,14 @@ private void applyState(Card c, int st) {
* not a fourth reading here.
*
* <p>The card endpoints and the content keys disagree on one name — the Wikipedia card is
* {@code kiwix} and its content type is {@code zim}. That belongs on {@code ContentType}
* as an endpoint field; it is exactly what ADFA-5062 exists to retire, and this adds one
* more instance of it.
* {@code kiwix} and its content type is {@code zim}. That alias now lives on {@code ContentType}
* as an {@code endpoint} field (ADFA-5062), so the lookup is {@code byEndpoint} rather than a
* hand-rolled remap here.
*/
private boolean contentInFlight(Card c) {
if (c == null || c.endpoint == null || passContent == null) return false;
String key = "kiwix".equals(c.endpoint) ? "zim" : c.endpoint;
org.iiab.controller.system.domain.ContentType type =
org.iiab.controller.system.domain.ContentType.byKey(key);
org.iiab.controller.system.domain.ContentType.byEndpoint(c.endpoint);
return type != null && passContent.isRunning(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,24 @@
public enum ContentType {

/** Wikipedia and other ZIM collections, downloaded by the server. */
ZIM("zim", Operation.ExecutionClass.LIVE),
ZIM("zim", "kiwix", Operation.ExecutionClass.LIVE),

/** Gutenberg books, downloaded by the server. */
BOOKS("books", Operation.ExecutionClass.LIVE),
BOOKS("books", "books", Operation.ExecutionClass.LIVE),

/** Kolibri channels, imported by the server. Tens of GB at the top end. */
COURSES("kolibri", Operation.ExecutionClass.LIVE),
COURSES("kolibri", "kolibri", Operation.ExecutionClass.LIVE),

/** Map layers, built by an Ansible runrole under proot. */
MAPS("maps", Operation.ExecutionClass.STOPPED);
MAPS("maps", "maps", Operation.ExecutionClass.STOPPED);

private final String key;
private final String endpoint;
private final Operation.ExecutionClass executionClass;

ContentType(String key, Operation.ExecutionClass executionClass) {
ContentType(String key, String endpoint, Operation.ExecutionClass executionClass) {
this.key = key;
this.endpoint = endpoint;
this.executionClass = executionClass;
}

Expand All @@ -67,6 +69,16 @@ public String key() {
return key;
}

/**
* The identifier the Home surface uses for this type's platform, which differs from
* {@link #key()} for exactly one type: the Wikipedia card is {@code kiwix} while its
* content key is {@code zim}. Carrying the alias here retires the hand-rolled
* {@code "kiwix" -> "zim"} remap the callers used to keep (ADFA-5062).
*/
public String endpoint() {
return endpoint;
}

public Operation.ExecutionClass executionClass() {
return executionClass;
}
Expand Down Expand Up @@ -98,4 +110,20 @@ public static ContentType byKey(String key) {
}
return null;
}

/**
* @param endpoint a Home-surface platform endpoint (e.g. {@code kiwix})
* @return the matching type, or {@code null} for an unknown endpoint
*/
public static ContentType byEndpoint(String endpoint) {
if (endpoint == null) {
return null;
}
for (ContentType t : values()) {
if (t.endpoint.equals(endpoint)) {
return t;
}
}
return null;
}
}
Loading