use of org.apache.commons.httpclient.NameValuePair 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.apache.commons.httpclient.NameValuePair in project ecf by eclipse.
the class PHPBB method getMessage.
public IThreadMessage getMessage(ID id) throws BBException {
GetRequest request = new GetRequest(httpClient, url, "viewtopic.php");
request.addParameter(new NameValuePair("p", String.valueOf(((ThreadMessageID) id).getLongValue())));
String resp = null;
try {
request.execute();
resp = request.getResponseBodyAsString();
} catch (IOException e) {
e.printStackTrace();
}
request.releaseConnection();
if (resp != null) {
ThreadMessage msg = getParser().parseRequestedMessage((ThreadMessageID) id, resp);
msg.setBulletinBoard(this);
IMember author = msg.author;
((Member) author).setBulletinBoard(this);
return msg;
}
return null;
}
use of org.apache.commons.httpclient.NameValuePair 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;
}
use of org.apache.commons.httpclient.NameValuePair in project ecf by eclipse.
the class VBulletin method getThread.
public IThread getThread(ID id) throws BBException {
GetRequest request = new GetRequest(httpClient, url, "showthread.php");
request.addParameter(new NameValuePair("t", String.valueOf(((ThreadID) id).getLongValue())));
String resp = null;
try {
request.execute();
resp = request.getResponseBodyAsString();
} catch (IOException e) {
e.printStackTrace();
}
request.releaseConnection();
if (resp != null) {
Thread t = getParser().parseThreadPageForThreadAttributes(resp);
t.setBulletinBoard(this);
return t;
}
return null;
}
use of org.apache.commons.httpclient.NameValuePair in project ecf by eclipse.
the class VBulletin method createMemberGroupListRequest.
@Override
protected WebRequest createMemberGroupListRequest() {
WebRequest request = new GetRequest(httpClient, url, "profile.php");
request.addParameter(new NameValuePair("do", "editusergroups"));
return request;
}
Aggregations