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);
}
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);
}
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());
}
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;
}
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;
}
Aggregations