mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.1'
This commit is contained in:
@@ -22,15 +22,15 @@ import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.sit
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.bldrs.css.*;
|
||||
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.guis.cbks.*;
|
||||
import gplx.xowa.guis.cbks.*; import gplx.xowa.guis.tabs.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.js.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.parsers.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.bldrs.wms.*;
|
||||
import gplx.xowa.users.*;
|
||||
import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.addons.*; import gplx.xowa.addons.apps.specials.*;
|
||||
public interface Xoa_app extends GfoInvkAble {
|
||||
import gplx.xowa.addons.*; import gplx.xowa.specials.mgrs.*;
|
||||
public interface Xoa_app extends Gfo_invk {
|
||||
boolean Tid_is_edit();
|
||||
Xoa_app_mode Mode();
|
||||
Xoapi_root Api_root();
|
||||
@@ -47,6 +47,7 @@ public interface Xoa_app extends GfoInvkAble {
|
||||
Xoa_css_extractor Html__css_installer();
|
||||
Xoh_bridge_mgr Html__bridge_mgr();
|
||||
Xog_cbk_mgr Gui__cbk_mgr();
|
||||
Xog_tab_mgr Gui__tab_mgr();
|
||||
Xou_user User();
|
||||
Xowmf_mgr Wmf_mgr();
|
||||
boolean Xwiki_mgr__missing(byte[] domain);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "3.5.1.1";
|
||||
public static final String Version = "3.6.3.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.gfui.kits.core.*;
|
||||
import gplx.langs.gfs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*;
|
||||
@@ -24,6 +25,7 @@ import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.guis.tabs.*;
|
||||
public class Xoa_app_fxt {
|
||||
public static Xoae_app Make__app__edit() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
@@ -34,7 +36,7 @@ public class Xoa_app_fxt {
|
||||
Io_url user_dir = root_dir.GenSubDir_nest("user", "test_user");
|
||||
Gfo_usr_dlg__log_base.Instance.Log_dir_(user_dir.GenSubDir_nest("tmp", "current"));
|
||||
Xoae_app app = new Xoae_app(Gfo_usr_dlg_.Test(), Xoa_app_mode.Itm_cmd, root_dir, root_dir.GenSubDir("wiki"), root_dir.GenSubDir("file"), user_dir, root_dir.GenSubDir_nest("user", "anonymous", "wiki"), op_sys);
|
||||
app.Setup_mgr().Dump_mgr().Data_storage_format_(gplx.core.ios.Io_stream_.Tid_raw); // TEST: set data_storage_format to file, else bldr tests will fails (expects plain text)
|
||||
app.Setup_mgr().Dump_mgr().Data_storage_format_(gplx.core.ios.streams.Io_stream_.Tid_raw); // TEST: set data_storage_format to file, else bldr tests will fails (expects plain text)
|
||||
GfsCore.Instance.Clear(); // NOTE: must clear
|
||||
GfsCore.Instance.AddCmd(app, Xoae_app.Invk_app); // NOTE: must add app to GfsCore; app.Gfs_mgr() always adds current app to GfsCore; note this causes old test to leave behind GfsCore for new test
|
||||
GfsCore.Instance.AddCmd(app, Xoae_app.Invk_xowa); // add alias for app; DATE:2014-06-09
|
||||
@@ -48,7 +50,7 @@ public class Xoa_app_fxt {
|
||||
public static Xoav_app Make__app__view(String op_sys, Io_url root_dir) {
|
||||
Io_url user_dir = root_dir.GenSubDir_nest("user", "test_user");
|
||||
Gfo_usr_dlg__log_base.Instance.Log_dir_(user_dir.GenSubDir_nest("tmp", "current"));
|
||||
Xoav_app rv = new Xoav_app(Gfo_usr_dlg_.Test(), Xoa_app_mode.Itm_gui, op_sys, root_dir, root_dir.GenSubDir("file"), root_dir.GenSubDir("css"));
|
||||
Xoav_app rv = new Xoav_app(Gfo_usr_dlg_.Test(), Xoa_app_mode.Itm_gui, Xog_tab_mgr_.New_mem(), op_sys, root_dir, root_dir.GenSubDir("file"), root_dir.GenSubDir("css"), root_dir);
|
||||
rv.Init_by_app(user_dir);
|
||||
rv.Wiki_mgr().Add(new Xowv_wiki(rv, Xow_domain_itm_.Bry__home, user_dir));
|
||||
return rv;
|
||||
@@ -94,7 +96,7 @@ public class Xoa_app_fxt {
|
||||
wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_a7("src:comm"), Bry_.new_a7("trg:comm"));
|
||||
}
|
||||
public static void Init_gui(Xoae_app app, Xowe_wiki wiki) {
|
||||
app.Gui_mgr().Browser_win().Init_by_kit(gplx.gfui.Mem_kit.Instance);
|
||||
app.Gui_mgr().Browser_win().Init_by_kit(Mem_kit.Instance);
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(wiki, Xoae_page.Empty);
|
||||
}
|
||||
public static Xob_bldr bldr_(Xoae_app app) {
|
||||
@@ -102,5 +104,5 @@ public class Xoa_app_fxt {
|
||||
rv.Sort_mem_len_(Io_mgr.Len_kb).Dump_fil_len_(Io_mgr.Len_kb).Make_fil_len_(Io_mgr.Len_kb);
|
||||
return rv;
|
||||
}
|
||||
public static final Io_url Root_dir = Op_sys.Cur().Tid_is_lnx() ? Io_url_.new_dir_("/xowa/") : Io_url_.new_dir_("C:\\xowa\\");
|
||||
public static final Io_url Root_dir = Op_sys.Cur().Tid_is_lnx() ? Io_url_.new_dir_("/xowa/") : Io_url_.new_dir_("C:\\xowa\\");
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public interface Xoa_page {
|
||||
boolean Exists();
|
||||
Xopg_revision_data Revision_data();
|
||||
Xopg_html_data Html_data();
|
||||
byte[] Redirect_to_ttl(); void Redirect_to_ttl_(byte[] v);
|
||||
|
||||
Xoa_page__commons_mgr Commons_mgr();
|
||||
void Xtn_gallery_packed_exists_y_();
|
||||
|
||||
@@ -290,7 +290,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
if (anch_bgn != -1) {
|
||||
if (anchor_encoder == null) {
|
||||
anchor_encoder = Gfo_url_encoder_.Id;
|
||||
anchor_encoder_bfr = Bry_bfr.reset_(32);
|
||||
anchor_encoder_bfr = Bry_bfr_.Reset(32);
|
||||
}
|
||||
anchor_encoder.Encode(anchor_encoder_bfr, src, cur, cur + 1);
|
||||
b_ary = anchor_encoder_bfr.To_bry_and_clear();
|
||||
@@ -303,7 +303,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
if (anch_bgn != -1) {
|
||||
if (anchor_encoder == null) {
|
||||
anchor_encoder = Gfo_url_encoder_.Id;
|
||||
anchor_encoder_bfr = Bry_bfr.reset_(32);
|
||||
anchor_encoder_bfr = Bry_bfr_.Reset(32);
|
||||
}
|
||||
anchor_encoder.Encode(anchor_encoder_bfr, src, cur, cur + 1);
|
||||
b_ary = anchor_encoder_bfr.To_bry_and_clear();
|
||||
@@ -375,6 +375,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
}
|
||||
Xow_ns tors_ns = ns.Id_is_talk() ? ns_mgr.Ords_get_at(ns.Ord_subj_id()) : ns_mgr.Ords_get_at(ns.Ord_talk_id());
|
||||
tors_txt = tors_ns.Name_ui_w_colon();
|
||||
// tors_txt = tors_ns == null ? Bry_.Empty : tors_ns.Name_ui_w_colon();
|
||||
return true;
|
||||
}
|
||||
public static byte[] Replace_spaces(byte[] raw) {return Bry_.Replace(raw, Byte_ascii.Space, Byte_ascii.Underline);}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.net.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xoa_url {
|
||||
public int Tid() {return tid;} private int tid;
|
||||
@@ -27,7 +27,7 @@ public class Xoa_url {
|
||||
public String Anch_str() {return anch_bry == null ? null : String_.new_u8(anch_bry);}
|
||||
public byte[][] Segs_ary() {return segs_ary;} private byte[][] segs_ary;
|
||||
public Gfo_qarg_itm[] Qargs_ary() {return qargs_ary;} public Xoa_url Qargs_ary_(Gfo_qarg_itm[] v) {qargs_ary = v; return this;} private Gfo_qarg_itm[] qargs_ary = Gfo_qarg_itm.Ary_empty;
|
||||
public Gfo_qarg_mgr Qargs_mgr() {if (qargs_mgr == null) qargs_mgr = new Gfo_qarg_mgr().Load(qargs_ary); return qargs_mgr;} private Gfo_qarg_mgr qargs_mgr;
|
||||
public Gfo_qarg_mgr_old Qargs_mgr() {if (qargs_mgr == null) qargs_mgr = new Gfo_qarg_mgr_old().Load(qargs_ary); return qargs_mgr;} private Gfo_qarg_mgr_old qargs_mgr;
|
||||
public byte Protocol_tid() {return protocol_tid;} private byte protocol_tid;
|
||||
public byte[] Protocol_bry() {return protocol_bry;} private byte[] protocol_bry;
|
||||
public boolean Protocol_is_relative() {return protocol_is_relative;} private boolean protocol_is_relative;
|
||||
@@ -100,13 +100,13 @@ public class Xoa_url {
|
||||
if (show_qargs || qargs_ary.length > 0) {
|
||||
Bry_bfr bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();
|
||||
bfr.Add(rv);
|
||||
Gfo_qarg_mgr.Concat_bfr(bfr, gplx.langs.htmls.encoders.Gfo_url_encoder_.Href, qargs_ary);
|
||||
Gfo_qarg_mgr_old.Concat_bfr(bfr, gplx.langs.htmls.encoders.Gfo_url_encoder_.Href, qargs_ary);
|
||||
return bfr.To_bry_and_rls();
|
||||
}
|
||||
else
|
||||
return rv;
|
||||
}
|
||||
public static final Xoa_url Null = null;
|
||||
public static final Xoa_url Null = null;
|
||||
public static Xoa_url blank() {return new Xoa_url();}
|
||||
public static Xoa_url new_(byte[] wiki, byte[] page) {
|
||||
Xoa_url rv = new Xoa_url();
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.sit
|
||||
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.apps.cfgs.old.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.css.*; import gplx.xowa.bldrs.installs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.guis.cbks.*;
|
||||
import gplx.xowa.guis.cbks.*; import gplx.xowa.guis.tabs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.guis.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.apps.fmtrs.*; import gplx.xowa.htmls.*; import gplx.xowa.wikis.xwikis.sitelinks.*; import gplx.xowa.wikis.xwikis.parsers.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.xndes.*;
|
||||
@@ -29,13 +29,13 @@ import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtn
|
||||
import gplx.xowa.parsers.utils.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.apps.servers.tcp.*; import gplx.xowa.apps.servers.http.*;
|
||||
import gplx.xowa.bldrs.wms.*;
|
||||
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.hives.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.addons.*; import gplx.xowa.addons.apps.specials.*;
|
||||
public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
import gplx.xowa.addons.*; import gplx.xowa.specials.mgrs.*;
|
||||
public class Xoae_app implements Xoa_app, Gfo_invk {
|
||||
public Xoae_app(Gfo_usr_dlg usr_dlg, Xoa_app_mode mode, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url user_dir, Io_url css_dir, String bin_dir_name) {
|
||||
Xoa_app_.Usr_dlg_(usr_dlg);
|
||||
this.mode = mode;
|
||||
Io_url.Http_file_str_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx;
|
||||
fsys_mgr = new Xoa_fsys_mgr(bin_dir_name, root_dir, wiki_dir, file_dir, css_dir);
|
||||
fsys_mgr = new Xoa_fsys_mgr(bin_dir_name, root_dir, wiki_dir, file_dir, css_dir, root_dir);
|
||||
log_wtr = usr_dlg.Log_wkr();
|
||||
cfg_mgr = new Xoa_cfg_mgr(this);
|
||||
api_root = new Xoapi_root(this);
|
||||
@@ -47,6 +47,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
lang_mgr = new Xoa_lang_mgr(this);
|
||||
wiki_mgr = new Xoae_wiki_mgr(this);
|
||||
gui_mgr = new Xoa_gui_mgr(this);
|
||||
this.gui__tab_mgr = new Xog_tab_mgr__swt(gui_mgr);
|
||||
bldr = new Xob_bldr(this);
|
||||
file_mgr.Ctor_by_app(this);
|
||||
sanitizer = new Xop_sanitizer(parser_amp_mgr, msg_log);
|
||||
@@ -83,7 +84,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
|
||||
public Json_parser Utl__json_parser() {return utl__json_parser;} private final Json_parser utl__json_parser = new Json_parser();
|
||||
public Gfo_inet_conn Utl__inet_conn() {return inet_conn;} private final Gfo_inet_conn inet_conn = Gfo_inet_conn_.new_();
|
||||
public Xoa_meta_mgr Dbmeta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;
|
||||
public Xoa_meta_mgr Dbmeta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;
|
||||
public boolean Bldr__running() {return bldr__running;} public void Bldr__running_(boolean v) {this.bldr__running = v;} private boolean bldr__running;
|
||||
public Xoa_parser_mgr Parser_mgr() {return parser_mgr;} private final Xoa_parser_mgr parser_mgr = new Xoa_parser_mgr();
|
||||
public Xoa_site_cfg_mgr Site_cfg_mgr() {return site_cfg_mgr;} private final Xoa_site_cfg_mgr site_cfg_mgr;
|
||||
@@ -94,7 +95,8 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
|
||||
public Xoa_special_regy Special_regy() {return special_regy;} private final Xoa_special_regy special_regy = new Xoa_special_regy();
|
||||
public Xob_bldr Bldr() {return bldr;} private Xob_bldr bldr;
|
||||
public Xog_cbk_mgr Gui__cbk_mgr() {return gui__cbk_mgr;} private final Xog_cbk_mgr gui__cbk_mgr = new Xog_cbk_mgr();
|
||||
public Xog_cbk_mgr Gui__cbk_mgr() {return gui__cbk_mgr;} private final Xog_cbk_mgr gui__cbk_mgr = new Xog_cbk_mgr();
|
||||
public Xog_tab_mgr Gui__tab_mgr() {return gui__tab_mgr;} private final Xog_tab_mgr gui__tab_mgr;
|
||||
|
||||
|
||||
public Xoae_wiki_mgr Wiki_mgr() {return wiki_mgr;} private Xoae_wiki_mgr wiki_mgr;
|
||||
@@ -226,7 +228,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_fmtrs)) return fmtr_mgr;
|
||||
else if (ctx.Match(k, Invk_cfg)) return cfg_regy;
|
||||
else if (ctx.Match(k, Invk_xwiki_langs_load)) xwiki_mgr__sitelink_mgr.Parse(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_gui = "gui", Invk_bldr = "bldr", Invk_wikis = "wikis", Invk_files = "files", Invk_langs = "langs", Invk_users = "users"
|
||||
|
||||
@@ -37,6 +37,7 @@ public class Xoae_page implements Xoa_page {
|
||||
public void Xtn_gallery_packed_exists_y_() {html_data.Xtn_gallery_packed_exists_y_();}
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;}
|
||||
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public Xowe_wiki Wikie() {return wiki;} private Xowe_wiki wiki;
|
||||
@@ -46,7 +47,7 @@ public class Xoae_page implements Xoa_page {
|
||||
public Xopg_hdump_data Hdump_data() {return hdump_data;} private final Xopg_hdump_data hdump_data = new Xopg_hdump_data();
|
||||
public boolean Missing() {return missing;} public Xoae_page Missing_() {return Missing_(true);} public Xoae_page Missing_(boolean v) {missing = v; return this;} private boolean missing;
|
||||
public boolean Redirected() {return redirected;} public Xoae_page Redirected_(boolean v) {redirected = v; return this;} private boolean redirected;
|
||||
public List_adp Redirected_ttls() {return redirected_ttls;} private List_adp redirected_ttls = List_adp_.new_();
|
||||
public List_adp Redirected_ttls() {return redirected_ttls;} private List_adp redirected_ttls = List_adp_.New();
|
||||
public byte[] Redirected_ttls__itm_0() {return (byte[])redirected_ttls.Get_at(0);}
|
||||
public byte[] Redirected_src() {return redirected_src;} public void Redirected_src_(byte[] v) {this.redirected_src = v;} private byte[] redirected_src;
|
||||
public byte Edit_mode() {return edit_mode;} private byte edit_mode; public void Edit_mode_update_() {edit_mode = Xoa_page_.Edit_mode_update;}
|
||||
@@ -55,12 +56,12 @@ public class Xoae_page implements Xoa_page {
|
||||
public Xow_hdr_mgr Hdr_mgr() {return hdr_mgr;} private Xow_hdr_mgr hdr_mgr;
|
||||
public Xoh_cmd_mgr Html_cmd_mgr() {return html_cmd_mgr;} private Xoh_cmd_mgr html_cmd_mgr = new Xoh_cmd_mgr();
|
||||
public byte[][] Category_list() {return category_list;} public Xoae_page Category_list_(byte[][] v) {category_list = v; return this;} private byte[][] category_list = new byte[0][];
|
||||
public List_adp Lnki_list() {return lnki_list;} public void Lnki_list_(List_adp v) {this.lnki_list = v;} private List_adp lnki_list = List_adp_.new_();
|
||||
public List_adp Lnki_list() {return lnki_list;} public void Lnki_list_(List_adp v) {this.lnki_list = v;} private List_adp lnki_list = List_adp_.New();
|
||||
public Xof_xfer_queue File_queue() {return file_queue;} private Xof_xfer_queue file_queue = new Xof_xfer_queue();
|
||||
public List_adp File_math() {return file_math;} private List_adp file_math = List_adp_.new_();
|
||||
public List_adp File_math() {return file_math;} private List_adp file_math = List_adp_.New();
|
||||
public Ref_itm_mgr Ref_mgr() {return ref_mgr;} private Ref_itm_mgr ref_mgr = new Ref_itm_mgr(); public void Ref_mgr_(Ref_itm_mgr v) {this.ref_mgr = v;}
|
||||
public Xopg_popup_mgr Popup_mgr() {return popup_mgr;} private Xopg_popup_mgr popup_mgr = new Xopg_popup_mgr();
|
||||
public List_adp Slink_list() {return slink_list;} private List_adp slink_list = List_adp_.new_();
|
||||
public List_adp Slink_list() {return slink_list;} private List_adp slink_list = List_adp_.New();
|
||||
public Wdata_external_lang_links_data Wdata_external_lang_links() {return wdata_external_lang_links;} private Wdata_external_lang_links_data wdata_external_lang_links = new Wdata_external_lang_links_data();
|
||||
public boolean Pages_recursed() {return pages_recursed;} public void Pages_recursed_(boolean v) {pages_recursed = v; } private boolean pages_recursed;
|
||||
public int Bldr__ns_ord() {return bldr__ns_ord;} public void Bldr__ns_ord_(int v) {bldr__ns_ord = v;} private int bldr__ns_ord;
|
||||
|
||||
@@ -166,7 +166,7 @@ public class Xop_fxt {
|
||||
}
|
||||
public Xop_fxt Init_para_y_() {ctx.Para().Enabled_y_(); return this;}
|
||||
public Xop_fxt Init_para_n_() {ctx.Para().Enabled_n_(); return this;}
|
||||
public Xop_fxt Init_log_(Gfo_msg_itm... itms) {for (Gfo_msg_itm itm : itms) log_itms.Add(itm); return this;} List_adp log_itms = List_adp_.new_();
|
||||
public Xop_fxt Init_log_(Gfo_msg_itm... itms) {for (Gfo_msg_itm itm : itms) log_itms.Add(itm); return this;} List_adp log_itms = List_adp_.New();
|
||||
public void Init_defn_add(String name, String text) {Init_defn_add(name, text, Xow_ns_case_.Tid__all);}
|
||||
public void Init_defn_add(String name, String text, byte case_match) {
|
||||
Xot_defn_tmpl itm = run_Parse_tmpl(Bry_.new_a7(name), Bry_.new_u8(text));
|
||||
@@ -190,7 +190,7 @@ public class Xop_fxt {
|
||||
public Xop_fxt Init_page_update(Xowe_wiki wiki, String ttl, String txt) {
|
||||
Xoa_ttl page_ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl));
|
||||
byte[] page_raw = Bry_.new_u8(txt);
|
||||
Xoae_page page = wiki.Data_mgr().Get_page(page_ttl, false);
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(page_ttl);
|
||||
wiki.Db_mgr().Save_mgr().Data_update(page, page_raw);
|
||||
return this;
|
||||
}
|
||||
@@ -285,8 +285,8 @@ public class Xop_fxt {
|
||||
}
|
||||
public String Exec_parse_page_all_as_str(String raw) {
|
||||
Xop_root_tkn root = Exec_parse_page_all_as_root(Bry_.new_u8(raw));
|
||||
Bry_bfr actl_bfr = Bry_bfr.new_();
|
||||
hdom_wtr.Write_all(actl_bfr, ctx, root.Root_src(), root);
|
||||
Bry_bfr actl_bfr = Bry_bfr_.New();
|
||||
hdom_wtr.Write_all(actl_bfr, ctx, hctx, root.Root_src(), root);
|
||||
return actl_bfr.To_str_and_clear();
|
||||
}
|
||||
public void Hctx_(Xoh_wtr_ctx v) {hctx = v;} private Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Basic;
|
||||
@@ -294,7 +294,7 @@ public class Xop_fxt {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Xop_root_tkn root = tkn_mkr.Root(raw_bry);
|
||||
parser.Parse_wtxt_to_wdom(root, ctx, tkn_mkr, raw_bry, Xop_parser_.Doc_bgn_bos);
|
||||
Bry_bfr actl_bfr = Bry_bfr.new_();
|
||||
Bry_bfr actl_bfr = Bry_bfr_.New();
|
||||
hdom_wtr.Write_all(actl_bfr, ctx, hctx, raw_bry, root);
|
||||
return actl_bfr.To_str_and_clear();
|
||||
}
|
||||
@@ -316,7 +316,7 @@ public class Xop_fxt {
|
||||
public String[] Log_xtoAry() {
|
||||
Gfo_msg_log msg_log = app.Msg_log();
|
||||
int len = msg_log.Ary_len();
|
||||
List_adp actl_list = List_adp_.new_();
|
||||
List_adp actl_list = List_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Gfo_msg_data eny = msg_log.Ary_get(i);
|
||||
if (eny.Item().Cmd() > Gfo_msg_itm_.Cmd_note) {
|
||||
@@ -353,7 +353,7 @@ public class Xop_fxt {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_url page_url = Xoa_url.new_(wiki.Domain_bry(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
return wiki.Data_mgr().Load_page_by_ttl(page_url, ttl).Data_raw();
|
||||
return wiki.Data_mgr().Load_page_and_parse(page_url, ttl).Data_raw();
|
||||
}
|
||||
public static void Reg_xwiki_alias(Xowe_wiki wiki, String alias, String domain) {
|
||||
byte[] domain_bry = Bry_.new_a7(domain);
|
||||
@@ -431,7 +431,7 @@ public class Xop_fxt {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
return new Xop_fxt(app, Xoa_app_fxt.Make__wiki__edit__nonwmf(app, "nethackwiki"));
|
||||
}
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(255);
|
||||
public String Exec__parse_to_hdump(String src_str) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
Xop_root_tkn root = Exec_parse_page_all_as_root(src_bry);
|
||||
|
||||
@@ -23,7 +23,7 @@ import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
public interface Xow_wiki extends Xow_ttl_parser, GfoInvkAble {
|
||||
public interface Xow_wiki extends Xow_ttl_parser, Gfo_invk {
|
||||
boolean Type_is_edit();
|
||||
Xoa_app App();
|
||||
Xol_lang_itm Lang();
|
||||
@@ -34,7 +34,7 @@ public interface Xow_wiki extends Xow_ttl_parser, GfoInvkAble {
|
||||
byte[] Domain_abrv(); // enwiki
|
||||
Xow_domain_itm Domain_itm();
|
||||
Xow_fsys_mgr Fsys_mgr();
|
||||
Xowd_db_mgr Data__core_mgr();
|
||||
Xow_db_mgr Data__core_mgr();
|
||||
Xof_fsdb_mode File__fsdb_mode();
|
||||
Fsdb_db_mgr File__fsdb_core();
|
||||
Xow_repo_mgr File__repo_mgr();
|
||||
@@ -50,6 +50,8 @@ public interface Xow_wiki extends Xow_ttl_parser, GfoInvkAble {
|
||||
Xow_wiki_props Props();
|
||||
Xow_site_stats_mgr Stats();
|
||||
void Init_by_wiki();
|
||||
void Init_by_wiki__force(); // HACK: force init for drd wiki
|
||||
Xow_url_parser Utl__url_parser();
|
||||
Xoax_addon_mgr Addon_mgr();
|
||||
void Init_needed_y_();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,17 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xow_wiki_ {
|
||||
public static void Rls_mem(Xowe_wiki wiki, boolean clear_ctx) {
|
||||
wiki.Appe().Free_mem(clear_ctx);
|
||||
wiki.Cache_mgr().Free_mem_all();
|
||||
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
|
||||
public static void Create_sql_backend(Xow_wiki wiki, gplx.xowa.wikis.data.Xowd_core_db_props core_db_props, gplx.xowa.bldrs.infos.Xob_info_session session) {
|
||||
if (wiki.Type_is_edit()) {
|
||||
Xowe_wiki wikie = (Xowe_wiki)wiki;
|
||||
wikie.Db_mgr_create_as_sql(); // edit-wikis are created with text-backend; convert to sql
|
||||
wiki.Data__core_mgr().Init_by_make(core_db_props, session); // make core_db
|
||||
}
|
||||
else {
|
||||
Xowv_wiki wikiv = (Xowv_wiki)wiki;
|
||||
wikiv.Init_by_make(core_db_props, session); // make core_db
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,20 +19,21 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.apps.cfgs.gui.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.addons.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.caches.*;
|
||||
import gplx.xowa.users.*; import gplx.xowa.htmls.*; import gplx.xowa.users.history.*; import gplx.xowa.specials.*; import gplx.xowa.xtns.*; import gplx.xowa.wikis.dbs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.css.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.installs.*; import gplx.xowa.bldrs.setups.maints.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.utils.*;
|
||||
import gplx.xowa.wikis.ctgs.*;
|
||||
import gplx.xowa.guis.cbks.*; import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.xtns.gallery.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.hives.*;
|
||||
public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.htmls.css.mgrs.*;
|
||||
public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm {
|
||||
private boolean init_in_process = false;
|
||||
public Xowe_wiki(Xoae_app app, Xol_lang_itm lang, Xow_ns_mgr ns_mgr, Xow_domain_itm domain_itm, Io_url wiki_dir) {
|
||||
this.ev_mgr = GfoEvMgr.new_(this);
|
||||
this.ev_mgr = new Gfo_evt_mgr(this);
|
||||
this.app = app; this.lang = lang; this.ns_mgr = ns_mgr;
|
||||
this.domain_itm = domain_itm; this.domain_str = domain_itm.Domain_str(); this.domain_bry = domain_itm.Domain_bry(); this.domain_tid = domain_itm.Domain_type_id(); this.domain_abrv = Xow_abrv_wm_.To_abrv(domain_itm);
|
||||
this.fsys_mgr = new Xow_fsys_mgr(wiki_dir, app.Fsys_mgr().File_dir().GenSubDir(domain_str));
|
||||
@@ -40,10 +41,11 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
this.xwiki_mgr = new Xow_xwiki_mgr(this);
|
||||
this.html__hdump_mgr = new Xow_hdump_mgr(this);
|
||||
this.html_mgr = new Xow_html_mgr(this);
|
||||
this.page_mgr = new Xowe_page_mgr(this);
|
||||
|
||||
tdb_fsys_mgr = new Xotdb_fsys_mgr(wiki_dir, ns_mgr);
|
||||
redirect_mgr = new Xop_redirect_mgr(this);
|
||||
data_mgr = new Xow_data_mgr(this);
|
||||
data_mgr = new Xow_page_mgr(this);
|
||||
file_mgr = new Xow_file_mgr(this);
|
||||
parser_mgr = new Xow_parser_mgr(this);
|
||||
cfg_parser = new Xowc_parser(this);
|
||||
@@ -51,7 +53,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
props.ContentLanguage_(lang.Key_bry());
|
||||
stats = new Xow_site_stats_mgr(this);
|
||||
Pf_func_.Reg(domain_itm, lang.Func_regy(), lang);
|
||||
special_mgr = new Xows_mgr(this, lang);
|
||||
special_mgr = new Xow_special_mgr(this, lang);
|
||||
sys_cfg = new Xow_sys_cfg(this);
|
||||
hive_mgr = new Xob_hive_mgr(this);
|
||||
util = new Xow_html_util(this);
|
||||
@@ -75,7 +77,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
cache_mgr = new Xow_cache_mgr(this);
|
||||
/*if (Bry_.Eq(domain_bry, Xow_domain_itm_.Bry__home))*/ xwiki_mgr.Add_by_atrs(domain_bry, domain_bry); // add full name to xwiki_mgr; needed for lookup in home ns; EX: [[home:Help/Contents]]
|
||||
}
|
||||
public GfoEvMgr EvMgr() {return ev_mgr;} private final GfoEvMgr ev_mgr;
|
||||
public Gfo_evt_mgr Evt_mgr() {return ev_mgr;} private final Gfo_evt_mgr ev_mgr;
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
|
||||
public Xoa_ttl Ttl_parse(byte[] ttl) {return Xoa_ttl.parse(this, ttl);}
|
||||
public Xoa_ttl Ttl_parse(byte[] src, int src_bgn, int src_end) {return Xoa_ttl.new_(this, app.Msg_log(), src, src_bgn, src_end);}
|
||||
@@ -90,7 +92,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
public byte[] Domain_abrv() {return domain_abrv;} private final byte[] domain_abrv;
|
||||
public Xow_domain_itm Domain_itm() {return domain_itm;} private final Xow_domain_itm domain_itm;
|
||||
public Xow_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xow_fsys_mgr fsys_mgr;
|
||||
public Xowd_db_mgr Data__core_mgr() {if (db_mgr == null) return null; return db_mgr.Tid() == Xodb_mgr_txt.Tid_txt ? null : this.Db_mgr_as_sql().Core_data_mgr();} // TEST:
|
||||
public Xow_db_mgr Data__core_mgr() {if (db_mgr == null) return null; return db_mgr.Tid() == Xodb_mgr_txt.Tid_txt ? null : this.Db_mgr_as_sql().Core_data_mgr();} // TEST:
|
||||
public Xof_fsdb_mode File__fsdb_mode() {return file_mgr.Fsdb_mode();}
|
||||
public Fsdb_db_mgr File__fsdb_core() {return file_mgr.Db_core();}
|
||||
public Xow_repo_mgr File__repo_mgr() {return file_mgr.Repo_mgr();}
|
||||
@@ -108,15 +110,16 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
public Xow_parser_mgr Parser_mgr() {return parser_mgr;} private final Xow_parser_mgr parser_mgr;
|
||||
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
|
||||
public Xog_cbk_mgr Gui__cbk_mgr() {return gui__cbk_mgr;} private final Xog_cbk_mgr gui__cbk_mgr = new Xog_cbk_mgr();
|
||||
public Xowe_page_mgr Page_mgr() {return page_mgr;} private final Xowe_page_mgr page_mgr;
|
||||
|
||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||
public Xoae_app Appe() {return app;} private Xoae_app app;
|
||||
public Xow_gui_mgr Gui_mgr() {return gui_mgr;} private final Xow_gui_mgr gui_mgr = new Xow_gui_mgr();
|
||||
public Xow_user User() {return user;} private Xow_user user = new Xow_user();
|
||||
public Xow_data_mgr Data_mgr() {return data_mgr;} private Xow_data_mgr data_mgr;
|
||||
public Xow_page_mgr Data_mgr() {return data_mgr;} private Xow_page_mgr data_mgr;
|
||||
public Xodb_mgr Db_mgr() {return db_mgr;} private Xodb_mgr db_mgr;
|
||||
public Xodb_mgr_sql Db_mgr_as_sql() {return (Xodb_mgr_sql)db_mgr;}
|
||||
public Xows_mgr Special_mgr() {return special_mgr;} private Xows_mgr special_mgr;
|
||||
public Xow_special_mgr Special_mgr() {return special_mgr;} private Xow_special_mgr special_mgr;
|
||||
public Xow_html_mgr Html_mgr() {return html_mgr;} private Xow_html_mgr html_mgr;
|
||||
public Xow_xtn_mgr Xtn_mgr() {return xtn_mgr;} private Xow_xtn_mgr xtn_mgr;
|
||||
public Xow_cache_mgr Cache_mgr() {return cache_mgr;} private Xow_cache_mgr cache_mgr;
|
||||
@@ -132,13 +135,13 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
public byte[] Wdata_wiki_abrv() {return wdata_wiki_abrv;} private byte[] wdata_wiki_abrv; private int wdata_wiki_tid;
|
||||
private void Wdata_wiki_abrv_() {
|
||||
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b128();
|
||||
Xow_abrv_wm_.To_abrv(bfr, wdata_wiki_lang, Int_obj_ref.new_(wdata_wiki_tid));
|
||||
Xow_abrv_wm_.To_abrv(bfr, wdata_wiki_lang, Int_obj_ref.New(wdata_wiki_tid));
|
||||
wdata_wiki_abrv = bfr.To_bry_and_rls();
|
||||
}
|
||||
private Xow_html_util util;
|
||||
public boolean Init_needed() {return init_needed;} public Xowe_wiki Init_needed_(boolean v) {init_needed = v; return this;} private boolean init_needed = true;
|
||||
public Xop_redirect_mgr Redirect_mgr() {return redirect_mgr;} private Xop_redirect_mgr redirect_mgr;
|
||||
public List_adp Rls_list() {if (rls_list == null) rls_list = List_adp_.new_(); return rls_list;} private List_adp rls_list;
|
||||
public List_adp Rls_list() {if (rls_list == null) rls_list = List_adp_.New(); return rls_list;} private List_adp rls_list;
|
||||
public Xow_file_mgr File_mgr() {return file_mgr;} private Xow_file_mgr file_mgr;
|
||||
public Xow_cfg_wiki_core Cfg_wiki_core() {return cfg_wiki_core;} private Xow_cfg_wiki_core cfg_wiki_core;
|
||||
public Xob_import_cfg Import_cfg() {return import_cfg;} private Xob_import_cfg import_cfg;
|
||||
@@ -156,10 +159,11 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
db_mgr.Load_mgr().Clear();
|
||||
}
|
||||
public Xodb_mgr_sql Db_mgr_create_as_sql() {Xodb_mgr_sql rv = new Xodb_mgr_sql(this); db_mgr = rv; return rv;}
|
||||
public void Init_by_wiki__force() {init_needed = true; Init_by_wiki();}
|
||||
public void Init_by_wiki() {Init_assert();}
|
||||
public Xowe_wiki Init_assert() {if (init_needed) Init_wiki(app.Usere()); return this;}
|
||||
public void Init_db_mgr() {
|
||||
Io_url core_db_url = gplx.xowa.wikis.Xow_fsys_mgr.Find_core_fil(this);
|
||||
Io_url core_db_url = gplx.xowa.wikis.data.Xow_db_file__core_.Find_core_fil(this);
|
||||
if (core_db_url == null) {
|
||||
tdb_fsys_mgr.Scan_dirs();
|
||||
}
|
||||
@@ -173,7 +177,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
private void Init_wiki(Xoue_user user) { // NOTE: (a) one-time initialization for all wikis; (b) not called by tests
|
||||
if (init_in_process) {
|
||||
app.Usr_dlg().Log_many("", "", "wiki.init: circular call canceled: ~{0}", domain_str);
|
||||
return; // NOTE: may be called multiple times due to "if (app.Stage() == Xoa_stage_.Tid_launch) init_needed = false;"; TODO: call this only once; DATE:2014-06-07
|
||||
return; // NOTE: may be called multiple times due to "if (app.Stage() == Xoa_stage_.Tid_launch) init_needed = false;"; TODO_OLD: call this only once; DATE:2014-06-07
|
||||
}
|
||||
init_in_process = true;
|
||||
if (app.Stage() == Xoa_stage_.Tid_launch) init_needed = false; // NOTE: only mark inited if app fully launched; otherwise statements in xowa.gfs can fire and prematurely set home to inited; DATE:2013-03-24
|
||||
@@ -190,6 +194,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
if (lang.Init_by_load()) {
|
||||
if (domain_tid == Xow_domain_tid_.Int__wikipedia) // NOTE: if type is wikipedia, add "Wikipedia" as an alias; PAGE:en.w:pt.wikipedia.org/wiki/Página principal which redirects to Wikipedia:Página principal
|
||||
ns_mgr.Aliases_add(Xow_ns_.Tid__project, Xow_ns_.Alias__wikipedia);
|
||||
special_mgr.Evt_lang_changed(lang);
|
||||
}
|
||||
app.Gfs_mgr().Run_url_for(this, app.Fsys_mgr().Cfg_wiki_core_dir().GenSubFil(domain_str + ".gfs")); // NOTE: must be run after lang.Init_by_load b/c lang will reload ns_mgr; DATE:2015-04-17run cfg for wiki by user ; EX: /xowa/user/anonymous/wiki/en.wikipedia.org/cfg/user_wiki.gfs
|
||||
cfg_parser.Xtns().Itm_pages().Init(ns_mgr); // init ns_mgr for Page / Index ns just before rebuild; usually set by #cfg file
|
||||
@@ -220,6 +225,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
rls.Rls();
|
||||
}
|
||||
}
|
||||
public void Init_needed_y_() {this.init_needed = true;}
|
||||
private void Copy_cfg(Xowe_wiki wiki) {html_mgr.Copy_cfg(wiki.Html_mgr());}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_files)) return file_mgr;
|
||||
@@ -249,7 +255,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
else if (ctx.Match(k, Invk_xtns)) return xtn_mgr;
|
||||
else if (ctx.Match(k, Invk_hdump_enabled_)) this.html_mgr__hdump_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, gplx.xowa.apps.apis.xowa.wikis.langs.Xoap_lang_variants.Evt_current_changed)) lang.Vnt_mgr().Cur_itm_(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String
|
||||
|
||||
@@ -23,6 +23,18 @@ public class Xowe_wiki_ {
|
||||
Xoapi_import import_api = wiki.Appe().Api_root().Bldr().Wiki().Import();
|
||||
Xowd_core_db_props db_mgr_props = import_api.New_props(wiki.Domain_str(), src_fil_len);
|
||||
Xob_info_session info_session = Xob_info_session.new_(import_api.User_name(), wiki.Domain_str(), src_fil_name);
|
||||
wiki.Db_mgr_as_sql().Core_data_mgr().Init_by_make(db_mgr_props, info_session); // make core_db
|
||||
wiki.Data__core_mgr().Init_by_make(db_mgr_props, info_session); // make core_db
|
||||
}
|
||||
public static void Rls_mem_if_needed(Xowe_wiki wiki) {
|
||||
Xoae_app app = wiki.Appe();
|
||||
if (gplx.core.envs.Env_.System_memory_free() < app.Sys_cfg().Free_mem_when()) // check if low in memory
|
||||
Xowe_wiki_.Rls_mem(wiki, false); // clear caches (which will clear bry_bfr_mkr)
|
||||
else // not low in memory
|
||||
app.Utl__bfr_mkr().Clear(); // clear bry_bfr_mkr only; NOTE: call before page parse, not when page is first added, else threading errors; DATE:2014-05-30
|
||||
}
|
||||
public static void Rls_mem(Xowe_wiki wiki, boolean clear_ctx) {
|
||||
wiki.Appe().Free_mem(clear_ctx);
|
||||
wiki.Cache_mgr().Free_mem_all();
|
||||
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
|
||||
public interface Xoax_addon_itm {
|
||||
byte[] Addon__key();
|
||||
String Addon__key();
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public interface Xoax_addon_itm__bldr {
|
||||
Xob_cmd[] Cmds_ary();
|
||||
Xob_cmd[] Bldr_cmds();
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
|
||||
public interface Xoax_addon_itm__json {
|
||||
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] Json__cmds();
|
||||
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] Json_cmds();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public interface Xoax_addon_itm__special {
|
||||
gplx.xowa.specials.Xows_page[] Pages_ary();
|
||||
gplx.xowa.specials.Xow_special_page[] Special_pages();
|
||||
}
|
||||
|
||||
@@ -17,17 +17,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
|
||||
public class Xoax_addon_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
// THREAD: must synchronized else two search tabs will fail on startup
|
||||
public Xoax_addon_itm Itms__get_or_null(byte[] key) {synchronized (hash) {return (Xoax_addon_itm)hash.Get_by(key);}}
|
||||
public Xoax_addon_itm Itms__get_or_null(String key) {synchronized (hash) {return (Xoax_addon_itm)hash.Get_by(key);}}
|
||||
public void Itms__add_many(Xoax_addon_itm... ary) {
|
||||
for (Xoax_addon_itm itm : ary)
|
||||
Itms__add(itm);
|
||||
}
|
||||
public void Itms__add(Xoax_addon_itm itm) {
|
||||
synchronized (hash) {
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "addons.init: ~{0}", itm.Addon__key());
|
||||
hash.Add(itm.Addon__key(), itm);
|
||||
String addon_key = itm.Addon__key();
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "addons.init: ~{0}", addon_key);
|
||||
hash.Add(addon_key, itm);
|
||||
}
|
||||
}
|
||||
public Xoax_addon_mgr Add_dflts_by_app(Xoa_app app) {
|
||||
@@ -36,16 +37,20 @@ public class Xoax_addon_mgr {
|
||||
);
|
||||
app.Addon_mgr().Itms__add_many
|
||||
// bldrs
|
||||
( new gplx.xowa.addons.builds.files .Xoax_builds_files_addon()
|
||||
, new gplx.xowa.addons.builds.pagelinks .Xoax_builds_pagelinks_addon()
|
||||
, new gplx.xowa.addons.builds.utils_rankings .Xoax_builds_utils_rankings_addon()
|
||||
, new gplx.xowa.addons.apps.searchs .Xoax_builds_search_addon()
|
||||
, new gplx.xowa.addons.updates.files .Xoax_updates_files_addon()
|
||||
, new gplx.xowa.addons.builds.htmls .Html__dump_to_fsys__addon()
|
||||
( new gplx.xowa.addons.bldrs.files .Xoax_builds_files_addon()
|
||||
, new gplx.xowa.addons.bldrs.pagelinks .Xoax_builds_pagelinks_addon()
|
||||
, new gplx.xowa.addons.bldrs.utils_rankings .Xoax_builds_utils_rankings_addon()
|
||||
, new gplx.xowa.addons.wikis.searchs .Xoax_builds_search_addon()
|
||||
, new gplx.xowa.addons.bldrs.updates.files .Xoax_updates_files_addon()
|
||||
, new gplx.xowa.addons.bldrs.htmls .Html__dump_to_fsys__addon()
|
||||
, new gplx.xowa.addons.bldrs.exports .Export_addon()
|
||||
, new gplx.xowa.addons.wikis.pages.randoms .Rndm_addon()
|
||||
|
||||
// specials
|
||||
, new gplx.xowa.addons.apps.file_browsers .Fbrow_addon()
|
||||
, new gplx.xowa.addons.builds.centrals .Xoax_downloads_addon()
|
||||
, new gplx.xowa.addons.wikis.registrys .Wiki_registry_addon()
|
||||
, new gplx.xowa.addons.wikis.imports .Xow_import_addon()
|
||||
, new gplx.xowa.addons.bldrs.centrals .Xobc_task_addon()
|
||||
, new gplx.xowa.addons.apps.helps.logs .Xolog_addon()
|
||||
|
||||
// jsons
|
||||
, new gplx.xowa.addons.servers.https .Xoax_long_poll_addon()
|
||||
@@ -56,23 +61,28 @@ public class Xoax_addon_mgr {
|
||||
int len = hash.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoax_addon_itm addon = (Xoax_addon_itm)hash.Get_at(i);
|
||||
// add bldr cmds
|
||||
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__bldr.class)) {
|
||||
Xoax_addon_itm__bldr addon_bldr = (Xoax_addon_itm__bldr)addon;
|
||||
app.Bldr().Cmd_regy().Add_many(addon_bldr.Cmds_ary());
|
||||
app.Bldr().Cmd_regy().Add_many(addon_bldr.Bldr_cmds());
|
||||
}
|
||||
|
||||
// add special pages
|
||||
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__special.class)) {
|
||||
Xoax_addon_itm__special addon_sp = (Xoax_addon_itm__special)addon;
|
||||
app.Special_regy().Add_many(addon_sp.Pages_ary());
|
||||
app.Special_regy().Add_many(addon_sp.Special_pages());
|
||||
}
|
||||
|
||||
// add json mgrs
|
||||
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__json.class)) {
|
||||
Xoax_addon_itm__json addon_json = (Xoax_addon_itm__json)addon;
|
||||
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] json_cmds = addon_json.Json__cmds();
|
||||
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] json_cmds = addon_json.Json_cmds();
|
||||
for (gplx.xowa.htmls.bridges.Bridge_cmd_itm json_cmd : json_cmds) {
|
||||
json_cmd.Init_by_app(app);
|
||||
app.Html__bridge_mgr().Cmd_mgr().Add(json_cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
app.Gui__cbk_mgr().Reg(gplx.xowa.addons.servers.https.Xog_cbk_wkr__http.Instance);
|
||||
// app.Gui__cbk_mgr().Reg(gplx.xowa.addons.servers.https.Xog_cbk_wkr__http.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Fbrow_special_page implements Xows_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xopage_html_data html_data = Write_html(wiki.App(), url.Qargs_ary());
|
||||
html_data.Apply(page);
|
||||
}
|
||||
private static Xopage_html_data Write_html(Xoa_app app, Gfo_qarg_itm[] args_ary) {
|
||||
// scan owner_dir
|
||||
Xoa_url_arg_mgr arg_mgr = new Xoa_url_arg_mgr(null).Init(args_ary);
|
||||
String owner_str = arg_mgr.Read_str_or_null("path"); if (owner_str == null) return Xopage_html_data.err_("url has unknown path");
|
||||
IoItmDir owner_dir = Io_mgr.Instance.QueryDir_args(Io_url_.new_any_(owner_str)).DirInclude_(true).ExecAsDir();
|
||||
Fbrow_file_itm owner_itm = Fbrow_file_itm.New(owner_dir);
|
||||
|
||||
// write body
|
||||
Io_url addon_dir = app.Fsys_mgr().Bin_addon_dir().GenSubDir_nest("import", "file_browser");
|
||||
byte[] template_src = Io_mgr.Instance.LoadFilBry(addon_dir.GenSubFil_nest("bin", "file_browser.mustache.html"));
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
byte[] body = gplx.langs.mustaches.Mustache_wtr_.Write_to_bry(tmp_bfr, template_src, owner_itm);
|
||||
|
||||
// write head
|
||||
Xopage_html_data rv = new Xopage_html_data(Display_ttl, body);
|
||||
rv.Head_tags().Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "file_browser.css")));
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static final String SPECIAL_KEY = "XowaFileBrowser";
|
||||
public static final byte[] Display_ttl = Bry_.new_a7("Import XOWA Wikis");
|
||||
public Xows_special_meta Special__meta() {return new Xows_special_meta(Xows_special_meta_.Src__xowa, SPECIAL_KEY);}
|
||||
public static final Xows_page Prototype = new Fbrow_special_page();
|
||||
public Xows_page Special__clone() {return this;}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Wikis_list_page implements Xows_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xoa_url_arg_mgr arg_mgr = new Xoa_url_arg_mgr(null).Init(url.Qargs_ary());
|
||||
Wikis_list_wtr wtr = new Wikis_list_wtr();
|
||||
byte[] cmd = arg_mgr.Read_bry_or_null("cmd");
|
||||
if (cmd == null) {
|
||||
Xopage_html_data html_data = wtr.Write(wiki.App(), url.Qargs_ary(), GfoInvkAble_.Null);
|
||||
html_data.Apply(page);
|
||||
}
|
||||
else {
|
||||
if (Bry_.Eq(cmd, Bry_.new_a7("add"))) {
|
||||
byte[] file = arg_mgr.Read_bry_or_null("file");
|
||||
if (file != null) {
|
||||
if (wiki.App().Tid_is_edit()) {
|
||||
wiki.App().User().User_db_mgr().Init_site_mgr();
|
||||
}
|
||||
wiki.App().Wiki_mgri().Import_by_url(Io_url_.new_fil_(String_.new_u8(file)));
|
||||
Xopage_html_data html_data = wtr.Write(wiki.App(), url.Qargs_ary(), GfoInvkAble_.Null);
|
||||
html_data.Apply(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final String SPECIAL_KEY = "XowaWikis";
|
||||
public static final byte[] Display_ttl = Bry_.new_a7("XOWA Wikis");
|
||||
public Xows_special_meta Special__meta() {return new Xows_special_meta(Xows_special_meta_.Src__xowa, SPECIAL_KEY);}
|
||||
public static final Xows_page Prototype = new Wikis_list_page();
|
||||
public Xows_page Special__clone() {return this;}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.wikis.pages.*;
|
||||
class Wikis_list_wtr {
|
||||
public Xopage_html_data Write(Xoa_app app, Gfo_qarg_itm[] args, GfoInvkAble select_invkable) {
|
||||
// scan wikis
|
||||
List_adp list = List_adp_.new_();
|
||||
app.User().User_db_mgr().Init_site_mgr();
|
||||
Xoud_site_row[] site_ary = app.User().User_db_mgr().Site_mgr().Get_all();
|
||||
int len = site_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoud_site_row site_itm = site_ary[i];
|
||||
if (String_.Eq(site_itm.Domain(), gplx.xowa.wikis.domains.Xow_domain_itm_.Str__home)) continue;
|
||||
list.Add(new Wikis_list_itm(Bry_.new_u8(site_itm.Domain()), Bry_.new_a7("2016-03-05")));
|
||||
}
|
||||
Wikis_list_mgr mgr = new Wikis_list_mgr(Get_root_url(), (Wikis_list_itm[])list.To_ary_and_clear(Wikis_list_itm.class));
|
||||
|
||||
// write body
|
||||
Io_url addon_dir = app.Fsys_mgr().Bin_addon_dir().GenSubDir_nest("app", "wiki_list");
|
||||
byte[] template_src = Io_mgr.Instance.LoadFilBry(addon_dir.GenSubFil_nest("bin", "wiki_list.mustache.html"));
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
byte[] body = gplx.langs.mustaches.Mustache_wtr_.Write_to_bry(tmp_bfr, template_src, mgr);
|
||||
|
||||
// write to html
|
||||
Xopage_html_data rv = new Xopage_html_data(Wikis_list_page.Display_ttl, body);
|
||||
rv.Head_tags().Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "wiki_list.css")));
|
||||
return rv;
|
||||
}
|
||||
private static byte[] Get_root_url() {
|
||||
byte tid = gplx.core.envs.Op_sys.Cur().Tid();
|
||||
byte[] rv = Bry_.new_a7("/");
|
||||
switch (tid) {
|
||||
case gplx.core.envs.Op_sys.Tid_wnt : rv = Bry_.new_a7("C:\\"); break;
|
||||
}
|
||||
rv = gplx.langs.htmls.encoders.Gfo_url_encoder_.Href.Encode(rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
public class Xoa_url_arg_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private final Xoa_url_enum_mgr enm_mgr;
|
||||
public Xoa_url_arg_mgr(Xoa_url_enum_mgr enm_mgr) {this.enm_mgr = enm_mgr;}
|
||||
public Xoa_url_arg_mgr Init(Gfo_qarg_itm[] args) {
|
||||
hash.Clear();
|
||||
int len = args.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_qarg_itm arg = args[i];
|
||||
hash.Add_bry_obj(arg.Key_bry(), arg);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public int Read_enm_or_neg1(byte[] key) {
|
||||
Xoa_url_enum_itm enm = enm_mgr.Get(key); if (enm == null) return -1;
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key); if (arg == null) return -1;
|
||||
return enm.Get_as_int_or(arg.Val_bry(), -1);
|
||||
}
|
||||
public byte[] Read_bry_or_empty(byte[] key) {return Read_bry_or(key, Bry_.Empty);}
|
||||
public byte[] Read_bry_or_null(String key) {return Read_bry_or_null(Bry_.new_u8(key));}
|
||||
public byte[] Read_bry_or_null(byte[] key) {return Read_bry_or(key, null);}
|
||||
public byte[] Read_bry_or(byte[] key, byte[] or) {
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key);
|
||||
return arg == null ? or : arg.Val_bry();
|
||||
}
|
||||
public String Read_str_or_null(String key) {return Read_str_or_null(Bry_.new_u8(key));}
|
||||
public String Read_str_or_null(byte[] key) {
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key);
|
||||
return arg == null ? null : String_.new_u8(arg.Val_bry());
|
||||
}
|
||||
}
|
||||
@@ -15,20 +15,14 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.builds.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
package gplx.xowa.addons.apps.helps.logs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.helps.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.htmls.bridges.*;
|
||||
public class Xoax_downloads_addon implements Xoax_addon_itm, Xoax_addon_itm__special, Xoax_addon_itm__json {
|
||||
public Xows_page[] Pages_ary() {
|
||||
return new Xows_page[]
|
||||
{ Xoa_dashboard_special.Prototype
|
||||
};
|
||||
}
|
||||
public Bridge_cmd_itm[] Json__cmds() {
|
||||
return new Bridge_cmd_itm[]
|
||||
{ gplx.xowa.addons.builds.centrals.Xoa_dashboard_bridge.Prototype
|
||||
public class Xolog_addon implements Xoax_addon_itm, Xoax_addon_itm__special {
|
||||
public Xow_special_page[] Special_pages() {
|
||||
return new Xow_special_page[]
|
||||
{ Xolog_special.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
public static final byte[] ADDON_KEY = Bry_.new_a7("xowa.imports.downloads");
|
||||
public byte[] Addon__key() {return ADDON_KEY;}
|
||||
public String Addon__key() {return "xowa.apps.helps.logs";}
|
||||
}
|
||||
87
400_xowa/src/gplx/xowa/addons/apps/helps/logs/Xolog_doc.java
Normal file
87
400_xowa/src/gplx/xowa/addons/apps/helps/logs/Xolog_doc.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.helps.logs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.helps.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
class Xolog_doc implements Mustache_doc_itm {
|
||||
public Xolog_doc(String log_file, String log_name, byte[] log_data, Xolog_doc_file[] log_files) {
|
||||
this.log_file = log_file; this.log_name = log_name;
|
||||
this.log_data = log_data; this.log_files = log_files;
|
||||
}
|
||||
public String Log_file() {return log_file;} private final String log_file; // EX: 20160613_165025
|
||||
public String Log_name() {return log_name;} private final String log_name; // EX: 2016-06-13 16:50:25
|
||||
public byte[] Log_data() {return log_data;} private final byte[] log_data;
|
||||
public Xolog_doc_file[] Log_files() {return log_files;} private final Xolog_doc_file[] log_files;
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "log_name")) bfr.Add_str_u8(log_name);
|
||||
else if (String_.Eq(key, "log_file")) bfr.Add_str_u8(log_file);
|
||||
else if (String_.Eq(key, "log_data")) bfr.Add_bry(log_data);
|
||||
return false;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "log_files")) return log_files;
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
class Xolog_doc_ {
|
||||
public static Xolog_doc New(Io_url log_dir, String log_file) {
|
||||
// read fsys
|
||||
Io_url[] fils = Io_mgr.Instance.QueryDir_fils(log_dir);
|
||||
int len = fils.length;
|
||||
|
||||
// get log_files
|
||||
Ordered_hash hash = Ordered_hash_.New();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Io_url fil = fils[i];
|
||||
String file = fil.NameOnly();
|
||||
String name = Xolog_file_utl.To_name(file);
|
||||
hash.Add(file, new Xolog_doc_file(file, name));
|
||||
}
|
||||
|
||||
// determine cur_file
|
||||
String cur_file = log_file;
|
||||
if ( cur_file == null // cur_file is null; happens for plain "Special:XowaLog"
|
||||
|| !hash.Has(cur_file) // cur_file deleted (accessed from history)
|
||||
) {
|
||||
cur_file = hash.Len() == 0
|
||||
? null
|
||||
: ((Xolog_doc_file)hash.Get_at(len - 1)).File();
|
||||
}
|
||||
if (cur_file != null)
|
||||
hash.Del(cur_file); // don't bother showing current item in list
|
||||
Xolog_doc_file[] log_files = (Xolog_doc_file[])hash.To_ary_and_clear(Xolog_doc_file.class);
|
||||
|
||||
// get body
|
||||
byte[] cur_body = Io_mgr.Instance.LoadFilBry(Xolog_file_utl.To_url_by_file(log_dir, cur_file));
|
||||
String cur_name = cur_file == null ? null : Xolog_file_utl.To_name(cur_file);
|
||||
return new Xolog_doc(cur_file, cur_name, cur_body, log_files);
|
||||
}
|
||||
}
|
||||
class Xolog_doc_file implements Mustache_doc_itm {
|
||||
public Xolog_doc_file(String file, String name) {
|
||||
this.file = file; this.name = name;
|
||||
}
|
||||
public String File() {return file;} private final String file;
|
||||
public String Name() {return name;} private final String name;
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "file")) bfr.Add_str_u8(file);
|
||||
else if (String_.Eq(key, "name")) bfr.Add_str_u8(name);
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {return Mustache_doc_itm_.Ary__empty;}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.helps.logs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.helps.*;
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
class Xolog_html extends Xow_special_wtr__base {
|
||||
private final Xolog_doc log_doc;
|
||||
public Xolog_html(Xolog_doc log_doc) {
|
||||
this.log_doc = log_doc;
|
||||
}
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "app", "help", "log");}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xolog.mustache.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
return log_doc;
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_alertify_.Add_tags (head_tags, app.Fsys_mgr().Http_root());
|
||||
page_data.Head_tags().Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xolog.css")));
|
||||
page_data.Head_tags().Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("bin", "xolog.js")));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.helps.logs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.helps.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.core.net.emails.*;
|
||||
public class Xolog_special implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
// init
|
||||
Gfo_qarg_mgr url_args = new Gfo_qarg_mgr().Init(url.Qargs_ary());
|
||||
Xoa_app app = wiki.App();
|
||||
Gfo_log_.Instance.Flush(); // flush log to write all memory itms to disk
|
||||
|
||||
// get file
|
||||
String file = url_args.Read_str_or_null("file");
|
||||
Io_url log_dir = app.Fsys_mgr().Root_dir().GenSubDir_nest("user", "anonymous", "app", "tmp", "xolog");
|
||||
Xolog_doc log_doc = Xolog_doc_.New(log_dir, file);
|
||||
if (log_doc.Log_file() == null) return; // occurs when all logs are deleted
|
||||
|
||||
// get cmd
|
||||
int cmd_tid = url_args.Read_enm_as_int_or(Enm_cmd.Itm, Enm_cmd.Tid__view);
|
||||
boolean redirect = true, redirect_to_same_file = false;;
|
||||
switch (cmd_tid) {
|
||||
case Enm_cmd.Tid__view: redirect = false; break;
|
||||
case Enm_cmd.Tid__email: redirect_to_same_file = true; Gfo_email_mgr_.Instance.Send("gnosygnu+xowa_xologs@gmail.com", "XOWA Log", String_.new_u8(log_doc.Log_data())); break;
|
||||
case Enm_cmd.Tid__delete_one: Io_mgr.Instance.DeleteFil(Xolog_file_utl.To_url_by_file(log_dir, log_doc.Log_file())); break;
|
||||
case Enm_cmd.Tid__delete_all: Io_mgr.Instance.DeleteDirDeep(log_dir); break;
|
||||
}
|
||||
|
||||
if (redirect) {
|
||||
String redirect_ttl = special__meta.Ttl_str() + "?cmd=view";
|
||||
if (redirect_to_same_file && file != null)
|
||||
redirect_ttl += "&file=" + file;
|
||||
page.Redirect_to_ttl_(Bry_.new_u8(redirect_ttl));
|
||||
return;
|
||||
}
|
||||
else
|
||||
new Xolog_html(log_doc).Bld_page_by_mustache(app, page, this);
|
||||
}
|
||||
static class Enm_cmd {//#*nested
|
||||
public static final int Tid__view = 0, Tid__email = 1, Tid__delete_one = 2, Tid__delete_all = 3;
|
||||
public static final Gfo_qarg_enum_itm Itm = new Gfo_qarg_enum_itm("cmd")
|
||||
.Add("view" , Tid__view)
|
||||
.Add("email" , Tid__email)
|
||||
.Add("delete_one" , Tid__delete_one)
|
||||
.Add("delete_all" , Tid__delete_all)
|
||||
;
|
||||
}
|
||||
Xolog_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
public Xow_special_page Special__clone() {return this;}
|
||||
public static final Xow_special_page Prototype = new Xolog_special(Xow_special_meta.New_xo("XowaLog", "Logs"));
|
||||
}
|
||||
class Xolog_file_utl {// yyyyMMdd_HHmmss.log
|
||||
private static final String Gui__date_fmt = "yyyy-MM-dd HH:mm:ss";
|
||||
public static String To_name(Io_url url) {return To_name(url.NameOnly());}
|
||||
public static String To_name(String file) {
|
||||
DateAdp date = DateAdp_.parse_fmt(file, Gfo_log_.File__fmt);
|
||||
return date.XtoStr_fmt(Gui__date_fmt);
|
||||
}
|
||||
public static Io_url To_url_by_file(Io_url dir, String file) {
|
||||
return dir.GenSubFil(file + Gfo_log_.File__ext);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
//namespace gplx.xowa.addons.apps.searchs.searchers.cbks {
|
||||
// class Srch_suggest_cmd__page_tbl {
|
||||
// private boolean Search_by_all_pages_v2() {
|
||||
// rslts_2.Clear();
|
||||
// Xoa_ttl search_ttl = Xoa_ttl.parse(wiki, search_bry); if (search_ttl == null) return false;
|
||||
// byte[] search_ttl_bry = search_ttl.Page_db();
|
||||
// wiki.Db_mgr().Load_mgr().Load_ttls_for_search_suggest(this, rslts_2, search_ttl.Ns(), search_ttl_bry, max_results, all_pages_min, all_pages_extend, true, false);
|
||||
// return true;
|
||||
// }
|
||||
// private boolean Search_by_all_pages_v1() {
|
||||
// rslts_2.Clear();
|
||||
// Xowd_page_itm rslt_nxt = new Xowd_page_itm();
|
||||
// Xowd_page_itm rslt_prv = new Xowd_page_itm();
|
||||
// Xoa_ttl search_ttl = Xoa_ttl.parse(wiki, search_bry); if (search_ttl == null) return false;
|
||||
// byte[] search_ttl_bry = search_ttl.Page_db();
|
||||
// List_adp page_list = List_adp_.new_();
|
||||
// wiki.Db_mgr().Load_mgr().Load_ttls_for_all_pages(this, page_list, rslt_nxt, rslt_prv, Int_obj_ref.zero_(), wiki.Ns_mgr().Ns_main(), search_ttl_bry, max_results, all_pages_min, all_pages_extend, true, false);
|
||||
// Xowd_page_itm[] page_ary = (Xowd_page_itm[])page_list.To_ary_and_clear(typeof(Xowd_page_itm));
|
||||
// int idx = 0, page_ary_len = page_ary.length;
|
||||
// for (int i = 0; i < page_ary_len; i++) {
|
||||
// Xowd_page_itm page = page_ary[i];
|
||||
// if (page != null) {
|
||||
// if (!Bry_.Has_at_bgn(page.Ttl_page_db(), search_ttl_bry)) continue; // look-ahead may return other titles that don't begin with search; ignore
|
||||
// if (page.Text_len() > all_pages_min) {
|
||||
// rslts_2.Add(page);
|
||||
// idx++;
|
||||
// }
|
||||
// }
|
||||
// if (idx == max_results) break;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.searchs.searchers.rslts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.searchs.*; import gplx.xowa.addons.apps.searchs.searchers.*;
|
||||
import gplx.core.primitives.*;
|
||||
class Hash_adp__int {
|
||||
private final Hash_adp hash = Hash_adp_.new_();
|
||||
private final Int_obj_ref tmp_key = Int_obj_ref.neg1_();
|
||||
public void Clear() {hash.Clear();}
|
||||
public Object Get_by(int key) {return hash.Get_by(tmp_key.Val_(key));}
|
||||
public void Add(int key, Object obj) {hash.Add(Int_obj_ref.new_(key), obj);}
|
||||
public void Add_if_dupe_use_1st(int key, Object obj) {hash.Add_if_dupe_use_1st(Int_obj_ref.new_(key), obj);}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.htmls.bridges.*;
|
||||
public class Xobc_task_addon implements Xoax_addon_itm, Xoax_addon_itm__special, Xoax_addon_itm__json {
|
||||
public Xow_special_page[] Special_pages() {
|
||||
return new Xow_special_page[]
|
||||
{ Xobc_task_special.Prototype
|
||||
};
|
||||
}
|
||||
public Bridge_cmd_itm[] Json_cmds() {
|
||||
return new Bridge_cmd_itm[]
|
||||
{ gplx.xowa.addons.bldrs.centrals.Xobc_task_bridge.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
public String Addon__key() {return "xowa.imports.downloads";}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*;
|
||||
public class Xobc_task_bridge implements gplx.xowa.htmls.bridges.Bridge_cmd_itm {
|
||||
public void Init_by_app(Xoa_app app) {}
|
||||
public String Exec(Json_nde data) {
|
||||
Xobc_task_mgr task_mgr = Xobc_task_special.Task_mgr;
|
||||
byte proc_id = proc_hash.Get_as_byte_or(data.Get_as_bry_or(Msg__proc, null), Byte_ascii.Max_7_bit);
|
||||
Json_nde args = data.Get_kv(Msg__args).Val_as_nde();
|
||||
switch (proc_id) {
|
||||
case Proc__reload: task_mgr.Reload(); break;
|
||||
case Proc__add_work: task_mgr.Todo_mgr().Add_work(args.Get_as_int("task_id")); break;
|
||||
case Proc__del_work: task_mgr.Work_mgr().Del_work(args.Get_as_int("task_id")); break;
|
||||
case Proc__del_done: task_mgr.Done_mgr().Del_done(args.Get_as_int("task_id")); break;
|
||||
case Proc__run_next: task_mgr.Work_mgr().Run_next(); break;
|
||||
case Proc__stop_cur: task_mgr.Work_mgr().Stop_cur(); break;
|
||||
case Proc__redo_cur: task_mgr.Work_mgr().Redo_cur(); break;
|
||||
case Proc__download_db: gplx.xowa.addons.bldrs.centrals.dbs.Xobc_data_db_upgrader.Check_for_updates(task_mgr); break;
|
||||
default: throw Err_.new_unhandled_default(proc_id);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
private static final byte[] Msg__proc = Bry_.new_a7("proc"), Msg__args = Bry_.new_a7("args");
|
||||
private static final byte Proc__reload = 0, Proc__add_work = 1, Proc__del_work = 2, Proc__del_done = 3, Proc__run_next = 4, Proc__stop_cur = 5, Proc__redo_cur = 6, Proc__download_db = 7;
|
||||
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("reload" , Proc__reload)
|
||||
.Add_str_byte("add_work" , Proc__add_work)
|
||||
.Add_str_byte("del_work" , Proc__del_work)
|
||||
.Add_str_byte("del_done" , Proc__del_done)
|
||||
.Add_str_byte("run_next" , Proc__run_next)
|
||||
.Add_str_byte("stop_cur" , Proc__stop_cur)
|
||||
.Add_str_byte("redo_cur" , Proc__redo_cur)
|
||||
.Add_str_byte("download_db" , Proc__download_db)
|
||||
;
|
||||
|
||||
public byte[] Key() {return BRIDGE_KEY;} public static final byte[] BRIDGE_KEY = Bry_.new_a7("builder_central.exec");
|
||||
public static final Xobc_task_bridge Prototype = new Xobc_task_bridge(); Xobc_task_bridge() {}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
class Xobc_task_doc implements Mustache_doc_itm {
|
||||
private final boolean app_is_drd;
|
||||
private final String link_help;
|
||||
public Xobc_task_doc(boolean app_is_drd, String link_help) {
|
||||
this.app_is_drd = app_is_drd; this.link_help = link_help;
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "link_help")) bfr.Add_str_u8(link_help);
|
||||
return false;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "app_is_drd")) return Mustache_doc_itm_.Ary__bool(app_is_drd);
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
class Xobc_task_html extends Xow_special_wtr__base {
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "bldr", "central");}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xobc.main.mustache.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
return new Xobc_task_doc(gplx.core.envs.Op_sys.Cur().Tid_is_drd(), "/site/home/wiki/App/Import/Download_Central");
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
Xopg_alertify_.Add_tags (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__mustache (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__jquery (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__notifyjs (head_tags, app.Fsys_mgr().Http_root());
|
||||
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("js", "xo.log.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xobc.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_htm_frag(addon_dir.GenSubFil_nest("bin", "xobc.row.mustache.html"), "xobc.row"));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.log.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.app.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.app." + (gplx.core.envs.Op_sys.Cur().Tid_is_drd() ? "drd" : "swt") + ".js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.elem.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.tmpl.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.notify.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.server.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.util.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.js")));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.core.brys.evals.*; import gplx.core.gfobjs.*; import gplx.core.progs.rates.*; import gplx.core.threads.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.tasks.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.xowa.guis.cbks.*;
|
||||
public class Xobc_task_mgr implements Xog_json_wkr {
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(Xobc_task_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Xobc_task_mgr(Xoa_app app, Io_url data_db_url) {
|
||||
this.app = app;
|
||||
this.cbk_mgr = app.Gui__cbk_mgr();
|
||||
this.user_db = new Xobc_user_db(app.User().User_db_mgr().Conn());
|
||||
this.data_db = new Xobc_data_db(data_db_url);
|
||||
this.work_mgr = new Xobc_task_regy__work(this, app);
|
||||
this.todo_mgr = new Xobc_task_regy__todo(this);
|
||||
this.done_mgr = new Xobc_task_regy__done(this);
|
||||
this.step_mgr = new Xobc_step_factory(this, data_db, app.Fsys_mgr().Wiki_dir());
|
||||
this.ary = new Xobc_task_regy__base[] {work_mgr, todo_mgr, done_mgr};
|
||||
this.rate_mgr = Xobc_cmd__base.New_rate_mgr();
|
||||
}
|
||||
public Xoa_app App() {return app;} private final Xoa_app app;
|
||||
public Xog_cbk_mgr Cbk_mgr() {return cbk_mgr;} private final Xog_cbk_mgr cbk_mgr;
|
||||
public Xobc_task_regy__work Work_mgr() {return work_mgr;} private final Xobc_task_regy__work work_mgr;
|
||||
public Xobc_task_regy__todo Todo_mgr() {return todo_mgr;} private final Xobc_task_regy__todo todo_mgr;
|
||||
public Xobc_task_regy__done Done_mgr() {return done_mgr;} private final Xobc_task_regy__done done_mgr;
|
||||
public Xobc_task_regy__base Get_at(int i) {return ary[i];} private final Xobc_task_regy__base[] ary;
|
||||
public Xobc_data_db Data_db() {return data_db;} private final Xobc_data_db data_db;
|
||||
public Xobc_user_db User_db() {return user_db;} private final Xobc_user_db user_db;
|
||||
public Gfo_rate_mgr Rate_mgr() {return rate_mgr;} private final Gfo_rate_mgr rate_mgr;
|
||||
public Xobc_step_factory Step_mgr() {return step_mgr;} private final Xobc_step_factory step_mgr;
|
||||
public void Send_json(String func, Gfobj_nde data) {cbk_mgr.Send_json(cbk_trg, func, data);}
|
||||
public Xobc_task_mgr Load_or_init() {
|
||||
Gfo_log_.Instance.Info("task_mgr.load_or_init.bgn");
|
||||
data_db.Tbl__task_regy().Select_all(todo_mgr);
|
||||
user_db.Work_task_tbl().Select_all(this, todo_mgr, work_mgr);
|
||||
user_db.Done_task_tbl().Select_all(todo_mgr, done_mgr);
|
||||
return this;
|
||||
}
|
||||
public void Reload() {
|
||||
Gfo_log_.Instance.Info("task_mgr.reload.bgn");
|
||||
Gfobj_nde root = Gfobj_nde.New();
|
||||
Gfobj_nde lists_nde = root.New_nde("lists");
|
||||
work_mgr.Save_to(lists_nde.New_ary("work"));
|
||||
todo_mgr.Save_to(lists_nde.New_ary("todo"));
|
||||
done_mgr.Save_to(lists_nde.New_ary("done"));
|
||||
cbk_mgr.Send_json(cbk_trg, "xo.bldr.core.reload__recv", root);
|
||||
}
|
||||
public void Transfer(Xobc_task_regy__base src, Xobc_task_regy__base trg, Xobc_task_itm task) {
|
||||
Gfo_log_.Instance.Info("task_mgr.transfer.bgn", "task_uid", task.Task_id(), "src", src.Name(), "trg", trg.Name());
|
||||
src.Del_by(task.Task_id());
|
||||
trg.Add(task);
|
||||
cbk_mgr.Send_json(cbk_trg, "xo.bldr.core.transfer__recv", Gfobj_nde.New().Add_str("src", src.Name()).Add_str("trg", trg.Name()).Add_nde("task", task.Save_to(Gfobj_nde.New())));
|
||||
}
|
||||
public static final int Lists_len = 3;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xobc_task_special implements Xow_special_page {
|
||||
public static Xobc_task_mgr Task_mgr;
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
// init task_mgr
|
||||
page.Html_data().Cbk_enabled_(true); // apply cbk_enabled early to capture logging statements
|
||||
Xoa_app app = wiki.App();
|
||||
if (Task_mgr == null) Task_mgr = New_task_mgr(app);
|
||||
Task_mgr.Load_or_init();
|
||||
|
||||
new Xobc_task_html().Bld_page_by_mustache(app, page, this);
|
||||
}
|
||||
private static Xobc_task_mgr New_task_mgr(Xoa_app app) {
|
||||
Io_url data_db_url = app.Fsys_mgr().Bin_addon_dir().GenSubFil_nest("bldr", "central", "bldr_central.data_db.xowa");
|
||||
app.User().User_db_mgr().Init_site_mgr();
|
||||
return new Xobc_task_mgr(app, data_db_url);
|
||||
}
|
||||
|
||||
Xobc_task_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
public Xow_special_page Special__clone() {return this;}
|
||||
public static final Xow_special_page Prototype = new Xobc_task_special(Xow_special_meta.New_xo("XowaDownloadCentral", "Download Central"));
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.gfobjs.*; import gplx.core.progs.*; import gplx.core.progs.rates.*;
|
||||
public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
|
||||
private final Xobc_task_mgr task_mgr;
|
||||
private final Gfo_rate_list rate_list; private final long notify_delay = 1000;
|
||||
private final double delta_threshold = .25d; // allow variance of up to 25% before updating rate
|
||||
private long time_prv;
|
||||
private double rate_cur;
|
||||
public Xobc_cmd__base(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_id) {
|
||||
this.task_mgr = task_mgr; this.task_id = task_id; this.step_id = step_id; this.cmd_id = cmd_id;
|
||||
this.cmd_uid = String_.Concat_with_str(":", Int_.To_str(task_id), Int_.To_str(step_id), Int_.To_str(cmd_id));
|
||||
this.rate_list = task_mgr == null ? null : task_mgr.Rate_mgr().Get_or_new(this.Cmd_type());
|
||||
}
|
||||
public long Prog_data_cur() {return data_cur;} private long data_cur; public void Prog_data_cur_(long v) {this.data_cur = v;}
|
||||
public long Prog_data_end() {return data_end;} private long data_end; public void Prog_data_end_(long v) {this.data_end = v;}
|
||||
public byte Prog_status() {return status;} private byte status = Gfo_prog_ui_.Status__init; public void Prog_status_(byte v) {status = v;}
|
||||
public boolean Canceled() {return status == Gfo_prog_ui_.Status__suspended;}
|
||||
public void Cancel() {status = Gfo_prog_ui_.Status__suspended;}
|
||||
|
||||
public int Task_id() {return task_id;} private final int task_id;
|
||||
public int Step_id() {return step_id;} private final int step_id;
|
||||
public int Cmd_id() {return cmd_id;} private final int cmd_id;
|
||||
public abstract String Cmd_type();
|
||||
public abstract String Cmd_name();
|
||||
@gplx.Virtual public boolean Cmd_suspendable() {return false;}
|
||||
public String Cmd_uid() {return cmd_uid;} private final String cmd_uid;
|
||||
@gplx.Virtual public String Cmd_fallback() {return this.Cmd_type();}
|
||||
@gplx.Virtual public void Cmd_clear() {// called when restarting failed task
|
||||
this.status = Gfo_prog_ui_.Status__init;
|
||||
this.cmd_exec_err = null;
|
||||
}
|
||||
|
||||
public void Cmd_exec(Xobc_cmd_ctx ctx) {
|
||||
// rate_list.Clear();
|
||||
// this.rate_cur = 0;
|
||||
this.time_prv = gplx.core.envs.Env_.TickCount();
|
||||
this.status = Gfo_prog_ui_.Status__working;
|
||||
this.Cmd_exec_hook(ctx);
|
||||
switch (status) {
|
||||
case Gfo_prog_ui_.Status__suspended: task_mgr.Work_mgr().On_suspended(this); break;
|
||||
case Gfo_prog_ui_.Status__fail: task_mgr.Work_mgr().On_fail(this, cmd_exec_err); break;
|
||||
case Gfo_prog_ui_.Status__working:
|
||||
this.Prog_notify_and_chk_if_suspended(data_end, data_end); // fire one more time for 100%; note that 100% may not fire due to timer logic below
|
||||
task_mgr.Work_mgr().On_done(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected abstract void Cmd_exec_hook(Xobc_cmd_ctx ctx);
|
||||
protected void Cmd_exec_err_(String v) {this.status = Gfo_prog_ui_.Status__fail; this.cmd_exec_err = v;} private String cmd_exec_err;
|
||||
@gplx.Virtual public void Cmd_cleanup() {}
|
||||
|
||||
public Gfobj_nde Save_to(Gfobj_nde nde) {
|
||||
nde.Add_int ("task_id" , task_id);
|
||||
nde.Add_int ("step_id" , step_id);
|
||||
nde.Add_int ("cmd_id" , cmd_id);
|
||||
nde.Add_str ("cmd_type" , this.Cmd_type());
|
||||
nde.Add_str ("cmd_name" , this.Cmd_name());
|
||||
nde.Add_bool("cmd_suspendable" , this.Cmd_suspendable());
|
||||
nde.Add_byte("prog_status" , this.Prog_status());
|
||||
nde.Add_long("prog_data_cur" , this.Prog_data_cur());
|
||||
nde.Add_long("prog_data_end" , this.Prog_data_end());
|
||||
nde.Add_long("prog_time_end" , 0);
|
||||
return nde;
|
||||
}
|
||||
public void Load_checkpoint() {
|
||||
long data_cur = this.Load_checkpoint_hook();
|
||||
this.Prog_data_cur_(data_cur);
|
||||
if (data_cur > 0)
|
||||
this.Prog_status_(Gfo_prog_ui_.Status__working); // set status to working, else js won't warn about accidental removal
|
||||
}
|
||||
@gplx.Virtual protected long Load_checkpoint_hook() {return 0;}
|
||||
|
||||
public boolean Prog_notify_and_chk_if_suspended(long new_data_cur, long new_data_end) {
|
||||
if (status == Gfo_prog_ui_.Status__suspended) return true; // task paused by ui; exit now;
|
||||
long time_cur = gplx.core.envs.Env_.TickCount();
|
||||
if (time_cur < time_prv + notify_delay) return false; // message came too soon. ignore it
|
||||
|
||||
// update rate
|
||||
double rate_now = (rate_list.Add(new_data_cur - data_cur, (time_cur - time_prv))) * 1000;
|
||||
double delta = Math_.Abs_double((rate_now - rate_cur) / rate_cur);
|
||||
if ( rate_cur == 0 // rate not set
|
||||
|| delta > delta_threshold) { // rate_now is at least 25% different than rate_prv
|
||||
if (delta > delta_threshold * 2) // rate_now is > 50% different
|
||||
rate_cur = rate_now; // update it now
|
||||
else {
|
||||
double rate_new = ((rate_now - rate_cur) * .05) + rate_cur; // calc new rate as 5% of difference
|
||||
Tfds.Dbg(delta, rate_now, rate_cur, rate_new);
|
||||
rate_cur = rate_new;
|
||||
}
|
||||
}
|
||||
|
||||
// update prog vals
|
||||
this.time_prv = time_cur;
|
||||
this.data_cur = new_data_cur;
|
||||
this.data_end = new_data_end;
|
||||
|
||||
task_mgr.Send_json("xo.bldr.work.prog__update__recv", Gfobj_nde.New()
|
||||
.Add_int ("task_id", task_id).Add_long("prog_data_cur", data_cur).Add_long("prog_data_end", data_end).Add_int("prog_rate", (int)rate_cur));
|
||||
return false;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__exec)) Cmd_exec((Xobc_cmd_ctx)m.ReadObj("v"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk__exec = "exec";
|
||||
public static final int Seqn__0 = 0;
|
||||
public static Gfo_rate_mgr New_rate_mgr() {
|
||||
Gfo_rate_mgr rv = new Gfo_rate_mgr(128);
|
||||
rv.Add_new(Xobc_cmd__verify_dir.CMD_TYPE);
|
||||
rv.Add_new(Xobc_cmd__verify_fil.CMD_TYPE);
|
||||
rv.Add_new(Xobc_cmd__download.CMD_TYPE);
|
||||
rv.Add_new(Xobc_cmd__unzip.CMD_TYPE);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.progs.*; import gplx.core.net.downloads.*;
|
||||
public class Xobc_cmd__download extends Xobc_cmd__base {
|
||||
private final String src_url; private final Io_url trg_url;
|
||||
private final long expd_size;
|
||||
private final Http_download_wkr wkr;
|
||||
public Xobc_cmd__download(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_id, String src_url, Io_url trg_url, long file_size_zip) {super(task_mgr, task_id, step_id, cmd_id);
|
||||
this.src_url = src_url; this.trg_url = trg_url; this.expd_size = file_size_zip;
|
||||
this.wkr = Http_download_wkr_.Proto.Make_new();
|
||||
this.Prog_data_end_(expd_size);
|
||||
}
|
||||
@Override public String Cmd_type() {return CMD_TYPE;} public static final String CMD_TYPE = "xowa.core.download";
|
||||
@Override public String Cmd_name() {return "download";}
|
||||
@Override public boolean Cmd_suspendable() {return true;}
|
||||
|
||||
@Override protected void Cmd_exec_hook(Xobc_cmd_ctx ctx) {
|
||||
if (wkr.Exec(this, src_url, trg_url, expd_size) == Gfo_prog_ui_.Status__fail)
|
||||
this.Cmd_exec_err_(wkr.Fail_msg());
|
||||
}
|
||||
@Override public void Cmd_cleanup() {
|
||||
wkr.Exec_cleanup();
|
||||
}
|
||||
@Override protected long Load_checkpoint_hook() {
|
||||
return wkr.Checkpoint__load_by_trg_fil(trg_url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
public class Xobc_cmd__move_fils extends Xobc_cmd__base {
|
||||
private final Io_url src_dir, trg_dir;
|
||||
private final List_adp trg_fils = List_adp_.New();
|
||||
public Xobc_cmd__move_fils(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_idx, Io_url src_dir, Io_url trg_dir) {super(task_mgr, task_id, step_id, cmd_idx);
|
||||
this.src_dir = src_dir; this.trg_dir = trg_dir;
|
||||
}
|
||||
@Override public String Cmd_type() {return CMD_TYPE;} public static final String CMD_TYPE = "xowa.core.move_fil";
|
||||
@Override public String Cmd_name() {return "move";}
|
||||
@Override protected void Cmd_exec_hook(Xobc_cmd_ctx ctx) {
|
||||
Io_url[] src_fils = Io_mgr.Instance.QueryDir_fils(src_dir);
|
||||
int len = src_fils.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Io_url src_fil = src_fils[i];
|
||||
if (String_.Eq(src_fil.Ext(), ".md5")) continue;
|
||||
Io_url trg_fil = trg_dir.GenSubFil(src_fil.NameAndExt());
|
||||
Io_mgr.Instance.MoveFil_args(src_fil, trg_fil, true).Exec();
|
||||
trg_fils.Add(trg_fil);
|
||||
}
|
||||
}
|
||||
@Override public void Cmd_cleanup() {
|
||||
Io_mgr.Instance.Delete_dir_empty(trg_dir.GenSubDir("tmp")); // deletes dir only if empty
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.ios.zips.*; import gplx.core.progs.*;
|
||||
public class Xobc_cmd__unzip extends Xobc_cmd__base {
|
||||
private final Io_url src_fil, trg_dir;
|
||||
private final Io_zip_decompress_cmd wkr;
|
||||
private final List_adp trg_fils = List_adp_.New();
|
||||
public Xobc_cmd__unzip(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_id, Io_url src_fil, Io_url trg_dir, long prog_data_end) {super(task_mgr, task_id, step_id, cmd_id);
|
||||
this.src_fil = src_fil; this.trg_dir = trg_dir;
|
||||
this.Prog_data_end_(prog_data_end);
|
||||
this.wkr = Io_zip_decompress_cmd_.Proto.Make_new();
|
||||
}
|
||||
@Override public String Cmd_type() {return CMD_TYPE;} public static final String CMD_TYPE = "xowa.core.ios.zips.zip_unzip";
|
||||
@Override public String Cmd_name() {return "unzip";}
|
||||
@Override public boolean Cmd_suspendable() {return true;}
|
||||
|
||||
@Override protected void Cmd_exec_hook(Xobc_cmd_ctx ctx) {
|
||||
if (wkr.Exec(this, src_fil, trg_dir, trg_fils) == Gfo_prog_ui_.Status__fail)
|
||||
this.Cmd_exec_err_(wkr.Fail_msg());
|
||||
}
|
||||
@Override public void Cmd_cleanup() {
|
||||
wkr.Exec_cleanup();
|
||||
Io_mgr.Instance.DeleteFil(src_fil);
|
||||
Io_mgr.Instance.DeleteDirDeep(trg_dir);
|
||||
}
|
||||
@Override protected long Load_checkpoint_hook() {
|
||||
return wkr.Checkpoint__load_by_src_fil(src_fil);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.progs.*;
|
||||
import gplx.core.security.*; import gplx.core.security.files.*;
|
||||
public class Xobc_cmd__verify_dir extends Xobc_cmd__base {
|
||||
private final Io_url delete_fil, checksum_fil;
|
||||
public Xobc_cmd__verify_dir(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_idx, Io_url dir_url, String checksum_fil_name, Io_url delete_fil) {super(task_mgr, task_id, step_id, cmd_idx);
|
||||
this.delete_fil = delete_fil;
|
||||
this.checksum_fil = dir_url.GenSubFil(checksum_fil_name);
|
||||
}
|
||||
@Override public String Cmd_type() {return CMD_TYPE;} public static final String CMD_TYPE = "xowa.core.hash_dir";
|
||||
@Override public String Cmd_name() {return "verify";}
|
||||
@Override public String Cmd_fallback() {return Xobc_cmd__unzip.CMD_TYPE;}
|
||||
|
||||
@Override protected void Cmd_exec_hook(Xobc_cmd_ctx ctx) {
|
||||
// parse file
|
||||
Cksum_list list = Cksum_list.Parse_by_fil(checksum_fil);
|
||||
this.Prog_data_end_(list.Itms_size);
|
||||
|
||||
// verify itms
|
||||
Hash_algo algo = Hash_algo_.New_by_tid(list.Type);
|
||||
Cksum_itm[] itms = list.Itms;
|
||||
int len = itms.length;
|
||||
long prog_data_cur = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Cksum_itm itm = itms[i];
|
||||
gplx.core.ios.streams.IoStream stream = Io_mgr.Instance.OpenStreamRead(itm.File_url);
|
||||
byte[] actl_hash = Bry_.Empty;
|
||||
this.Prog_data_cur_(prog_data_cur);
|
||||
try {actl_hash = algo.Hash_stream_as_bry(this, stream);}
|
||||
finally {stream.Rls();}
|
||||
prog_data_cur += itm.File_size;
|
||||
if (this.Prog_notify_and_chk_if_suspended(prog_data_cur, Prog_data_end())) return;
|
||||
if (this.Prog_status() != Gfo_prog_ui_.Status__suspended && !Bry_.Eq(itm.Hash, actl_hash)) {
|
||||
this.Cmd_exec_err_(String_.Format("bad hash; file={0} bad={1} good={2}", itm.File_url.Raw(), actl_hash, itm.Hash));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override public void Cmd_cleanup() {
|
||||
Io_mgr.Instance.DeleteFil(checksum_fil);
|
||||
Io_mgr.Instance.DeleteFil(delete_fil);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.progs.*; import gplx.core.security.*;
|
||||
public class Xobc_cmd__verify_fil extends Xobc_cmd__base {
|
||||
private final Io_url src_url; private final byte[] expd_hash;
|
||||
public Xobc_cmd__verify_fil(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_id, Io_url src_url, String expd_hash_str, long prog_data_end) {super(task_mgr, task_id, step_id, cmd_id);
|
||||
this.src_url = src_url;
|
||||
this.expd_hash = Bry_.new_a7(expd_hash_str);
|
||||
this.Prog_data_end_(prog_data_end);
|
||||
}
|
||||
@Override public String Cmd_type() {return CMD_TYPE;} public static final String CMD_TYPE = "xowa.core.hash_fil";
|
||||
@Override public String Cmd_name() {return "verify";}
|
||||
@Override public String Cmd_fallback() {return Xobc_cmd__download.CMD_TYPE;}
|
||||
|
||||
@Override protected void Cmd_exec_hook(Xobc_cmd_ctx ctx) {
|
||||
Hash_algo algo = Hash_algo_.New__md5();
|
||||
gplx.core.ios.streams.IoStream stream = Io_mgr.Instance.OpenStreamRead(src_url);
|
||||
byte[] actl_hash = Bry_.Empty;
|
||||
try {actl_hash = algo.Hash_stream_as_bry(this, stream);}
|
||||
finally {stream.Rls();}
|
||||
if (this.Prog_status() != Gfo_prog_ui_.Status__suspended && !Bry_.Eq(expd_hash, actl_hash))
|
||||
this.Cmd_exec_err_(Xobc_cmd__verify_fil.Err_make(actl_hash, expd_hash));
|
||||
}
|
||||
|
||||
public static String Err_make(byte[] actl, byte[] expd) {return String_.Format("bad hash: bad={0} good={1}", String_.new_u8(actl), String_.new_u8(expd));}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.addons.bldrs.exports.splits.mgrs.*; import gplx.xowa.addons.bldrs.exports.merges.*;
|
||||
public class Xobc_cmd__wiki_merge extends Xobc_cmd__base {
|
||||
private final String wiki_domain;
|
||||
private final Io_url src_dir;
|
||||
private final Merge2_mgr merge_mgr;
|
||||
private final Merge_prog_wkr prog_wkr;
|
||||
private final int idx_cur;
|
||||
public Xobc_cmd__wiki_merge(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_idx, Merge2_mgr merge_mgr, String wiki_domain, Io_url src_dir
|
||||
, long prog_size_end, int prog_count_end, int idx_cur) {super(task_mgr, task_id, step_id, cmd_idx);
|
||||
this.merge_mgr = merge_mgr;
|
||||
this.wiki_domain = wiki_domain;
|
||||
this.src_dir = src_dir;
|
||||
this.prog_wkr = new Merge_prog_wkr(this, src_dir.GenSubFil("merge.checkpoint"), prog_count_end, prog_size_end);
|
||||
merge_mgr.Prog_wkr_(prog_wkr);
|
||||
this.Prog_data_end_(prog_count_end);
|
||||
this.idx_cur = idx_cur;
|
||||
}
|
||||
@Override public String Cmd_type() {return CMD_TYPE;} public static final String CMD_TYPE = "xowa.wiki.merge";
|
||||
@Override public String Cmd_name() {return "merge";}
|
||||
@Override public boolean Cmd_suspendable() {return true;}
|
||||
@Override protected void Cmd_exec_hook(Xobc_cmd_ctx ctx) {
|
||||
Xow_wiki wiki = ctx.App().Wiki_mgri().Make(Bry_.new_u8(wiki_domain), ctx.App().Fsys_mgr().Wiki_dir().GenSubDir(wiki_domain));
|
||||
Io_url[] fils = Io_mgr.Instance.QueryDir_fils(src_dir);
|
||||
for (Io_url fil : fils) {
|
||||
if (prog_wkr.Checkpoint__skip_fil(fil)) continue;
|
||||
switch (Split_file_tid_.To_tid(fil)) {
|
||||
case Split_file_tid_.Tid__core: merge_mgr.ctx.Idx_cur_add_(); merge_mgr.Merge_core(wiki, fil); break;
|
||||
case Split_file_tid_.Tid__data: merge_mgr.ctx.Idx_cur_add_(); merge_mgr.Merge_data(wiki, fil, idx_cur); break;
|
||||
}
|
||||
}
|
||||
prog_wkr.Checkpoint__delete();
|
||||
}
|
||||
@Override public void Cmd_cleanup() {
|
||||
Io_mgr.Instance.DeleteDirDeep(src_dir.OwnerDir()); // src_dir is "unzip" dir; owner dir is actual archive dir
|
||||
}
|
||||
@Override protected long Load_checkpoint_hook() {return prog_wkr.Checkpoint__load();}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.security.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xobc_cmd__wiki_reg extends Xobc_cmd__base {
|
||||
private final Io_url wiki_dir;
|
||||
private final String wiki_domain;
|
||||
public Xobc_cmd__wiki_reg(Xobc_task_mgr task_mgr, int task_id, int step_id, int cmd_idx, Io_url wiki_dir, String wiki_domain) {super(task_mgr, task_id, step_id, cmd_idx);
|
||||
this.wiki_dir = wiki_dir;
|
||||
this.wiki_domain = wiki_domain;
|
||||
}
|
||||
@Override public String Cmd_type() {return CMD_TYPE;} public static final String CMD_TYPE = "xowa.wiki.reg";
|
||||
@Override public String Cmd_name() {return "import";}
|
||||
@Override protected void Cmd_exec_hook(Xobc_cmd_ctx ctx) {
|
||||
ctx.App().User().User_db_mgr().Init_site_mgr(); // must init for wiki.register cmd
|
||||
|
||||
// get wiki_core_url
|
||||
Io_url[] wiki_fils = Io_mgr.Instance.QueryDir_fils(wiki_dir);
|
||||
Io_url wiki_core_url = null;
|
||||
int len = wiki_fils.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Io_url url = wiki_fils[i];
|
||||
if (gplx.xowa.wikis.data.Xow_db_file__core_.Is_core_fil_name(wiki_domain, url.NameAndExt())) {
|
||||
wiki_core_url = url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (wiki_core_url == null) throw Err_.new_("wiki_import", "import_url not found", "domain", wiki_domain);
|
||||
|
||||
// import; open
|
||||
Xoa_wiki_mgr wiki_mgr = ctx.App().Wiki_mgri();
|
||||
Gfo_invk_.Invk_by_val(wiki_mgr, gplx.xowa.wikis.Xoa_wiki_mgr_.Invk__import_by_url, wiki_core_url);
|
||||
// COMMENTED: do not auto-open wiki; wait for true-pack mode
|
||||
// Xow_wiki wiki = wiki_mgr.Get_by_or_null(Bry_.new_u8(wiki_domain));
|
||||
// Gfo_invk_.Invk_by_msg(ctx.App().Gui__tab_mgr() , gplx.xowa.guis.tabs.Xog_tab_mgr_.Invk__new_tab, GfoMsg_.new_cast_("").Add("focus", true).Add("site", wiki_domain).Add("page", String_.new_u8(wiki.Props().Main_page())));
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,8 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.wikis.randoms.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.randoms.*;
|
||||
public class Rndm_core_row {
|
||||
public void Load(int uid, String where_sql, int total, int interval) {this.uid = uid; this.where_sql = where_sql; this.total = total; this.interval = interval;}
|
||||
public int uid;
|
||||
public String where_sql;
|
||||
public int total;
|
||||
public int interval;
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
public class Xobc_cmd_ctx {
|
||||
public Xobc_cmd_ctx(Xoa_app app) {this.app = app;}
|
||||
public Xoa_app App() {return app;} private final Xoa_app app;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.progs.*; import gplx.core.gfobjs.*;
|
||||
public interface Xobc_cmd_itm extends Gfo_prog_ui, Gfo_invk {
|
||||
int Task_id();
|
||||
int Step_id();
|
||||
int Cmd_id();
|
||||
String Cmd_type(); // "xowa.core.http_download"
|
||||
String Cmd_name(); // "download"
|
||||
boolean Cmd_suspendable(); // "true"
|
||||
String Cmd_uid(); // for thread_pool_mgr: "0:0:0"
|
||||
void Cmd_cleanup();
|
||||
String Cmd_fallback();
|
||||
void Cmd_clear();
|
||||
|
||||
Gfobj_nde Save_to(Gfobj_nde nde);
|
||||
void Load_checkpoint();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*;
|
||||
public class Xobc_data_db {
|
||||
public Xobc_data_db(Io_url db_url) {
|
||||
this.url = db_url;
|
||||
this.conn = Db_conn_bldr.Instance.Get_or_autocreate(true, db_url);
|
||||
this.tbl__task_regy = new Xobc_task_regy_tbl(conn);
|
||||
this.tbl__step_regy = new Xobc_step_regy_tbl(conn);
|
||||
this.tbl__step_map = new Xobc_step_map_tbl(conn);
|
||||
this.tbl__import_step = new Xobc_import_step_tbl(conn);
|
||||
this.tbl__host_regy = new Xobc_host_regy_tbl(conn);
|
||||
this.tbl__version_regy = new Xobc_version_regy_tbl(conn);
|
||||
conn.Meta_tbl_assert(tbl__task_regy, tbl__step_regy, tbl__step_map, tbl__import_step, tbl__host_regy, tbl__version_regy);
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public Io_url Url() {return url;} private final Io_url url;
|
||||
public Xobc_task_regy_tbl Tbl__task_regy() {return tbl__task_regy;} private final Xobc_task_regy_tbl tbl__task_regy;
|
||||
public Xobc_step_regy_tbl Tbl__step_regy() {return tbl__step_regy;} private final Xobc_step_regy_tbl tbl__step_regy;
|
||||
public Xobc_step_map_tbl Tbl__step_map() {return tbl__step_map;} private final Xobc_step_map_tbl tbl__step_map;
|
||||
public Xobc_import_step_tbl Tbl__import_step() {return tbl__import_step;} private final Xobc_import_step_tbl tbl__import_step;
|
||||
public Xobc_host_regy_tbl Tbl__host_regy() {return tbl__host_regy;} private final Xobc_host_regy_tbl tbl__host_regy;
|
||||
public Xobc_version_regy_tbl Tbl__version_regy() {return tbl__version_regy;} private final Xobc_version_regy_tbl tbl__version_regy;
|
||||
|
||||
public void Delete_by_import(byte[] wiki_abrv, String wiki_date) {
|
||||
// get all step ids from import_regy
|
||||
Xobc_task_step_hash task_step_hash = new Xobc_task_step_hash();
|
||||
tbl__import_step.Select_tasks_steps(task_step_hash, tbl__step_map, wiki_abrv, wiki_date);
|
||||
for (int i = 0; i < task_step_hash.Tasks__len(); ++i) {
|
||||
int task_id = task_step_hash.Tasks__get_at(i);
|
||||
tbl__task_regy.Delete(task_id);
|
||||
tbl__step_map.Delete_by_task_id(task_id);
|
||||
}
|
||||
for (int i = 0; i < task_step_hash.Steps__len(); ++i) {
|
||||
int step_id = task_step_hash.Steps__get_at(i);
|
||||
tbl__step_regy.Delete(step_id);
|
||||
tbl__import_step.Delete(step_id);
|
||||
}
|
||||
}
|
||||
private final gplx.core.lists.hashs.Hash_adp__int host_hash = new gplx.core.lists.hashs.Hash_adp__int();
|
||||
public String Bld_src_http_url(gplx.core.brys.evals.Bry_eval_mgr eval_mgr, int host_id, String file_name) {
|
||||
Xobc_host_regy_itm host_itm = (Xobc_host_regy_itm)host_hash.Get_by_or_null(host_id);
|
||||
if (host_itm == null) {
|
||||
host_itm = tbl__host_regy.Select(host_id);
|
||||
host_hash.Add(host_id, host_itm);
|
||||
}
|
||||
String host_dir = String_.new_u8(eval_mgr.Eval(Bry_.new_u8(host_itm.Host_data_dir())));
|
||||
return String_.Format("http://{0}/{1}/{2}", host_itm.Host_domain(), host_dir, file_name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.core.progs.*; import gplx.core.net.downloads.*; import gplx.core.gfobjs.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
import gplx.xowa.wikis.pages.tags.*;
|
||||
public class Xobc_data_db_upgrader {
|
||||
private static final String
|
||||
Cfg__last_check_date = "xowa.bldr_central.data_db.last_check_date"
|
||||
// , Cfg__next_check_interval = "xowa.bldr_central.data_db.next_check_interval"
|
||||
, Date_fmt = "yyyy-MM-dd HH:mm"
|
||||
;
|
||||
public static void Check_for_updates(Xobc_task_mgr task_mgr) {
|
||||
Io_url data_db_url = task_mgr.Data_db().Url();
|
||||
Xoud_cfg_mgr cfg_mgr = task_mgr.App().User().User_db_mgr().Cfg_mgr();
|
||||
|
||||
// check if update needed
|
||||
//String last_check_str = cfg_mgr.Select_str_or("", Cfg__last_check_date, "");
|
||||
//int next_check_interval = cfg_mgr.Select_int_or("", Cfg__next_check_interval, 24 * 7);
|
||||
//DateAdp last_check = DateAdp_.parse_fmt_or(last_check_str, Date_fmt, null);
|
||||
//if (last_check != null) { // check if last_check_str exists
|
||||
// Time_span span = DateAdp_.Now().Diff(last_check);
|
||||
// if (span.Total_hours().To_double() < next_check_interval) { // check if enough time passed
|
||||
// Gfo_log_.Instance.Info("xobc_db update not needed", "last_check", last_check_str, "next_check_interval", next_check_interval);
|
||||
// return;
|
||||
// }
|
||||
// else
|
||||
// Gfo_log_.Instance.Info("xobc_db update needed b/c of last_check", "last_check", last_check_str);
|
||||
//}
|
||||
//else
|
||||
// Gfo_log_.Instance.Info("xobc_db update needed b/c of missing or invalid last_check_str", "last_check", last_check_str);
|
||||
|
||||
// update needed; first, update cfg_key, then get host
|
||||
cfg_mgr.Upsert_str("", Cfg__last_check_date, DateAdp_.Now().XtoStr_fmt(Date_fmt));
|
||||
Xobc_data_db bc_db = task_mgr.Data_db();
|
||||
Xobc_host_regy_itm host_itm = bc_db.Tbl__host_regy().Select(Xobc_host_regy_tbl.Host_id__archive_org);
|
||||
|
||||
// download manifest
|
||||
Http_download_wkr download_wkr = Http_download_wkr_.Proto.Make_new();
|
||||
Io_url manifest_url = data_db_url.GenNewExt(".txt");
|
||||
download_wkr.Exec(Gfo_prog_ui_.Always
|
||||
, String_.Format("http://{0}/{1}/bldr_central.data_db.txt", host_itm.Host_domain(), host_itm.Host_update_dir())
|
||||
, manifest_url, -1);
|
||||
|
||||
// parse manifest and get version_id
|
||||
byte[] manifest_txt = Io_mgr.Instance.LoadFilBry(manifest_url);
|
||||
byte[][] manifest_data = Bry_split_.Split(manifest_txt, Byte_ascii.Pipe);
|
||||
int expd_version_id = Bry_.To_int(manifest_data[0]);
|
||||
Xobc_version_regy_itm actl_version = bc_db.Tbl__version_regy().Select_latest();
|
||||
|
||||
// cleanup
|
||||
Io_mgr.Instance.DeleteFil(manifest_url);
|
||||
bc_db.Conn().Rls_conn();
|
||||
if (expd_version_id == actl_version.Id()) {
|
||||
Gfo_log_.Instance.Info("xobc_db update not needed", "version", expd_version_id);
|
||||
Xopg_alertify_.Exec_log(task_mgr, "Wikis are up-to-date");
|
||||
return; // version matches; exit
|
||||
}
|
||||
|
||||
// version doesn't match; download new
|
||||
// next_check_interval = Bry_.To_int(manifest_data[2]);
|
||||
// cfg_mgr.Upsert_int("", Cfg__next_check_interval, next_check_interval);
|
||||
// Gfo_log_.Instance.Info("xobc_db update needed", "version", expd_version_id, "next_check_interval", next_check_interval);
|
||||
byte[] new_db_url = manifest_data[1];
|
||||
String note = String_.new_u8(manifest_data[3]);
|
||||
download_wkr.Exec(Gfo_prog_ui_.Always
|
||||
, String_.new_u8(new_db_url)
|
||||
, data_db_url, -1);
|
||||
Xopg_alertify_.Exec_log(task_mgr, "Wikis have been updated:<br/>" + note);
|
||||
task_mgr.Load_or_init();
|
||||
task_mgr.Reload();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
public class Xobc_task_step_hash {
|
||||
private final Ordered_hash tasks_hash = Ordered_hash_.New();
|
||||
private final Ordered_hash steps_hash = Ordered_hash_.New();
|
||||
public int Tasks__len() {return tasks_hash.Len();}
|
||||
public int Tasks__get_at(int i) {return Int_.cast(tasks_hash.Get_at(i));}
|
||||
public int Steps__len() {return steps_hash.Len();}
|
||||
public int Steps__get_at(int i) {return Int_.cast(steps_hash.Get_at(i));}
|
||||
public void Clear() {tasks_hash.Clear(); steps_hash.Clear();}
|
||||
public void Add(int task_id, int step_id) {
|
||||
tasks_hash.Add_if_dupe_use_nth(task_id, task_id);
|
||||
steps_hash.Add_if_dupe_use_nth(step_id, step_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.users.*;
|
||||
public class Xobc_user_db {
|
||||
public Xobc_user_db(Db_conn conn) {
|
||||
this.work_task_tbl = new Xobc_work_task_tbl(conn);
|
||||
this.done_task_tbl = new Xobc_done_task_tbl(conn);
|
||||
this.done_step_tbl = new Xobc_done_step_tbl(conn);
|
||||
conn.Meta_tbl_assert(work_task_tbl, done_task_tbl, done_step_tbl);
|
||||
}
|
||||
public Xobc_work_task_tbl Work_task_tbl() {return work_task_tbl;} private final Xobc_work_task_tbl work_task_tbl;
|
||||
public Xobc_done_task_tbl Done_task_tbl() {return done_task_tbl;} private final Xobc_done_task_tbl done_task_tbl;
|
||||
public Xobc_done_step_tbl Done_step_tbl() {return done_step_tbl;} private final Xobc_done_step_tbl done_step_tbl;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
public class Xobc_host_regy_itm {
|
||||
public Xobc_host_regy_itm(int host_id, String host_domain, String host_data_dir, String host_update_dir) {
|
||||
this.host_id = host_id;
|
||||
this.host_domain = host_domain;
|
||||
this.host_data_dir = host_data_dir;
|
||||
this.host_update_dir = host_update_dir;
|
||||
}
|
||||
public int Host_id() {return host_id;} private final int host_id;
|
||||
public String Host_domain() {return host_domain;} private final String host_domain;
|
||||
public String Host_data_dir() {return host_data_dir;} private final String host_data_dir;
|
||||
public String Host_update_dir() {return host_update_dir;} private final String host_update_dir;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xobc_host_regy_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_host_id, fld_host_domain, fld_host_data_dir, fld_host_update_dir;
|
||||
private final Db_conn conn;
|
||||
public Xobc_host_regy_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "host_regy";
|
||||
this.fld_host_id = flds.Add_int_pkey("host_id");
|
||||
this.fld_host_domain = flds.Add_str("host_domain", 255); // EX: archive.org
|
||||
this.fld_host_data_dir = flds.Add_str("host_data_dir", 255); // EX: download/Xowa_~{host_regy|wiki_abrv}_latest
|
||||
this.fld_host_update_dir = flds.Add_str("host_update_dir", 255); // EX: download/Xowa_app_support
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
conn.Stmt_insert(tbl_name, flds)
|
||||
.Val_int(fld_host_id, Host_id__archive_org).Val_str(fld_host_domain, "archive.org")
|
||||
.Val_str(fld_host_data_dir, "download/Xowa_~{host_regy|wiki_abrv}_latest").Val_str(fld_host_update_dir, "download/Xowa_app_support")
|
||||
.Exec_insert();
|
||||
}
|
||||
public Xobc_host_regy_itm Select(int host_id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_host_id).Crt_int(fld_host_id, host_id).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? Load_itm(rdr) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xobc_host_regy_itm Load_itm(Db_rdr rdr) {
|
||||
return new Xobc_host_regy_itm(rdr.Read_int(fld_host_id), rdr.Read_str(fld_host_domain), rdr.Read_str(fld_host_data_dir), rdr.Read_str(fld_host_update_dir));
|
||||
}
|
||||
public void Rls() {}
|
||||
public static final int Host_id__archive_org = 1;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
public class Xobc_step_map_itm {
|
||||
public Xobc_step_map_itm(int sm_id, int task_id, int step_id, int step_seqn) {
|
||||
this.Sm_id = sm_id;
|
||||
this.Task_id = task_id;
|
||||
this.Step_id = step_id;
|
||||
this.Step_seqn = step_seqn;
|
||||
}
|
||||
public final int Sm_id;
|
||||
public final int Task_id;
|
||||
public final int Step_id;
|
||||
public final int Step_seqn;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xobc_step_map_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_sm_id, fld_step_seqn, fld_task_id, fld_step_id;
|
||||
private final Db_conn conn; private Db_stmt insert_stmt;
|
||||
public Xobc_step_map_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "step_map";
|
||||
this.fld_sm_id = flds.Add_int_pkey("sm_id");
|
||||
this.fld_task_id = flds.Add_int("task_id");
|
||||
this.fld_step_id = flds.Add_int("step_id");
|
||||
this.fld_step_seqn = flds.Add_int("step_seqn");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public int Select_step_id(int task_id, int step_seqn) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_task_id, fld_step_seqn).Crt_int(fld_task_id, task_id).Crt_int(fld_step_seqn, step_seqn).Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next())
|
||||
return rdr.Read_int(fld_step_id);
|
||||
else
|
||||
throw Err_.new_("", "xobc:could not find step_id", "task_id", task_id, "step_seqn", step_seqn);
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public Xobc_step_map_itm Select_one(int task_id, int step_id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_task_id, fld_step_id).Crt_int(fld_task_id, task_id).Crt_int(fld_step_id, step_id).Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next())
|
||||
return new Xobc_step_map_itm
|
||||
( rdr.Read_int(fld_sm_id)
|
||||
, rdr.Read_int(fld_task_id)
|
||||
, rdr.Read_int(fld_step_id)
|
||||
, rdr.Read_int(fld_step_seqn)
|
||||
);
|
||||
else
|
||||
throw Err_.new_("", "bldr.central:could not find step_id", "task_id", task_id, "step_id", step_id);
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public int Select_seqn_but_skip_done(int task_id, Hash_adp step_ids) {
|
||||
Db_rdr rdr = conn.Stmt_select_order(tbl_name, flds, String_.Ary(fld_task_id), fld_step_seqn).Crt_int(fld_task_id, task_id).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
int step_id = rdr.Read_int("step_id");
|
||||
if (step_ids.Has(step_id))
|
||||
return rdr.Read_int("step_seqn");
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
throw Err_.new_("", "xobc:could not find next sort", "task_id", task_id);
|
||||
}
|
||||
public void Insert(int sm_id, int task_id, int step_id, int step_seqn) {
|
||||
if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds);
|
||||
insert_stmt.Clear().Val_int(fld_sm_id, sm_id).Val_int(fld_task_id, task_id).Val_int(fld_step_id, step_id).Val_int(fld_step_seqn, step_seqn)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Delete_by_task_id(int task_id) {
|
||||
conn.Stmt_delete(tbl_name, fld_task_id).Crt_int(fld_task_id, task_id).Exec_delete();
|
||||
}
|
||||
public void Rls() {
|
||||
insert_stmt = Db_stmt_.Rls(insert_stmt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
|
||||
public class Xobc_step_regy_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_step_id, fld_step_type;
|
||||
private final Db_conn conn; private Db_stmt insert_stmt;
|
||||
public Xobc_step_regy_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "step_regy";
|
||||
this.fld_step_id = flds.Add_int_pkey("step_id");
|
||||
this.fld_step_type = flds.Add_int("step_type");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public int Select_type(int step_id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_step_id).Crt_int(fld_step_id, step_id).Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next())
|
||||
return rdr.Read_int(fld_step_type);
|
||||
else
|
||||
throw Err_.new_("", "bldr.central:could not find step_type", "step_id", step_id);
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Insert(int step_id, int step_type) {
|
||||
if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds);
|
||||
insert_stmt.Clear().Val_int(fld_step_id, step_id).Val_int(fld_step_type, step_type)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Delete(int step_id) {
|
||||
conn.Stmt_delete(tbl_name, fld_step_id).Crt_int(fld_step_id, step_id).Exec_delete();
|
||||
}
|
||||
public void Rls() {
|
||||
insert_stmt = Db_stmt_.Rls(insert_stmt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
|
||||
public class Xobc_task_regy_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_task_id, fld_task_seqn, fld_step_count, fld_task_key, fld_task_name;
|
||||
private final Db_conn conn; private Db_stmt insert_stmt;
|
||||
public Xobc_task_regy_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "task_regy";
|
||||
this.fld_task_id = flds.Add_int_pkey("task_id");
|
||||
this.fld_task_seqn = flds.Add_int("task_seqn");
|
||||
this.fld_step_count = flds.Add_int("step_count");
|
||||
this.fld_task_key = flds.Add_str("task_key", 255);
|
||||
this.fld_task_name = flds.Add_str("task_name", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "task_seqn", fld_task_seqn));
|
||||
}
|
||||
public void Select_all(Xobc_task_regy__base todo_regy) {
|
||||
todo_regy.Clear();
|
||||
Db_rdr rdr = conn.Stmt_select_order(tbl_name, flds, String_.Ary_empty, fld_task_seqn).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
int task_id = rdr.Read_int(fld_task_id);
|
||||
int task_seqn = rdr.Read_int(fld_task_seqn);
|
||||
int step_count = rdr.Read_int(fld_step_count);
|
||||
String task_key = rdr.Read_str(fld_task_name);
|
||||
String task_name = rdr.Read_str(fld_task_name);
|
||||
todo_regy.Add(new Xobc_task_itm(task_id, task_seqn, step_count, task_key, task_name));
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
public int Select_by_key(String key) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_task_key).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? rdr.Read_int(fld_task_id) : -1;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Insert(int task_id, int task_seqn, int step_count, String task_key, String task_name) {
|
||||
if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds);
|
||||
insert_stmt.Clear().Val_int(fld_task_id, task_id).Val_int(fld_task_seqn, task_seqn).Val_int(fld_step_count, step_count)
|
||||
.Val_str(fld_task_key, task_key).Val_str(fld_task_name, task_name)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Delete(int task_id) {
|
||||
conn.Stmt_delete(tbl_name, fld_task_id).Crt_int(fld_task_id, task_id).Exec_delete();
|
||||
}
|
||||
public void Rls() {
|
||||
insert_stmt = Db_stmt_.Rls(insert_stmt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
public class Xobc_version_regy_itm {
|
||||
public Xobc_version_regy_itm(int id, String date, String note) {
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
this.note = note;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Date() {return date;} private final String date;
|
||||
public String Note() {return note;} private final String note;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xobc_version_regy_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_version_id, fld_version_date, fld_version_note;
|
||||
private final Db_conn conn;
|
||||
public Xobc_version_regy_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "version_regy";
|
||||
this.fld_version_id = flds.Add_int_pkey("version_id");
|
||||
this.fld_version_date = flds.Add_str("version_date", 16);
|
||||
this.fld_version_note = flds.Add_str("version_note", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
conn.Stmt_insert(tbl_name, flds)
|
||||
.Val_int(fld_version_id, 1).Val_str(fld_version_date, DateAdp_.Now().XtoStr_fmt_yyyy_MM_dd_HH_mm()).Val_str(fld_version_note, "initial")
|
||||
.Exec_insert();
|
||||
}
|
||||
public Xobc_version_regy_itm Select_latest() {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds).Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next())
|
||||
return new Xobc_version_regy_itm(rdr.Read_int(fld_version_id), rdr.Read_str(fld_version_date), rdr.Read_str(fld_version_note));
|
||||
else
|
||||
throw Err_.new_("", "version_regy does not have version");
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -15,13 +15,9 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.servers.jobs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.servers.*;
|
||||
public class Xob_job_mgr {
|
||||
private Ordered_hash jobs = Ordered_hash_.New();
|
||||
public int Count() {return jobs.Count();}
|
||||
public Xob_job_itm Get_at(int i) {return (Xob_job_itm)jobs.Get_at(i);}
|
||||
public Xob_job_itm Get(String k) {return (Xob_job_itm)jobs.Get_by(k);}
|
||||
public void Load(String text) {
|
||||
jobs.Add(null, null);
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
public class Xobc_import_date {
|
||||
public static String To_str__yyyy_mm(String raw, String dlm) {
|
||||
return String_.Mid(raw, 0, 4) + dlm + String_.Mid(raw, 4, 6);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xobc_import_step_itm {
|
||||
public Xobc_import_step_itm(int step_id, int host_id, byte[] wiki_abrv, String wiki_date
|
||||
, String import_name, int import_type, byte import_zip_type, long import_size_zip, long import_size_raw, String import_md5
|
||||
, long import_prog_data_max, int import_prog_row_max
|
||||
) {
|
||||
this.Step_id = step_id;
|
||||
this.Host_id = host_id;
|
||||
this.wiki_abrv = wiki_abrv;
|
||||
this.Wiki_date = wiki_date;
|
||||
this.Import_name = import_name;
|
||||
this.Import_type = import_type;
|
||||
this.Import_zip_type = import_zip_type;
|
||||
this.Import_size_zip = import_size_zip;
|
||||
this.Import_size_raw = import_size_raw;
|
||||
this.Import_md5 = import_md5;
|
||||
this.Import_prog_data_max = import_prog_data_max;
|
||||
this.Import_prog_row_max = import_prog_row_max;
|
||||
}
|
||||
public final int Step_id;
|
||||
public final int Host_id;
|
||||
public byte[] Wiki_abrv() {return wiki_abrv;} private final byte[] wiki_abrv;
|
||||
public final String Wiki_date;
|
||||
public final String Import_name;
|
||||
public final int Import_type;
|
||||
public final byte Import_zip_type;
|
||||
public final long Import_size_zip;
|
||||
public final long Import_size_raw;
|
||||
public final String Import_md5;
|
||||
public final long Import_prog_data_max;
|
||||
public final int Import_prog_row_max;
|
||||
|
||||
public static final Xobc_import_step_itm Null = null;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xobc_import_step_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_step_id, fld_host_id, fld_wiki_abrv, fld_wiki_date, fld_import_name, fld_import_type, fld_import_zip, fld_import_md5, fld_import_size_zip, fld_import_size_raw, fld_prog_size_end, fld_prog_count_end;
|
||||
public final Db_conn conn; private Db_stmt insert_stmt;
|
||||
public Xobc_import_step_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "import_step";
|
||||
this.fld_step_id = flds.Add_int_pkey("step_id");
|
||||
this.fld_host_id = flds.Add_int("host_id");
|
||||
this.fld_wiki_abrv = flds.Add_str("wiki_abrv", 255);
|
||||
this.fld_wiki_date = flds.Add_str("wiki_date", 8);
|
||||
this.fld_import_name = flds.Add_str("import_name", 255);
|
||||
this.fld_import_type = flds.Add_int("import_type");
|
||||
this.fld_import_zip = flds.Add_byte("import_zip");
|
||||
this.fld_import_size_zip = flds.Add_long("import_size_zip");
|
||||
this.fld_import_size_raw = flds.Add_long("import_size_raw");
|
||||
this.fld_import_md5 = flds.Add_str("import_md5", 48);
|
||||
this.fld_prog_size_end = flds.Add_long("prog_size_end");
|
||||
this.fld_prog_count_end = flds.Add_long("prog_count_end");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public Xobc_import_step_itm Select_one(int step_id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_step_id).Crt_int(fld_step_id, step_id).Exec_select__rls_auto();
|
||||
try {
|
||||
return (rdr.Move_next())
|
||||
? new Xobc_import_step_itm
|
||||
( rdr.Read_int(fld_step_id)
|
||||
, rdr.Read_int(fld_host_id)
|
||||
, rdr.Read_bry_by_str(fld_wiki_abrv)
|
||||
, rdr.Read_str(fld_wiki_date)
|
||||
, rdr.Read_str(fld_import_name)
|
||||
, rdr.Read_int(fld_import_type)
|
||||
, rdr.Read_byte(fld_import_zip)
|
||||
, rdr.Read_long(fld_import_size_zip)
|
||||
, rdr.Read_long(fld_import_size_raw)
|
||||
, rdr.Read_str(fld_import_md5)
|
||||
, rdr.Read_long(fld_prog_size_end)
|
||||
, rdr.Read_int(fld_prog_count_end)
|
||||
)
|
||||
: Xobc_import_step_itm.Null;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Delete(int step_id) {
|
||||
conn.Stmt_delete(tbl_name, fld_step_id).Crt_int(fld_step_id, step_id).Exec_delete();
|
||||
}
|
||||
public void Insert(int step_id, int host_id, byte[] wiki_abrv, String wiki_date, String import_name, int import_type, byte zip_type, byte[] md5, long size_zip, long size_raw
|
||||
, long prog_size_end, int prog_count_end) {
|
||||
if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds);
|
||||
insert_stmt.Clear().Val_int(fld_step_id, step_id).Val_int(fld_host_id, host_id)
|
||||
.Val_bry_as_str(fld_wiki_abrv, wiki_abrv).Val_str(fld_wiki_date, wiki_date)
|
||||
.Val_str(fld_import_name, import_name)
|
||||
.Val_int(fld_import_type, import_type).Val_byte(fld_import_zip, zip_type)
|
||||
.Val_long(fld_import_size_zip, size_zip).Val_long(fld_import_size_raw, size_raw).Val_bry_as_str(fld_import_md5, md5)
|
||||
.Val_long(fld_prog_size_end, prog_size_end).Val_int(fld_prog_count_end, prog_count_end)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Select_tasks_steps(Xobc_task_step_hash task_step_hash, Xobc_step_map_tbl step_map_tbl, byte[] wiki_abrv, String wiki_date) {
|
||||
task_step_hash.Clear();
|
||||
Db_rdr rdr = conn.Stmt_sql(String_.Concat_lines_nl_skip_last
|
||||
( "SELECT DISTINCT sm.task_id, sm.step_id"
|
||||
, "FROM " + tbl_name + " imps"
|
||||
, " JOIN " + step_map_tbl.Tbl_name() + " sm ON sm.step_id = imps.step_id"
|
||||
, "WHERE imps.wiki_abrv = ?"
|
||||
, "AND imps.wiki_date = ?"
|
||||
))
|
||||
.Crt_bry_as_str(fld_wiki_abrv, wiki_abrv)
|
||||
.Crt_str(fld_wiki_date, wiki_date)
|
||||
.Exec_select__rls_auto()
|
||||
;
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
task_step_hash.Add(rdr.Read_int("task_id"), rdr.Read_int("step_id"));
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
public void Rls() {
|
||||
insert_stmt = Db_stmt_.Rls(insert_stmt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
public class Xobc_import_type {
|
||||
public static final int // SERIALIZED: bc_db; import_step
|
||||
Tid__ignore = 0
|
||||
, Tid__pack = 1
|
||||
, Tid__wiki__core = 2
|
||||
, Tid__wiki__srch = 3
|
||||
, Tid__wiki__html = 4
|
||||
, Tid__wiki__text = 5
|
||||
, Tid__file__core = 6
|
||||
, Tid__file__data = 7
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.datas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
public class Xobc_zip_type {
|
||||
public static String To_str(byte type) {
|
||||
switch (type) {
|
||||
case Type__zip: return "zip";
|
||||
default: throw Err_.new_unhandled_default(type);
|
||||
}
|
||||
}
|
||||
public static final byte Type__zip = 1; // SERIALIZED
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.users; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
|
||||
public class Xobc_done_step_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_task_id, fld_step_id;
|
||||
private final Db_conn conn;
|
||||
public Xobc_done_step_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "xobc_done_step";
|
||||
this.fld_task_id = flds.Add_int("task_id");
|
||||
this.fld_step_id = flds.Add_int("step_id");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "main", fld_task_id, fld_step_id));
|
||||
}
|
||||
public void Insert(int task_id, int step_id) {
|
||||
conn.Stmt_insert(tbl_name, fld_task_id, fld_step_id)
|
||||
.Val_int(fld_task_id, task_id).Val_int(fld_step_id, step_id)
|
||||
.Exec_insert();
|
||||
}
|
||||
public Hash_adp Select_all(int task_id) {
|
||||
Hash_adp rv = null;
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, String_.Ary(fld_step_id), fld_task_id).Crt_int(fld_task_id, task_id).Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
if (rv == null) rv = Hash_adp_.New();
|
||||
rv.Add_as_key_and_val(rdr.Read_int("step_id"));
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
return null;
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.users; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
|
||||
public class Xobc_done_task_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_task_id, fld_task_seqn;
|
||||
private final Db_conn conn;
|
||||
public Xobc_done_task_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "xobc_done_task";
|
||||
this.fld_task_id = flds.Add_int_pkey("task_id");
|
||||
this.fld_task_seqn = flds.Add_int("task_seqn");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert(int task_id, int task_seqn) {
|
||||
conn.Stmt_insert(tbl_name, fld_task_id, fld_task_seqn)
|
||||
.Val_int(fld_task_id, task_id).Val_int(fld_task_seqn, task_seqn)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Delete(int task_id) {
|
||||
conn.Stmt_delete(tbl_name, fld_task_id)
|
||||
.Crt_int(fld_task_id, task_id)
|
||||
.Exec_delete();
|
||||
}
|
||||
public void Select_all(Xobc_task_regy__base todo_regy, Xobc_task_regy__base done_regy) {
|
||||
done_regy.Clear();
|
||||
Db_rdr rdr = conn.Stmt_select_all(tbl_name, flds).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
int task_id = rdr.Read_int(fld_task_id);
|
||||
int task_seqn = rdr.Read_int(fld_task_seqn);
|
||||
Xobc_task_itm itm = (Xobc_task_itm)todo_regy.Get_by(task_id);
|
||||
if (itm == null) {
|
||||
Gfo_log_.Instance.Warn("task exists in done, but not in todo", "task_id", task_id);
|
||||
continue;
|
||||
}
|
||||
done_regy.Add(itm);
|
||||
todo_regy.Del_by(task_id);
|
||||
itm.Task_seqn_(task_seqn);
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.dbs.users; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
|
||||
public class Xobc_work_task_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_task_id, fld_task_seqn, fld_step_id, fld_cmd_id;
|
||||
private final Db_conn conn;
|
||||
public Xobc_work_task_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "xobc_work_task";
|
||||
this.fld_task_id = flds.Add_int_pkey("task_id");
|
||||
this.fld_task_seqn = flds.Add_int("task_seqn");
|
||||
this.fld_step_id = flds.Add_int("step_id");
|
||||
this.fld_cmd_id = flds.Add_int("cmd_id");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Select_all(Xobc_task_mgr task_mgr, Xobc_task_regy__base todo_regy, Xobc_task_regy__base work_regy) {
|
||||
work_regy.Clear();
|
||||
Db_rdr rdr = conn.Stmt_select_all(tbl_name, flds).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
int task_id = rdr.Read_int(fld_task_id);
|
||||
int task_seqn = rdr.Read_int(fld_task_seqn);
|
||||
int step_id = rdr.Read_int(fld_step_id);
|
||||
int cmd_id = rdr.Read_int(fld_cmd_id);
|
||||
Xobc_task_itm task = (Xobc_task_itm)todo_regy.Get_by(task_id);
|
||||
if (task == null) {
|
||||
Gfo_log_.Instance.Warn("task exists in work, but not in todo", "task_id", task_id);
|
||||
continue;
|
||||
}
|
||||
work_regy.Add(task);
|
||||
todo_regy.Del_by(task_id);
|
||||
task.Task_seqn_(task_seqn);
|
||||
task.Task_status_(cmd_id == Xobc_cmd__base.Seqn__0 ? gplx.core.progs.Gfo_prog_ui_.Status__init : gplx.core.progs.Gfo_prog_ui_.Status__working);
|
||||
task_mgr.Step_mgr().Load(task, step_id, cmd_id);
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
public void Insert(int task_id, int task_seqn, int step_id, int cmd_id) {
|
||||
conn.Stmt_insert(tbl_name, fld_task_id, fld_task_seqn, fld_step_id, fld_cmd_id)
|
||||
.Val_int(fld_task_id, task_id).Val_int(fld_task_seqn, task_seqn).Val_int(fld_step_id, step_id).Val_int(fld_cmd_id, cmd_id)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Update(int task_id, int task_seqn, int step_id, int cmd_id) {
|
||||
conn.Stmt_update_exclude(tbl_name, flds, fld_task_id)
|
||||
.Val_int(fld_task_seqn, task_seqn).Val_int(fld_step_id, step_id).Val_int(fld_cmd_id, cmd_id).Crt_int(fld_task_id, task_id)
|
||||
.Exec_update();
|
||||
}
|
||||
public void Delete(int task_id) {
|
||||
conn.Stmt_delete(tbl_name, fld_task_id).Val_int(fld_task_id, task_id).Exec_insert();
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.steps; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.brys.evals.*; import gplx.core.primitives.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.tasks.*; import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.utils.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*;
|
||||
import gplx.xowa.addons.bldrs.exports.merges.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xobc_step_factory {
|
||||
private final Xobc_task_mgr task_mgr;
|
||||
private final Xobc_data_db data_db;
|
||||
private final Bry_eval_mgr eval_mgr = Bry_eval_mgr.Dflt(), eval_mgr__host_regy = Bry_eval_mgr.Dflt();
|
||||
private final Bry_eval_wkr__host_regy eval_wkr__host_regy = new Bry_eval_wkr__host_regy();
|
||||
public Xobc_step_factory(Xobc_task_mgr task_mgr, Xobc_data_db data_db, Io_url wiki_dir) {
|
||||
this.task_mgr = task_mgr;
|
||||
this.data_db = data_db;
|
||||
eval_mgr.Add_many(new Bry_eval_wkr__builder_central(wiki_dir));
|
||||
eval_mgr__host_regy.Add_many(eval_wkr__host_regy);
|
||||
}
|
||||
public void Load(Xobc_task_itm task, int step_id, int cmd_idx) {
|
||||
int step_type = data_db.Tbl__step_regy().Select_type(step_id);
|
||||
switch (step_type) {
|
||||
case Xobc_step_itm.Type__wiki_import: Load_wiki_import(task, step_id, cmd_idx); break;
|
||||
default: throw Err_.new_unhandled_default(step_type);
|
||||
}
|
||||
}
|
||||
private void Load_wiki_import(Xobc_task_itm task, int step_id, int cmd_idx) {
|
||||
int step_seqn = data_db.Tbl__step_map().Select_one(task.Task_id(), step_id).Step_seqn;
|
||||
Xobc_import_step_itm import_itm = data_db.Tbl__import_step().Select_one(step_id); String_obj_ref step_name = String_obj_ref.empty_();
|
||||
Xobc_cmd_itm[] cmds = Make_wiki_import_cmds(import_itm, task.Task_id(), step_id, step_name, step_seqn);
|
||||
Xobc_step_itm step = new Xobc_step_itm(step_id, step_seqn, cmds).Cmd_idx_(cmd_idx);
|
||||
step.Step_name_(String_.Format("{0} ·({1}/{2})", step_name.Val(), step_seqn + List_adp_.Base1, task.Step_count()));
|
||||
task.Step_(step);
|
||||
step.Cmd().Load_checkpoint();
|
||||
if (step.Cmd().Prog_status() == gplx.core.progs.Gfo_prog_ui_.Status__working)
|
||||
task.Task_status_(step.Cmd().Prog_status());
|
||||
}
|
||||
private Xobc_cmd_itm[] Make_wiki_import_cmds(Xobc_import_step_itm import_itm, int task_id, int step_id, String_obj_ref step_name, int step_seqn) {
|
||||
List_adp list = List_adp_.New();
|
||||
Xow_domain_itm domain_itm = Xow_abrv_xo_.To_itm(import_itm.Wiki_abrv());
|
||||
String wiki_domain = domain_itm.Domain_str();
|
||||
String file_name = import_itm.Import_name;
|
||||
step_name.Val_(file_name);
|
||||
eval_wkr__host_regy.Domain_itm_(domain_itm);
|
||||
String src_http_url = data_db.Bld_src_http_url(eval_mgr__host_regy, import_itm.Host_id, file_name);
|
||||
Io_url zip_file_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__download_fil, wiki_domain, file_name));
|
||||
Io_url unzip_dir_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__unzip_dir, wiki_domain, file_name));
|
||||
Io_url wiki_dir_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__wiki_dir, wiki_domain, file_name));
|
||||
list.Add(new Xobc_cmd__download (task_mgr, task_id, step_id, 0, src_http_url, zip_file_url, import_itm.Import_size_zip));
|
||||
list.Add(new Xobc_cmd__verify_fil (task_mgr, task_id, step_id, 1, zip_file_url, import_itm.Import_md5, import_itm.Import_size_zip));
|
||||
list.Add(new Xobc_cmd__unzip (task_mgr, task_id, step_id, 2, zip_file_url, unzip_dir_url, import_itm.Import_size_raw));
|
||||
list.Add(new Xobc_cmd__verify_dir (task_mgr, task_id, step_id, 3, unzip_dir_url, String_.Replace(file_name, ".zip", ".md5"), zip_file_url));
|
||||
// list.Add(new Xobc_cmd__wiki_merge (task_mgr, task_id, step_id, 4, merge_mgr, wiki_domain, unzip_dir_url, import_itm.Import_prog_data_max, import_itm.Import_prog_row_max, step_seqn));
|
||||
list.Add(new Xobc_cmd__move_fils (task_mgr, task_id, step_id, 4, unzip_dir_url, wiki_dir_url));
|
||||
if (import_itm.Import_type == Xobc_import_type.Tid__wiki__core) {
|
||||
list.Add(new Xobc_cmd__wiki_reg (task_mgr, task_id, step_id, 5, wiki_dir_url, wiki_domain));
|
||||
}
|
||||
return (Xobc_cmd_itm[])list.To_ary_and_clear(Xobc_cmd_itm.class);
|
||||
}
|
||||
private Io_url Eval_url(String src) {return Io_url_.new_any_(String_.new_u8(eval_mgr.Eval(Bry_.new_u8(src))));}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.steps; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.gfobjs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*;
|
||||
public class Xobc_step_itm {
|
||||
private int cmd_idx = 0;
|
||||
private final Xobc_cmd_itm[] cmds;
|
||||
public Xobc_step_itm(int step_id, int step_seqn, Xobc_cmd_itm[] cmds) {
|
||||
this.step_id = step_id; this.step_seqn = step_seqn; this.cmds = cmds;
|
||||
}
|
||||
public int Step_id() {return step_id;} private final int step_id;
|
||||
public int Step_seqn() {return step_seqn;} private final int step_seqn;
|
||||
public String Step_name() {return step_name;} private String step_name;
|
||||
public Xobc_cmd_itm Cmd() {return cmds[cmd_idx];}
|
||||
public Xobc_step_itm Cmd_idx_(int v) {cmd_idx = v; return this;}
|
||||
public void Cmd_idx_next_() {++cmd_idx;}
|
||||
public boolean Cmd_is_last() {return cmd_idx == cmds.length - 1;}
|
||||
public Xobc_cmd_itm Step_fallback_to(String fallback_id) {
|
||||
int fallback_idx = 0;
|
||||
int len = cmds.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xobc_cmd_itm cmd = cmds[i];
|
||||
if (String_.Eq(cmd.Cmd_type(), fallback_id)) {
|
||||
fallback_idx = cmd.Cmd_id();
|
||||
break;
|
||||
}
|
||||
}
|
||||
cmd_idx = fallback_idx;
|
||||
return Cmd();
|
||||
}
|
||||
public void Step_name_(String v) {this.step_name = v;}
|
||||
public void Step_cleanup() {
|
||||
int len = cmds.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
cmds[i].Cmd_cleanup();
|
||||
}
|
||||
}
|
||||
public Gfobj_nde Save_to(Gfobj_nde nde) {
|
||||
nde.Add_int ("step_id", step_id);
|
||||
nde.Add_str ("step_name", step_name);
|
||||
this.Cmd().Save_to(nde.New_nde("cmd"));
|
||||
return nde; // fluent
|
||||
}
|
||||
|
||||
public static final int Type__wiki_import = 1;
|
||||
public static final int Seqn__0 = 0;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.tasks; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.gfobjs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.steps.*;
|
||||
public class Xobc_task_itm {
|
||||
public Xobc_task_itm(int task_id, int task_seqn, int step_count, String task_key, String task_name) {
|
||||
this.task_id = task_id; this.task_seqn = task_seqn;
|
||||
this.step_count = step_count;
|
||||
this.task_key = task_key;
|
||||
this.task_name = task_name;
|
||||
}
|
||||
public int Task_id() {return task_id;} private final int task_id;
|
||||
public String Task_key() {return task_key;} private final String task_key;
|
||||
public String Task_name() {return task_name;} private final String task_name;
|
||||
public int Step_count() {return step_count;} private final int step_count;
|
||||
public int Task_seqn() {return task_seqn;} private int task_seqn;
|
||||
public byte Task_status() {return task_status;} private byte task_status;
|
||||
public Xobc_step_itm Step() {return step;} public void Step_(Xobc_step_itm v) {this.step = v;} private Xobc_step_itm step;
|
||||
public boolean Step_is_last() {return step.Step_seqn() == step_count - 1;}
|
||||
public void Task_status_(byte v) {task_status = v;} // called when task moves from init -> working -> suspended -> done
|
||||
public void Task_seqn_(int v) {this.task_seqn = v;} // called when task is init'd from db, or added to list
|
||||
|
||||
public Gfobj_nde Save_to(Gfobj_nde nde) {
|
||||
nde.Add_int ("task_id" , task_id);
|
||||
nde.Add_str ("task_name" , task_name);
|
||||
nde.Add_byte("task_status" , task_status);
|
||||
if (step != null) {
|
||||
step.Save_to(nde.New_nde("step"));
|
||||
}
|
||||
return nde; // FLUENT
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.tasks; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.gfobjs.*;
|
||||
public abstract class Xobc_task_regy__base {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
protected final Xobc_task_mgr task_mgr;
|
||||
public Xobc_task_regy__base(Xobc_task_mgr task_mgr, String name) {this.task_mgr = task_mgr; this.name = name;}
|
||||
public String Name() {return name;} private final String name;
|
||||
public int Len() {return hash.Len();}
|
||||
public void Add(Xobc_task_itm t) {hash.Add(t.Task_id(), t);}
|
||||
public void Clear() {hash.Clear();}
|
||||
public Xobc_task_itm Get_at(int i) {return (Xobc_task_itm)hash.Get_at(i);}
|
||||
public Xobc_task_itm Get_by(int i) {return (Xobc_task_itm)hash.Get_by(i);}
|
||||
public void Del_by(int i) {hash.Del(i);}
|
||||
|
||||
public void Save_to(Gfobj_ary ary) {
|
||||
int len = hash.Len();
|
||||
Gfobj_nde[] sub_ndes = new Gfobj_nde[len];
|
||||
ary.Ary_(sub_ndes);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfobj_nde sub_nde = sub_ndes[i] = Gfobj_nde.New();
|
||||
Xobc_task_itm sub_task = (Xobc_task_itm)hash.Get_at(i);
|
||||
sub_task.Save_to(sub_nde);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,11 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.builds.centrals.jobs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*; import gplx.xowa.addons.builds.centrals.*;
|
||||
public interface Xobc_job_itm extends gplx.core.progs.Gfo_prog_ui, GfoInvkAble {
|
||||
String Job_uid();
|
||||
String Job_name();
|
||||
void Write_to_nde(Bry_bfr tmp_bfr, gplx.core.gfobjs.Gfobj_nde itm);
|
||||
Xobc_job_itm Owner();
|
||||
Xobc_job_itm[] Subs();
|
||||
package gplx.xowa.addons.bldrs.centrals.tasks; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
public class Xobc_task_regy__done extends Xobc_task_regy__base {
|
||||
public Xobc_task_regy__done(Xobc_task_mgr task_mgr) {super(task_mgr, "done");}
|
||||
public void Del_done(int task_id) {
|
||||
task_mgr.User_db().Done_task_tbl().Delete(task_id);
|
||||
task_mgr.Transfer(this, task_mgr.Todo_mgr(), this.Get_by(task_id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.tasks; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.gfobjs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.dbs.*;
|
||||
public class Xobc_task_regy__todo extends Xobc_task_regy__base {
|
||||
public Xobc_task_regy__todo(Xobc_task_mgr task_mgr) {super(task_mgr, "todo");}
|
||||
public void Add_work(int task_id) {
|
||||
Xobc_user_db user_db = task_mgr.User_db();
|
||||
Xobc_task_itm task = task_mgr.Todo_mgr().Get_by(task_id);
|
||||
task.Task_status_(gplx.core.progs.Gfo_prog_ui_.Status__init);
|
||||
task.Task_seqn_(task_mgr.Work_mgr().Len());
|
||||
|
||||
// get step_id; default is 1st step with seqn=0, but skip any steps that have already been downloaded; handles user accidentally removing item from work;
|
||||
int step_seqn = Xobc_step_itm.Seqn__0;
|
||||
Hash_adp done_steps = user_db.Done_step_tbl().Select_all(task_id);
|
||||
if (done_steps != null)
|
||||
step_seqn = task_mgr.Data_db().Tbl__step_map().Select_seqn_but_skip_done(task_id, done_steps);
|
||||
int step_id = task_mgr.Data_db().Tbl__step_map().Select_step_id(task_id, step_seqn);
|
||||
|
||||
// load task, cur_step, and all cmds
|
||||
task_mgr.Step_mgr().Load(task, step_id, Xobc_cmd__base.Seqn__0);
|
||||
|
||||
// do transfer
|
||||
user_db.Work_task_tbl().Insert(task_id, task.Task_seqn(), step_id, Xobc_cmd__base.Seqn__0);
|
||||
task_mgr.Transfer(this, task_mgr.Work_mgr(), task);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.tasks; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.gfobjs.*; import gplx.core.progs.*; import gplx.core.threads.*;
|
||||
import gplx.xowa.drds.powers.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.cmds.*;
|
||||
public class Xobc_task_regy__work extends Xobc_task_regy__base {
|
||||
private final Thread_adp_mgr thread_mgr = new Thread_adp_mgr(1000, 5000);
|
||||
private final Xobc_cmd_ctx ctx;
|
||||
public Xobc_task_regy__work(Xobc_task_mgr task_mgr, Xoa_app app) {super(task_mgr, "work");
|
||||
this.ctx = new Xobc_cmd_ctx(app);
|
||||
}
|
||||
public void Del_work(int task_id) {
|
||||
Xobc_task_itm task = this.Get_by(task_id);
|
||||
if (task.Step() != null) task.Step().Step_cleanup();
|
||||
this.Del_task(task, task_mgr.Todo_mgr());
|
||||
}
|
||||
private void Del_task(Xobc_task_itm task, Xobc_task_regy__base trg) {
|
||||
task_mgr.User_db().Work_task_tbl().Delete(task.Task_id());
|
||||
task_mgr.Transfer(this, trg, task);
|
||||
}
|
||||
public void Run_next() {
|
||||
Xod_power_mgr_.Instance.Wake_lock__get("task_mgr");
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xobc_task_itm task = this.Get_at(i);
|
||||
Xobc_cmd_itm cmd = task.Step().Cmd();
|
||||
if (gplx.core.bits.Bitmask_.Has_byte(Gfo_prog_ui_.Status__runnable, cmd.Prog_status())) { // must be runnable
|
||||
Run_task(task, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Run_task(Xobc_task_itm task, Xobc_cmd_itm cmd) {
|
||||
task.Task_status_(gplx.core.progs.Gfo_prog_ui_.Status__working);
|
||||
task_mgr.Send_json("xo.bldr.work.prog__start__recv", task.Save_to(Gfobj_nde.New()));
|
||||
thread_mgr.Add(cmd.Cmd_uid(), Thread_adp_.Start_by_val("xobc: " + cmd.Cmd_name(), cmd, cmd, Xobc_cmd__base.Invk__exec, ctx));
|
||||
}
|
||||
public void Stop_cur() {
|
||||
Xod_power_mgr_.Instance.Wake_lock__rls("task_mgr");
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xobc_task_itm task = this.Get_at(i);
|
||||
Xobc_cmd_itm cmd = task.Step().Cmd();
|
||||
if (gplx.core.bits.Bitmask_.Has_byte(Gfo_prog_ui_.Status__working, cmd.Prog_status())) { // must be runnable
|
||||
Stop_task(cmd.Cmd_uid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Redo_cur() {
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xobc_task_itm task = this.Get_at(i);
|
||||
Xobc_step_itm step = task.Step();
|
||||
Xobc_cmd_itm cmd = step.Cmd();
|
||||
if (gplx.core.bits.Bitmask_.Has_byte(Gfo_prog_ui_.Status__fail, cmd.Prog_status())) { // must be runnable
|
||||
Redo_task(task, step, cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Stop_task(String cmd_uid) {
|
||||
thread_mgr.Halt(cmd_uid, Thread_halt_cbk_.Noop);
|
||||
}
|
||||
private void Redo_task(Xobc_task_itm task, Xobc_step_itm step, Xobc_cmd_itm cmd) {
|
||||
cmd.Cmd_clear();
|
||||
cmd = step.Step_fallback_to(cmd.Cmd_fallback());
|
||||
task.Task_status_(gplx.core.progs.Gfo_prog_ui_.Status__working);
|
||||
task_mgr.Send_json("xo.bldr.work.prog__start__recv", task.Save_to(Gfobj_nde.New()));
|
||||
thread_mgr.Add(cmd.Cmd_uid(), Thread_adp_.Start_by_val("xobc: " + cmd.Cmd_name(), cmd, cmd, Xobc_cmd__base.Invk__exec, ctx));
|
||||
}
|
||||
public void On_done(Xobc_cmd_itm cmd) {
|
||||
Xobc_task_itm task = this.Get_by(cmd.Task_id());
|
||||
Xobc_step_itm step = task.Step();
|
||||
boolean step_is_done = step.Cmd_is_last();
|
||||
boolean task_is_done = step_is_done && task.Step_is_last();
|
||||
task_mgr.Send_json("xo.bldr.work.prog__done__recv", Gfobj_nde.New().Add_int("task_id", task.Task_id()).Add_bool("task_is_done", task_is_done));
|
||||
|
||||
// step.done -> task.done || step.next
|
||||
if (step_is_done) {
|
||||
step.Step_cleanup();
|
||||
task_mgr.User_db().Done_step_tbl().Insert(cmd.Task_id(), cmd.Step_id());
|
||||
// task.done
|
||||
if (task_is_done) {
|
||||
task.Task_status_(Gfo_prog_ui_.Status__done);
|
||||
task_mgr.User_db().Done_task_tbl().Insert(cmd.Task_id(), task.Task_seqn()); // NOTE: this will order by todo's sort, not by actually completed sorted
|
||||
Del_task(task, task_mgr.Done_mgr());
|
||||
}
|
||||
// step.next
|
||||
else {
|
||||
int next_step = task_mgr.Data_db().Tbl__step_map().Select_step_id(task.Task_id(), step.Step_seqn() + 1);
|
||||
task_mgr.Step_mgr().Load(task, next_step, Xobc_cmd__base.Seqn__0);
|
||||
}
|
||||
}
|
||||
// step.work -> cmd.next
|
||||
else {
|
||||
step.Cmd_idx_next_();
|
||||
}
|
||||
|
||||
// task_regy.done
|
||||
if (task_is_done) {
|
||||
if (this.Len() == 0)
|
||||
Xod_power_mgr_.Instance.Wake_lock__rls("task_mgr");
|
||||
else
|
||||
this.Run_next();
|
||||
}
|
||||
// task_regy.work
|
||||
else {
|
||||
cmd = task.Step().Cmd();
|
||||
task_mgr.User_db().Work_task_tbl().Update(cmd.Task_id(), task.Task_seqn(), cmd.Step_id(), cmd.Cmd_id());
|
||||
this.Run_next();
|
||||
}
|
||||
}
|
||||
public void On_suspended(Xobc_cmd_itm cmd) {
|
||||
Xobc_task_itm task = this.Get_by(cmd.Task_id());
|
||||
task.Task_status_(Gfo_prog_ui_.Status__suspended);
|
||||
task_mgr.Send_json("xo.bldr.work.stop_cur__recv", Gfobj_nde.New().Add_int("task_id", task.Task_id()));
|
||||
}
|
||||
public void On_fail(Xobc_cmd_itm task, String msg) {
|
||||
Xod_power_mgr_.Instance.Wake_lock__rls("task_mgr");
|
||||
task_mgr.Send_json("xo.bldr.work.prog__fail__recv", Gfobj_nde.New().Add_int("task_id", task.Task_id()).Add_str("err", msg));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.brys.evals.*;
|
||||
public class Bry_eval_wkr__builder_central implements Bry_eval_wkr {
|
||||
private final byte[] wiki_dir;
|
||||
public Bry_eval_wkr__builder_central(Io_url wiki_dir) {this.wiki_dir = wiki_dir.RawBry();}
|
||||
public String Key() {return "builder_central";}
|
||||
public void Resolve(Bry_bfr rv, byte[] src, int args_bgn, int args_end) {
|
||||
// EX: "~{builder_central|download_fil|en.wikipedia.org|en.wikipedia.org-2016.05-html-ns.000-db.001.zip}" -> "/xowa/wiki/en.wikipedia.org/tmp/bldr/en.wikipedia.org-2016.05-html-ns.000-db.001.zip/download.zip"
|
||||
byte[][] args = Bry_split_.Split(src, args_bgn, args_end, Byte_ascii.Pipe, Bool_.N);
|
||||
int type = hash.Get_as_byte_or(args[0], Byte_.Max_value_127);
|
||||
if (type == Byte_.Max_value_127) throw Err_.new_wo_type("unknown eval type", "src", src);
|
||||
byte dir_spr = gplx.core.envs.Op_sys.Cur().Fsys_dir_spr_byte();
|
||||
rv.Add(wiki_dir); // "/xowa/wiki/"
|
||||
rv.Add(args[1]).Add_byte(dir_spr); // "en.wikipedia.org/"
|
||||
if (type == Type__wiki_dir) return;
|
||||
rv.Add_str_a7("tmp").Add_byte(dir_spr); // "tmp/"
|
||||
rv.Add_str_a7("bldr").Add_byte(dir_spr); // "bldr/"
|
||||
rv.Add(args[2]).Add_byte(dir_spr); // "en.wikipedia.org-2016.05-html-ns.000-db.001.zip/"
|
||||
switch (type) {
|
||||
case Type__download_fil: rv.Add_str_a7("download.zip"); break;
|
||||
case Type__unzip_dir: rv.Add_str_a7("unzip").Add_byte(dir_spr); break;
|
||||
default: throw Err_.new_unhandled_default(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte Type__download_fil = 0, Type__unzip_dir = 1, Type__wiki_dir = 2;
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("download_fil", Type__download_fil)
|
||||
.Add_str_byte("unzip_dir", Type__unzip_dir)
|
||||
.Add_str_byte("wiki_dir", Type__wiki_dir)
|
||||
;
|
||||
public static String Make_str(byte type, String domain, String file_name) {
|
||||
String type_name = null;
|
||||
switch (type) {
|
||||
case Type__download_fil: type_name = "download_fil"; break;
|
||||
case Type__unzip_dir: type_name = "unzip_dir"; break;
|
||||
case Type__wiki_dir: type_name = "wiki_dir"; break;
|
||||
default: throw Err_.new_unhandled_default(type);
|
||||
}
|
||||
return "~{" + String_.Format("builder_central|{0}|{1}|{2}", type_name, domain, file_name) + "}";
|
||||
}
|
||||
public static String Make_str(byte type, String domain) {
|
||||
String type_name = null;
|
||||
switch (type) {
|
||||
case Type__wiki_dir: type_name = "wiki_dir"; break;
|
||||
default: throw Err_.new_unhandled_default(type);
|
||||
}
|
||||
return "~{" + String_.Format("builder_central|{0}|{1}", type_name, domain) + "}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.brys.evals.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Bry_eval_wkr__host_regy implements Bry_eval_wkr {
|
||||
private Xow_domain_itm domain_itm;
|
||||
public String Key() {return "host_regy";}
|
||||
public Bry_eval_wkr__host_regy Domain_itm_(Xow_domain_itm domain_itm) {this.domain_itm = domain_itm; return this;}
|
||||
public void Resolve(Bry_bfr rv, byte[] src, int args_bgn, int args_end) {
|
||||
// EX: "~{host_regy|wiki_abrv}" -> "enwiki"
|
||||
int type = hash.Get_as_byte_or(src, args_bgn, args_end, Byte_.Max_value_127);
|
||||
switch (type) {
|
||||
case Type__wiki_abrv: rv.Add(domain_itm.Abrv_wm()); break;
|
||||
default: throw Err_.new_unhandled_default(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte Type__wiki_abrv = 0;
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("wiki_abrv", Type__wiki_abrv)
|
||||
;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.builds.centrals.jobs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*; import gplx.xowa.addons.builds.centrals.*;
|
||||
package gplx.xowa.addons.bldrs.centrals.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
public class Time_dhms_ {
|
||||
public static String To_str(Bry_bfr bfr, long val, boolean show_unit, int max_places) {To_bfr(bfr, val, show_unit, max_places); return bfr.To_str_and_clear();}
|
||||
public static void To_bfr(Bry_bfr bfr, long val, boolean show_unit, int max_places) {
|
||||
@@ -15,22 +15,22 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.builds.centrals.jobs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*; import gplx.xowa.addons.builds.centrals.*;
|
||||
package gplx.xowa.addons.bldrs.centrals.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Time_dhms__tst {
|
||||
private final Time_dhms__fxt fxt = new Time_dhms__fxt();
|
||||
@Test public void S___0() {fxt.Test__to_str( 0, 4, "0 s");}
|
||||
@Test public void S___1() {fxt.Test__to_str( 1, 4, "1 s");}
|
||||
@Test public void S___2() {fxt.Test__to_str( 30, 4, "30 s");}
|
||||
@Test public void M___1() {fxt.Test__to_str( 60, 4, "1:00 m");}
|
||||
@Test public void M___2() {fxt.Test__to_str( 600, 4, "10:00 m");}
|
||||
@Test public void H___1() {fxt.Test__to_str( 3600, 4, "1:00:00 h");}
|
||||
@Test public void H___2() {fxt.Test__to_str( 5025, 4, "1:23:45 h");}
|
||||
@Test public void D___1() {fxt.Test__to_str( 86400, 4, "1:00:00:00 d");}
|
||||
@Test public void S__0() {fxt.Test__to_str( 0, 4, "0 s");}
|
||||
@Test public void S__1() {fxt.Test__to_str( 1, 4, "1 s");}
|
||||
@Test public void S__2() {fxt.Test__to_str( 30, 4, "30 s");}
|
||||
@Test public void M__1() {fxt.Test__to_str( 60, 4, "1:00 m");}
|
||||
@Test public void M__2() {fxt.Test__to_str( 600, 4, "10:00 m");}
|
||||
@Test public void H__1() {fxt.Test__to_str( 3600, 4, "1:00:00 h");}
|
||||
@Test public void H__2() {fxt.Test__to_str( 5025, 4, "1:23:45 h");}
|
||||
@Test public void D__1() {fxt.Test__to_str( 86400, 4, "1:00:00:00 d");}
|
||||
@Test public void Max_places() {fxt.Test__to_str( 86400, 2, "1:00 d");}
|
||||
}
|
||||
class Time_dhms__fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public Time_dhms__fxt Test__to_str(long v, int max_places, String expd) {
|
||||
Gftest.Eq__str(expd, Time_dhms_.To_str(bfr, v, Bool_.Y, max_places));
|
||||
return this;}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Export_addon implements Xoax_addon_itm, Xoax_addon_itm__bldr {
|
||||
public Xob_cmd[] Bldr_cmds() {
|
||||
return new Xob_cmd[]
|
||||
{ gplx.xowa.addons.bldrs.exports.splits.Split_bldr_cmd.Prototype
|
||||
, gplx.xowa.addons.bldrs.exports.merges.Merge_bldr_cmd.Prototype
|
||||
, gplx.xowa.addons.bldrs.exports.packs.splits.Pack_split_bldr_cmd.Prototype
|
||||
, gplx.xowa.addons.bldrs.exports.packs.files.Pack_file_bldr_cmd.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
public String Addon__key() {return "xowa.builds.repacks";}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xow_db_file_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Len() {return hash.Len();}
|
||||
public Xow_db_file Get_at(int i) {return (Xow_db_file)hash.Get_at(i);}
|
||||
public Xow_db_file_mgr Load_by_type(Xow_db_mgr db_mgr, int type) {
|
||||
int len = db_mgr.Dbs__len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_db_file db_file = db_mgr.Dbs__get_at(i);
|
||||
if (db_file.Tid() != type) continue;
|
||||
hash.Add(db_file.Url().Raw(), db_file);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*;
|
||||
public class Merge2_copy_utl {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private final String tbl_name, fld_pkey, fld_blob;
|
||||
private final boolean tbl_has_blob;
|
||||
private Db_conn conn;
|
||||
public Merge2_copy_utl(String tbl_name, String fld_pkey, String fld_blob, boolean tbl_has_blob) {
|
||||
this.tbl_name = tbl_name;
|
||||
this.fld_pkey = fld_pkey;
|
||||
this.fld_blob = fld_blob;
|
||||
this.tbl_has_blob = tbl_has_blob;
|
||||
}
|
||||
public void Init_conn(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
}
|
||||
public byte[] Select_blob(Db_rdr data_rdr, String fld_blob_pkey) { // NOTE: need to SELECT entire BLOB; cannot UPDATE in 1 MB increments b/c SQLite does not really concat BLOBS; REF.SQLITE: http://sqlite.1065341.n5.nabble.com/Append-data-to-a-BLOB-field-td46003.html
|
||||
int id = data_rdr.Read_int(fld_blob_pkey);
|
||||
int len_max = data_rdr.Read_int("blob_len");
|
||||
int len_cur = 1, len_gap = 1000000;
|
||||
while (len_cur < len_max) {
|
||||
// determine substr args; EX: Substr(blob_col, 1, 1000000); Substr(blob_col, 1000001, 1000000); Substr(blob_col, 2000001, 1234);
|
||||
int len_new = len_cur + len_gap;
|
||||
if (len_new >= len_max) len_gap = len_max - len_cur; // last SELECT; Substr remainder, not full 1 MB
|
||||
|
||||
// read data; note that stmt needs to be new'd for each loop b/c SQL is different
|
||||
Db_stmt stmt = conn.Stmt_sql(String_.Format(String_.Concat_lines_nl_skip_last // ANSI.N; NOTE: will only run on Android SQLite
|
||||
( "SELECT Substr({0}, {1}, {2}) AS blob_data"
|
||||
, "FROM {3}"
|
||||
, "WHERE {4} = {5}"
|
||||
), fld_blob, len_cur, len_gap, tbl_name, fld_pkey, id));
|
||||
Db_rdr rdr = stmt.Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next())
|
||||
bfr.Add(rdr.Read_bry("blob_data"));
|
||||
else
|
||||
throw Err_.new_wo_type("failed to read blob in increments", "id", id, "len_cur", len_cur);
|
||||
}
|
||||
finally {
|
||||
rdr.Rls();
|
||||
stmt.Rls();
|
||||
}
|
||||
|
||||
len_cur = len_new;
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public String Bld_sql(Dbmeta_fld_list flds, int flds_end, boolean src_is_pack, byte mode, int resume__db_id) {
|
||||
bfr.Add_str_a7("SELECT");
|
||||
for (int i = 0; i < flds_end; ++i) {
|
||||
bfr.Add_str_a7(i == 0 ? " " : ", ");
|
||||
bfr.Add_str_u8(flds.Get_at(i).Name());
|
||||
}
|
||||
bfr.Add_str_u8(Bld_select_fld(mode));
|
||||
bfr.Add_str_a7("\nFROM ").Add_str_u8(tbl_name);
|
||||
if (!src_is_pack) {
|
||||
}
|
||||
else {
|
||||
bfr.Add_str_a7("\nWHERE ");
|
||||
if (src_is_pack) {
|
||||
bfr.Add_str_a7("trg_db_id >= ");
|
||||
bfr.Add_int_variable(resume__db_id);
|
||||
if (mode != Merge2_copy_utl.Mode__all)
|
||||
bfr.Add_str_a7("\nAND ");
|
||||
}
|
||||
bfr.Add_str_a7(Bld_where(mode));
|
||||
}
|
||||
if (!src_is_pack) {
|
||||
bfr.Add_str_a7("\nORDER BY ");
|
||||
bfr.Add_str_u8(fld_pkey);
|
||||
}
|
||||
else {
|
||||
bfr.Add_str_a7("\nORDER BY trg_db_id, ");
|
||||
bfr.Add_str_u8(fld_pkey);
|
||||
}
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public String Bld_select_fld(byte mode) {
|
||||
switch (mode) {
|
||||
case Merge2_copy_utl.Mode__all:
|
||||
case Merge2_copy_utl.Mode__drd__small: return tbl_has_blob ? ", " + fld_blob : "";
|
||||
case Merge2_copy_utl.Mode__drd__large: return ", blob_len";
|
||||
default: throw Err_.new_unhandled_default(mode);
|
||||
}
|
||||
}
|
||||
public String Bld_where(byte mode) {
|
||||
switch (mode) {
|
||||
case Merge2_copy_utl.Mode__all: return "";
|
||||
case Merge2_copy_utl.Mode__drd__small: return "blob_len <= 1000000";
|
||||
case Merge2_copy_utl.Mode__drd__large: return "blob_len > 1000000";
|
||||
default: throw Err_.new_unhandled_default(mode);
|
||||
}
|
||||
}
|
||||
public static final byte Mode__all = 0, Mode__drd__small = 1, Mode__drd__large = 2;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
class Merge2_copy_wkr__lot {
|
||||
private final Split_tbl tbl;
|
||||
private final String tbl_name, fld_blob_pkey, fld_blob_data;
|
||||
private final Merge2_copy_utl copy_utl;
|
||||
private int resume__db_id;
|
||||
private boolean tbl_has_blob;
|
||||
public Merge2_copy_wkr__lot(Split_tbl tbl) {
|
||||
this.tbl = tbl;
|
||||
this.tbl_name = tbl.Tbl_name();
|
||||
this.fld_blob_pkey = tbl.Fld_pkeys()[0];
|
||||
this.fld_blob_data = tbl.Fld_blob();
|
||||
this.tbl_has_blob = Split_tbl_.Tbl_has_blob(tbl);
|
||||
this.copy_utl = new Merge2_copy_utl(tbl.Tbl_name(), fld_blob_pkey, fld_blob_data, tbl_has_blob);
|
||||
}
|
||||
public void Copy_by_sql(String msg, Merge_ctx ctx, Merge_prog_wkr prog_wkr, Db_conn src_conn, Merge2_trg_itm trg_db, Merge2_trg_mgr trg_mgr, boolean src_is_pack) {
|
||||
Xow_wiki wiki = ctx.Wiki();
|
||||
if (src_is_pack) {
|
||||
int[] trg_db_idxs = Get_trg_dbs(src_conn, tbl_name);
|
||||
int trg_db_idxs_len = trg_db_idxs.length;
|
||||
for (int i = 0; i < trg_db_idxs_len; ++i) {
|
||||
int trg_db_id = trg_db_idxs[i];
|
||||
Merge2_trg_itm trg_db_new = trg_mgr.Cur_or_new(ctx, prog_wkr, wiki, trg_db_id);
|
||||
Copy_by_trg_conn(msg, prog_wkr, src_conn, trg_db_new, trg_db_id, src_is_pack);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Copy_by_trg_conn(msg, prog_wkr, src_conn, trg_db, trg_db.Idx(), src_is_pack);
|
||||
}
|
||||
}
|
||||
private void Copy_by_trg_conn(String msg, Merge_prog_wkr prog_wkr, Db_conn src_conn, Merge2_trg_itm trg_db, int trg_db_id, boolean src_is_pack) {
|
||||
Dbmeta_fld_list src_flds = tbl.Flds().Clone(); // src_flds.Insert(0, Dbmeta_fld_itm.new_int("trg_db_id"));
|
||||
Merge_wkr_utl.Merge_by_sql(prog_wkr, msg, tbl.Tbl_name(), src_flds, src_conn, trg_db, trg_db_id, !src_is_pack);
|
||||
}
|
||||
private int[] Get_trg_dbs(Db_conn conn, String tbl_name) {
|
||||
List_adp list = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_sql(String_.Format("SELECT trg_db_id FROM {0} GROUP BY trg_db_id", tbl_name)).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
list.Add(rdr.Read_int("trg_db_id"));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
return (int[])list.To_ary_and_clear(int.class);
|
||||
}
|
||||
public void Copy_entire_src(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Db_conn src_conn, Merge2_trg_itm trg_db, Merge2_trg_mgr trg_mgr, boolean src_is_pack) {
|
||||
Xow_wiki wiki = ctx.Wiki();
|
||||
|
||||
if (gplx.core.envs.Op_sys.Cur().Tid_is_drd() && tbl_has_blob) {
|
||||
Copy_rows(ctx, prog_wkr, wiki, tbl, src_conn, trg_db, trg_mgr, src_is_pack, Merge2_copy_utl.Mode__drd__small);
|
||||
Copy_rows(ctx, prog_wkr, wiki, tbl, src_conn, trg_db, trg_mgr, src_is_pack, Merge2_copy_utl.Mode__drd__large);
|
||||
}
|
||||
else
|
||||
Copy_rows(ctx, prog_wkr, wiki, tbl, src_conn, trg_db, trg_mgr, src_is_pack, Merge2_copy_utl.Mode__all);
|
||||
}
|
||||
private void Copy_rows(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Xow_wiki wiki, Split_tbl tbl, Db_conn src_conn, Merge2_trg_itm trg_db, Merge2_trg_mgr trg_mgr, boolean src_is_pack, byte select_mode) {
|
||||
// init src
|
||||
Dbmeta_fld_list src_flds = tbl.Flds().Clone();
|
||||
if (src_is_pack)
|
||||
src_flds.Insert(0, Dbmeta_fld_itm.new_int("trg_db_id"));
|
||||
int flds_nth = src_flds.Len();
|
||||
if (tbl_has_blob) {
|
||||
Split_tbl_.Flds__add_blob_len(src_flds);
|
||||
flds_nth = src_flds.Len() - 1; // ignore blob which is last fld by convention
|
||||
}
|
||||
String src_sql = copy_utl.Bld_sql(src_flds, flds_nth, src_is_pack, select_mode, resume__db_id);
|
||||
Db_rdr src_rdr = src_conn.Stmt_sql(src_sql).Exec_select__rls_auto();
|
||||
copy_utl.Init_conn(src_conn);
|
||||
|
||||
Dbmeta_fld_list trg_flds = tbl.Flds().Clone();
|
||||
if (tbl_has_blob && src_is_pack) {
|
||||
Split_tbl_.Flds__add_blob_len(trg_flds);
|
||||
}
|
||||
|
||||
Db_stmt trg_stmt = null; Db_conn trg_conn = null; int cur_trg = -1;
|
||||
if (trg_db != null) {
|
||||
trg_conn = trg_db.Conn();
|
||||
trg_conn.Txn_bgn("merge_" + tbl_name);
|
||||
trg_stmt = trg_conn.Stmt_insert(tbl_name, trg_flds);
|
||||
cur_trg = trg_db.Idx();
|
||||
}
|
||||
try {
|
||||
while (src_rdr.Move_next()) {
|
||||
// switch trg_db if null, or diff than cur; note that trg_stmt also changes
|
||||
if (src_is_pack) {
|
||||
int trg_db_id = src_rdr.Read_int("trg_db_id");
|
||||
if (cur_trg != trg_db_id) {
|
||||
if (trg_conn != null) trg_conn.Txn_end();
|
||||
trg_conn = trg_mgr.Cur_or_new(ctx, prog_wkr, wiki, trg_db_id).Conn();
|
||||
trg_conn.Txn_bgn("merge_" + tbl_name);
|
||||
trg_stmt = trg_conn.Stmt_insert(tbl_name, trg_flds);
|
||||
cur_trg = trg_db_id;
|
||||
resume__db_id = trg_db_id;
|
||||
prog_wkr.Checkpoint__save();
|
||||
}
|
||||
}
|
||||
|
||||
// read and insert
|
||||
trg_stmt.Clear();
|
||||
gplx.dbs.diffs.Gfdb_rdr_utl_.Stmt_args(trg_stmt, trg_flds, 0, trg_flds.Len() - (tbl_has_blob ? 1 : 0), src_rdr);
|
||||
if (tbl_has_blob) {
|
||||
byte[] val_blob = select_mode == Merge2_copy_utl.Mode__drd__large
|
||||
? copy_utl.Select_blob(src_rdr, fld_blob_pkey)
|
||||
: src_rdr.Read_bry(fld_blob_data);
|
||||
trg_stmt.Val_bry(fld_blob_data , val_blob);
|
||||
}
|
||||
trg_stmt.Exec_insert();
|
||||
|
||||
if (prog_wkr.Prog__insert_and_stop_if_suspended(0)) break;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
src_rdr.Rls();
|
||||
if (trg_conn != null) {
|
||||
trg_conn.Txn_end();
|
||||
}
|
||||
trg_stmt = Db_stmt_.Rls(trg_stmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
2 situations:
|
||||
- pack (trg_db,blob_len,*) -> heap (blob_len,*)
|
||||
- heap (blob_len,*) -> wiki (*)
|
||||
*/
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
public class Merge2_heap_db implements Merge2_trg_itm {
|
||||
public Merge2_heap_db(Split_tbl tbl, Dbmeta_fld_list flds, int idx, Io_url url, Db_conn conn) {
|
||||
this.tbl = tbl; this.flds = flds; this.idx = idx;
|
||||
this.url = url; this.conn = conn;
|
||||
}
|
||||
public Split_tbl Tbl() {return tbl;} private final Split_tbl tbl;
|
||||
public Dbmeta_fld_list Flds() {return flds;} private final Dbmeta_fld_list flds;
|
||||
public int Idx() {return idx;} private final int idx;
|
||||
public Io_url Url() {return url;} private final Io_url url;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
public class Merge2_heap_mgr {// data tbls will only have 1 itms; blob tbls will have N itms
|
||||
private final Split_tbl tbl;
|
||||
private final List_adp list = List_adp_.New(), deleted = List_adp_.New();
|
||||
private Dbmeta_fld_list heap_flds;
|
||||
public Merge2_heap_mgr(Split_tbl tbl) {this.tbl = tbl;}
|
||||
public Merge2_heap_db Cur() {return cur;} private Merge2_heap_db cur;
|
||||
public Merge2_heap_db Make_itm(Xow_wiki wiki, int trg_db_id) {
|
||||
// clone tbl_flds; disable primary key
|
||||
this.heap_flds = tbl.Flds().Clone();
|
||||
int len = heap_flds.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbmeta_fld_itm itm = heap_flds.Get_at(i);
|
||||
if (itm.Primary()) itm.Primary_n_();
|
||||
}
|
||||
|
||||
// if blob, add "blob_len" in penultimate pos; note that last fld is "blob_fld"
|
||||
// if (Split_tbl_.Tbl_has_blob(tbl))
|
||||
// Split_tbl_.Flds__add_blob_len(heap_flds);
|
||||
|
||||
// init heap_conn
|
||||
String tbl_name = tbl.Tbl_name();
|
||||
Io_url heap_dir = wiki.Fsys_mgr().Root_dir().GenSubDir_nest("tmp", "merge", tbl_name);
|
||||
Io_url heap_url = heap_dir.GenSubFil(String_.Format("xowa.merge.temp.{0}{1}.sqlite3", tbl_name, trg_db_id == -1 ? "" : "." + Int_.To_str_pad_bgn_zero(trg_db_id, 4)));
|
||||
Db_conn_bldr_data bldr_data = Db_conn_bldr.Instance.Get_or_new(heap_url);
|
||||
Db_conn heap_conn = bldr_data.Conn();
|
||||
if (bldr_data.Created())
|
||||
heap_conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, heap_flds));
|
||||
|
||||
// make itm and return it
|
||||
Merge2_heap_db rv = new Merge2_heap_db(tbl, heap_flds, trg_db_id, heap_url, heap_conn);
|
||||
this.Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public void Copy_to_wiki(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_wkr__heap_base wkr) {
|
||||
// do copy for all itms; only 1 itm for page, fsdb_fil, etc..; but many for html, fsdb_bin
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
Copy_to_wiki__itm(ctx, prog_wkr, wkr, this.Get_at(i), i == len - 1);
|
||||
|
||||
// delete any old dbs
|
||||
len = deleted.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Merge2_heap_db itm = (Merge2_heap_db)deleted.Get_at(i);
|
||||
list.Del(itm);
|
||||
}
|
||||
deleted.Clear();
|
||||
|
||||
// if last idx, cleanup
|
||||
if (ctx.Heap__last_idx()) this.Cleanup();
|
||||
}
|
||||
public void Cleanup() {
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
Cleanup_file(this.Get_at(i));
|
||||
}
|
||||
private Merge2_heap_db Get_at(int i) {return (Merge2_heap_db)list.Get_at(i);}
|
||||
private void Add(Merge2_heap_db itm) {
|
||||
list.Add(itm);
|
||||
cur = itm;
|
||||
}
|
||||
private void Copy_to_wiki__itm(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_wkr__heap_base wkr, Merge2_heap_db itm, boolean itm_is_cur) {
|
||||
// init
|
||||
Split_tbl tbl = wkr.Tbl();
|
||||
String tbl_name = tbl.Tbl_name();
|
||||
Db_conn heap_conn = itm.Conn();
|
||||
Dbmeta_fld_list tbl_flds = tbl.Flds();
|
||||
Db_conn wiki_conn = tbl.Wiki_conn__get_or_new(ctx.Wiki(), itm.Idx());
|
||||
|
||||
// index heap table
|
||||
// String[] pkey_flds = tbl.Fld_pkeys();
|
||||
// heap_conn.Meta_idx_create(tbl_name, "sort", pkey_flds);
|
||||
|
||||
// do bulk copy into wiki tbls; note ORDER BY
|
||||
wkr.Copy_to_wiki(ctx, prog_wkr, tbl_name, tbl_flds, heap_conn, new Merge2_trg_itm__wiki(itm.Idx(), wiki_conn), String_.Ary_empty);
|
||||
|
||||
// cleanup
|
||||
if (itm_is_cur) { // if cur, rebuild heap table; vaccum;
|
||||
// heap_conn.Meta_tbl_remake(Dbmeta_tbl_itm.New(tbl_name, heap_flds));
|
||||
// heap_conn.Env_vacuum();
|
||||
heap_conn.Rls_conn();
|
||||
Io_mgr.Instance.DeleteFil(itm.Url()); // SQLite: file delete is faster than DROP TABLE or DELETE FROM
|
||||
heap_conn.Reopen_conn();
|
||||
heap_conn.Meta_tbl_remake(Dbmeta_tbl_itm.New(tbl_name, heap_flds));
|
||||
}
|
||||
else { // else, delete file; EX: fsdb_bin has 2 heap files; delete 1st, but still keep 2nd
|
||||
Cleanup_file(itm);
|
||||
deleted.Add(itm);
|
||||
}
|
||||
}
|
||||
private void Cleanup_file(Merge2_heap_db itm) {
|
||||
itm.Conn().Rls_conn();
|
||||
Io_mgr.Instance.DeleteFil(itm.Url());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
public class Merge2_mgr {
|
||||
public final Merge_ctx ctx;
|
||||
private final Ordered_hash wkr_hash;
|
||||
|
||||
public Merge2_mgr() {
|
||||
this.ctx = new Merge_ctx();
|
||||
this.wkr_hash = Make_wkrs
|
||||
( new Merge2_wkr__heap_one(Split_tbl_.Page)
|
||||
, new Merge2_wkr__heap_lot(Split_tbl_.Html)
|
||||
, new Merge2_wkr__heap_one(Split_tbl_.Srch_word)
|
||||
, new Merge2_wkr__heap_lot(Split_tbl_.Srch_link)
|
||||
, new Merge2_wkr__heap_one(Split_tbl_.Fsdb_fil)
|
||||
, new Merge2_wkr__heap_one(Split_tbl_.Fsdb_thm)
|
||||
, new Merge2_wkr__heap_one(Split_tbl_.Fsdb_org)
|
||||
, new Merge2_wkr__heap_lot(Split_tbl_.Fsdb_bin)
|
||||
);
|
||||
}
|
||||
public void Prog_wkr_(Merge_prog_wkr prog_wkr) {this.prog_wkr = prog_wkr;} private Merge_prog_wkr prog_wkr;
|
||||
public void Merge_core(Xow_wiki wiki, Io_url src_url) {
|
||||
Db_conn src_conn = Db_conn_bldr.Instance.Get_or_autocreate(false, src_url);
|
||||
new Merge_wkr__core().Copy_to_temp(null, wiki, src_conn);
|
||||
Gfo_invk_.Invk_by_val(wiki.App().Wiki_mgri(), gplx.xowa.wikis.Xoa_wiki_mgr_.Invk__import_by_url, src_url);
|
||||
src_conn.Rls_conn(); // NOTE: must close conn else pack_conn will stay open
|
||||
// fails b/c no Main_Page; Gfo_invk_.Invk_by_msg(wiki.App().Gui__tab_mgr(), gplx.xowa.guis.tabs.Xog_tab_mgr_.Invk__new_tab, GfoMsg_.new_cast_("").Add("focus", true).Add("site", wiki.Domain_str()).Add("page", String_.new_u8(wiki.Props().Main_page())));
|
||||
}
|
||||
public void Merge_data(Xow_wiki wiki, Io_url src_url, int idx_cur) {
|
||||
long all_time_bgn = gplx.core.envs.Env_.TickCount();
|
||||
wiki.Init_by_wiki();
|
||||
Db_conn src_conn = Db_conn_bldr.Instance.Get_or_autocreate(false, src_url);
|
||||
ctx.Init(wiki, src_conn);
|
||||
|
||||
// merge data
|
||||
int hash_len = wkr_hash.Len();
|
||||
for (int i = 0; i < hash_len; ++i) {
|
||||
if (prog_wkr.Canceled()) break;
|
||||
Merge2_wkr wkr = (Merge2_wkr)wkr_hash.Get_at(i);
|
||||
// if (prog_wkr.Checkpoint__skip_wkr(src_url, wkr.Tbl_name())) continue;
|
||||
long wkr_time_bgn = gplx.core.envs.Env_.TickCount();
|
||||
wkr.Merge_data(ctx, prog_wkr);
|
||||
Gfo_log_.Instance.Info("merge.wkr.done", "data", src_url.NameAndExt() + "|" + wkr.Tbl().Tbl_name() + "|" + gplx.core.envs.Env_.TickCount_elapsed_in_frac(wkr_time_bgn));
|
||||
}
|
||||
if (ctx.Heap__copy_to_wiki()) ctx.Heap__increment_nxt();
|
||||
Gfo_log_.Instance.Info("merge.wkr.done", "data", src_url.NameAndExt() + "|-1|" + gplx.core.envs.Env_.TickCount_elapsed_in_frac(all_time_bgn));
|
||||
src_conn.Rls_conn(); // NOTE: must close conn else pack_conn will stay open
|
||||
}
|
||||
private static Ordered_hash Make_wkrs(Merge2_wkr... wkrs) {
|
||||
Ordered_hash rv = Ordered_hash_.New();
|
||||
for (Merge2_wkr wkr : wkrs)
|
||||
rv.Add(wkr.Tbl().Tbl_name(), wkr);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*;
|
||||
public interface Merge2_trg_itm {
|
||||
int Idx();
|
||||
Db_conn Conn();
|
||||
}
|
||||
class Merge2_trg_itm__wiki implements Merge2_trg_itm {
|
||||
public Merge2_trg_itm__wiki(int idx, Db_conn conn) {this.idx = idx; this.conn = conn;}
|
||||
public int Idx() {return idx;} private final int idx;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
interface Merge2_trg_mgr {
|
||||
Merge2_trg_itm Cur();
|
||||
Merge2_trg_itm Cur_or_new(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Xow_wiki wiki, int trg_db_id);
|
||||
}
|
||||
class Merge2_trg_mgr__heap implements Merge2_trg_mgr {
|
||||
private final Merge2_heap_mgr heap_mgr;
|
||||
public Merge2_trg_mgr__heap(Merge2_heap_mgr heap_mgr) {this.heap_mgr = heap_mgr;}
|
||||
public Merge2_trg_itm Cur() {return heap_mgr.Cur();}
|
||||
public Merge2_trg_itm Cur_or_new(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Xow_wiki wiki, int trg_db_id) {
|
||||
Merge2_heap_db cur = heap_mgr.Cur();
|
||||
if (cur == null || cur.Idx() != trg_db_id) {
|
||||
cur = heap_mgr.Make_itm(ctx.Wiki(), trg_db_id);
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
class Merge2_trg_mgr__wiki implements Merge2_trg_mgr {
|
||||
private final Split_tbl tbl;
|
||||
public Merge2_trg_mgr__wiki(Split_tbl tbl) {this.tbl = tbl;}
|
||||
public Merge2_trg_itm Cur() {return cur;} private Merge2_trg_itm__wiki cur;
|
||||
public Merge2_trg_itm Cur_or_new(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Xow_wiki wiki, int trg_db_id) {
|
||||
if (cur == null || cur.Idx() != trg_db_id) {
|
||||
Db_conn conn = tbl.Wiki_conn__get_or_new(wiki, trg_db_id);
|
||||
cur = new Merge2_trg_itm__wiki(trg_db_id, conn);
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,9 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.builds.centrals.jobs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*; import gplx.xowa.addons.builds.centrals.*;
|
||||
public class Xobc_job_itm_ {
|
||||
public static final Xobc_job_itm[] Ary_empty = new Xobc_job_itm[0];
|
||||
public static final Xobc_job_itm Null = null;
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
interface Merge2_wkr {
|
||||
Split_tbl Tbl();
|
||||
void Merge_data(Merge_ctx ctx, Merge_prog_wkr prog_wkr);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
public abstract class Merge2_wkr__heap_base implements Merge2_wkr {
|
||||
public Merge2_wkr__heap_base(Split_tbl tbl) {
|
||||
this.tbl = tbl;
|
||||
this.heap_mgr = new Merge2_heap_mgr(tbl);
|
||||
}
|
||||
public Split_tbl Tbl() {return tbl;} private final Split_tbl tbl;
|
||||
protected Merge2_heap_mgr Heap_mgr() {return heap_mgr;} private final Merge2_heap_mgr heap_mgr;
|
||||
public void Merge_data(Merge_ctx ctx, Merge_prog_wkr prog_wkr) { // fires once per file
|
||||
this.Copy_to_heap(ctx, prog_wkr, heap_mgr, tbl);
|
||||
this.Copy_to_wiki(ctx, prog_wkr, heap_mgr, tbl);
|
||||
}
|
||||
protected abstract void Copy_to_heap(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_heap_mgr heap_mgr, Split_tbl tbl);
|
||||
protected abstract void Copy_to_wiki(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_heap_mgr heap_mgr, Split_tbl tbl);
|
||||
public abstract void Copy_to_wiki(Merge_ctx ctx, Merge_prog_wkr prog_wkr, String tbl_name, Dbmeta_fld_list src_flds, Db_conn src_conn, Merge2_trg_itm trg_db, String[] fld_pkeys);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
public class Merge2_wkr__heap_lot extends Merge2_wkr__heap_base {
|
||||
private final Merge2_copy_wkr__lot copy_wkr;
|
||||
private final Merge2_trg_mgr trg_mgr__heap;
|
||||
public Merge2_wkr__heap_lot(Split_tbl tbl) {super(tbl);
|
||||
this.copy_wkr = new Merge2_copy_wkr__lot(tbl);
|
||||
this.trg_mgr__heap = new Merge2_trg_mgr__heap(this.Heap_mgr());
|
||||
}
|
||||
@Override protected void Copy_to_heap(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_heap_mgr heap_mgr, Split_tbl tbl) {
|
||||
copy_wkr.Copy_by_sql("merging " + tbl.Tbl_name(), ctx, prog_wkr, ctx.Pack_conn(), null, trg_mgr__heap, Bool_.Y);
|
||||
// copy_wkr.Copy_entire_src(ctx, prog_wkr, ctx.Pack_conn(), null, trg_mgr__heap, Bool_.Y);
|
||||
}
|
||||
@Override protected void Copy_to_wiki(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_heap_mgr heap_mgr, Split_tbl tbl) {
|
||||
if (ctx.Heap__copy_to_wiki())
|
||||
heap_mgr.Copy_to_wiki(ctx, prog_wkr, this);
|
||||
}
|
||||
@Override public void Copy_to_wiki(Merge_ctx ctx, Merge_prog_wkr prog_wkr, String tbl_name, Dbmeta_fld_list trg_flds, Db_conn src_conn, Merge2_trg_itm trg_db, String[] fld_pkeys) {
|
||||
copy_wkr.Copy_by_sql("merging " + tbl_name, ctx, prog_wkr, src_conn, trg_db, trg_mgr__heap, Bool_.N);
|
||||
// copy_wkr.Copy_entire_src(ctx, prog_wkr, src_conn, trg_db, trg_mgr__heap, Bool_.N);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
public class Merge2_wkr__heap_one extends Merge2_wkr__heap_base {
|
||||
public Merge2_wkr__heap_one(Split_tbl tbl) {super(tbl);}
|
||||
@Override protected void Copy_to_heap(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_heap_mgr heap_mgr, Split_tbl tbl) {
|
||||
// init
|
||||
String tbl_name = tbl.Tbl_name();
|
||||
Dbmeta_fld_list flds = tbl.Flds();
|
||||
Merge2_heap_db heap_db = heap_mgr.Cur();
|
||||
if (heap_db == null) heap_db = heap_mgr.Make_itm(ctx.Wiki(), -1);
|
||||
|
||||
// copy
|
||||
Merge_wkr_utl.Merge_by_sql(prog_wkr, "merging " + tbl_name, tbl_name, flds, ctx.Pack_conn(), heap_db, -1, Bool_.N);
|
||||
}
|
||||
@Override protected void Copy_to_wiki(Merge_ctx ctx, Merge_prog_wkr prog_wkr, Merge2_heap_mgr heap_mgr, Split_tbl tbl) {
|
||||
if (ctx.Heap__copy_to_wiki())
|
||||
heap_mgr.Copy_to_wiki(ctx, prog_wkr, this);
|
||||
}
|
||||
@Override public void Copy_to_wiki(Merge_ctx ctx, Merge_prog_wkr prog_wkr, String tbl_name, Dbmeta_fld_list trg_flds, Db_conn src_conn, Merge2_trg_itm trg_db, String[] fld_pkeys) {
|
||||
Merge_wkr_utl.Merge_by_sql(prog_wkr, "merging " + tbl_name, tbl_name, trg_flds, src_conn, trg_db, -1, Bool_.Y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.xowa.addons.bldrs.exports.splits.mgrs.*; import gplx.xowa.addons.bldrs.exports.splits.rslts.*;
|
||||
public class Merge_bldr_cmd extends Xob_cmd__base {
|
||||
public Merge_bldr_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
Io_mgr.Instance.DeleteDirDeep(wiki.Fsys_mgr().Root_dir());
|
||||
wiki.Init_assert();
|
||||
|
||||
Merge2_mgr merge_mgr = new Merge2_mgr();
|
||||
Io_url[] urls = Io_mgr.Instance.QueryDir_fils(Io_url_.new_fil_("C:\\xowa\\wiki\\simple.wikipedia.org\\tmp\\split\\"));
|
||||
int i = 0;
|
||||
for (Io_url url : urls) {
|
||||
// if (++i == 5) break;
|
||||
switch (Split_file_tid_.To_tid(url)) {
|
||||
case Split_file_tid_.Tid__core: merge_mgr.Merge_core(wiki, url); break;
|
||||
case Split_file_tid_.Tid__data:
|
||||
Db_conn conn = Db_conn_bldr.Instance.Get_or_noop(url);
|
||||
Wkr_stats_tbl stats_tbl = new Wkr_stats_tbl(conn);
|
||||
Wkr_stats_itm summary_itm = stats_tbl.Select_all__summary();
|
||||
Merge_prog_wkr prog_wkr = new Merge_prog_wkr(gplx.core.progs.Gfo_prog_ui_.Always, url.GenNewNameAndExt("merge.checkpoint"), summary_itm.Count, summary_itm.Size);
|
||||
merge_mgr.Prog_wkr_(prog_wkr);
|
||||
merge_mgr.Merge_data(wiki, url, i); break;
|
||||
default: continue;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String BLDR_CMD_KEY = "bldr.export.merge";
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;}
|
||||
public static final Xob_cmd Prototype = new Merge_bldr_cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Merge_bldr_cmd(bldr, wiki);}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*;
|
||||
public class Merge_ctx {
|
||||
public void Init(Xow_wiki wiki, Db_conn pack_conn) {
|
||||
this.wiki = wiki;
|
||||
this.pack_conn = pack_conn;
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public Db_conn Pack_conn() {return pack_conn;} private Db_conn pack_conn;
|
||||
public int Idx_cur() {return idx_cur;} private int idx_cur; public void Idx_cur_add_() {++idx_cur;}
|
||||
public int Idx_end = 70;
|
||||
public int Idx_gap = 10;
|
||||
public int Idx_nxt = 10;
|
||||
public boolean Heap__copy_to_wiki() {return idx_cur == Idx_nxt || idx_cur == Idx_end;}
|
||||
public void Heap__increment_nxt() {Idx_nxt += Idx_gap;}
|
||||
public boolean Heap__last_idx() {return idx_cur == Idx_end;}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
public class Merge_prog_checkpoint {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private final Io_url url;
|
||||
private String resume_fil;
|
||||
private int resume_wkr = -1;
|
||||
private int resume_db = -1;
|
||||
public Merge_prog_checkpoint(Io_url url) {this.url = url;}
|
||||
public int Resume_db() {return resume_db;}
|
||||
public boolean Skip_fil(Io_url fil) {
|
||||
if (resume_fil == null) return false; // not resume; do not skip
|
||||
boolean rv = String_.Eq(fil.NameAndExt(), resume_fil);
|
||||
if (rv) resume_fil = null; // null out for next call
|
||||
return !rv;
|
||||
}
|
||||
public boolean Skip_wkr(byte wkr_tid) {
|
||||
if (resume_wkr == -1) return false; // not resume; do not skip;
|
||||
boolean rv = wkr_tid == resume_wkr;
|
||||
if (rv) resume_wkr = -1; // null out for next call
|
||||
return !rv;
|
||||
}
|
||||
public int Load() {
|
||||
byte[] bry = Io_mgr.Instance.LoadFilBryOrNull(url); if (bry == null) return 0;
|
||||
byte[][] parts = Bry_split_.Split(bry, Byte_ascii.Pipe);
|
||||
this.resume_fil = String_.new_u8(parts[0]);
|
||||
this.resume_wkr = Bry_.To_int(parts[1]);
|
||||
this.resume_db = Bry_.To_int(parts[2]);
|
||||
return Bry_.To_int(parts[3]);
|
||||
}
|
||||
public void Save(Io_url fil, byte wkr_tid, int db_id, int prog_count) { // EX: file.xowa|0|4|1234
|
||||
if (fil == null) return;
|
||||
bfr.Add_str_u8(fil.NameAndExt()).Add_byte_pipe();
|
||||
bfr.Add_int_variable(wkr_tid).Add_byte_pipe();
|
||||
bfr.Add_int_variable(db_id).Add_byte_pipe();
|
||||
bfr.Add_int_variable(prog_count);
|
||||
Io_mgr.Instance.SaveFilBry(url, bfr.To_bry_and_clear());
|
||||
}
|
||||
public void Delete() {
|
||||
resume_fil = null;
|
||||
resume_wkr = -1;
|
||||
resume_db = -1;
|
||||
Io_mgr.Instance.DeleteFil(url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.core.progs.*; import gplx.dbs.bulks.*;
|
||||
public class Merge_prog_wkr implements Db_bulk_prog {
|
||||
private final Gfo_prog_ui prog_ui;
|
||||
private final Merge_prog_checkpoint checkpoint;
|
||||
private final int prog_count_end;
|
||||
private int prog_count_cur;
|
||||
private long time_nxt, time_gap = 100;
|
||||
// private final int[] mergepoint_ary = new int[gplx.xowa.addons.bldrs.exports.splits.rslts.Split_rslt_tid_.Tid_max];
|
||||
public Merge_prog_wkr(Gfo_prog_ui prog_ui, Io_url checkpoint_fil, int prog_count_end, long prog_size_end) {
|
||||
this.prog_ui = prog_ui;
|
||||
this.checkpoint = new Merge_prog_checkpoint(checkpoint_fil);
|
||||
this.prog_count_end = prog_count_end;
|
||||
}
|
||||
public boolean Canceled() {return prog_ui.Canceled();}
|
||||
public long Checkpoint__load() {
|
||||
long rv = checkpoint.Load();
|
||||
this.prog_count_cur = (int)rv;
|
||||
return rv;
|
||||
}
|
||||
public int Checkpoint__resume_db() {return checkpoint.Resume_db();}
|
||||
public void Checkpoint__delete() {checkpoint.Delete();}
|
||||
public boolean Checkpoint__skip_fil(Io_url fil) {return checkpoint.Skip_fil(fil);}
|
||||
private Io_url cur_fil; private byte cur_wkr_tid;
|
||||
public boolean Checkpoint__skip_wkr(Io_url fil, byte wkr_tid) {
|
||||
boolean rv = checkpoint.Skip_wkr(wkr_tid);
|
||||
if (rv) return true;
|
||||
this.cur_fil = fil;
|
||||
this.cur_wkr_tid = wkr_tid;
|
||||
this.Checkpoint__save();
|
||||
time_nxt = gplx.core.envs.Env_.TickCount() + time_gap;
|
||||
return false;
|
||||
}
|
||||
public void Checkpoint__save() {
|
||||
// cur_wkr.Resume__db_id()
|
||||
checkpoint.Save(cur_fil, cur_wkr_tid, -1, prog_count_cur);
|
||||
}
|
||||
public boolean Prog__insert_and_stop_if_suspended(int row_size) {
|
||||
++prog_count_cur;
|
||||
long time_cur = gplx.core.envs.Env_.TickCount();
|
||||
if (time_cur < time_nxt) return false;
|
||||
// gplx.core.threads.Thread_adp_.Sleep(10);
|
||||
time_nxt = time_cur + time_gap;
|
||||
boolean rv = prog_ui.Prog_notify_and_chk_if_suspended(prog_count_cur, prog_count_end);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.dbs.bulks.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.infos.*;
|
||||
import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.dbs.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
class Merge_wkr__core {
|
||||
private final Db_attach_mgr attach_mgr = new Db_attach_mgr();
|
||||
private final Db_tbl_copy copy_mgr = new Db_tbl_copy();
|
||||
public void Copy_to_temp(Merge_prog_wkr prog_wkr, Xow_wiki wiki, Db_conn src_conn) {
|
||||
Create_dbs(wiki, src_conn);
|
||||
Merge_core(wiki, src_conn);
|
||||
Merge_srch(wiki, src_conn);
|
||||
Merge_file(wiki, src_conn);
|
||||
}
|
||||
private void Create_dbs(Xow_wiki wiki, Db_conn src_conn) {
|
||||
Db_cfg_tbl cfg_tbl = Xowd_cfg_tbl_.New(src_conn, "xowa_cfg__core");
|
||||
Xowd_core_db_props core_db_props = Xowd_core_db_props.Cfg_load(src_conn, cfg_tbl);
|
||||
Xob_info_session session = Xob_info_session.Load(cfg_tbl);
|
||||
|
||||
Xow_wiki_.Create_sql_backend(wiki, core_db_props, session);
|
||||
}
|
||||
private void Merge_core(Xow_wiki wiki, Db_conn src_conn) {
|
||||
Db_conn trg_conn = wiki.Data__core_mgr().Db__core().Conn();
|
||||
copy_mgr.Copy_many(src_conn, trg_conn, "site_ns", "css_core", "css_file"); // NOTE: "xowa_db" skipped; NOTE: css_core must go before Init_by_wiki
|
||||
copy_mgr.Copy_one(src_conn, trg_conn, "xowa_cfg__core", "xowa_cfg");
|
||||
wiki.Init_by_wiki();
|
||||
|
||||
// make text_db b/c page entries have Load_page_wkr will try to load from text
|
||||
Xow_db_file text_db = null;
|
||||
if (wiki.Data__core_mgr().Props().Layout_text().Tid_is_lot()) {
|
||||
text_db = wiki.Data__core_mgr().Dbs__get_by_tid_or_null(Xow_db_file_.Tid__text);
|
||||
if (text_db == null)
|
||||
text_db = wiki.Data__core_mgr().Dbs__make_by_tid(Xow_db_file_.Tid__text);
|
||||
}
|
||||
else
|
||||
text_db = wiki.Data__core_mgr().Db__core();
|
||||
text_db.Tbl__text().Create_tbl();
|
||||
|
||||
// merge at end for site_stats
|
||||
copy_mgr.Copy_many(src_conn, trg_conn, "site_stats");
|
||||
}
|
||||
private void Merge_srch(Xow_wiki wiki, Db_conn src_conn) {
|
||||
Srch_search_addon addon = Srch_search_addon.Get(wiki);
|
||||
|
||||
Srch_db_mgr srch_db_mgr = addon.Db_mgr();
|
||||
srch_db_mgr.Create_all();
|
||||
srch_db_mgr.Tbl__word().Create_idx();
|
||||
int len = srch_db_mgr.Tbl__link__len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
srch_db_mgr.Tbl__link__get_at(i).Create_idx__link_score();
|
||||
|
||||
Db_conn trg_conn = addon.Db_mgr().Tbl__word().conn;
|
||||
// copy_mgr.Copy_many(src_conn, trg_conn, "search_link_reg");
|
||||
Merge_cfg(src_conn, trg_conn, "xowa_cfg__srch");
|
||||
}
|
||||
private void Merge_file(Xow_wiki wiki, Db_conn src_conn) {
|
||||
if (wiki.Type_is_edit())
|
||||
((Xowe_wiki)wiki).File_mgr().Init_file_mgr_by_load(wiki);
|
||||
else
|
||||
wiki.File__mnt_mgr().Ctor_by_load(wiki.File__fsdb_core());
|
||||
Db_conn trg_conn = wiki.File__fsdb_core().File__atr_file__at(Fsm_mnt_mgr.Mnt_idx_main).Conn();
|
||||
copy_mgr.Copy_many(src_conn, trg_conn, "fsdb_dba", "fsdb_dbb", "fsdb_dir", "fsdb_mnt");
|
||||
Merge_cfg(src_conn, trg_conn, "xowa_cfg__file");
|
||||
}
|
||||
private void Merge_cfg(Db_conn src_conn, Db_conn trg_conn, String src_tbl_name) {
|
||||
if (trg_conn.Meta_tbl_exists("xowa_cfg")) {
|
||||
attach_mgr.Conn_main_(trg_conn).Conn_others_(new Db_attach_itm("src_db", src_conn));
|
||||
attach_mgr.Exec_sql(String_.Concat_lines_nl
|
||||
( "INSERT INTO xowa_cfg"
|
||||
, "SELECT s.cfg_grp, s.cfg_key, s.cfg_val"
|
||||
, "FROM <src_db>" + src_tbl_name + " s"
|
||||
, " LEFT JOIN xowa_cfg t ON s.cfg_grp = t.cfg_grp AND s.cfg_key = t.cfg_key"
|
||||
, "WHERE t.cfg_grp IS NULL"
|
||||
));
|
||||
}
|
||||
else
|
||||
copy_mgr.Copy_one (src_conn, trg_conn, src_tbl_name, "xowa_cfg");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.merges; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*;
|
||||
import gplx.dbs.*; import gplx.dbs.bulks.*; import gplx.dbs.engines.sqlite.*;
|
||||
import gplx.xowa.addons.bldrs.exports.utls.*;
|
||||
class Merge_wkr_utl {
|
||||
public static void Merge_by_sql(Db_bulk_prog prog_wkr, String msg, String tbl_name, Dbmeta_fld_list flds, Db_conn src_conn, Merge2_trg_itm trg_db, int trg_db_id, boolean disable_synchronous) {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Db_conn trg_conn = trg_db.Conn();
|
||||
Db_attach_mgr attach_mgr = new Db_attach_mgr(trg_conn, new Db_attach_itm("src_db", src_conn));
|
||||
Io_url trg_url = Sqlite_conn_info.To_url(trg_conn);
|
||||
if (disable_synchronous) {
|
||||
Io_mgr.Instance.CopyFil(trg_url, trg_url.GenNewExt(".bak"), true);
|
||||
trg_conn.Exec_qry(Sqlite_pragma.New__synchronous__off());
|
||||
Set_journal(trg_conn, "OFF");
|
||||
}
|
||||
attach_mgr.Exec_sql(Bld_insert_into(bfr, tbl_name, flds, trg_db_id, disable_synchronous));
|
||||
if (disable_synchronous) {
|
||||
trg_conn.Exec_qry(Sqlite_pragma.New__synchronous__normal());
|
||||
Io_mgr.Instance.DeleteFil(trg_url.GenNewExt(".bak"));
|
||||
Set_journal(trg_conn, "DELETE");
|
||||
}
|
||||
prog_wkr.Prog__insert_and_stop_if_suspended(1);
|
||||
}
|
||||
private static void Set_journal(Db_conn conn, String mode) {
|
||||
Db_rdr rdr = conn.Stmt_sql("PRAGMA journal_mode=" + mode).Exec_select__rls_auto();
|
||||
try {
|
||||
rdr.Move_next();
|
||||
rdr.Read_at(0);
|
||||
}
|
||||
finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
private static String Bld_insert_into(Bry_bfr bfr, String tbl_name, Dbmeta_fld_list flds, int trg_db_id, boolean disable_synchronous) {
|
||||
Split_tbl_.Bld_insert_by_select(bfr, tbl_name, flds);
|
||||
if (trg_db_id != -1 && !disable_synchronous)
|
||||
bfr.Add_str_u8_fmt("WHERE trg_db_id = {0}", trg_db_id);
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public static void Merge_by_rows(Db_bulk_prog prog_wkr, String msg, String tbl_name, Dbmeta_fld_list flds, Db_conn src_conn, Db_conn trg_conn, String[] order_bys) {
|
||||
Db_stmt src_stmt = order_bys == String_.Ary_empty
|
||||
? src_conn.Stmt_select_all(tbl_name, flds)
|
||||
: src_conn.Stmt_select_order(tbl_name, flds, String_.Ary_empty, order_bys)
|
||||
;
|
||||
Db_rdr src = src_stmt.Exec_select__rls_auto();
|
||||
Db_stmt trg = trg_conn.Stmt_insert(tbl_name, flds);
|
||||
try {Db_bulk_exec_.Insert(prog_wkr, msg, flds.To_fld_ary(), src, trg, trg_conn);}
|
||||
finally {
|
||||
src.Rls();
|
||||
trg.Rls();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Pack_file_bldr_cmd extends Xob_cmd__base {
|
||||
public Pack_file_bldr_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
new Pack_file_mgr().Exec(wiki);
|
||||
}
|
||||
|
||||
public static final String BLDR_CMD_KEY = "bldr.export.pack.file";
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;}
|
||||
public static final Xob_cmd Prototype = new Pack_file_bldr_cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Pack_file_bldr_cmd(bldr, wiki);}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
import gplx.core.progs.*; import gplx.core.ios.zips.*; import gplx.core.ios.streams.*; import gplx.core.security.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.steps.*;
|
||||
class Pack_file_mgr {
|
||||
public void Exec(Xowe_wiki wiki) {
|
||||
// init
|
||||
wiki.Init_assert();
|
||||
Io_url wiki_dir = wiki.Fsys_mgr().Root_dir();
|
||||
Io_url pack_dir = wiki_dir.GenSubDir_nest("tmp", "pack");
|
||||
Io_mgr.Instance.DeleteDirDeep(pack_dir); Io_mgr.Instance.CreateDirIfAbsent(pack_dir);
|
||||
String wiki_date = wiki.Props().Modified_latest().XtoStr_fmt("yyyy.MM");
|
||||
Pack_hash hash = Pack_hash_bldr.Bld(wiki, wiki_dir, pack_dir, wiki_date);
|
||||
|
||||
// get import_tbl
|
||||
byte[] wiki_abrv = wiki.Domain_itm().Abrv_xo();
|
||||
Xobc_data_db bc_db = new Xobc_data_db(wiki.App().Fsys_mgr().Bin_addon_dir().GenSubFil_nest("bldr", "central", "bldr_central.data_db.xowa"));
|
||||
Db_conn bc_conn = bc_db.Conn();
|
||||
bc_db.Delete_by_import(wiki_abrv, wiki_date);
|
||||
bc_conn.Txn_bgn("xobc_import_insert");
|
||||
|
||||
// build zip packs
|
||||
Hash_algo hash_algo = Hash_algo_.New__md5();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
int hash_len = hash.Len();
|
||||
for (int i = 0; i < hash_len; ++i) {
|
||||
Pack_list list = (Pack_list)hash.Get_at(i);
|
||||
int list_len = list.Len();
|
||||
for (int j = 0; j < list_len; ++j) {
|
||||
Pack_itm itm = (Pack_itm)list.Get_at(j);
|
||||
Make_pack(wiki, wiki_dir, wiki_abrv, wiki_date, bc_db, hash_algo, tmp_bfr, itm, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// build tasks
|
||||
Make_task(tmp_bfr, wiki, wiki_date, bc_db, hash, "html", Xobc_import_type.Tid__wiki__core, Xobc_import_type.Tid__wiki__srch, Xobc_import_type.Tid__wiki__html);
|
||||
Make_task(tmp_bfr, wiki, wiki_date, bc_db, hash, "file", Xobc_import_type.Tid__file__core, Xobc_import_type.Tid__file__data);
|
||||
bc_conn.Txn_end();
|
||||
}
|
||||
private static void Make_task(Bry_bfr tmp_bfr, Xow_wiki wiki, String wiki_date, Xobc_data_db bc_db, Pack_hash hash, String task_type, int... list_tids) {
|
||||
// get packs
|
||||
List_adp pack_list = List_adp_.New();
|
||||
int list_tids_len = list_tids.length;
|
||||
long raw_len = 0;
|
||||
for (int i = 0; i < list_tids_len; ++i) {
|
||||
Pack_list list = hash.Get_by(list_tids[i]);
|
||||
if (list == null) continue; // no lists for that tid;
|
||||
int list_len = list.Len();
|
||||
for (int j = 0; j < list_len; ++j) {
|
||||
Pack_itm itm = (Pack_itm)list.Get_at(j);
|
||||
raw_len += itm.Raw_size();
|
||||
pack_list.Add(itm);
|
||||
}
|
||||
}
|
||||
int pack_list_len = pack_list.Len();
|
||||
|
||||
// create task
|
||||
String task_key = wiki.Domain_str() + "|" + wiki_date + "|" + task_type;
|
||||
String task_name = Build_task_name(tmp_bfr, wiki, wiki_date, task_type, raw_len);
|
||||
Xobc_task_regy_tbl task_regy_tbl = bc_db.Tbl__task_regy();
|
||||
int task_id = bc_db.Conn().Sys_mgr().Autonum_next("task_regy.task_id");
|
||||
task_regy_tbl.Insert(task_id, task_id, pack_list_len, task_key, task_name);
|
||||
|
||||
// map steps
|
||||
for (int i = 0; i < pack_list_len; ++i) {
|
||||
Pack_itm itm = (Pack_itm)pack_list.Get_at(i);
|
||||
int sm_id = bc_db.Conn().Sys_mgr().Autonum_next("step_map.sm_id");
|
||||
bc_db.Tbl__step_map().Insert(sm_id, task_id, itm.Step_id(), i);
|
||||
}
|
||||
}
|
||||
public static String Build_task_name(Bry_bfr tmp_bfr, Xow_wiki wiki, String wiki_date, String task_type, long raw_len) {// Simple Wikipedia - Articles (2016-06) [420.31 MB]
|
||||
byte[] lang_name = gplx.xowa.langs.Xol_lang_stub_.Get_by_key_or_null(wiki.Domain_itm().Lang_orig_key()).Canonical_name(); // EX: Deutsch
|
||||
byte[] wiki_name = wiki.Domain_itm().Domain_type().Display_bry(); // EX: Wikipedia
|
||||
String type_name = String_.Eq(task_type, "html") ? "Articles" : "Images";
|
||||
wiki_date = String_.Replace(wiki_date, ".", "-");
|
||||
String file_size = gplx.core.ios.Io_size_.To_str_new(tmp_bfr, raw_len, 2);
|
||||
return String_.Format("{0} {1} - {2} ({3}) [{4}]", lang_name, wiki_name, type_name, wiki_date, file_size);
|
||||
}
|
||||
private static void Make_pack(Xowe_wiki wiki, Io_url wiki_dir, byte[] wiki_abrv, String wiki_date, Xobc_data_db bc_db, Hash_algo hash_algo, Bry_bfr tmp_bfr, Pack_itm itm, int task_id) {
|
||||
// hash raws
|
||||
Io_url zip_url = itm.Zip_url();
|
||||
Gfo_log_.Instance.Prog("hashing raw: " + zip_url.NameAndExt());
|
||||
Io_url md5_url = wiki_dir.GenSubFil(zip_url.NameOnly() + ".md5");
|
||||
long raw_size = 0;
|
||||
Io_url[] raw_urls = itm.Raw_urls();
|
||||
int raw_urls_len = raw_urls.length;
|
||||
for (int i = 0; i < raw_urls_len; ++i) {
|
||||
Io_url raw_url = raw_urls[i];
|
||||
IoStream raw_stream = Io_mgr.Instance.OpenStreamRead(raw_url);
|
||||
byte[] raw_md5 = null;
|
||||
try {raw_md5 = hash_algo.Hash_stream_as_bry(Gfo_prog_ui_.Noop, raw_stream);}
|
||||
finally {raw_stream.Rls();}
|
||||
tmp_bfr.Add(raw_md5).Add_byte_space().Add_byte(Byte_ascii.Star).Add_str_a7(raw_url.NameAndExt()).Add_byte_nl();
|
||||
raw_size += raw_stream.Len();
|
||||
}
|
||||
Io_mgr.Instance.SaveFilBfr(md5_url, tmp_bfr);
|
||||
itm.Raw_size_(raw_size);
|
||||
|
||||
// compress raws
|
||||
Gfo_log_.Instance.Prog("compressing raw");
|
||||
Io_zip_compress_cmd__jre zip_cmd = new Io_zip_compress_cmd__jre();
|
||||
raw_urls = (Io_url[])Array_.Insert(raw_urls, new Io_url[] {md5_url}, 0); // add ".md5" to .zip
|
||||
zip_cmd.Exec_hook(Gfo_prog_ui_.Noop, raw_urls, zip_url, "", 0, 0);
|
||||
|
||||
// hash zip
|
||||
Gfo_log_.Instance.Prog("hashing zip");
|
||||
IoStream zip_stream = Io_mgr.Instance.OpenStreamRead(zip_url);
|
||||
byte[] zip_md5 = null;
|
||||
try {zip_md5 = hash_algo.Hash_stream_as_bry(Gfo_prog_ui_.Noop, zip_stream);}
|
||||
finally {zip_stream.Rls();}
|
||||
long zip_len = Io_mgr.Instance.QueryFil(zip_url).Size();
|
||||
|
||||
// cleanup
|
||||
Io_mgr.Instance.DeleteFil(md5_url);
|
||||
|
||||
// generate import
|
||||
Gfo_log_.Instance.Prog("generating tasks");
|
||||
int step_id = bc_db.Conn().Sys_mgr().Autonum_next("step_regy.step_id");
|
||||
itm.Step_id_(step_id);
|
||||
bc_db.Tbl__step_regy().Insert(step_id, Xobc_step_itm.Type__wiki_import);
|
||||
bc_db.Tbl__import_step().Insert(step_id, gplx.xowa.addons.bldrs.centrals.dbs.datas.Xobc_host_regy_tbl.Host_id__archive_org, wiki_abrv, wiki_date, zip_url.NameAndExt(), itm.Tid(), Xobc_zip_type.Type__zip, zip_md5, zip_len, raw_size, 0, 0);
|
||||
}
|
||||
}
|
||||
class Pack_hash_bldr {
|
||||
public static Pack_hash Bld(Xow_wiki wiki, Io_url wiki_dir, Io_url pack_dir, String wiki_date) {
|
||||
Pack_hash rv = new Pack_hash();
|
||||
Pack_zip_name_bldr zip_name_bldr = new Pack_zip_name_bldr(pack_dir, wiki.Domain_str(), String_.new_a7(wiki.Domain_itm().Abrv_wm()), wiki_date);
|
||||
|
||||
// bld html pack
|
||||
Xow_db_mgr db_mgr = wiki.Data__core_mgr();
|
||||
int len = db_mgr.Dbs__len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_db_file file = db_mgr.Dbs__get_at(i);
|
||||
int pack_tid = Get_pack_tid(file.Tid());
|
||||
if (pack_tid == Xobc_import_type.Tid__ignore) continue;
|
||||
rv.Add(zip_name_bldr, pack_tid, file.Url());
|
||||
}
|
||||
rv.Consolidate(Xobc_import_type.Tid__wiki__srch);
|
||||
|
||||
// bld file pack
|
||||
Fsm_mnt_itm mnt_itm = wiki.File__mnt_mgr().Mnts__get_at(Fsm_mnt_mgr.Mnt_idx_main);
|
||||
rv.Add(zip_name_bldr, Xobc_import_type.Tid__file__core, wiki_dir.GenSubFil(mnt_itm.Atr_mgr().Db__core().Url_rel()));
|
||||
if (db_mgr.Props().Layout_file().Tid_is_lot()) {
|
||||
Fsm_bin_mgr bin_mgr = mnt_itm.Bin_mgr();
|
||||
int bin_len = bin_mgr.Dbs__len();
|
||||
for (int i = 0; i < bin_len; ++i) {
|
||||
Fsm_bin_fil bin_fil = bin_mgr.Dbs__get_at(i);
|
||||
rv.Add(zip_name_bldr, Xobc_import_type.Tid__file__data, bin_fil.Url());
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static int Get_pack_tid(byte db_file_tid) {
|
||||
switch (db_file_tid) {
|
||||
case Xow_db_file_.Tid__core: return Xobc_import_type.Tid__wiki__core;
|
||||
case Xow_db_file_.Tid__search_core:
|
||||
case Xow_db_file_.Tid__search_link: return Xobc_import_type.Tid__wiki__srch;
|
||||
case Xow_db_file_.Tid__html_solo:
|
||||
case Xow_db_file_.Tid__html_data: return Xobc_import_type.Tid__wiki__html;
|
||||
case Xow_db_file_.Tid__file_core: return Xobc_import_type.Tid__file__core;
|
||||
case Xow_db_file_.Tid__file_solo:
|
||||
case Xow_db_file_.Tid__file_data: return Xobc_import_type.Tid__file__data;
|
||||
default: return Xobc_import_type.Tid__ignore;
|
||||
}
|
||||
}
|
||||
}
|
||||
class Pack_zip_name_bldr { // en.wikipedia.org-file-ns.000-db.001.xowa -> Xowa_enwiki_2016-05_file_ns.000_db.001.zip
|
||||
private final Io_url pack_dir;
|
||||
private final byte[] wiki_domain, zip_name_prefix;
|
||||
|
||||
public Pack_zip_name_bldr(Io_url pack_dir, String wiki_domain_str, String wiki_abrv, String wiki_date) {
|
||||
this.pack_dir = pack_dir;
|
||||
this.wiki_domain = Bry_.new_u8(wiki_domain_str);
|
||||
this.zip_name_prefix = Bry_.new_u8("Xowa_" + wiki_abrv + "_" + String_.Replace(wiki_date, ".", "-"));
|
||||
}
|
||||
public Io_url Bld(Io_url orig_url) {
|
||||
String orig_str = String_.Replace(orig_url.NameAndExt(), ".xowa", ".zip");
|
||||
byte[] orig_bry = Bry_.new_u8(orig_str);
|
||||
orig_bry = Bry_.Replace(orig_bry, Byte_ascii.Dash, Byte_ascii.Underline);
|
||||
orig_bry = Bry_.Replace(orig_bry, wiki_domain, zip_name_prefix);
|
||||
return pack_dir.GenSubFil(String_.new_u8(orig_bry));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
class Pack_hash {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Len() {return hash.Len();}
|
||||
public Pack_list Get_at(int i) {return (Pack_list)hash.Get_at(i);}
|
||||
public Pack_list Get_by(int tid) {return (Pack_list)hash.Get_by(tid);}
|
||||
public void Add(Pack_zip_name_bldr bldr, int list_tid, Io_url file_url) {
|
||||
Pack_list list = (Pack_list)hash.Get_by(list_tid);
|
||||
if (list == null) {
|
||||
list = new Pack_list(list_tid);
|
||||
hash.Add(list_tid, list);
|
||||
}
|
||||
Pack_itm itm = new Pack_itm(list_tid, bldr.Bld(file_url), file_url);
|
||||
list.Add(itm);
|
||||
}
|
||||
public void Consolidate(int... tids) { // merge n itms into 1 itm; needed for search-core + search-link -> search
|
||||
int tids_len = tids.length;
|
||||
for (int i = 0; i < tids_len; ++i) {
|
||||
Pack_list list = (Pack_list)hash.Get_by(tids[i]);
|
||||
if (list == null) continue; // tid doesn't exist; EX: search in Tid_few
|
||||
int list_len = list.Len();
|
||||
Pack_itm itm_0 = (Pack_itm)list.Get_at(0);
|
||||
Io_url[] urls = new Io_url[list_len];
|
||||
for (int j = 0; j < list_len; ++j) {
|
||||
urls[j] = ((Pack_itm)list.Get_at(j)).Raw_urls()[0];
|
||||
}
|
||||
list.Clear();
|
||||
itm_0.Raw_urls_(urls);
|
||||
list.Add(itm_0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
class Pack_itm {
|
||||
public Pack_itm(int tid, Io_url zip_url, Io_url... raw_urls) {
|
||||
this.tid = tid;
|
||||
this.zip_url = zip_url;
|
||||
this.raw_urls = raw_urls;
|
||||
}
|
||||
public int Tid() {return tid;} private int tid;
|
||||
public Io_url Zip_url() {return zip_url;} private Io_url zip_url;
|
||||
public Io_url[] Raw_urls() {return raw_urls;} private Io_url[] raw_urls; public void Raw_urls_(Io_url[] v) {this.raw_urls = v;}
|
||||
public long Raw_size() {return raw_size;} private long raw_size; public void Raw_size_(long v) {this.raw_size = v;}
|
||||
public int Step_id() {return step_id;} private int step_id; public void Step_id_(int v) {this.step_id = v;}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
class Pack_list {
|
||||
private final List_adp list = List_adp_.New();
|
||||
public Pack_list(int tid) {this.tid = tid;}
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public int Len() {return list.Len();}
|
||||
public Pack_itm Get_at(int i) {return (Pack_itm)list.Get_at(i);}
|
||||
public void Add(Pack_itm itm) {list.Add(itm);}
|
||||
public void Clear() {list.Clear();}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.exports.packs.splits; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
class Pack_itm {
|
||||
public Pack_itm(int idx, int type, Io_url zip_url, Io_url[] raw_urls) {
|
||||
this.idx = idx;
|
||||
this.type = type;
|
||||
this.zip_url = zip_url;
|
||||
this.raw_urls = raw_urls;
|
||||
}
|
||||
public int Idx() {return idx;} private final int idx;
|
||||
public int Type() {return type;} private final int type;
|
||||
public Io_url[] Raw_urls() {return raw_urls;} private final Io_url[] raw_urls;
|
||||
public Io_url Zip_url() {return zip_url;} private final Io_url zip_url;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user