Search in sources :

Example 1 with IThread

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

the class VBulletin method getThread.

public IThread getThread(ID id) throws BBException {
    GetRequest request = new GetRequest(httpClient, url, "showthread.php");
    request.addParameter(new NameValuePair("t", String.valueOf(((ThreadID) id).getLongValue())));
    String resp = null;
    try {
        request.execute();
        resp = request.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }
    request.releaseConnection();
    if (resp != null) {
        Thread t = getParser().parseThreadPageForThreadAttributes(resp);
        t.setBulletinBoard(this);
        return t;
    }
    return null;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) IOException(java.io.IOException) IThread(org.eclipse.ecf.bulletinboard.IThread)

Example 2 with IThread

use of org.eclipse.ecf.bulletinboard.IThread 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 3 with IThread

use of org.eclipse.ecf.bulletinboard.IThread 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)

Example 4 with IThread

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

the class AbstractParser method parseThreads.

public Map<ID, IThread> parseThreads(final CharSequence seq) {
    IPatternDescriptor pattern = getThreadPattern();
    IBBObjectFactory factory = getThreadFactory();
    Matcher m = pattern.getPattern().matcher(seq);
    Map<ID, IThread> threads = new LinkedHashMap<ID, IThread>();
    while (m.find()) {
        Map<String, Object> values = pattern.getValueMap(m);
        ID id = null;
        try {
            id = factory.createBBObjectId(namespace, baseURL, (String) values.get(IPatternDescriptor.ID_PARAM));
        } catch (IDCreateException e) {
            // TODO autogen e
            e.printStackTrace();
        }
        String name = StringUtil.stripHTMLTrim((String) values.get(IPatternDescriptor.NAME_PARAM));
        String authorInfo = (String) values.get("authorInfo");
        IBBObject member = genericParser.parseSingleIdName(getAuthorInfoMemberPattern(), authorInfo, getMemberFactory());
        if (member != null) {
            values.put("author", member);
        } else {
            IBBObjectFactory gf = getGuestFactory();
            String guestName = StringUtil.stripHTMLTrim(authorInfo);
            ID guestID = null;
            try {
                guestID = gf.createBBObjectId(namespace, baseURL, guestName);
            } catch (IDCreateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            values.put("author", getGuestFactory().createBBObject(guestID, guestName, null));
        }
        IThread obj = (IThread) factory.createBBObject(id, new String(name), values);
        threads.put(id, obj);
    }
    return threads;
}
Also used : Matcher(java.util.regex.Matcher) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) ID(org.eclipse.ecf.core.identity.ID) IPatternDescriptor(org.eclipse.ecf.internal.bulletinboard.commons.parsing.IPatternDescriptor) IThread(org.eclipse.ecf.bulletinboard.IThread) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with IThread

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

the class PHPBB method getThread.

public IThread getThread(ID id) throws BBException {
    GetRequest request = new GetRequest(httpClient, url, "viewtopic.php");
    request.addParameter(new NameValuePair("t", String.valueOf(((ThreadID) id).getLongValue())));
    String resp = null;
    try {
        request.execute();
        resp = request.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }
    request.releaseConnection();
    if (resp != null) {
        Thread t = getParser().parseThreadPageForThreadAttributes(resp);
        t.setBulletinBoard(this);
        return t;
    }
    return null;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) IOException(java.io.IOException) IThread(org.eclipse.ecf.bulletinboard.IThread)

Aggregations

IThread (org.eclipse.ecf.bulletinboard.IThread)6 IOException (java.io.IOException)4 NameValuePair (org.apache.commons.httpclient.NameValuePair)4 GetRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest)4 ID (org.eclipse.ecf.core.identity.ID)3 HashSet (java.util.HashSet)2 AbstractBBObject (org.eclipse.ecf.internal.bulletinboard.commons.AbstractBBObject)2 WebRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest)2 URL (java.net.URL)1 LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)1 IllegalWriteException (org.eclipse.ecf.bulletinboard.IllegalWriteException)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 IPatternDescriptor (org.eclipse.ecf.internal.bulletinboard.commons.parsing.IPatternDescriptor)1 ForumID (org.eclipse.ecf.internal.provider.phpbb.identity.ForumID)1 ForumID (org.eclipse.ecf.internal.provider.vbulletin.identity.ForumID)1