Commit 6baeaa81 authored by Iain R. Learmonth's avatar Iain R. Learmonth Committed by Karsten Loesing
Browse files

Removes DetailsDocumentFields interface

This interface only ever provided two of the many fields in details
documents.

Fixes: #27180
parent 405faa26
/* Copyright 2017--2018 The Tor Project
* See LICENSE for licensing information */
package org.torproject.onionoo.docs;
/** Provides constants for details document field names. */
public interface DetailsDocumentFields {
public static final String FIRST_SEEN = "first_seen";
public static final String CONSENSUS_WEIGHT = "consensus_weight";
}
......@@ -3,22 +3,20 @@
package org.torproject.onionoo.server;
import org.torproject.onionoo.docs.DetailsDocumentFields;
/** Provides constants for order parameter values. */
public class OrderParameterValues {
private static final String DESCENDING = "-";
public static final String FIRST_SEEN_ASC = DetailsDocumentFields.FIRST_SEEN;
public static final String FIRST_SEEN_ASC = "first_seen";
public static final String FIRST_SEEN_DES =
DESCENDING + DetailsDocumentFields.FIRST_SEEN;
DESCENDING + FIRST_SEEN_ASC;
public static final String CONSENSUS_WEIGHT_ASC =
DetailsDocumentFields.CONSENSUS_WEIGHT;
"consensus_weight";
public static final String CONSENSUS_WEIGHT_DES =
DESCENDING + DetailsDocumentFields.CONSENSUS_WEIGHT;
DESCENDING + CONSENSUS_WEIGHT_ASC;
}
......@@ -6,7 +6,6 @@ package org.torproject.onionoo.server;
import org.torproject.onionoo.docs.BandwidthDocument;
import org.torproject.onionoo.docs.ClientsDocument;
import org.torproject.onionoo.docs.DetailsDocument;
import org.torproject.onionoo.docs.DetailsDocumentFields;
import org.torproject.onionoo.docs.DocumentStore;
import org.torproject.onionoo.docs.DocumentStoreFactory;
import org.torproject.onionoo.docs.SummaryDocument;
......@@ -261,7 +260,7 @@ public class ResponseBuilder {
} else if (field.equals("last_changed_address_or_port")) {
dd.setLastChangedAddressOrPort(
detailsDocument.getLastChangedAddressOrPort());
} else if (field.equals(DetailsDocumentFields.FIRST_SEEN)) {
} else if (field.equals("first_seen")) {
dd.setFirstSeen(detailsDocument.getFirstSeen());
} else if (field.equals("running")) {
dd.setRunning(detailsDocument.getRunning());
......@@ -285,7 +284,7 @@ public class ResponseBuilder {
dd.setAsNumber(detailsDocument.getAsNumber());
} else if (field.equals("as_name")) {
dd.setAsName(detailsDocument.getAsName());
} else if (field.equals(DetailsDocumentFields.CONSENSUS_WEIGHT)) {
} else if (field.equals("consensus_weight")) {
dd.setConsensusWeight(detailsDocument.getConsensusWeight());
} else if (field.equals("verified_host_names")) {
dd.setVerifiedHostNames(detailsDocument.getVerifiedHostNames());
......
......@@ -6,7 +6,6 @@ package org.torproject.onionoo.server;
import static org.junit.Assert.assertEquals;
import org.torproject.onionoo.docs.DateTimeHelper;
import org.torproject.onionoo.docs.DetailsDocumentFields;
import org.torproject.onionoo.docs.SummaryDocument;
import org.hamcrest.Matchers;
......@@ -73,7 +72,7 @@ public class SummaryDocumentComparatorTest {
public SummaryDocumentComparatorTest(String order, long[] vals) {
for (int i = 0; i < sd.length; i++) {
sd[i] = createSummaryDoc();
if (order.contains(DetailsDocumentFields.FIRST_SEEN)) {
if (order.contains("first_seen")) {
sd[i].setFirstSeenMillis(vals[i]);
} else {
sd[i].setConsensusWeight(vals[i]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment