Package org.wikipediacleaner.api

Examples of org.wikipediacleaner.api.APIException


    try {
      ApiXmlPropertiesResult result = new ApiXmlPropertiesResult(wiki, httpClient);
      result.updateRedirect(root, pages);
    } catch (JDOMException e) {
      log.error("Error redirects", e);
      throw new APIException("Error parsing XML result", e);
    }
  }
View Full Code Here


        if (statusCode != HttpStatus.SC_OK) {
          String message = "URL access returned " + HttpStatus.getStatusText(statusCode);
          log.error(message);
          if (attempt >= maxTry) {
            log.warn("Error. Maximum attempts count reached.");
            throw new APIException(message, statusCode);
          }
          waitBeforeRetrying();
        } else {
          InputStream stream = method.getResponseBodyAsStream();
          stream = new BufferedInputStream(stream);
          Header contentEncoding = method.getResponseHeader("Content-Encoding");
          if (contentEncoding != null) {
            if (contentEncoding.getValue().equals("gzip")) {
              stream = new GZIPInputStream(stream);
            }
          }
          SAXBuilder sxb = new SAXBuilder();
          Document document = sxb.build(stream);
          traceDocument(document);
          root = document.getRootElement();
          checkForError(root);
          return root;
        }
      } catch (JDOMParseException e) {
        // NOTE: to deal with api.php login action being disabled.
        String message = "JDOMParseException: " + e.getMessage();
        log.error(message);
        if (attempt > maxTry) {
          log.warn("Error. Maximum attempts count reached.");
          throw e;
        }
        waitBeforeRetrying();
      } catch (JDOMException e) {
        String message = "JDOMException: " + e.getMessage();
        log.error(message);
        if (attempt > maxTry) {
          log.warn("Error. Maximum attempts count reached.");
          throw new APIException("Error parsing XML result", e);
        }
        waitBeforeRetrying();
      } catch (IOException e) {
        String message = "" + e.getClass().getName() + ": " + e.getMessage();
        log.error(message);
        if (attempt > maxTry) {
          log.warn("Error. Maximum attempts count reached.");
          throw new APIException("Error accessing MediaWiki", e);
        }
        waitBeforeRetrying();
      } catch (APIException e) {
        if (!e.shouldRetry() || (attempt > e.getMaxRetry())) {
          throw e;
View Full Code Here

        XPath xpaInfo = XPath.newInstance("./@info");
        while (iterErrors.hasNext()) {
          Element currentNode = (Element) iterErrors.next();
          String text = "Error reported: " + xpaCode.valueOf(currentNode) + " - " + xpaInfo.valueOf(currentNode);
          log.warn(text);
          throw new APIException(text, xpaCode.valueOf(currentNode));
        }
      }
    } catch (JDOMException e) {
      log.error("JDOMException: " + e.getMessage());
    }
View Full Code Here

 
      // Manage redirects and missing pages
      updateRedirect(root, pages);
    } catch (JDOMException e) {
      log.error("Error loading redirects", e);
      throw new APIException("Error parsing XML", e);
    }
  }
View Full Code Here

      return shouldContinue(
          root, "/api/query-continue/links",
          properties);
    } catch (JDOMException e) {
      log.error("Error loading links", e);
      throw new APIException("Error parsing XML", e);
    }
  }
View Full Code Here

      return shouldContinue(
          root, "/api/query-continue/links",
          properties);
    } catch (JDOMException e) {
      log.error("Error loading links", e);
      throw new APIException("Error parsing XML", e);
    }
  }
View Full Code Here

      // Retrieve continue
      return false;
    } catch (JDOMException e) {
      log.error("Error loading revisions", e);
      throw new APIException("Error parsing XML", e);
    }
  }
View Full Code Here

      return shouldContinue(
          root, "/api/query-continue/querypage",
          properties);
    } catch (JDOMException e) {
      log.error("Error loading query page list", e);
      throw new APIException("Error parsing XML", e);
    }
  }
View Full Code Here

        user.setRights(rights);
        return user;
      }
    } catch (JDOMException e) {
      log.error("Error retrieving user information", e);
      throw new APIException("Error parsing XML", e);
    }
    return null;
  }
View Full Code Here

          throws APIException {
    try {
      checkForError(getRoot(properties, ApiRequest.MAX_ATTEMPTS));
    } catch (JDOMParseException e) {
      log.error("Error deleting page", e);
      throw new APIException("Error parsing XML", e);
    }
  }
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.APIException

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.