aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCheng Chen2012-05-21 23:28:12 (EDT)
committerCheng Chen2012-05-21 23:28:12 (EDT)
commitdb0342bfffb12a9c06d0972c69fab6d353774302 (patch)
tree227995d94d978253c5bf2627e72237ec0c047503
parent0964802ee63c31e770423ac52792e30a4cfdc353 (diff)
downloadorg.eclipse.recommenders-db0342bfffb12a9c06d0972c69fab6d353774302.zip
org.eclipse.recommenders-db0342bfffb12a9c06d0972c69fab6d353774302.tar.gz
org.eclipse.recommenders-db0342bfffb12a9c06d0972c69fab6d353774302.tar.bz2
[snipmatch] switch to remote client for class LoginThreadrefs/changes/65/6065/1
Change-Id: I2592d8e374e80552e8252035ff6158b3c1eb7213 Signed-off-by: Cheng Chen <chengchendoc@gmail.com>
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/LoginThread.java179
1 files changed, 89 insertions, 90 deletions
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/LoginThread.java b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/LoginThread.java
index 23a3cc2..a69e448 100755..100644
--- a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/LoginThread.java
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/LoginThread.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
-*/
+ */
package org.eclipse.recommenders.snipmatch.web;
@@ -21,92 +21,91 @@ import org.w3c.dom.Document;
*/
class LoginThread extends PostThread {
- private String username;
- private String password;
- private ArrayList<ILoginListener> listeners;
-
- public LoginThread(MatchClient client, String username, String password) {
-
- super(client, MatchClient.LOGIN_URL);
- this.username = username;
- this.password = password;
- this.listeners = new ArrayList<ILoginListener>();
- }
-
- public void addListener(ILoginListener listener) {
-
- listeners.add(listener);
- }
-
- public void removeListener(ILoginListener listener) {
-
- listeners.remove(listener);
- }
-
- public void clearListeners() {
-
- listeners.clear();
- }
-
- @Override
- public void run() {
-
- addParameter("username", username);
- addParameter("password", password);
- addParameter("clientName", client.getName());
- addParameter("clientVersion", client.getVersion());
-
- InputStream response = post();
-
- if (response == null) {
-
- for (ILoginListener listener : listeners) {
- listener.loginFailed("Connection error.");
- }
-
- done = true;
- return;
- }
-
- if (done) return;
-
- DocumentBuilderFactory dbf;
- DocumentBuilder db;
- Document responseXml;
-
- try {
-
- dbf = DocumentBuilderFactory.newInstance();
- db = dbf.newDocumentBuilder();
- responseXml = db.parse(response);
- }
- catch (Exception e) {
-
- e.printStackTrace();
-
- for (ILoginListener listener : listeners) {
- listener.loginFailed("Bad response format.");
- }
-
- done = true;
- return;
- }
-
- String msg = responseXml.getDocumentElement().getTextContent();
-
- if (msg.equals("User authenticated.")) {
-
- for (ILoginListener listener : listeners) {
- listener.loginSucceeded();
- }
- }
- else {
-
- for (ILoginListener listener : listeners) {
- listener.loginFailed(msg);
- }
- }
-
- done = true;
- }
-}
+ private String username;
+ private String password;
+ private ArrayList<ILoginListener> listeners;
+
+ public LoginThread(RemoteMatchClient client, String username, String password) {
+
+ super(client, RemoteMatchClient.LOGIN_URL);
+ this.username = username;
+ this.password = password;
+ this.listeners = new ArrayList<ILoginListener>();
+ }
+
+ public void addListener(ILoginListener listener) {
+
+ listeners.add(listener);
+ }
+
+ public void removeListener(ILoginListener listener) {
+
+ listeners.remove(listener);
+ }
+
+ public void clearListeners() {
+
+ listeners.clear();
+ }
+
+ @Override
+ public void run() {
+
+ addParameter("username", username);
+ addParameter("password", password);
+ addParameter("clientName", client.getName());
+ addParameter("clientVersion", client.getVersion());
+
+ InputStream response = post();
+
+ if (response == null) {
+
+ for (ILoginListener listener : listeners) {
+ listener.loginFailed("Connection error.");
+ }
+
+ done = true;
+ return;
+ }
+
+ if (done)
+ return;
+
+ DocumentBuilderFactory dbf;
+ DocumentBuilder db;
+ Document responseXml;
+
+ try {
+
+ dbf = DocumentBuilderFactory.newInstance();
+ db = dbf.newDocumentBuilder();
+ responseXml = db.parse(response);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+
+ for (ILoginListener listener : listeners) {
+ listener.loginFailed("Bad response format.");
+ }
+
+ done = true;
+ return;
+ }
+
+ String msg = responseXml.getDocumentElement().getTextContent();
+
+ if (msg.equals("User authenticated.")) {
+
+ for (ILoginListener listener : listeners) {
+ listener.loginSucceeded();
+ }
+ } else {
+
+ for (ILoginListener listener : listeners) {
+ listener.loginFailed(msg);
+ }
+ }
+
+ done = true;
+ }
+} \ No newline at end of file