Search in sources :

Example 6 with WebRequest

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

the class AbstractBulletinBoard method getMemberGroups.

public Collection<IMemberGroup> getMemberGroups() throws BBException {
    if (cachedMemberGroups.isEmpty()) {
        final WebRequest request = createMemberGroupListRequest();
        try {
            request.execute();
            final String str = request.getResponseBodyAsString();
            request.releaseConnection();
            cachedMemberGroups = parser.parseMemberGroups(str);
            for (final IMemberGroup grp : cachedMemberGroups.values()) {
                ((AbstractBBObject) grp).setBulletinBoard(this);
            }
        } catch (final IOException e) {
        // log.error(e);
        }
    }
    return new HashSet<IMemberGroup>(cachedMemberGroups.values());
}
Also used : IMemberGroup(org.eclipse.ecf.bulletinboard.IMemberGroup) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 7 with WebRequest

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

the class AbstractBulletinBoard method getMembers.

public List<IMember> getMembers() throws BBException {
    // TODO: this only returns first page
    if (cachedMembers.isEmpty()) {
        final WebRequest request = createMemberListRequest();
        try {
            request.execute();
            final String str = request.getResponseBodyAsString();
            request.releaseConnection();
            cachedMembers = parser.parseMembers(str);
            for (final IMember member : cachedMembers.values()) {
                ((AbstractBBObject) member).setBulletinBoard(this);
            }
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
    return new ArrayList<IMember>(cachedMembers.values());
}
Also used : WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IMember(org.eclipse.ecf.bulletinboard.IMember)

Example 8 with WebRequest

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

the class PHPBB method createMemberPageRequest.

@Override
protected WebRequest createMemberPageRequest(ID id) {
    WebRequest request = new GetRequest(httpClient, url, "profile.php");
    NameValuePair[] params = { new NameValuePair("mode", "viewprofile"), new NameValuePair("u", String.valueOf(((MemberID) id).getLongValue())) };
    request.setParameters(params);
    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 9 with WebRequest

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

the class Forum method postThread.

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("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;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) PostRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) IllegalWriteException(org.eclipse.ecf.bulletinboard.IllegalWriteException) IOException(java.io.IOException)

Example 10 with WebRequest

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

the class ThreadBrowser2 method createRequest.

public WebRequest createRequest(int page) {
    /*
		 * String ppStr =
		 * bb.getActiveConfiguration().getProperties().getProperty(
		 * 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;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) PostRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) ThreadID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadID)

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