Search in sources :

Example 1 with BBException

use of org.eclipse.ecf.bulletinboard.BBException in project ecf by eclipse.

the class AbstractBBContainer method connect.

public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException {
    this.targetID = targetID;
    bb.postConnect();
    IBBCredentials creds = getCredentialsFromConnectContext(connectContext);
    if (creds != null) {
        try {
            bb.login(creds);
        } catch (BBException e) {
            throw new ContainerConnectException(e);
        }
    }
}
Also used : ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) IBBCredentials(org.eclipse.ecf.bulletinboard.IBBCredentials) BBException(org.eclipse.ecf.bulletinboard.BBException)

Example 2 with BBException

use of org.eclipse.ecf.bulletinboard.BBException in project ecf by eclipse.

the class AbstractBulletinBoard method getMember.

public IMember getMember(ID id) throws BBException {
    if (cachedMembers.containsKey(id)) {
        return cachedMembers.get(id);
    } else {
        final WebRequest request = createMemberPageRequest(id);
        try {
            request.execute();
            final String str = request.getResponseBodyAsString();
            request.releaseConnection();
            final IMember member = parser.parseMemberPageForName(str, id);
            if (member != null) {
                ((AbstractBBObject) member).setBulletinBoard(this);
                cachedMembers.put(member.getID(), member);
                return member;
            }
        } catch (final Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
Also used : WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) IMember(org.eclipse.ecf.bulletinboard.IMember) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) BBException(org.eclipse.ecf.bulletinboard.BBException)

Example 3 with BBException

use of org.eclipse.ecf.bulletinboard.BBException in project ecf by eclipse.

the class PHPBB method getTitle.

public String getTitle() throws BBException {
    if (this.title == null) {
        GetRequest request = new GetRequest(httpClient, url, "");
        String resp = null;
        try {
            request.execute();
            resp = request.getResponseBodyAsString();
        } catch (IOException e) {
            throw new BBException(e);
        }
        request.releaseConnection();
        if (resp != null) {
            this.title = getParser().parseTitle(resp);
        }
    }
    return this.title;
}
Also used : GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) BBException(org.eclipse.ecf.bulletinboard.BBException) IOException(java.io.IOException)

Example 4 with BBException

use of org.eclipse.ecf.bulletinboard.BBException in project ecf by eclipse.

the class VBParser method parseThreadPageForThreadAttributes.

public Thread parseThreadPageForThreadAttributes(CharSequence seq) throws BBException {
    Thread t = (Thread) genericParser.parseSingleIdName(PD_THREAD_ATTRS, seq, new ThreadFactory());
    if (t != null) {
        Map<ID, IBBObject> forums = genericParser.parseMultiIdName(PD_THREAD_ATTRS_FORUM, seq, new ForumFactory(), true);
        Forum prev = null;
        Forum f = null;
        for (IBBObject obj : forums.values()) {
            f = (Forum) obj;
            if (prev != null) {
                prev.subforums.add(f);
            }
            f.setParent(prev);
            prev = f;
        }
        t.forum = f;
        return t;
    } else {
        throw new BBException("Failed to parse the thread.");
    }
}
Also used : ForumFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory) BBException(org.eclipse.ecf.bulletinboard.BBException) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) ThreadMessageID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID) ID(org.eclipse.ecf.core.identity.ID)

Example 5 with BBException

use of org.eclipse.ecf.bulletinboard.BBException in project ecf by eclipse.

the class VBulletin method login.

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);
        }
        if (detectedCookies.containsKey(VBCookies.KEY_USER_ID)) {
            // We have a user id
            ID id = new MemberFactory().createBBObjectId(namespace, url, (String) detectedCookies.get(VBCookies.KEY_USER_ID));
            if (id == null) {
                return false;
            } else {
                loggedInMemberId = id;
                return true;
            }
        }
    } catch (Exception e) {
        throw new BBException(e);
    }
    return false;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) PostRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest) MemberFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.MemberFactory) BBException(org.eclipse.ecf.bulletinboard.BBException) ID(org.eclipse.ecf.core.identity.ID) ThreadID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadID) MemberID(org.eclipse.ecf.internal.provider.vbulletin.identity.MemberID) IOException(java.io.IOException) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) BBException(org.eclipse.ecf.bulletinboard.BBException)

Aggregations

BBException (org.eclipse.ecf.bulletinboard.BBException)10 IOException (java.io.IOException)8 PostRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest)5 NameValuePair (org.apache.commons.httpclient.NameValuePair)4 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)3 ID (org.eclipse.ecf.core.identity.ID)3 GetRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest)2 MalformedURLException (java.net.MalformedURLException)1 Matcher (java.util.regex.Matcher)1 IBBCredentials (org.eclipse.ecf.bulletinboard.IBBCredentials)1 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)1 IMember (org.eclipse.ecf.bulletinboard.IMember)1 IThreadMessage (org.eclipse.ecf.bulletinboard.IThreadMessage)1 IllegalWriteException (org.eclipse.ecf.bulletinboard.IllegalWriteException)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 WebRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest)1 MemberID (org.eclipse.ecf.internal.provider.phpbb.identity.MemberID)1 ThreadID (org.eclipse.ecf.internal.provider.phpbb.identity.ThreadID)1 ThreadMessageID (org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID)1 MemberID (org.eclipse.ecf.internal.provider.vbulletin.identity.MemberID)1