mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Bldr: Call recentchanges api
This commit is contained in:
parent
e5baaaabc6
commit
d5d3c68350
@ -18,16 +18,39 @@ import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.apps.wms.apis.origs.*;
|
||||
import gplx.xowa.addons.bldrs.files.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.files.missing_origs.apis.*;
|
||||
public class Xobldr_missing_origs_cmd extends Xob_cmd__base {
|
||||
private int fail_max = 100000;
|
||||
private String recentchanges_bgn, recentchanges_end;
|
||||
public Xobldr_missing_origs_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
// got orig_tbl
|
||||
gplx.xowa.files.downloads.Xof_download_wkr download_wkr = wiki.App().Wmf_mgr().Download_wkr();
|
||||
|
||||
// get recentchanges
|
||||
Xowmf_recentchanges_api rc_api = new Xowmf_recentchanges_api();
|
||||
if (recentchanges_bgn == null || recentchanges_end == null) {
|
||||
throw Err_.new_wo_type("bldr.find_missing: recentchanges_bgn or recentchanges_end not set");
|
||||
}
|
||||
Ordered_hash rc_list = rc_api.Find(download_wkr, gplx.xowa.wikis.domains.Xow_domain_itm_.Str__commons, recentchanges_bgn, recentchanges_end, 500);
|
||||
|
||||
// got orig_db
|
||||
Db_conn conn = Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
String sql_fmt = "UPDATE orig_regy SET orig_page_id = -1 WHERE lnki_ttl = '{0}' AND orig_page_id IS NULL";
|
||||
|
||||
// loop recentchanges
|
||||
int rc_list_len = rc_list.Len();
|
||||
conn.Txn_bgn("orig_regy__recentchanges");
|
||||
for (int i = 0; i < rc_list_len; i++) {
|
||||
Xowmf_recentchanges_item item = (Xowmf_recentchanges_item)rc_list.Get_at(i);
|
||||
conn.Exec_sql_args(sql_fmt, item.Title());
|
||||
}
|
||||
conn.Txn_end();
|
||||
|
||||
// get counts; fail if too many
|
||||
int fail_count = conn.Exec_select_as_int(Db_sql_.Make_by_fmt(String_.Ary("SELECT Count(lnki_ttl) FROM orig_regy WHERE orig_page_id IS NULL")), Int_.Max_value);
|
||||
if (fail_count > fail_max) throw Err_.new_wo_type("bldr.find_missing: too many missing: missing=~{0} max=~{1}", fail_count, fail_max);
|
||||
int fail_count = conn.Exec_select_as_int(Db_sql_.Make_by_fmt(String_.Ary("SELECT Count(lnki_ttl) FROM orig_regy WHERE orig_page_id = -1")), Int_.Max_value);
|
||||
if (fail_count > fail_max) {
|
||||
throw Err_.new_wo_type("bldr.find_missing: too many missing: missing=~{0} max=~{1}", fail_count, fail_max);
|
||||
}
|
||||
Gfo_usr_dlg_.Instance.Note_many("", "", "bldr.find_missing: found=~{0}", fail_count);
|
||||
|
||||
// select into list; ignore any which are invalid titles
|
||||
@ -46,7 +69,7 @@ public class Xobldr_missing_origs_cmd extends Xob_cmd__base {
|
||||
}
|
||||
|
||||
// create itm and add to list
|
||||
Xobldr_missing_origs_item itm = new Xobldr_missing_origs_item();
|
||||
Xowmf_imageinfo_item itm = new Xowmf_imageinfo_item();
|
||||
itm.Init_by_orig_tbl(lnki_ttl);
|
||||
list.Add(itm.Lnki_ttl(), itm);
|
||||
}
|
||||
@ -60,7 +83,7 @@ public class Xobldr_missing_origs_cmd extends Xob_cmd__base {
|
||||
Ordered_hash unfound = Ordered_hash_.New();
|
||||
int list_len = list.Len();
|
||||
for (int i = 0; i < list_len; i++) {
|
||||
Xobldr_missing_origs_item item = (Xobldr_missing_origs_item)list.Get_at(i);
|
||||
Xowmf_imageinfo_item item = (Xowmf_imageinfo_item)list.Get_at(i);
|
||||
if (item.Orig_page_id() == -1)
|
||||
unfound.Add(item.Lnki_ttl(), item);
|
||||
}
|
||||
@ -69,7 +92,7 @@ public class Xobldr_missing_origs_cmd extends Xob_cmd__base {
|
||||
Download(conn, unfound, Xof_repo_tid_.Tid__local , wiki.Domain_str());
|
||||
}
|
||||
private void Download(Db_conn conn, Ordered_hash list, byte repo_tid, String repo_domain) {
|
||||
Xobldr_missing_origs_wmfapi wmf_api = new Xobldr_missing_origs_wmfapi(wiki.App().Wmf_mgr().Download_wkr());
|
||||
Xowmf_imageinfo_api wmf_api = new Xowmf_imageinfo_api(wiki.App().Wmf_mgr().Download_wkr());
|
||||
int list_len = list.Len();
|
||||
int list_bgn = 0;
|
||||
// loop until no more entries
|
||||
@ -89,7 +112,7 @@ public class Xobldr_missing_origs_cmd extends Xob_cmd__base {
|
||||
, "orig_size", "orig_w", "orig_h", "orig_media_type", "orig_minor_mime", "orig_timestamp");
|
||||
// , "orig_bits"
|
||||
for (int i = list_bgn; i < list_end; i++) {
|
||||
Xobldr_missing_origs_item itm = (Xobldr_missing_origs_item)list.Get_at(i);
|
||||
Xowmf_imageinfo_item itm = (Xowmf_imageinfo_item)list.Get_at(i);
|
||||
update_stmt
|
||||
.Val_byte("orig_repo", itm.Orig_repo())
|
||||
.Val_int("orig_page_id", itm.Orig_page_id())
|
||||
@ -116,10 +139,12 @@ public class Xobldr_missing_origs_cmd extends Xob_cmd__base {
|
||||
}
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__fail_max_)) this.fail_max = m.ReadInt("v");
|
||||
if (ctx.Match(k, "fail_max_")) this.fail_max = m.ReadInt("v");
|
||||
else if (ctx.Match(k, "recentchanges_bgn_")) this.recentchanges_bgn = m.ReadStr("v");
|
||||
else if (ctx.Match(k, "recentchanges_end_")) this.recentchanges_end = m.ReadStr("v");
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
return this;
|
||||
} private static final String Invk__fail_max_ = "fail_max_";
|
||||
}
|
||||
|
||||
public static final String BLDR_CMD_KEY = "file.orig_regy.find_missing";
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;}
|
||||
|
@ -13,17 +13,17 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.addons.bldrs.files.missing_origs.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.files.downloads.*;
|
||||
import gplx.xowa.apps.wms.apis.origs.*;
|
||||
public class Xobldr_missing_origs_wmfapi {
|
||||
public class Xowmf_imageinfo_api {
|
||||
private final Xof_download_wkr download_wkr;
|
||||
private final Ordered_hash temp_hash = Ordered_hash_.New();
|
||||
public static final byte[] FILE_NS_PREFIX = Bry_.new_a7("File:");
|
||||
public Xobldr_missing_origs_wmfapi(Xof_download_wkr download_wkr) {
|
||||
public Xowmf_imageinfo_api(Xof_download_wkr download_wkr) {
|
||||
this.download_wkr = download_wkr;
|
||||
}
|
||||
public void Find_by_list(Ordered_hash src, byte repo_id, String api_domain, int idx) {
|
||||
@ -52,7 +52,7 @@ public class Xobldr_missing_origs_wmfapi {
|
||||
|
||||
// add titles; EX: File:A.png|File:B.png|
|
||||
for (int i = idx; i < idx + 500; i++) {
|
||||
Xobldr_missing_origs_item item = (Xobldr_missing_origs_item)src.Get_at(i);
|
||||
Xowmf_imageinfo_item item = (Xowmf_imageinfo_item)src.Get_at(i);
|
||||
|
||||
// skip "|" if first
|
||||
if (i != idx) bfr.Add_byte_pipe();
|
||||
@ -92,7 +92,7 @@ public class Xobldr_missing_origs_wmfapi {
|
||||
|
||||
// add to trg hash
|
||||
try {
|
||||
Xobldr_missing_origs_item trg_item = new Xobldr_missing_origs_item().Init_by_api_page(repo_id, page_id, title, size, width, height, mediatype, mime, timestamp);
|
||||
Xowmf_imageinfo_item trg_item = new Xowmf_imageinfo_item().Init_by_api_page(repo_id, page_id, title, size, width, height, mediatype, mime, timestamp);
|
||||
temp_hash.Add(trg_item.Orig_file_ttl(), trg_item);
|
||||
} catch (Exception e2) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "missing_origs:failed to deserialize api obj; domain=~{0} ttl=~{1} json=~{2} err=~{3}", api_domain, title, page.Print_as_json(), Err_.Message_gplx_log(e2));
|
||||
@ -109,7 +109,7 @@ public class Xobldr_missing_origs_wmfapi {
|
||||
byte[] to = redirect.Get_as_bry("to");
|
||||
|
||||
// get nde by "to" and copy redirect
|
||||
Xobldr_missing_origs_item trg_item = (Xobldr_missing_origs_item)temp_hash.Get_by_or_fail(to);
|
||||
Xowmf_imageinfo_item trg_item = (Xowmf_imageinfo_item)temp_hash.Get_by_or_fail(to);
|
||||
trg_item.Init_by_api_redirect(from, to);
|
||||
|
||||
// update temp_hash key
|
||||
@ -120,8 +120,8 @@ public class Xobldr_missing_origs_wmfapi {
|
||||
// loop over hash and copy back to src
|
||||
int temp_hash_len = temp_hash.Len();
|
||||
for (int i = 0; i < temp_hash_len; i++) {
|
||||
Xobldr_missing_origs_item trg_item = (Xobldr_missing_origs_item)temp_hash.Get_at(i);
|
||||
Xobldr_missing_origs_item src_item = (Xobldr_missing_origs_item)temp_hash.Get_by(trg_item.Lnki_ttl());
|
||||
Xowmf_imageinfo_item trg_item = (Xowmf_imageinfo_item)temp_hash.Get_at(i);
|
||||
Xowmf_imageinfo_item src_item = (Xowmf_imageinfo_item)temp_hash.Get_by(trg_item.Lnki_ttl());
|
||||
src_item.Copy_api_props(trg_item);
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.addons.bldrs.files.missing_origs.*;
|
||||
import gplx.xowa.files.*;
|
||||
class Xobldr_missing_origs_item {
|
||||
public class Xowmf_imageinfo_item {
|
||||
public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
|
||||
public byte Orig_repo() {return orig_repo;} private byte orig_repo;
|
||||
public int Orig_page_id() {return orig_page_id;} private int orig_page_id = -1;
|
||||
@ -33,11 +33,11 @@ class Xobldr_missing_origs_item {
|
||||
public int Orig_redirect_ext() {return orig_redirect_ext;} private int orig_redirect_ext;
|
||||
public int Orig_redirect_id() {return orig_redirect_id;} private int orig_redirect_id;
|
||||
|
||||
public Xobldr_missing_origs_item Init_by_orig_tbl(byte[] lnki_ttl) {
|
||||
public Xowmf_imageinfo_item Init_by_orig_tbl(byte[] lnki_ttl) {
|
||||
this.lnki_ttl = lnki_ttl;
|
||||
return this;
|
||||
}
|
||||
public Xobldr_missing_origs_item Init_by_api_page(byte orig_repo, int orig_page_id, byte[] orig_file_ttl, int orig_size, int orig_w, int orig_h, byte[] orig_media_type, byte[] orig_minor_mime, byte[] orig_timestamp) {
|
||||
public Xowmf_imageinfo_item Init_by_api_page(byte orig_repo, int orig_page_id, byte[] orig_file_ttl, int orig_size, int orig_w, int orig_h, byte[] orig_media_type, byte[] orig_minor_mime, byte[] orig_timestamp) {
|
||||
this.orig_repo = orig_repo;
|
||||
this.orig_page_id = orig_page_id;
|
||||
this.orig_file_ttl = Normalize_ttl(orig_file_ttl);
|
||||
@ -50,7 +50,7 @@ class Xobldr_missing_origs_item {
|
||||
this.orig_timestamp = Normalize_timestamp(orig_timestamp);
|
||||
return this;
|
||||
}
|
||||
public Xobldr_missing_origs_item Init_by_api_redirect(byte[] from, byte[] to) {
|
||||
public Xowmf_imageinfo_item Init_by_api_redirect(byte[] from, byte[] to) {
|
||||
this.lnki_ttl = Normalize_ttl(from);
|
||||
this.orig_redirect_ttl = Normalize_ttl(to);
|
||||
// page_id is always redirect_id
|
||||
@ -59,7 +59,7 @@ class Xobldr_missing_origs_item {
|
||||
this.orig_page_id = -987;
|
||||
return this;
|
||||
}
|
||||
public void Copy_api_props(Xobldr_missing_origs_item src) {
|
||||
public void Copy_api_props(Xowmf_imageinfo_item src) {
|
||||
// page nde
|
||||
this.orig_repo = src.orig_repo;
|
||||
this.orig_page_id = src.orig_page_id;
|
||||
@ -81,8 +81,8 @@ class Xobldr_missing_origs_item {
|
||||
}
|
||||
public static byte[] Normalize_ttl(byte[] v) {
|
||||
// remove "File:"
|
||||
if (Bry_.Has_at_bgn(v, Xobldr_missing_origs_wmfapi.FILE_NS_PREFIX)) {
|
||||
v = Bry_.Mid(v, Xobldr_missing_origs_wmfapi.FILE_NS_PREFIX.length);
|
||||
if (Bry_.Has_at_bgn(v, Xowmf_imageinfo_api.FILE_NS_PREFIX)) {
|
||||
v = Bry_.Mid(v, Xowmf_imageinfo_api.FILE_NS_PREFIX.length);
|
||||
}
|
||||
else {
|
||||
throw Err_.new_wo_type("wmf_api does not start with 'File:'", "title", v);
|
@ -13,10 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.addons.bldrs.files.missing_origs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xobldr_missing_origs_item__tst {
|
||||
private final Xobldr_missing_origs_item__fxt fxt = new Xobldr_missing_origs_item__fxt();
|
||||
public class Xowmf_imageinfo_item__tst {
|
||||
private final Xowmf_imageinfo_item__fxt fxt = new Xowmf_imageinfo_item__fxt();
|
||||
|
||||
@Test public void Normalize_ttl() {
|
||||
fxt.Test__Normalize_ttl("File:A b.png", "A_b.png");
|
||||
@ -28,14 +28,14 @@ public class Xobldr_missing_origs_item__tst {
|
||||
fxt.Test__Normalize_timestamp("2017-03-06T08:09:10Z", "20170306080910");
|
||||
}
|
||||
}
|
||||
class Xobldr_missing_origs_item__fxt {
|
||||
class Xowmf_imageinfo_item__fxt {
|
||||
public void Test__Normalize_ttl(String src, String expd) {
|
||||
Gftest.Eq__str(expd, Xobldr_missing_origs_item.Normalize_ttl(Bry_.new_u8(src)));
|
||||
Gftest.Eq__str(expd, Xowmf_imageinfo_item.Normalize_ttl(Bry_.new_u8(src)));
|
||||
}
|
||||
public void Test__Normalize_timestamp(String src, String expd) {
|
||||
Gftest.Eq__str(expd, Xobldr_missing_origs_item.Normalize_timestamp(Bry_.new_u8(src)));
|
||||
Gftest.Eq__str(expd, Xowmf_imageinfo_item.Normalize_timestamp(Bry_.new_u8(src)));
|
||||
}
|
||||
public void Test__Normalize_minor_mime(String src, String expd) {
|
||||
Gftest.Eq__str(expd, Xobldr_missing_origs_item.Normalize_minor_mime(Bry_.new_u8(src)));
|
||||
Gftest.Eq__str(expd, Xowmf_imageinfo_item.Normalize_minor_mime(Bry_.new_u8(src)));
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.addons.bldrs.files.missing_origs.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.files.downloads.*;
|
||||
public class Xowmf_recentchanges_api {
|
||||
public Ordered_hash Find(Xof_download_wkr download_wkr, String api_domain, String bgn_date, String end_date, int limit) {
|
||||
// fail if web access disabled
|
||||
if (!gplx.core.ios.IoEngine_system.Web_access_enabled) {
|
||||
throw Err_.new_wo_type("web access must be enabled for missing_origs cmd");
|
||||
}
|
||||
|
||||
Json_parser parser = new Json_parser();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Ordered_hash list = Ordered_hash_.New_bry();
|
||||
String rcccontinue = null;
|
||||
// loop until all titles found
|
||||
while (true) {
|
||||
// generate api: https://commons.wikimedia.org/w/api.php?format=json&formatversion=2&action=query&list=recentchanges&rcnamespace=6&rctype=log&rcdir=older&rcstart=20170306000000&rcend=20170301000000&rcprop=title|ids|sizes|loginfo&rclimit=5&rccontinue=20170305235910|537908722
|
||||
bfr.Add_str_a7("https://");
|
||||
bfr.Add_str_a7(api_domain);
|
||||
bfr.Add_str_a7("/w/api.php");
|
||||
bfr.Add_str_a7("?format=json"); // json easier to use than xml
|
||||
bfr.Add_str_a7("&formatversion=2"); // json easier to use than xml
|
||||
bfr.Add_str_a7("&action=query");
|
||||
bfr.Add_str_a7("&list=recentchanges");
|
||||
bfr.Add_str_a7("&rcnamespace=6");
|
||||
bfr.Add_str_a7("&rctype=log");
|
||||
bfr.Add_str_a7("&rcdir=older"); // NOTE: newer can take a long time
|
||||
bfr.Add_str_a7("&rcstart=").Add_str_a7(end_date); // NOTE: reverse start and end date so that api is more natural; i.e.: start=20170301 end=20170307
|
||||
bfr.Add_str_a7("&rcend=").Add_str_a7(bgn_date);
|
||||
bfr.Add_str_a7("&rcprop=title|ids|sizes|loginfo"); // list of props; NOTE: "url" / "sha1" for future; "bitdepth" always 0?
|
||||
bfr.Add_str_a7("&rclimit=").Add_int_variable(limit);
|
||||
if (rcccontinue != null)
|
||||
bfr.Add_str_a7("&rccontinue=").Add_str_a7(rcccontinue);
|
||||
|
||||
// call api
|
||||
byte[] rslt = null;
|
||||
try {
|
||||
rslt = download_wkr.Download_xrg().Exec_as_bry(bfr.To_str_and_clear());
|
||||
}
|
||||
catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "wmf_api:failure while calling api; domain=~{0} err=~{1}", api_domain, Err_.Message_gplx_log(e));
|
||||
}
|
||||
|
||||
// deserialize
|
||||
Json_doc jdoc = parser.Parse(rslt);
|
||||
|
||||
// get items
|
||||
Json_ary ary = (Json_ary)jdoc.Get_grp_many("query", "recentchanges");
|
||||
int ary_len = ary.Len();
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Json_nde nde = ary.Get_as_nde(i);
|
||||
try {
|
||||
byte[] title = Xowmf_imageinfo_item.Normalize_ttl(nde.Get_as_bry("title"));
|
||||
Xowmf_recentchanges_item item = (Xowmf_recentchanges_item)list.Get_by(title);
|
||||
// not in list; add it
|
||||
if (item == null) {
|
||||
item = new Xowmf_recentchanges_item();
|
||||
list.Add(title, item);
|
||||
}
|
||||
// is in list; update with latest props
|
||||
else {
|
||||
item.Logtype_push();
|
||||
}
|
||||
|
||||
String logaction = nde.Get_as_str("logaction");
|
||||
item.Init_base
|
||||
( nde.Get_as_int("ns")
|
||||
, title
|
||||
, nde.Get_as_int("pageid")
|
||||
, nde.Get_as_int("revid")
|
||||
, nde.Get_as_int("old_revid")
|
||||
, nde.Get_as_int("rcid")
|
||||
, nde.Get_as_int("oldlen")
|
||||
, nde.Get_as_int("newlen")
|
||||
, nde.Get_as_int("logid")
|
||||
, nde.Get_as_str("logtype")
|
||||
, nde.Get_as_str("logaction")
|
||||
);
|
||||
|
||||
Json_nde logparams_nde = nde.Get_as_nde("logparams");
|
||||
if (String_.Eq(logaction, "upload")) {
|
||||
item.Init_upload(Xowmf_imageinfo_item.Normalize_timestamp(logparams_nde.Get_as_bry("img_timestamp")));
|
||||
}
|
||||
else if (String_.Eq(logaction, "move")) {
|
||||
item.Init_move
|
||||
( logparams_nde.Get_as_int("target_ns")
|
||||
, Xowmf_imageinfo_item.Normalize_ttl(logparams_nde.Get_as_bry("target_title"))
|
||||
);
|
||||
}
|
||||
else if (String_.Eq(logaction, "delete")) {}// NOTE: logparams nde is empty; DATE:2017-03-07
|
||||
}
|
||||
catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "wmf_api:failure while deserializing node; domain=~{0} err=~{1}", api_domain, Err_.Message_gplx_log(e));
|
||||
}
|
||||
}
|
||||
|
||||
// extract continue
|
||||
Json_nde continue_nde = (Json_nde)jdoc.Get_grp_many("continue");
|
||||
if (continue_nde == null) {
|
||||
break;
|
||||
}
|
||||
rcccontinue = continue_nde.Get_as_str("rccontinue");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.files.missing_origs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.addons.bldrs.files.missing_origs.*;
|
||||
public class Xowmf_recentchanges_item {
|
||||
public int Ns() {return ns;} private int ns;
|
||||
public byte[] Title() {return title;} private byte[] title;
|
||||
public int Pageid() {return pageid;} private int pageid;
|
||||
public int Revid() {return revid;} private int revid;
|
||||
public int Old_revid() {return old_revid;} private int old_revid;
|
||||
public int Rcid() {return rcid;} private int rcid;
|
||||
public int Oldlen() {return oldlen;} private int oldlen;
|
||||
public int Newlen() {return newlen;} private int newlen;
|
||||
public int Logid() {return logid;} private int logid;
|
||||
public String Logtype() {return logtype;} private String logtype;
|
||||
public String Logaction() {return logaction;} private String logaction; // upload, move, delete
|
||||
|
||||
public byte[] Img_timestamp() {return img_timestamp;} private byte[] img_timestamp;
|
||||
|
||||
public int Target_ns() {return target_ns;} private int target_ns;
|
||||
public byte[] Target_title() {return target_title;} private byte[] target_title;
|
||||
|
||||
public List_adp Logtypes() {return logtypes;} private List_adp logtypes;
|
||||
public void Init_base(int ns, byte[] title, int pageid, int revid, int old_revid, int rcid, int oldlen, int newlen, int logid, String logtype, String logaction) {
|
||||
this.ns = ns;
|
||||
this.title = title;
|
||||
this.pageid = pageid;
|
||||
this.revid = revid;
|
||||
this.old_revid = old_revid;
|
||||
this.rcid = rcid;
|
||||
this.oldlen = oldlen;
|
||||
this.newlen = newlen;
|
||||
this.logid = logid;
|
||||
this.logtype = logtype;
|
||||
this.logaction = logaction;
|
||||
}
|
||||
public void Init_upload(byte[] img_timestamp) {
|
||||
this.img_timestamp = img_timestamp;
|
||||
}
|
||||
public void Init_move(int target_ns, byte[] target_title) {
|
||||
this.target_ns = target_ns;
|
||||
this.target_title = target_title;
|
||||
}
|
||||
public void Logtype_push() {
|
||||
if (logtypes == null) {
|
||||
logtypes = List_adp_.New();
|
||||
}
|
||||
logtypes.Add(logtype);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user