예제 #1
0
 public void Init_db_sqlite() {
   Xowe_wiki wiki = this.Wiki();
   Db_conn_pool.I.Clear();
   Db_conn_bldr.I.Reg_default_sqlite();
   Io_mgr.I.DeleteDir_cmd(wiki.Fsys_mgr().Root_dir()).MissingIgnored_().Exec();
   wiki.Db_mgr_create_as_sql()
       .Core_data_mgr()
       .Init_by_make(Xowd_core_db_props.Test, Xob_info_session.Test);
   Io_mgr.I.SaveFilStr(wiki.Import_cfg().Src_dir().GenSubFil("a.xml"), "<test/>");
 }
예제 #2
0
 public boolean Chk(Xowe_wiki wiki) {
   if (!wiki.App().App_type().Uid_is_gui())
     return true; // NOTE: ignore during Server / Console modes; DATE:2015-04-01
   if (in_progress_hash.Has(wiki.Domain_bry()))
     return true; // NOTE: ignore if currently building; different bldr commands call
                  // wiki.Init_assert() which may lead to fals checks;
   Io_url url = url_(wiki);
   if (!Io_mgr.I.ExistsFil(url)) return true;
   Xoae_app app = wiki.Appe();
   app.Usr_dlg().Log_many("", "", "import.marker: marker found: url=~{0}", url.Raw());
   byte[] incompete_msg_bry =
       app.Usere()
           .Msg_mgr()
           .Val_by_key_args(Bry_.new_a7("api-xowa.import.core.incomplete"), wiki.Domain_str());
   int rslt = app.Gui_mgr().Kit().Ask_yes_no_cancel("", "", String_.new_u8(incompete_msg_bry));
   switch (rslt) {
     case Gfui_dlg_msg_.Btn_yes:
       Xob_cleanup_cmd.Delete_wiki_sql(wiki);
       End(wiki);
       return false; // delete wiki
     case Gfui_dlg_msg_.Btn_no:
       End(wiki);
       return true; // delete marker
     case Gfui_dlg_msg_.Btn_cancel:
       return true; // noop
     default:
       throw Err_.unhandled(rslt);
   }
 }
예제 #3
0
	public void tst_trg_fils() {
		for (int i = 0; i < trg_fils.length; i++) {
			Io_fil trg_fil = trg_fils[i];
			String data = Io_mgr.I.LoadFilStr(trg_fil.Url());
			Tfds.Eq_str_lines(trg_fil.Data(), data, trg_fil.Url().Raw());
		}		
	}
예제 #4
0
	public void ini_src_fils() {
		if (src_fils != null) {
			for (int i = 0; i < src_fils.length; i++) {
				Io_fil src_fil = src_fils[i];
				Io_mgr.I.SaveFilStr(src_fil.Url(), src_fil.Data());
			}
		}
	}
예제 #5
0
파일: Io_fil.java 프로젝트: qq98982/xowa
 public static Io_fil[] new_ary_(Io_url[] url_ary) {
   int url_ary_len = url_ary.length;
   Io_fil[] rv = new Io_fil[url_ary_len];
   for (int i = 0; i < url_ary_len; i++) {
     Io_url url = url_ary[i];
     String data = Io_mgr.I.LoadFilStr(url);
     Io_fil fil = new Io_fil(url, data);
     rv[i] = fil;
   }
   return rv;
 }
예제 #6
0
 public void Save_as() {
   if (this.Active_tab_is_null()) return;
   Xog_tab_itm tab = win.Tab_mgr().Active_tab();
   String file_name =
       Xoa_app_.Utl__encoder_mgr()
               .Fsys_safe()
               .Encode_str(String_.new_u8(tab.Page().Ttl().Full_url()))
           + ".html";
   String file_url =
       app.Gui_mgr()
           .Kit()
           .New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:")
           .Init_file_(file_name)
           .Ask();
   if (String_.Len_eq_0(file_url)) return;
   Io_mgr.I.SaveFilStr(file_url, tab.Html_box().Text());
   app.Usr_dlg().Prog_many("", "", "saved page: file=~{0}", file_url);
 }
예제 #7
0
  public static Io_stream_rdr Get_rdr_or_null(
      Io_url src_fil, Io_url src_dir, Io_stream_unzip_mgr unzip_mgr, String... filter_ary) {
    IoItmFil src_itm = null;
    if (src_fil != null) src_itm = Io_mgr.I.QueryFil(src_fil);

    // specified file doesn't exist; try to find similar file based on filter
    if (src_itm == null || !src_itm.Exists()) {
      src_itm = Get_itm_by_filters(src_dir, filter_ary);
      if (src_itm == null) return null;
    }

    // return rdr
    Io_url src_itm_url = src_itm.Url();
    Io_stream_rdr rv =
        unzip_mgr.Handles(src_itm_url)
            ? unzip_mgr.New_rdr(src_itm_url)
            : Io_stream_rdr_.file_(src_itm_url);
    rv.Len_(src_itm.Size());
    return rv;
  }
