Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.Page


   *
   * @param page Page.
   * @param pageId Page id.
   */
  private void addPage(String page, Integer pageId) {
    Page tmpPage = DataManager.getPage(wikipedia, page, pageId, null, null);
    if (!errors.contains(tmpPage)) {
      errors.add(tmpPage);
    }
  }
View Full Code Here


    // Retrieve configuration
    if (wiki.getConfigurationPage() != null) {

      // Decide which pages to be retrieved
      String configPageName = wiki.getConfigurationPage();
      Page page = DataManager.getPage(
          wiki, configPageName, null, null, null);
      Page userConfigPage = null;
      if ((userName != null) && (userName.trim().length() > 0) &&
          (wiki.getUserConfigurationPage(userName) != null) &&
          (!Page.areSameTitle(wiki.getUserConfigurationPage(userName), configPageName))) {
        userConfigPage = DataManager.getPage(
            wiki,
            wiki.getUserConfigurationPage(userName),
            null, null, null);
      }

      // Retrieve contents
      List<Page> pages = new ArrayList<Page>();
      pages.add(page);
      if (userConfigPage != null) {
        pages.add(userConfigPage);
      }
      retrieveContents(wiki, pages, false, false);

      // Set configuration
      wiki.getConfiguration().setGeneralConfiguration(
          new StringReader(page.getContents()));
      if (userConfigPage != null) {
        if (Boolean.TRUE.equals(userConfigPage.isExisting())) {
          wiki.getConfiguration().setUserConfiguration(
              new StringReader(userConfigPage.getContents()));
        }
      }
    }
  }
View Full Code Here

    properties.put("rvprop", "content");
    StringBuilder titles = new StringBuilder();
    for (int i = 0; i < pages.size();) {
      titles.setLength(0);
      for (int j = 0; (j < MAX_PAGES_PER_QUERY) && (i < pages.size()); i++, j++) {
        Page p = pages.get(i);
        if (j > 0) {
          titles.append("|");
        }
        titles.append(p.getTitle());
      }
      properties.put("titles", titles.toString());
      try {
        constructContents(
            pages,
View Full Code Here

        } while (hasCaptcha);
      } catch (APIException e) {
        if (e.getHttpStatus() == HttpStatus.SC_GATEWAY_TIMEOUT) {
          log.warn("Gateway timeout, waiting to see if modification has been taken into account");
          waitBeforeRetrying();
          Page tmpPage = page.replicatePage();
          retrieveContents(wikipedia, Collections.singletonList(tmpPage), false, false);
          String tmpContents = tmpPage.getContents();
          if ((tmpContents != null) &&
              (tmpContents.equals(newContents))) {
            return QueryResult.createCorrectQuery(
                tmpPage.getPageId(), tmpPage.getTitle(),
                page.getPageId(), tmpPage.getPageId());
          }
        }
        if (attemptNumber > 1) {
          throw e;
        }
View Full Code Here

    properties.put("redirects", "");
    StringBuilder titles = new StringBuilder();
    for (int i = 0; i < pages.size();) {
      titles.setLength(0);
      for (int j = 0; (j < MAX_PAGES_PER_QUERY) && (i < pages.size()); i++, j++) {
        Page p = pages.get(i);
        if (j > 0) {
          titles.append("|");
        }
        titles.append(p.getTitle());
      }
      properties.put("titles", titles.toString());
      try {
        updateRedirectStatus(
            wiki, pages,
View Full Code Here

        // Find if the redirect is already taken into account
        boolean exists = false;
        Iterator<Page> itPage = p.getRedirectIteratorWithPage();
        while (itPage.hasNext()) {
          Page tmp = itPage.next();
          String title = getNormalizedTitle(tmp.getTitle(), normalization);
          if (Page.areSameTitle(title, toPage)) {
            exists = true;
          }
        }

        // Add the redirect if needed
        itPage = p.getRedirectIteratorWithPage();
        while (itPage.hasNext()) {
          Page tmp = itPage.next();
          String title = getNormalizedTitle(tmp.getTitle(), normalization);
          if (!exists && Page.areSameTitle(title, fromPage)) {
            XPath xpaPage = createXPath("page", "title", toPage);
            List listTo = xpaPage.selectNodes(listPages);
            if (!listTo.isEmpty()) {
              Element to = (Element) listTo.get(0);
              Page pageTo = DataManager.getPage(
                  p.getWikipedia(), xpaTitle.valueOf(to), null, null, null);
              pageTo.setNamespace(xpaNamespace.valueOf(to));
              pageTo.setPageId(xpaPageId.valueOf(to));
              p.addRedirect(pageTo);
            }
          }
        }
      }
    }

    // Analyzing missing pages
    for (Page p : pages) {
      Iterator<Page> itPage = p.getRedirectIteratorWithPage();
      while (itPage.hasNext()) {
        Page tmp = itPage.next();
        String title = getNormalizedTitle(tmp.getTitle(), normalization);
        XPath xpaPage = createXPath("page", "title", title);
        Element page = (Element) xpaPage.selectSingleNode(listPages);
        if (page != null) {
          List pageId = xpaPageId.selectNodes(page);
          if ((pageId != null) && (!pageId.isEmpty())) {
            tmp.setExisting(Boolean.TRUE);
          } else {
            Attribute attrMissing = page.getAttribute("missing");
            if (attrMissing != null) {
              tmp.setExisting(Boolean.FALSE);
            }
          }
        }
      }
    }
View Full Code Here

    config.setString(
        null,
        ConfigurationValueString.PAGE_NAME,
        pageName);
    config.save();
    Page page = DataManager.getPage(
        getWikipedia(), pageName, null, null, null);
    new PageListWorker(
        getWikipedia(), this, page,
        Collections.singletonList(pageName),
        PageListWorker.Mode.BACKLINKS, false,
View Full Code Here

        ConfigurationValueString.PAGE_NAME,
        pageName);
    config.save();
    String title = getWikipedia().getWikiConfiguration().getPageTitle(
        Namespace.CATEGORY, pageName);
    Page page = DataManager.getPage(
        getWikipedia(), title, null, null, null);
    new PageListWorker(
        getWikipedia(), this, page,
        Collections.singletonList(title),
        PageListWorker.Mode.CATEGORY_MEMBERS, false,
View Full Code Here

        ConfigurationValueString.PAGE_NAME,
        pageName);
    config.save();
    String title = getWikipedia().getWikiConfiguration().getPageTitle(
        Namespace.TEMPLATE, pageName);
    Page page = DataManager.getPage(
        getWikipedia(), title, null, null, null);
    new PageListWorker(
        getWikipedia(), this, page,
        Collections.singletonList(title),
        PageListWorker.Mode.EMBEDDED_IN, false,
View Full Code Here

        }
        List listLinks = xpaLinks.selectNodes(pageNode);
        Iterator itLinks = listLinks.iterator();
        while (itLinks.hasNext()) {
          Element linkNode = (Element) itLinks.next();
          Page link = DataManager.getPage(
              getWiki(), linkNode.getAttributeValue("title"), null, null, null);
          link.setNamespace(linkNode.getAttributeValue("ns"));
          links.add(link);
        }
      }

      // Retrieve continue
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.data.Page

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.