Niedzielski has uploaded a new change for review. https://gerrit.wikimedia.org/r/321698
Change subject: Hygiene: remove EditTask ...................................................................... Hygiene: remove EditTask This class has been superseded by EditClient. No functional change intended. Change-Id: Ie989b6e1de37f7a3e288cf083b63a0468f78381b --- D app/src/main/java/org/wikipedia/edit/EditTask.java 1 file changed, 0 insertions(+), 86 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/98/321698/1 diff --git a/app/src/main/java/org/wikipedia/edit/EditTask.java b/app/src/main/java/org/wikipedia/edit/EditTask.java deleted file mode 100644 index 9069111..0000000 --- a/app/src/main/java/org/wikipedia/edit/EditTask.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.wikipedia.edit; - -import android.content.Context; - -import org.json.JSONObject; -import org.mediawiki.api.json.Api; -import org.mediawiki.api.json.ApiException; -import org.mediawiki.api.json.ApiResult; -import org.mediawiki.api.json.RequestBuilder; -import org.wikipedia.WikipediaApp; -import org.wikipedia.captcha.CaptchaResult; -import org.wikipedia.dataclient.ApiTask; -import org.wikipedia.page.PageTitle; - -import java.util.concurrent.TimeUnit; - -public class EditTask extends ApiTask<EditResult> { - private final PageTitle title; - private final String sectionWikitext; - private final int sectionID; - private final String summary; - private final String editToken; - private final boolean loggedIn; - - public EditTask(Context context, PageTitle title, String sectionWikitext, int sectionID, - String editToken, String summary, boolean loggedIn) { - super(((WikipediaApp)context.getApplicationContext()).getAPIForSite(title.getWikiSite())); - this.title = title; - this.sectionWikitext = sectionWikitext; - this.sectionID = sectionID; - this.editToken = editToken; - this.summary = summary; - this.loggedIn = loggedIn; - } - - @Override - public RequestBuilder buildRequest(Api api) { - RequestBuilder req = api.action("edit") - .param("title", title.getPrefixedText()) - .param("section", String.valueOf(sectionID)) - .param("text", sectionWikitext) - .param("token", editToken) - .param("summary", summary); - if (loggedIn) { - // if the app believes that the user is logged in, then make sure to send an "assert" - // parameter to the API, so that it will notify us if the user was actually logged - // out on another device, and we'll need to log back in behind the scenes. - req = req.param("assert", "user"); - } - return req; - } - - @Override - protected ApiResult makeRequest(RequestBuilder builder) throws ApiException { - return builder.post(); // Editing requires POST requests - } - - @Override - public EditResult processResult(ApiResult result) throws Throwable { - JSONObject resultJSON = result.asObject(); - JSONObject edit = resultJSON.optJSONObject("edit"); - String status = edit.optString("result"); - if (status.equals("Success")) { - - // TODO: remove when the server reflects the updated page content immediately - // after submitting the edit, instead of a short while after. - Thread.sleep(TimeUnit.SECONDS.toMillis(2)); - - return new EditSuccessResult(edit.optInt("newrevid")); - } else if (status.equals("Failure")) { - if (edit.has("captcha")) { - return new CaptchaResult( - edit.optJSONObject("captcha").optString("id") - ); - } - if (edit.has("code")) { - return new EditAbuseFilterResult(edit); - } - if (edit.has("spamblacklist")) { - return new EditSpamBlacklistResult(edit.optString("spamblacklist")); - } - } - // Handle other type of return codes here - throw new RuntimeException("Failure to recognise edit status: " + resultJSON.toString()); - } -} -- To view, visit https://gerrit.wikimedia.org/r/321698 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie989b6e1de37f7a3e288cf083b63a0468f78381b Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits