Package org.wikipediacleaner.api.constants

Examples of org.wikipediacleaner.api.constants.CWConfiguration


    // Retrieve general configuration
    final API api = APIFactory.getAPI();
    final WPCConfiguration wpcConfiguration = wiki.getConfiguration();
    boolean useLabs = wiki.getConfiguration().getBoolean(WPCConfigurationBoolean.CW_USE_LABS);
    final CWConfiguration cwConfiguration = wiki.getCWConfiguration();
    if (!useLabs) {
      String code = wiki.getSettings().getCodeCheckWiki().replace("-", "_");
      try {
        ResponseManager manager = new ResponseManager() {
         
          public void manageResponse(InputStream stream) throws IOException, APIException {
            if (stream != null) {
              cwConfiguration.setGeneralConfiguration(
                  new InputStreamReader(stream, "UTF-8"));
            }
          }
        };
        toolServer.sendGet(
            "~sk/checkwiki/" + code + "/" + code + "_translation.txt",
            manager);
      } catch (APIException e) {
        System.err.println("Error retrieving Check Wiki configuration: " + e.getMessage());
      }
    }

    // Retrieve specific configuration
    try {
      String translationPage = wpcConfiguration.getString(WPCConfigurationString.CW_TRANSLATION_PAGE);
      if (translationPage != null) {
        Page page = DataManager.getPage(
            wiki, translationPage,
            null, null, null);
        api.retrieveContents(wiki, Collections.singleton(page), false, false);
        if (Boolean.TRUE.equals(page.isExisting())) {
          cwConfiguration.setWikiConfiguration(new StringReader(page.getContents()));
        }
      }
    } catch (APIException e) {
      System.err.println("Error retrieving Check Wiki configuration: " + e.getMessage());
    }

    // Retrieving white lists
    HashMap<String, Page> whiteListPages = new HashMap<String, Page>();
    for (int i = 0; i < CWConfiguration.MAX_ERROR_NUMBER; i++) {
      CWConfigurationError error = cwConfiguration.getErrorConfiguration(i);
      if ((error != null) && (error.getWhiteListPageName() != null)) {
        Page page = DataManager.getPage(
            wiki, error.getWhiteListPageName(), null, null, null);
        whiteListPages.put(error.getWhiteListPageName(), page);
      }
    }
    if (whiteListPages.size() > 0) {
      api.retrieveLinks(wiki, whiteListPages.values());
      for (int i = 0; i < CWConfiguration.MAX_ERROR_NUMBER; i++) {
        CWConfigurationError error = cwConfiguration.getErrorConfiguration(i);
        if ((error != null) && (error.getWhiteListPageName() != null)) {
          Page page = whiteListPages.get(error.getWhiteListPageName());
          error.setWhiteList(page);
        }
      }
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.constants.CWConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.