Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Finkbeiner2015-07-20 17:48:28 -0400
committerAndrew M. Finkbeiner2015-07-20 17:48:28 -0400
commitb34d68f9f8483831a142888acf1c523b7f87c4fa (patch)
treee9035949e57875a077195601c0e2bf006c86bff0 /plugins/org.eclipse.osee.ote.master.rest.client
parent33c5ff91cd27eafb4da03298f091ef3e59be17a9 (diff)
downloadorg.eclipse.osee-b34d68f9f8483831a142888acf1c523b7f87c4fa.tar.gz
org.eclipse.osee-b34d68f9f8483831a142888acf1c523b7f87c4fa.tar.xz
org.eclipse.osee-b34d68f9f8483831a142888acf1c523b7f87c4fa.zip
feature[ats_ATS213282]: Clean up some logging
Diffstat (limited to 'plugins/org.eclipse.osee.ote.master.rest.client')
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java21
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java24
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java10
4 files changed, 48 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF
index 2a3763e9ed..8934fd9409 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Import-Package: com.google.inject,
javax.ws.rs.client;version="2.0.0",
javax.ws.rs.core;version="2.0.0",
org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.logging,
org.eclipse.osee.jaxrs,
org.eclipse.osee.jaxrs.client,
org.eclipse.osee.ote.master.rest.model
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java
index eb08691b6d..afba074881 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java
@@ -1,13 +1,17 @@
package org.eclipse.osee.ote.master.rest.client.internal;
+import java.net.HttpURLConnection;
import java.net.URI;
import java.util.concurrent.Callable;
+import java.util.logging.Level;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
+import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
@@ -25,17 +29,22 @@ public class AddServer implements Callable<OTEMasterServerResult> {
@Override
public OTEMasterServerResult call() throws Exception {
- URI targetUri =
- UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).build();
-
OTEMasterServerResult result = new OTEMasterServerResult();
try {
- webClientProvider.target(targetUri).request(MediaType.APPLICATION_XML).post(Entity.xml(server));
+ URI targetUri =
+ UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).build();
+
+ if(HttpUtil.canConnect(targetUri)){
+ JaxRsWebTarget target = webClientProvider.target(targetUri);
+ javax.ws.rs.client.Invocation.Builder builder = target.request(MediaType.APPLICATION_XML);
+ builder.post(Entity.xml(server));
+ } else {
+ result.setSuccess(false);
+ }
} catch (Throwable th) {
result.setSuccess(false);
- result.setThrowable(th);
+ // result.setThrowable(th);
}
return result;
}
-
}
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java
new file mode 100644
index 0000000000..1f7edc3820
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java
@@ -0,0 +1,24 @@
+package org.eclipse.osee.ote.master.rest.client.internal;
+
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.util.logging.Level;
+
+import org.eclipse.osee.framework.logging.OseeLog;
+
+public class HttpUtil {
+
+ public static boolean canConnect(URI targetUri) {
+ try{
+ HttpURLConnection connection = (HttpURLConnection)targetUri.toURL().openConnection();
+ connection.setRequestMethod("HEAD");
+ int responseCode = connection.getResponseCode();
+ if(responseCode == 200){
+ return true;
+ }
+ } catch (Throwable th){
+ OseeLog.log(HttpUtil.class, Level.INFO, th);
+ }
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java
index 84bd404078..e1caf94368 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java
@@ -1,11 +1,14 @@
package org.eclipse.osee.ote.master.rest.client.internal;
+import java.net.HttpURLConnection;
import java.net.URI;
import java.util.concurrent.Callable;
+import java.util.logging.Level;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.UriBuilder;
+import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
@@ -28,12 +31,15 @@ public class RemoveServer implements Callable<OTEMasterServerResult> {
try {
URI targetUri =
UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).path(server.getUUID().toString()).build();
- webClientProvider.target(targetUri).request().method(HttpMethod.DELETE);
+ if(HttpUtil.canConnect(targetUri)){
+ webClientProvider.target(targetUri).request().method(HttpMethod.DELETE);
+ } else {
+ result.setSuccess(false);
+ }
} catch (Throwable th) {
result.setSuccess(false);
result.setThrowable(th);
}
return result;
}
-
}

Back to the top