use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.
the class VBParser method parseMessages2.
public List<ThreadMessage> parseMessages2(final CharSequence seq, final ID lastReadId, boolean desc, SkippedStatus skipped) throws BBException {
Matcher m;
ThreadMessage msg;
List<ThreadMessage> messages = new ArrayList<ThreadMessage>();
m = PAT_MSG.matcher(seq);
while (m.find()) {
ThreadMessageFactory tmf = new ThreadMessageFactory();
ThreadMessageID id = null;
try {
id = (ThreadMessageID) tmf.createBBObjectId(namespace, baseURL, m.group(1));
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IDCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (lastReadId == null || id.getLongValue() > ((ThreadMessageID) lastReadId).getLongValue()) {
String msgSrc = m.group(2);
msg = parseMessage2(id, msgSrc);
if (msg != null) {
if (desc) {
messages.add(0, msg);
} else {
messages.add(msg);
}
}
} else {
skipped.messagesSkipped = true;
}
}
return messages;
}
use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.
the class Thread method postReply.
public ID postReply(IThreadMessage message) throws IllegalWriteException, BBException {
if ((mode & READ_ONLY) == READ_ONLY) {
throw new IllegalWriteException(E_READ_ONLY);
}
ThreadMessage msg = (ThreadMessage) message;
// FIXME assert msg.bb == bb;
assert msg.getThread() == this;
PostRequest request = new PostRequest(bb.getHttpClient(), bb.getURL(), "posting.php");
NameValuePair[] params = new NameValuePair[] { new NameValuePair("subject", msg.getName()), new NameValuePair("message", msg.getMessage()), new NameValuePair("t", String.valueOf(id.getLongValue())), new NameValuePair("mode", "reply"), // checkbox : disabled new NameValuePair("notify", "on"),
new NameValuePair("post", "Submit") };
request.addParameters(params);
String resp = null;
try {
request.execute();
resp = request.getResponseBodyAsString();
String info = ((PHPBBParser) bb.getParser()).parseInformationMessage(resp);
Matcher m = Pattern.compile("<a href=\"viewtopic.php\\?p=([0-9]+)(?:.*?)\">").matcher(info);
if (m.find()) {
synchronized (this) {
try {
lastReadMessageId = (ThreadMessageID) new ThreadMessageFactory().createBBObjectId(bb.getNamespace(), bb.getURL(), m.group(1));
return lastReadMessageId;
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IDCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
throw new BBException("The message was not posted.");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.
the class ServiceIDTest method testServiceIDFactoryNullProto.
/*
* org.eclipse.ecf.discovery.identity.IServiceIDFactory.createServiceID(Namespace, String[], String[], String[], String, String)
*/
public void testServiceIDFactoryNullProto() {
try {
Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, services, scopes, null, namingAuthority);
} catch (IDCreateException e) {
return;
}
fail("Invalid services may cause InvalidIDException");
}
use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.
the class AbstractParser method parseThreads.
public Map<ID, IThread> parseThreads(final CharSequence seq) {
IPatternDescriptor pattern = getThreadPattern();
IBBObjectFactory factory = getThreadFactory();
Matcher m = pattern.getPattern().matcher(seq);
Map<ID, IThread> threads = new LinkedHashMap<ID, IThread>();
while (m.find()) {
Map<String, Object> values = pattern.getValueMap(m);
ID id = null;
try {
id = factory.createBBObjectId(namespace, baseURL, (String) values.get(IPatternDescriptor.ID_PARAM));
} catch (IDCreateException e) {
// TODO autogen e
e.printStackTrace();
}
String name = StringUtil.stripHTMLTrim((String) values.get(IPatternDescriptor.NAME_PARAM));
String authorInfo = (String) values.get("authorInfo");
IBBObject member = genericParser.parseSingleIdName(getAuthorInfoMemberPattern(), authorInfo, getMemberFactory());
if (member != null) {
values.put("author", member);
} else {
IBBObjectFactory gf = getGuestFactory();
String guestName = StringUtil.stripHTMLTrim(authorInfo);
ID guestID = null;
try {
guestID = gf.createBBObjectId(namespace, baseURL, guestName);
} catch (IDCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
values.put("author", getGuestFactory().createBBObject(guestID, guestName, null));
}
IThread obj = (IThread) factory.createBBObject(id, new String(name), values);
threads.put(id, obj);
}
return threads;
}
use of org.eclipse.ecf.core.identity.IDCreateException 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;
}
Aggregations