Search in sources :

Example 61 with ID

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

the class Client1 method createAndConnect.

public void createAndConnect() throws ECFException {
    // create container instance from ECF ContainerFactory
    container = ContainerFactory.getDefault().createContainer(CONTAINER_TYPE);
    // create target ID
    ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(), TARGET_SERVER);
    // connect container to target
    container.connect(targetID, null);
}
Also used : ID(org.eclipse.ecf.core.identity.ID)

Example 62 with ID

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

the class DsClient1 method createAndConnect.

public void createAndConnect() throws ECFException {
    // create container instance from ECF ContainerFactory
    container = ContainerFactory.getDefault().createContainer(CONTAINER_TYPE);
    // create channel
    channel = createChannel(container);
    // create target ID
    ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(), TARGET_SERVER);
    // connect container to target
    container.connect(targetID, null);
}
Also used : ID(org.eclipse.ecf.core.identity.ID)

Example 63 with ID

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

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

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

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