Search in sources :

Example 1 with WebRequest

use of org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest 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 2 with WebRequest

use of org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest in project ecf by eclipse.

the class VBulletin method createMemberGroupListRequest.

@Override
protected WebRequest createMemberGroupListRequest() {
    WebRequest request = new GetRequest(httpClient, url, "profile.php");
    request.addParameter(new NameValuePair("do", "editusergroups"));
    return request;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest)

Example 3 with WebRequest

use of org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest in project ecf by eclipse.

the class Forum method getThreads.

public Collection<IThread> getThreads() {
    PHPBBParser parser = (PHPBBParser) bb.getParser();
    Map<ID, IThread> threadMap = null;
    try {
        WebRequest request = new GetRequest(bb.getHttpClient(), new URL(id.toExternalForm()), "");
        request.addParameter(new NameValuePair("f", String.valueOf(id.getLongValue())));
        request.execute();
        String resp = request.getResponseBodyAsString();
        request.releaseConnection();
        threadMap = parser.parseThreads(resp);
        for (IThread thread : threadMap.values()) {
            ((AbstractBBObject) thread).setBulletinBoard(bb);
            ((Thread) thread).forum = this;
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return new HashSet<IThread>(threadMap.values());
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) AbstractBBObject(org.eclipse.ecf.internal.bulletinboard.commons.AbstractBBObject) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) ID(org.eclipse.ecf.core.identity.ID) ForumID(org.eclipse.ecf.internal.provider.phpbb.identity.ForumID) IOException(java.io.IOException) URL(java.net.URL) IThread(org.eclipse.ecf.bulletinboard.IThread) HashSet(java.util.HashSet)

Example 4 with WebRequest

use of org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest in project ecf by eclipse.

the class ThreadBrowser2 method fetchNewMessages.

public List<IThreadMessage> fetchNewMessages() throws BBException {
    List<IThreadMessage> messages = new ArrayList<IThreadMessage>();
    try {
        int nextPage = STARTPAGE;
        while (nextPage > NONE) {
            WebRequest req = createRequest(nextPage);
            req.execute();
            String resp = req.getResponseBodyAsString();
            req.releaseConnection();
            // Add messages from page
            messages.addAll(0, ((PHPBBParser) bb.getParser()).parseMessages2(resp, thread.lastReadMessageId, true));
            nextPage = ((PHPBBParser) bb.getParser()).parseNextPage(resp);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return messages;
}
Also used : IThreadMessage(org.eclipse.ecf.bulletinboard.IThreadMessage) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 5 with WebRequest

use of org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest in project ecf by eclipse.

the class Forum method getThreads.

public Collection<IThread> getThreads() {
    VBParser parser = (VBParser) bb.getParser();
    Map<ID, IThread> threadMap = null;
    WebRequest request = new GetRequest(bb.getHttpClient(), getURL(), "");
    request.addParameter(new NameValuePair("f", String.valueOf(id.getLongValue())));
    try {
        request.execute();
        String resp = request.getResponseBodyAsString();
        request.releaseConnection();
        threadMap = parser.parseThreads(resp);
        for (IThread thread : threadMap.values()) {
            ((AbstractBBObject) thread).setBulletinBoard(bb);
            ((Thread) thread).forum = this;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return new HashSet<IThread>(threadMap.values());
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) AbstractBBObject(org.eclipse.ecf.internal.bulletinboard.commons.AbstractBBObject) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) ID(org.eclipse.ecf.core.identity.ID) ForumID(org.eclipse.ecf.internal.provider.vbulletin.identity.ForumID) IOException(java.io.IOException) IThread(org.eclipse.ecf.bulletinboard.IThread) HashSet(java.util.HashSet)

Aggregations

WebRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest)12 IOException (java.io.IOException)8 NameValuePair (org.apache.commons.httpclient.NameValuePair)7 GetRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest)5 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 IMember (org.eclipse.ecf.bulletinboard.IMember)2 IThread (org.eclipse.ecf.bulletinboard.IThread)2 IThreadMessage (org.eclipse.ecf.bulletinboard.IThreadMessage)2 ID (org.eclipse.ecf.core.identity.ID)2 AbstractBBObject (org.eclipse.ecf.internal.bulletinboard.commons.AbstractBBObject)2 PostRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 BBException (org.eclipse.ecf.bulletinboard.BBException)1 IMemberGroup (org.eclipse.ecf.bulletinboard.IMemberGroup)1 IllegalWriteException (org.eclipse.ecf.bulletinboard.IllegalWriteException)1 ForumID (org.eclipse.ecf.internal.provider.phpbb.identity.ForumID)1 ThreadID (org.eclipse.ecf.internal.provider.phpbb.identity.ThreadID)1 ForumID (org.eclipse.ecf.internal.provider.vbulletin.identity.ForumID)1