use of org.apache.commons.httpclient.NameValuePair in project ecf by eclipse.
the class Forum method getThreads.
public Collection<IThread> getThreads() {
PHPBBParser parser = (PHPBBParser) bb.getParser();
Map<ID, IThread> threadMap = null;
try {
WebRequest request = new GetRequest(bb.getHttpClient(), new URL(id.toExternalForm()), "");
request.addParameter(new NameValuePair("f", String.valueOf(id.getLongValue())));
request.execute();
String resp = request.getResponseBodyAsString();
request.releaseConnection();
threadMap = parser.parseThreads(resp);
for (IThread thread : threadMap.values()) {
((AbstractBBObject) thread).setBulletinBoard(bb);
((Thread) thread).forum = this;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new HashSet<IThread>(threadMap.values());
}
use of org.apache.commons.httpclient.NameValuePair 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.apache.commons.httpclient.NameValuePair in project ecf by eclipse.
the class Forum method getThreads.
public Collection<IThread> getThreads() {
VBParser parser = (VBParser) bb.getParser();
Map<ID, IThread> threadMap = null;
WebRequest request = new GetRequest(bb.getHttpClient(), getURL(), "");
request.addParameter(new NameValuePair("f", String.valueOf(id.getLongValue())));
try {
request.execute();
String resp = request.getResponseBodyAsString();
request.releaseConnection();
threadMap = parser.parseThreads(resp);
for (IThread thread : threadMap.values()) {
((AbstractBBObject) thread).setBulletinBoard(bb);
((Thread) thread).forum = this;
}
} catch (IOException e) {
e.printStackTrace();
}
return new HashSet<IThread>(threadMap.values());
}
use of org.apache.commons.httpclient.NameValuePair in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseAttributeNullPath.
public void testParseAttributeNullPath() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie();
cookiespec.parseAttribute(new NameValuePair("path", null), cookie);
assertEquals("/", cookie.getPath());
}
use of org.apache.commons.httpclient.NameValuePair in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseAttributeUnknownValue.
public void testParseAttributeUnknownValue() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie();
cookiespec.parseAttribute(new NameValuePair("nonsense", null), cookie);
}
Aggregations