summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCheng Chen2012-05-21 23:03:34 (EDT)
committer Cheng Chen2012-05-21 23:03:34 (EDT)
commit0f31d18df450edfc336440a2f26f44be8195a53b (patch)
tree3d60914fb480eabfad82284791047df8f974f2eb
parent0964802ee63c31e770423ac52792e30a4cfdc353 (diff)
downloadorg.eclipse.recommenders-0f31d18df450edfc336440a2f26f44be8195a53b.zip
org.eclipse.recommenders-0f31d18df450edfc336440a2f26f44be8195a53b.tar.gz
org.eclipse.recommenders-0f31d18df450edfc336440a2f26f44be8195a53b.tar.bz2
[snipmatch] switch to remote client part 1refs/changes/63/6063/2
Switch to remote client for class DeleteEffectThread Signed-off-by: Cheng Chen <chengchendoc@gmail.com> Change-Id: Idd2d19e15af20d53a5d7ed44f1647b536432a4ea
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/DeleteEffectThread.java167
1 files changed, 82 insertions, 85 deletions
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/DeleteEffectThread.java b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/DeleteEffectThread.java
index 08db9b6..4d9887d 100755..100644
--- a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/DeleteEffectThread.java
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/web/DeleteEffectThread.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;
@@ -16,91 +16,88 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.eclipse.recommenders.snipmatch.core.Effect;
import org.w3c.dom.Document;
-
/**
* Sends a request to delete an effect from the SnipMatch repository.
*/
public class DeleteEffectThread extends PostThread {
-
- private Effect effect;
- private long waitTime;
- private IDeleteEffectListener listener;
-
- public DeleteEffectThread(MatchClient client, Effect effect, long waitTime,
- IDeleteEffectListener listener) {
-
- super(client, MatchClient.DELETE_URL);
- this.effect = effect;
- this.waitTime = waitTime;
- this.listener = listener;
- }
-
- @Override
- public void run() {
-
- if (!client.isLoggedIn()) {
- listener.deleteEffectFailed("User not authenticated.");
- done = true;
- return;
- }
-
- try {
- sleep(waitTime);
- }
- catch (Exception e) {
- e.printStackTrace();
- listener.deleteEffectFailed("Client thread error.");
- done = true;
- return;
- }
-
- addParameter("username", client.getUsername());
- addParameter("password", client.getPassword());
- addParameter("clientName", client.getName());
- addParameter("clientVersion", client.getVersion());
- addParameter("effectId", effect.getId());
-
- if (done) return;
-
- InputStream response = post();
-
- if (response == null) {
- listener.deleteEffectFailed("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();
-
- listener.deleteEffectFailed("Bad response format.");
-
- done = true;
- return;
- }
-
- String msg = responseXml.getDocumentElement().getTextContent();
-
- if (msg.equals("Deleted.")) {
- listener.deleteEffectSucceeded();
- }
- else {
- listener.deleteEffectFailed(msg);
- }
-
- done = true;
- }
-}
+
+ private Effect effect;
+ private long waitTime;
+ private IDeleteEffectListener listener;
+
+ public DeleteEffectThread(RemoteMatchClient client, Effect effect, long waitTime, IDeleteEffectListener listener) {
+
+ super(client, RemoteMatchClient.DELETE_URL);
+ this.effect = effect;
+ this.waitTime = waitTime;
+ this.listener = listener;
+ }
+
+ @Override
+ public void run() {
+
+ if (!client.isLoggedIn()) {
+ listener.deleteEffectFailed("User not authenticated.");
+ done = true;
+ return;
+ }
+
+ try {
+ sleep(waitTime);
+ } catch (Exception e) {
+ e.printStackTrace();
+ listener.deleteEffectFailed("Client thread error.");
+ done = true;
+ return;
+ }
+
+ addParameter("username", client.getUsername());
+ addParameter("password", client.getPassword());
+ addParameter("clientName", client.getName());
+ addParameter("clientVersion", client.getVersion());
+ addParameter("effectId", effect.getId());
+
+ if (done)
+ return;
+
+ InputStream response = post();
+
+ if (response == null) {
+ listener.deleteEffectFailed("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();
+
+ listener.deleteEffectFailed("Bad response format.");
+
+ done = true;
+ return;
+ }
+
+ String msg = responseXml.getDocumentElement().getTextContent();
+
+ if (msg.equals("Deleted.")) {
+ listener.deleteEffectSucceeded();
+ } else {
+ listener.deleteEffectFailed(msg);
+ }
+
+ done = true;
+ }
+} \ No newline at end of file