Search in sources :

Example 1 with ThreadMessageID

use of org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID in project ecf by eclipse.

the class PHPBBParser method parseMessage2.

private ThreadMessage parseMessage2(final CharSequence seq, final ThreadMessageID lastReadId) {
    ThreadMessage msg = null;
    Matcher m;
    m = PAT_MSG_POSTID_USERNAME.matcher(seq);
    if (m.find()) {
        final ThreadMessageFactory tmf = new ThreadMessageFactory();
        String idStr = m.group(1);
        ThreadMessageID id = null;
        try {
            id = (ThreadMessageID) tmf.createBBObjectId(namespace, baseURL, idStr);
        } catch (final IDCreateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        if (lastReadId == null || id.getLongValue() > lastReadId.getLongValue()) {
            final String uname = new String(m.group(2));
            msg = new ThreadMessage(id, null);
            m = PAT_MSG_TIMESTAMP.matcher(seq);
            if (m.find()) {
                msg.timePosted = new Date(parseTimestamp(new String(m.group(1))).longValue());
            }
            m = PAT_MSG_TITLE.matcher(seq);
            m.find();
            msg.setNameInternal(new String(m.group(1)));
            m = PAT_MSG_MESSAGE.matcher(seq);
            m.find();
            final String message = StringUtil.stripHTMLFullTrim(m.group(1));
            msg.message = message;
            m = PAT_MEMBER_ID_FROM_LINK.matcher(seq);
            if (m.find()) {
                final MemberFactory mf = new MemberFactory();
                idStr = m.group(1);
                ID id2 = null;
                try {
                    id2 = mf.createBBObjectId(namespace, baseURL, idStr);
                } catch (final NumberFormatException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (final IDCreateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                msg.author = new Member(id2, uname);
            } else {
                final GuestFactory gf = new GuestFactory();
                ID id2 = null;
                try {
                    id2 = gf.createBBObjectId(namespace, baseURL, null);
                } catch (final IDCreateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                msg.author = new Member(id2, uname);
            }
        }
    }
    return msg;
}
Also used : Matcher(java.util.regex.Matcher) ThreadMessageID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ID(org.eclipse.ecf.core.identity.ID) ThreadMessageID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID) Date(java.util.Date)

Example 2 with ThreadMessageID

use of org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID in project ecf by eclipse.

the class PHPBBParser method parseRequestedMessage.

public ThreadMessage parseRequestedMessage(final ThreadMessageID id, final CharSequence seq) throws BBException {
    final ThreadMessageFactory tmf = new ThreadMessageFactory();
    // lastRead = -1 the one we want
    ThreadMessageID lastReadId = null;
    try {
        lastReadId = (ThreadMessageID) tmf.createBBObjectId(namespace, baseURL, String.valueOf(id.getLongValue() - 1));
    } catch (final IDCreateException e) {
        e.printStackTrace();
    }
    final List<ThreadMessage> msgs = parseMessages2(seq, lastReadId, true);
    if (msgs.size() > 0) {
        return msgs.get(0);
    }
    return null;
}
Also used : ThreadMessageID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException)

Aggregations

IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)2 ThreadMessageID (org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID)2 Date (java.util.Date)1 Matcher (java.util.regex.Matcher)1 ID (org.eclipse.ecf.core.identity.ID)1