예제 #8
0
	@gplx.Virtual public void Clear(boolean src_repo_is_wmf) {
		Io_mgr.I.InitEngine_mem();
		if (app == null) {
			app = Xoa_app_fxt.app_();
			en_wiki = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_enwiki);
			commons = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_commons);
			app.Wiki_mgr().Add(commons);
			app.Wiki_mgr().Add(en_wiki);
			
			Xof_file_mgr file_mgr = app.File_mgr();
			file_mgr.Img_mgr().Wkr_resize_img_(Xof_img_wkr_resize_img_mok._);
			file_mgr.Img_mgr().Wkr_query_img_size_(new Xof_img_wkr_query_img_size_test());
			app.Wmf_mgr().Api_mgr().Api_orig_(api_size);

			byte[] src_commons = Bry_.new_a7("src_commons");
			byte[] src_en_wiki = Bry_.new_a7("src_en_wiki");
			byte[] trg_commons = Bry_.new_a7("trg_commons");
			byte[] trg_en_wiki = Bry_.new_a7("trg_en_wiki");
			src_commons_repo = Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, false);
			src_en_wiki_repo = Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/"		, Xow_domain_.Domain_str_enwiki, false);
			Ini_repo_add(file_mgr, trg_commons, "mem/trg/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, true).Primary_(true);
			Ini_repo_add(file_mgr, trg_en_wiki, "mem/trg/en.wikipedia.org/"		, Xow_domain_.Domain_str_enwiki, true).Primary_(true);
			Xowe_repo_mgr wiki_repo_mgr = en_wiki.File_mgr().Repo_mgr();
			Xof_repo_pair pair = null;
			pair = wiki_repo_mgr.Add_repo(src_commons, trg_commons);
			pair.Src().Fsys_is_wnt_(true).Wmf_fsys_(src_repo_is_wmf).Tarball_(!src_repo_is_wmf);
			pair.Trg().Fsys_is_wnt_(true);

			pair = wiki_repo_mgr.Add_repo(src_en_wiki, trg_en_wiki);
			pair.Src().Fsys_is_wnt_(true).Wmf_fsys_(src_repo_is_wmf);
			pair.Trg().Fsys_is_wnt_(true);
		}
		en_wiki.Clear_for_tests();
		commons.Clear_for_tests();
		src_fils = trg_fils = Io_fil.Ary_empty;
		html_view_str = null;
		html_w = html_h = -1;
	}
예제 #9
0
  private static IoItmFil Get_itm_by_filters(Io_url dir, String... filter_ary) {
    // create array of matches based on filters
    int match_ary_len = filter_ary.length;
    Criteria_ioMatch[] match_ary = new Criteria_ioMatch[match_ary_len];
    for (int i = 0; i < match_ary_len; ++i)
      match_ary[i] = Criteria_ioMatch.parse_(true, filter_ary[i], dir.Info().CaseSensitive());

    // get files and check each file for match
    IoItmFil rv = null;
    IoItmHash itm_hash = Io_mgr.I.QueryDir_args(dir).ExecAsItmHash();
    int len = itm_hash.Count();
    for (int i = 0; i < len; ++i) {
      IoItm_base itm = itm_hash.Get_at(i);
      for (int j = 0; j < match_ary_len; ++j) {
        if (itm.Type_fil() && match_ary[j].Matches(itm.Url()))
          rv =
              (IoItmFil)
                  itm; // NOTE: this will return the last match; useful for getting latest dump when
                       // multiple dumps are in one dir; (assuming latest should alphabetize last)
      }
    }
    return rv;
  }
예제 #10
0
 public Io_line_rdr_fxt File_lines_(int fil_idx, int bgn, int end) {
   for (int i = bgn; i < end; i++) tmp.Add_int_fixed(i, 2).Add_byte_nl();
   Io_mgr.I.SaveFilBry(rdr.Urls()[fil_idx], tmp.Xto_bry_and_clear());
   return this;
 }
예제 #11
0
 public void Bgn(Xowe_wiki wiki) {
   in_progress_hash.Add_as_key_and_val(wiki.Domain_bry());
   Io_mgr.I.SaveFilStr(
       url_(wiki),
       "XOWA has created this file to indicate that an import is in progress. This file will be deleted once the import is completed.");
 }
예제 #12
0
 public void End(Xowe_wiki wiki) {
   in_progress_hash.Del(wiki.Domain_bry());
   Io_mgr.I.DeleteFil_args(url_(wiki)).MissingFails_off().Exec();
 }
예제 #13
0
	public void fil_absent(String url)					{Tfds.Eq_false(Io_mgr.I.ExistsFil(Io_url_.mem_fil_(url)), "fil should not exist: {0}", url);}
예제 #14
0
	public void	 save_(Io_fil v)						{Io_mgr.I.SaveFilStr(v.Url(), v.Data());}
예제 #15
0
 public Io_line_rdr_fxt File_lines_(int count) {
   for (int i = 0; i < count; i++) tmp.Add_int_fixed(i, 2).Add_byte_nl();
   Io_mgr.I.SaveFilBry(rdr.Urls()[0], tmp.Xto_bry_and_clear());
   return this;
 }
예제 #16
0
 public Db_mgr_fxt Init_fil(Io_url url, String raw) {
   Io_mgr.I.SaveFilStr(url, raw);
   return this;
 }
예제 #17
0
 public void Test_file(String url, String expd) {
   String actl = Io_mgr.I.LoadFilStr(url);
   Tfds.Eq_str_lines(expd, actl);
 }