Search in sources :

Example 1 with IMember

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

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

the class MemberGroup method getMembers.

public Collection<IMember> getMembers() {
    Map<ID, IMember> map = Collections.emptyMap();
    GetRequest request = new GetRequest(bb.getHttpClient(), bb.getURL(), "groupcp.php");
    request.addParameter(new NameValuePair("g", String.valueOf(id.getLongValue())));
    try {
        request.execute();
        String str = request.getResponseBodyAsString();
        request.releaseConnection();
        if (str != null) {
            map = bb.getParser().parseMembers(str);
            for (IMember member : map.values()) {
                ((AbstractBBObject) member).setBulletinBoard(bb);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return new HashSet<IMember>(map.values());
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) AbstractBBObject(org.eclipse.ecf.internal.bulletinboard.commons.AbstractBBObject) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) ID(org.eclipse.ecf.core.identity.ID) MemberGroupID(org.eclipse.ecf.internal.provider.phpbb.identity.MemberGroupID) IOException(java.io.IOException) IMember(org.eclipse.ecf.bulletinboard.IMember) HashSet(java.util.HashSet)

Example 3 with IMember

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

the class PHPBB method getMessage.

public IThreadMessage getMessage(ID id) throws BBException {
    GetRequest request = new GetRequest(httpClient, url, "viewtopic.php");
    request.addParameter(new NameValuePair("p", String.valueOf(((ThreadMessageID) id).getLongValue())));
    String resp = null;
    try {
        request.execute();
        resp = request.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }
    request.releaseConnection();
    if (resp != null) {
        ThreadMessage msg = getParser().parseRequestedMessage((ThreadMessageID) id, resp);
        msg.setBulletinBoard(this);
        IMember author = msg.author;
        ((Member) author).setBulletinBoard(this);
        return msg;
    }
    return null;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) IOException(java.io.IOException) IThreadMessage(org.eclipse.ecf.bulletinboard.IThreadMessage) IMember(org.eclipse.ecf.bulletinboard.IMember) IMember(org.eclipse.ecf.bulletinboard.IMember)

Example 4 with IMember

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

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

the class AbstractParser method parseMembers.

public Map<ID, IMember> parseMembers(final CharSequence seq) {
    // TODO is stripHTMLTrim needed? GenericParser doesn't do it
    Map<ID, IBBObject> objects = genericParser.parseMultiIdName(getMemberPattern(), seq, getMemberFactory(), true);
    Map<ID, IMember> members = new LinkedHashMap<ID, IMember>(objects.size());
    for (IBBObject obj : objects.values()) {
        members.put(obj.getID(), (IMember) obj);
    }
    return members;
}
Also used : IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) ID(org.eclipse.ecf.core.identity.ID) IMember(org.eclipse.ecf.bulletinboard.IMember) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

IMember (org.eclipse.ecf.bulletinboard.IMember)8 IOException (java.io.IOException)4 IThreadMessage (org.eclipse.ecf.bulletinboard.IThreadMessage)3 ID (org.eclipse.ecf.core.identity.ID)3 NameValuePair (org.apache.commons.httpclient.NameValuePair)2 GetRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest)2 WebRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 BBException (org.eclipse.ecf.bulletinboard.BBException)1 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 AbstractBBObject (org.eclipse.ecf.internal.bulletinboard.commons.AbstractBBObject)1 MemberGroupID (org.eclipse.ecf.internal.provider.phpbb.identity.MemberGroupID)1 ThreadMessageID (org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID)1 MemberFactory (org.eclipse.ecf.internal.provider.vbulletin.internal.MemberFactory)1