Package net.sourceforge.jwbf.core.contentRep

Examples of net.sourceforge.jwbf.core.contentRep.SimpleArticle


   * @throws ProcessException
   * @throws ActionException
   */
  private void writeArticle(MediaWikiText text) throws ActionException, ProcessException {
   
    SimpleArticle article = new SimpleArticle();
    article.setTitle(text.getLabel());
    article.setText(text.getText());
    article.setMinorEdit(text.isMinorEdit());
    article.setEditSummary(text.getEditSummary());
   
    bot.writeContent(article);
   
  }
View Full Code Here


    if (store != null) {
      if (store.containsKey(name)) {
        ac = new GetRevision(getVersion(), name, GetRevision.TIMESTAMP);
        performAction(ac);

        SimpleArticle storeSa = store.get(name);
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("stored article (" + storeSa.getTitle() + ") revid: " + storeSa.getRevisionId());
        }
        SimpleArticle liveSa = ac.getArticle();
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("live article revid: " + liveSa.getRevisionId());
        }
        if (liveSa.getRevisionId().equals(storeSa.getRevisionId())) {

          return store.get(name);
        }
      }
View Full Code Here


    performAction(new PostModifyContent(this, simpleArticle));
    if (store != null) {
      String label = simpleArticle.getTitle();
      SimpleArticle sa;
      if (store.containsKey(label)) {
        if (LOGGER.isDebugEnabled())
          LOGGER.debug("contains article: " + label); // TODO RM
        sa = store.get(label);
      } else {
        sa = new SimpleArticle(label);
      }
      sa.setText(simpleArticle.getText());
      sa.setEditor(getUserinfo().getUsername());
      sa.setEditSummary(simpleArticle.getEditSummary());
      sa.setMinorEdit(simpleArticle.isMinorEdit());
      //      sa.setRevisionId((Integer.parseInt(sa.getRevisionId()) + 1) + "");
      if (LOGGER.isDebugEnabled())
        LOGGER.debug("update cache (write)");
      store.put(sa);
    }
View Full Code Here

   */
  public GetRevision(final String articlename) throws ProcessException {
    if (articlename.length() <= 0) {
      throw new ProcessException("articlename is empty");
    }
    sa = new SimpleArticle();
    sa.setTitle(articlename);

   
    contentGet = new Get("/" + articlename + "?format=txt");
    versionGet = new Get("/" + articlename);
View Full Code Here

    //    if (!bot.getUserinfo().getRights().contains("read")) {
    //      throw new ActionException("reading is not permited, make sure that this account is able to read");
    //    } FIXME check if

    this.properties = properties;
    sa = new SimpleArticle();
    sa.setTitle(articlename);
    String uS = "/api.php?action=query&prop=revisions&titles="
      + MediaWiki.encode(articlename) + "&rvprop="
      + getDataProperties(properties) + getReversion(properties)
      + "&rvlimit=1" + "&format=xml";
View Full Code Here

   * zimWiki to mediaWiki
   */
  public SimpleArticle readData(String name, int properties)
      throws ActionException, ProcessException {
    File f = new File(getRootFolder(), name + ZIMEXT);
    SimpleArticle sa = new SimpleArticle();
    sa.setTitle(name);
    StringBuffer text = new StringBuffer();
    // create a file reader
    try {
      BufferedReader myInput = new BufferedReader(new FileReader(f));

      String line = "";
      String cont = "";

      // if we are reading content, than
      while ((line = myInput.readLine()) != null) {

        // omit the headline
        if (line.startsWith("====== " + name + " ======")) {

          // store every line in 'text' and add a newline
          while ((cont = myInput.readLine()) != null) {

            // zim encapsulates bold letters with **
            // media wiki encapsulates bold letters with '''
            cont = cont.replace("**", "'''");

            // images are written in zim:
            // {{../MatlabSVM_01.png?width=400}}
            // in media wiki:
            // [[MatlabSVM_01.png|45px|none|MatlabSVM_01]]
            cont = cont.replace("{{../", "[[Image:");
            cont = cont.replace("?width=", "|");
            cont = cont.replace("}}", "|none| " + name + "]]");
            text.append( cont + "\n");
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace(); // TODO transform to system exception
    }
    sa.setText(text.toString());
    return sa;
  }
View Full Code Here

   */
  public GetRevision(final String articlename) throws ProcessException {
    if (articlename.length() <= 0) {
      throw new ProcessException("articlename is empty");
    }
    sa = new SimpleArticle();
    sa.setTitle(articlename);

   
    contentGet = new Get("/" + articlename + "?action=export&format=raw&");
    versionGet = new Get("/" + articlename);
View Full Code Here

   * {@inheritDoc}
   */
  public SimpleArticle get(String title) {
    if (containsKey(title))
      return read(title);
    return new SimpleArticle(title);
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.jwbf.core.contentRep.SimpleArticle

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.