Search in sources :

Example 66 with ID

use of org.eclipse.ecf.core.identity.ID 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)

Example 67 with ID

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

the class VBParser method parseThreadPageForThreadAttributes.

public Thread parseThreadPageForThreadAttributes(CharSequence seq) throws BBException {
    Thread t = (Thread) genericParser.parseSingleIdName(PD_THREAD_ATTRS, seq, new ThreadFactory());
    if (t != null) {
        Map<ID, IBBObject> forums = genericParser.parseMultiIdName(PD_THREAD_ATTRS_FORUM, seq, new ForumFactory(), true);
        Forum prev = null;
        Forum f = null;
        for (IBBObject obj : forums.values()) {
            f = (Forum) obj;
            if (prev != null) {
                prev.subforums.add(f);
            }
            f.setParent(prev);
            prev = f;
        }
        t.forum = f;
        return t;
    } else {
        throw new BBException("Failed to parse the thread.");
    }
}
Also used : ForumFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory) BBException(org.eclipse.ecf.bulletinboard.BBException) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) ThreadMessageID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID) ID(org.eclipse.ecf.core.identity.ID)

Example 68 with ID

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

the class VBulletin method login.

public boolean login(IBBCredentials credentials) throws BBException {
    PostRequest request = new PostRequest(httpClient, url, "login.php");
    NameValuePair[] params = { new NameValuePair("vb_login_username", credentials.getUsername()), new NameValuePair("cookieuser", "1"), new NameValuePair("vb_login_password", credentials.getPassword()), new NameValuePair("submit", "Login"), new NameValuePair("s", ""), new NameValuePair("do", "login"), new NameValuePair("forceredirect", "0"), new NameValuePair("vb_login_md5password", ""), new NameValuePair("vb_login_md5password_utf", "") };
    request.setParameters(params);
    try {
        request.execute();
        request.releaseConnection();
        Map<String, String> detectedCookies = VBCookies.detectCookies(httpClient.getState().getCookies());
        if (detectedCookies.containsKey(VBCookies.KEY_SESS_ID)) {
            // We have a session id
            sessionId = detectedCookies.get(VBCookies.KEY_SESS_ID);
        }
        if (detectedCookies.containsKey(VBCookies.KEY_USER_ID)) {
            // We have a user id
            ID id = new MemberFactory().createBBObjectId(namespace, url, (String) detectedCookies.get(VBCookies.KEY_USER_ID));
            if (id == null) {
                return false;
            } else {
                loggedInMemberId = id;
                return true;
            }
        }
    } catch (Exception e) {
        throw new BBException(e);
    }
    return false;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) PostRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest) MemberFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.MemberFactory) BBException(org.eclipse.ecf.bulletinboard.BBException) ID(org.eclipse.ecf.core.identity.ID) ThreadID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadID) MemberID(org.eclipse.ecf.internal.provider.vbulletin.identity.MemberID) IOException(java.io.IOException) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) BBException(org.eclipse.ecf.bulletinboard.BBException)

Example 69 with ID

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

the class Activator method unregisterChannel.

private void unregisterChannel(IChannelContainerAdapter channelAdapter) {
    try {
        ID channelID = channelAdapter.getChannelNamespace().createInstance(new Object[] { Activator.PLUGIN_ID });
        channelAdapter.removeChannel(channelID);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ID(org.eclipse.ecf.core.identity.ID)

Example 70 with ID

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

the class Activator method registerChannel.

private void registerChannel(IChannelContainerAdapter channelAdapter) {
    try {
        ID channelID = channelAdapter.getChannelNamespace().createInstance(new Object[] { Activator.PLUGIN_ID });
        IChannel channel = channelAdapter.getChannel(channelID);
        if (channel == null) {
            channel = channelAdapter.createChannel(channelID, this, null);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ID(org.eclipse.ecf.core.identity.ID)

Aggregations

ID (org.eclipse.ecf.core.identity.ID)256 IContainer (org.eclipse.ecf.core.IContainer)29 IOException (java.io.IOException)19 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)18 UUID (java.util.UUID)17 HashMap (java.util.HashMap)12 ArrayList (java.util.ArrayList)11 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)11 GUID (org.eclipse.ecf.core.identity.GUID)11 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)11 XMPPRoomID (org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)11 Namespace (org.eclipse.ecf.core.identity.Namespace)10 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)10 Map (java.util.Map)9 Matcher (java.util.regex.Matcher)9 ECFException (org.eclipse.ecf.core.util.ECFException)9 List (java.util.List)8 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)8 IChannel (org.eclipse.ecf.datashare.IChannel)8 Iterator (java.util.Iterator)7