Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom endpoints #4805

Merged
merged 6 commits into from
Aug 20, 2021
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.odk.collect.android.openrosa.HttpGetResult;
import org.odk.collect.android.openrosa.HttpHeadResult;
import org.odk.collect.android.openrosa.HttpPostResult;
import org.odk.collect.android.openrosa.OpenRosaConstants;
import org.odk.collect.android.openrosa.OpenRosaHttpInterface;
import org.odk.collect.shared.strings.Md5;

Expand All @@ -34,9 +35,6 @@ public class StubOpenRosaServer implements OpenRosaHttpInterface {

private static final String HOST = "server.example.com";

private String formListPath = "/formList";
private String submissionPath = "/submission";

private final List<FormManifestEntry> forms = new ArrayList<>();
private String username;
private String password;
Expand All @@ -55,7 +53,7 @@ public HttpGetResult executeGetRequest(@NonNull URI uri, @Nullable String conten
return new HttpGetResult(null, new HashMap<>(), "Trying to connect to incorrect server: " + uri.getHost(), 410);
} else if (credentialsIncorrect(credentials)) {
return new HttpGetResult(null, new HashMap<>(), "", 401);
} else if (uri.getPath().equals(formListPath)) {
} else if (uri.getPath().equals(OpenRosaConstants.FORM_LIST)) {
return new HttpGetResult(getFormListResponse(), getStandardHeaders(), "", 200);
} else if (uri.getPath().equals("/form")) {
if (fetchingFormsError) {
Expand All @@ -79,7 +77,7 @@ public HttpHeadResult executeHeadRequest(@NonNull URI uri, @Nullable HttpCredent
return new HttpHeadResult(410, new CaseInsensitiveEmptyHeaders());
} else if (credentialsIncorrect(credentials)) {
return new HttpHeadResult(401, new CaseInsensitiveEmptyHeaders());
} else if (uri.getPath().equals(submissionPath)) {
} else if (uri.getPath().equals(OpenRosaConstants.SUBMISSION)) {
HashMap<String, String> headers = getStandardHeaders();
headers.put("x-openrosa-accept-content-length", "10485760");

Expand All @@ -100,21 +98,13 @@ public HttpPostResult uploadSubmissionAndFiles(@NonNull File submissionFile, @No
return new HttpPostResult("Trying to connect to incorrect server: " + uri.getHost(), 410, "");
} else if (credentialsIncorrect(credentials)) {
return new HttpPostResult("", 401, "");
} else if (uri.getPath().equals(submissionPath)) {
} else if (uri.getPath().equals(OpenRosaConstants.SUBMISSION)) {
return new HttpPostResult("", 201, "");
} else {
return new HttpPostResult("", 404, "");
}
}

public void setFormListPath(String path) {
formListPath = path;
}

public void setFormSubmissionPath(String path) {
submissionPath = path;
}

public void setCredentials(String username, String password) {
this.username = username;
this.password = password;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public ServerSettingsPage clickOnURL() {
return this;
}

public CustomServerPathsPage clickCustomServerPaths() {
onView(withText(getTranslatedString(R.string.custom_server_paths))).perform(click());
return new CustomServerPathsPage().assertOnPage();
}

public ServerSettingsPage clickServerPassword() {
onView(withText(getTranslatedString(R.string.password))).perform(click());
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.odk.collect.android.fragments.dialogs.SimpleDialog;
import org.odk.collect.android.injection.DaggerUtils;
import org.odk.collect.android.listeners.InstanceUploaderListener;
import org.odk.collect.android.openrosa.OpenRosaConstants;
import org.odk.collect.android.tasks.InstanceServerUploaderTask;
import org.odk.collect.android.utilities.ApplicationConstants;
import org.odk.collect.android.utilities.ArrayUtils;
Expand Down Expand Up @@ -168,7 +169,7 @@ private void init(Bundle savedInstanceState) {
instanceServerUploaderTask = new InstanceServerUploaderTask();

if (url != null) {
instanceServerUploaderTask.setCompleteDestinationUrl(url + getString(R.string.default_odk_submission));
instanceServerUploaderTask.setCompleteDestinationUrl(url + OpenRosaConstants.SUBMISSION);

if (deleteInstanceAfterUpload != null) {
instanceServerUploaderTask.setDeleteInstanceAfterSubmission(deleteInstanceAfterUpload);
Expand Down Expand Up @@ -360,7 +361,7 @@ public void updatedCredentials() {
// TODO: is this really needed here? When would the task not have gotten a server set in
// init already?
if (url != null) {
instanceServerUploaderTask.setCompleteDestinationUrl(url + getString(R.string.default_odk_submission), false);
instanceServerUploaderTask.setCompleteDestinationUrl(url + OpenRosaConstants.SUBMISSION, false);
}
instanceServerUploaderTask.setRepositories(instancesRepository, formsRepository, settingsProvider);
instanceServerUploaderTask.execute(instancesToSend);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ private AnalyticsEvents() {
*/
public static final String MATCH_EXACTLY_SYNC_COMPLETED = "MatchExactlySyncCompleted";

/**
* Track submissions to a URL with a custom submission endpoint configured in settings. The action
* should be a hash of the endpoint setting.
*/
public static final String CUSTOM_ENDPOINT_SUB = "CustomEndpointSub";

/**
* Tracks how often the audio player seek bar is used.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ class FormSourceProvider(
val generalSettings = settingsProvider.getGeneralSettings(projectId)

val serverURL = generalSettings.getString(ProjectKeys.KEY_SERVER_URL)
val formListPath = generalSettings.getString(ProjectKeys.KEY_FORMLIST_URL)

return OpenRosaFormSource(
serverURL,
formListPath,
openRosaHttpInterface,
WebCredentialsUtils(generalSettings),
OpenRosaResponseParserImpl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
import org.odk.collect.forms.instances.Instance;
import org.odk.collect.forms.instances.InstancesRepository;
import org.odk.collect.shared.Settings;
import org.odk.collect.shared.strings.Md5;

import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import timber.log.Timber;

import static org.odk.collect.android.analytics.AnalyticsEvents.CUSTOM_ENDPOINT_SUB;
import static org.odk.collect.android.analytics.AnalyticsEvents.SUBMISSION;
import static org.odk.collect.android.preferences.keys.ProjectKeys.KEY_GOOGLE_SHEETS_URL;
import static org.odk.collect.android.utilities.InstanceUploaderUtils.SPREADSHEET_UPLOADED_TO_GOOGLE_DRIVE;
Expand Down Expand Up @@ -121,12 +118,6 @@ public Pair<Boolean, String> submitInstances(List<Instance> toUpload) throws Sub
"HTTP-Sheets auto" : "HTTP auto";
String label = Collect.getFormIdentifierHash(instance.getFormId(), instance.getFormVersion());
analytics.logEvent(SUBMISSION, action, label);

String submissionEndpoint = generalSettings.getString(ProjectKeys.KEY_SUBMISSION_URL);
if (!submissionEndpoint.equals(TranslationHandler.getString(Collect.getInstance(), R.string.default_odk_submission))) {
String submissionEndpointHash = Md5.getMd5Hash(new ByteArrayInputStream(submissionEndpoint.getBytes()));
analytics.logEvent(CUSTOM_ENDPOINT_SUB, submissionEndpointHash);
}
} catch (UploadException e) {
Timber.d(e);
anyFailure = true;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.odk.collect.android.openrosa

object OpenRosaConstants {
// HTTP Header strings
const val VERSION_HEADER = "X-OpenRosa-Version"
const val ACCEPT_CONTENT_LENGTH_HEADER = "X-OpenRosa-Accept-Content-Length"

// Endpoints
const val FORM_LIST = "/formList"
const val SUBMISSION = "/submission"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ public class OpenRosaFormSource implements FormSource {
private final WebCredentialsUtils webCredentialsUtils;

private String serverURL;
private final String formListPath;

public OpenRosaFormSource(String serverURL, String formListPath, OpenRosaHttpInterface openRosaHttpInterface, WebCredentialsUtils webCredentialsUtils, OpenRosaResponseParser openRosaResponseParser) {
public OpenRosaFormSource(String serverURL, OpenRosaHttpInterface openRosaHttpInterface, WebCredentialsUtils webCredentialsUtils, OpenRosaResponseParser openRosaResponseParser) {
this.openRosaResponseParser = openRosaResponseParser;
this.webCredentialsUtils = webCredentialsUtils;
this.openRosaXMLFetcher = new OpenRosaXmlFetcher(openRosaHttpInterface, this.webCredentialsUtils);
this.serverURL = serverURL;
this.formListPath = formListPath;
}

@Override
Expand Down Expand Up @@ -151,18 +149,14 @@ private String getFormListURL() {
downloadListUrl = downloadListUrl.substring(0, downloadListUrl.length() - 1);
}

downloadListUrl += formListPath;
downloadListUrl += OpenRosaConstants.FORM_LIST;
return downloadListUrl;
}

public String getServerURL() {
return serverURL;
}

public String getFormListPath() {
return formListPath;
}

public WebCredentialsUtils getWebCredentialsUtils() {
return webCredentialsUtils;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ object ProjectKeys {
const val KEY_USERNAME = "username"
const val KEY_PASSWORD = "password"

// custom_server_paths_preferences.xml
const val KEY_FORMLIST_URL = "formlist_url"
const val KEY_SUBMISSION_URL = "submission_url"

// google_preferences.xml
const val KEY_SELECTED_GOOGLE_ACCOUNT = "selected_google_account"
const val KEY_GOOGLE_SHEETS_URL = "google_sheets_url"
Expand Down Expand Up @@ -126,11 +122,6 @@ object ProjectKeys {
hashMap[KEY_GOOGLE_SHEETS_URL] = ""
// identity_preferences.xml
hashMap[KEY_ANALYTICS] = true
// custom_server_paths_preferenceshs_preferences.xml
hashMap[KEY_FORMLIST_URL] =
Collect.getInstance().getString(R.string.default_odk_formlist)
hashMap[KEY_SUBMISSION_URL] =
Collect.getInstance().getString(R.string.default_odk_submission)
// server_preferences.xml
hashMap[KEY_PROTOCOL] = PROTOCOL_SERVER
// user_interface_preferences.xml
Expand Down

This file was deleted.

Loading