Search in sources :

Example 6 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class AbstractPresenceTestCase method getServerConnectID.

protected ID getServerConnectID(int client) {
    final IContainer container = getClient(client);
    final Namespace connectNamespace = container.getConnectNamespace();
    final String username = getUsername(client);
    try {
        return IDFactory.getDefault().createID(connectNamespace, username);
    } catch (final IDCreateException e) {
        fail("Could not create server connect ID");
        return null;
    }
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IContainer(org.eclipse.ecf.core.IContainer) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 7 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class ChatRoomMessageHandler method preChatRoomConnect.

public void preChatRoomConnect(IChatRoomContainer roomContainer, ID roomID) {
    // retrieve our name
    ID connectedID = container.getConnectedID();
    botName = connectedID.getName();
    IChatID chatID = (IChatID) connectedID.getAdapter(IChatID.class);
    if (chatID != null) {
        botName = chatID.getUsername();
    }
    messageSenders.put(roomID, roomContainer.getChatRoomMessageSender());
    if (password != null) {
        try {
            sendMessage(IDFactory.getDefault().createStringID("nickserv"), "identify " + password);
        } catch (IDCreateException e) {
        }
    }
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IChatID(org.eclipse.ecf.presence.im.IChatID) ID(org.eclipse.ecf.core.identity.ID) IChatID(org.eclipse.ecf.presence.im.IChatID)

Example 8 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class PHPBBParser method parseMessages.

public Map<ID, ThreadMessage> parseMessages(final CharSequence seq, final boolean newOnly) throws BBException {
    Matcher matcher;
    String title;
    ThreadMessage msg;
    final Map<ID, ThreadMessage> messages = new HashMap<ID, ThreadMessage>();
    matcher = PAT_MSG.matcher(seq);
    boolean anyFound = false;
    while (matcher.find()) {
        anyFound = true;
        title = StringUtil.stripHTMLTrim(matcher.group(3));
        if (StringUtil.notEmptyStr(title)) {
            final ThreadMessageFactory tmf = new ThreadMessageFactory();
            final String idStr = matcher.group(1);
            ID id = null;
            try {
                id = tmf.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 = (ThreadMessage) tmf.createBBObject(id, title, null);
            messages.put(id, msg);
        }
    }
    if (!anyFound) {
        throw createPHPBBException("No messages found!", seq);
    }
    return messages;
}
Also used : Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ID(org.eclipse.ecf.core.identity.ID) ThreadMessageID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID)

Example 9 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class PHPBBParser method parseForums.

/**
 * Parses forum HTML output into a list of forums.
 * @param seq
 * @return map of ID -> Forum associations.
 */
public Map<ID, Forum> parseForums(final CharSequence seq) {
    final Map<ID, Forum> forums = new LinkedHashMap<ID, Forum>();
    final Matcher matcher = PAT_FORUM_OR_CATEGORY.matcher(seq);
    Category lastCat = null;
    while (matcher.find()) {
        // Matched forum
        if (matcher.group(2) != null) {
            final String name = StringUtil.stripHTMLTrim(matcher.group(2));
            final String desc = StringUtil.stripHTMLTrim(matcher.group(3));
            if (StringUtil.notEmptyStr(name)) {
                final ForumFactory ff = new ForumFactory();
                final String idStr = matcher.group(1);
                ID id = null;
                try {
                    id = ff.createBBObjectId(namespace, baseURL, idStr);
                } catch (final IDCreateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                final Forum forum = (Forum) ff.createBBObject(id, name, null);
                forum.setDescription(desc);
                if (lastCat != null) {
                    lastCat.addSubForum(forum);
                    forum.setParent(lastCat);
                }
                forums.put(id, forum);
            }
        }
        // Matched category
        if (matcher.group(5) != null) {
            final String name = StringUtil.stripHTMLTrim(matcher.group(5));
            if (StringUtil.notEmptyStr(name)) {
                final CategoryFactory cf = new CategoryFactory();
                final String idStr = matcher.group(4);
                ID id = null;
                try {
                    id = cf.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();
                }
                lastCat = (Category) cf.createBBObject(id, name, null);
                forums.put(id, lastCat);
            }
        }
    }
    return forums;
}
Also used : Matcher(java.util.regex.Matcher) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ID(org.eclipse.ecf.core.identity.ID) ThreadMessageID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID) LinkedHashMap(java.util.LinkedHashMap)

Example 10 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class VBParser method parseForums.

public Map<ID, Forum> parseForums(final CharSequence seq) {
    Map<ID, Forum> forums = new LinkedHashMap<ID, Forum>();
    Matcher matcher = PAT_FORUM.matcher(seq);
    while (matcher.find()) {
        String name = StringUtil.stripHTMLTrim(matcher.group(2));
        // String desc = StringUtil.stripHTMLTrim(matcher.group(3));
        if (StringUtil.notEmptyStr(name)) {
            ForumFactory ff = new ForumFactory();
            String idStr = matcher.group(1);
            ID id = null;
            try {
                id = ff.createBBObjectId(namespace, baseURL, idStr);
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IDCreateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Forum forum = (Forum) ff.createBBObject(id, name, null);
            // forum.setDescription(desc);
            forums.put(id, forum);
        }
    }
    return forums;
}
Also used : ForumFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory) Matcher(java.util.regex.Matcher) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ThreadMessageID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID) ID(org.eclipse.ecf.core.identity.ID) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)34 ID (org.eclipse.ecf.core.identity.ID)16 Matcher (java.util.regex.Matcher)11 Namespace (org.eclipse.ecf.core.identity.Namespace)8 ThreadMessageID (org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID)5 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 ExecutionException (org.eclipse.core.commands.ExecutionException)4 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)4 UnknownHostException (java.net.UnknownHostException)3 ContainerConnectedEvent (org.eclipse.ecf.core.events.ContainerConnectedEvent)3 ContainerConnectingEvent (org.eclipse.ecf.core.events.ContainerConnectingEvent)3 ThreadMessageFactory (org.eclipse.ecf.internal.provider.vbulletin.internal.ThreadMessageFactory)3 URI (java.net.URI)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 NameValuePair (org.apache.commons.httpclient.NameValuePair)2 Job (org.eclipse.core.runtime.jobs.Job)2 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)2 IThreadMessage (org.eclipse.ecf.bulletinboard.IThreadMessage)2