Package org.eclipse.ecf.internal.bulletinboard.commons.webapp

Examples of org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest


  protected WebRequest createMemberGroupListRequest() {
    return new GetRequest(httpClient, url, "groupcp.php");
  }

  public boolean login(IBBCredentials credentials) throws BBException {
    PostRequest request = new PostRequest(httpClient, url, "login.php");
    NameValuePair params[] = {
        new NameValuePair("username", credentials.getUsername()),
        new NameValuePair("password", credentials.getPassword()),
        // disabled checkbox: new NameValuePair("autologin", "on"),
        new NameValuePair("redirect", ""),
        new NameValuePair("login", "Log in") };
    request.setParameters(params);

    try {
      request.execute();
      request.releaseConnection();
      Map<String, String> detectedCookies = PHPBBCookies
          .detectCookies(httpClient.getState().getCookies());
      if (detectedCookies.containsKey(PHPBBCookies.KEY_SESS_ID)) {
        // We have a session id
        sessionId = detectedCookies.get(PHPBBCookies.KEY_SESS_ID);
View Full Code Here


    }
    return false;
  }

  public boolean logout() throws BBException {
    PostRequest request = new PostRequest(httpClient, url, "login.php");
    request.addParameter(new NameValuePair("logout", "true"));
    try {
      request.execute();
      request.releaseConnection();
      loggedInMemberId = null;
      return true;
    } catch (Exception e) {
      throw new BBException(e);
    }
View Full Code Here

  public boolean postThread(IThread thread) throws IllegalWriteException,
      BBException {
    if ((mode & READ_ONLY) == READ_ONLY) {
      throw new IllegalWriteException(E_READ_ONLY);
    }
    WebRequest request = new PostRequest(bb.getHttpClient(), bb.getURL(),
        "posting.php");

    NameValuePair params[];
    params = new NameValuePair[] {
        new NameValuePair("subject", thread.getPrePostMessage()
            .getName()),
        new NameValuePair("message", thread.getPrePostMessage()
            .getMessage()),
        new NameValuePair("f", String.valueOf(id.getLongValue())),
        new NameValuePair("mode", "newtopic"),
        // checkbox : disabled new NameValuePair("disable_smilies",
        // "on"),
        // checkbox : disabled new NameValuePair("disable_bbcode",
        // "on"),
        // checkbox : disabled new NameValuePair("notify", "on"),
        new NameValuePair("post", "Submit") };
    request.addParameters(params);
    // We seem to always have to get the response body.
    try {
      request.execute();
      request.getResponseBodyAsString();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    request.releaseConnection();
    return true;
  }
View Full Code Here

      throw new IllegalWriteException(E_READ_ONLY);
    }
    ThreadMessage msg = (ThreadMessage) message;
    // FIXME assert msg.bb == bb;
    assert msg.getThread() == this;
    PostRequest request = new PostRequest(bb.getHttpClient(), bb.getURL(),
        "posting.php");
    NameValuePair[] params = new NameValuePair[] {
        new NameValuePair("subject", msg.getName()),
        new NameValuePair("message", msg.getMessage()),
        new NameValuePair("t", String.valueOf(id.getLongValue())),
        new NameValuePair("mode", "reply"),
        // checkbox : disabled new NameValuePair("disable_smilies",
        // "on"),
        // checkbox : disabled new NameValuePair("disable_bbcode",
        // "on"),
        // checkbox : disabled new NameValuePair("notify", "on"),
        new NameValuePair("post", "Submit") };
    request.addParameters(params);
    String resp = null;
    try {
      request.execute();
      resp = request.getResponseBodyAsString();
      String info = ((PHPBBParser) bb.getParser())
          .parseInformationMessage(resp);
      Matcher m = Pattern.compile(
          "<a href=\"viewtopic.php\\?p=([0-9]+)(?:.*?)\">").matcher(
          info);
 
View Full Code Here

     * IBBConfiguration.P_POSTS_PER_PAGE);
     */
    int pp = 15;
    int start = (page - 1) * pp;

    WebRequest req = new PostRequest(bb.getHttpClient(), bb.getURL(),
        "viewtopic.php?t=" + ((ThreadID) thread.getID()).getLongValue()
            + "&start=" + start);
    req.addParameter(new NameValuePair("postorder", "desc"));
    req.addParameter(new NameValuePair("postdays", "0"));
    req.addParameter(new NameValuePair("submit", "Go"));
    return req;
  }
View Full Code Here

    request.setParameters(params);
    return request;
  }

  public boolean login(IBBCredentials credentials) throws BBException {
    PostRequest request = new PostRequest(httpClient, url, "login.php");
    NameValuePair params[] = {
        new NameValuePair("vb_login_username", credentials
            .getUsername()),
        new NameValuePair("cookieuser", "1"),
        new NameValuePair("vb_login_password", credentials
            .getPassword()), new NameValuePair("submit", "Login"),
        new NameValuePair("s", ""), new NameValuePair("do", "login"),
        new NameValuePair("forceredirect", "0"),
        new NameValuePair("vb_login_md5password", ""),
        new NameValuePair("vb_login_md5password_utf", "") };
    request.setParameters(params);
    try {
      request.execute();
      request.releaseConnection();
      Map<String, String> detectedCookies = VBCookies
          .detectCookies(httpClient.getState().getCookies());
      if (detectedCookies.containsKey(VBCookies.KEY_SESS_ID)) {
        // We have a session id
        sessionId = detectedCookies.get(VBCookies.KEY_SESS_ID);
View Full Code Here

    }
    return false;
  }

  public boolean logout() throws BBException {
    PostRequest request = new PostRequest(httpClient, url, "logout.php");
    try {
      request.execute();
      request.releaseConnection();
      loggedInMemberId = null;
      return true;
    } catch (Exception e) {
      throw new BBException(e);
    }
View Full Code Here

      throw new IllegalWriteException(E_READ_ONLY);
    }
    ThreadMessage msg = (ThreadMessage) message;
    // FIXME assert msg.bb == bb;
    assert msg.getThread() == this;
    PostRequest request = new PostRequest(bb.getHttpClient(), bb.getURL(),
        "newreply.php");
    NameValuePair[] params = new NameValuePair[] {
        new NameValuePair("emailupdate", "9999"),
        new NameValuePair("rating", "0") };
    request.addParameters(params);
    params = new NameValuePair[] {
        new NameValuePair("title", message.getName()),
        new NameValuePair("message", msg.getMessage()),
        new NameValuePair("iconid", "0"), new NameValuePair("s", ""),
        new NameValuePair("do", "postreply"),
        new NameValuePair("t", String.valueOf(id.getLongValue())) };
    request.addParameters(params);
    if (message.getReplyTo() != null) {
      params = new NameValuePair[] { new NameValuePair("p", String
          .valueOf(((ThreadMessageID) message.getReplyTo().getID())
              .getLongValue())) };
      request.addParameters(params);
    }
    params = new NameValuePair[] { new NameValuePair("posthash", ""),
        new NameValuePair("poststarttime", ""),
        new NameValuePair("sbutton", "Submit Reply"),
        new NameValuePair("parseurl", "1"),
    // checkbox : disabled new NameValuePair("disablesmilies", "1"),
    };
    request.addParameters(params);
    try {
      request.execute();
      // TODO: do we have to do this?
      String resp = request.getResponseBodyAsString();
      Header newLocation = request.getMethod().getResponseHeader(
          "Location");
      if (newLocation == null) {
        throw ((VBParser) bb.getParser()).createVBException(
            "The message was not posted.", resp);
      }
View Full Code Here

    }
    return messages;
  }

  public WebRequest createRequest(int page) {
    WebRequest req = new PostRequest(bb.getHttpClient(), bb.getURL(),
        "showthread.php?t="
            + ((ThreadID) thread.getID()).getLongValue() + "&page="
            + page);
    return req;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest

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.