Search in sources :

Example 81 with NameValuePair

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());
}
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 82 with NameValuePair

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;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) IOException(java.io.IOException) IThreadMessage(org.eclipse.ecf.bulletinboard.IThreadMessage) IMember(org.eclipse.ecf.bulletinboard.IMember) IMember(org.eclipse.ecf.bulletinboard.IMember)

Example 83 with NameValuePair

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;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) PostRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.PostRequest) MemberFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.MemberFactory) BBException(org.eclipse.ecf.bulletinboard.BBException) ID(org.eclipse.ecf.core.identity.ID) ThreadID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadID) MemberID(org.eclipse.ecf.internal.provider.vbulletin.identity.MemberID) IOException(java.io.IOException) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) BBException(org.eclipse.ecf.bulletinboard.BBException)

Example 84 with NameValuePair

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;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest) IOException(java.io.IOException) IThread(org.eclipse.ecf.bulletinboard.IThread)

Example 85 with NameValuePair

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;
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) WebRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.WebRequest) GetRequest(org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest)

Aggregations

NameValuePair (org.apache.commons.httpclient.NameValuePair)217 ArrayList (java.util.ArrayList)114 Credentials (org.apache.commons.httpclient.Credentials)64 UsernamePasswordCredentials (org.apache.commons.httpclient.UsernamePasswordCredentials)64 Test (org.junit.Test)61 HttpTest (org.apache.sling.commons.testing.integration.HttpTest)49 JsonObject (javax.json.JsonObject)43 PostMethod (org.apache.commons.httpclient.methods.PostMethod)41 HashMap (java.util.HashMap)28 IOException (java.io.IOException)23 Header (org.apache.commons.httpclient.Header)21 JsonArray (javax.json.JsonArray)20 HttpClient (org.apache.commons.httpclient.HttpClient)19 HashSet (java.util.HashSet)17 HttpMethod (org.apache.commons.httpclient.HttpMethod)16 GetMethod (org.apache.commons.httpclient.methods.GetMethod)16 Cookie (org.apache.commons.httpclient.Cookie)13 GetRequest (org.eclipse.ecf.internal.bulletinboard.commons.webapp.GetRequest)10 LinkedList (java.util.LinkedList)8 Map (java.util.Map)8