Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Finkbeiner2014-09-13 08:44:30 -0400
committerAndrew M. Finkbeiner2014-09-13 08:45:30 -0400
commit9a88ba425592462812ef3cb765e218f86cbc46a4 (patch)
tree239b2eb00da3320ecfc3bd0dff072462e47a9f21
parent5170228162f28d3d67d81e4132831af400107057 (diff)
downloadorg.eclipse.osee-9a88ba425592462812ef3cb765e218f86cbc46a4.tar.gz
org.eclipse.osee-9a88ba425592462812ef3cb765e218f86cbc46a4.tar.xz
org.eclipse.osee-9a88ba425592462812ef3cb765e218f86cbc46a4.zip
feature[ats_ATS106617]: Update lookup delete
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java8
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java11
-rw-r--r--plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/OTELookup.java3
-rw-r--r--plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/internal/OTELookupImpl.java18
4 files changed, 37 insertions, 3 deletions
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 b966e07956..2cf3eafb5d 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.URI;
+import java.util.UUID;
import java.util.concurrent.Callable;
+
import javax.ws.rs.HttpMethod;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
+
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;
@@ -25,12 +28,11 @@ public class RemoveServer implements Callable<OTEMasterServerResult> {
@Override
public OTEMasterServerResult call() throws Exception {
URI targetUri =
- UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).build();
+ UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).path(server.getUUID().toString()).build();
OTEMasterServerResult result = new OTEMasterServerResult();
try {
- webClientProvider.target(targetUri).request(MediaType.APPLICATION_XML).method(HttpMethod.DELETE,
- Entity.xml(server));
+ webClientProvider.target(targetUri).request(MediaType.APPLICATION_XML).method(HttpMethod.DELETE);
} catch (Throwable th) {
result.setSuccess(false);
result.setThrowable(th);
diff --git a/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java
index 724d0f3413..b0250b0ada 100644
--- a/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java
+++ b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java
@@ -3,18 +3,22 @@ package org.eclipse.osee.ote.master.rest.internal;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import java.util.concurrent.ExecutionException;
+
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriBuilderException;
import javax.ws.rs.core.UriInfo;
+
import org.eclipse.osee.ote.master.OTELookup;
import org.eclipse.osee.ote.master.OTELookupServerEntry;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
@@ -101,5 +105,12 @@ public class OTEAvailableServersResource {
OTELookup oteLookup = OTERestApplication.getOTELookup();
oteLookup.removeServer(Util.convert(server));
}
+
+ @DELETE
+ @Path("{uuid}")
+ public void removeServer(@PathParam("uuid") String uuid) throws Exception {
+ OTELookup oteLookup = OTERestApplication.getOTELookup();
+ oteLookup.removeServer(UUID.fromString(uuid));
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/OTELookup.java b/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/OTELookup.java
index f61c4e15e1..16037c54bc 100644
--- a/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/OTELookup.java
+++ b/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/OTELookup.java
@@ -1,6 +1,7 @@
package org.eclipse.osee.ote.master;
import java.util.List;
+import java.util.UUID;
public interface OTELookup {
List<OTELookupServerEntry> getAvailableServers();
@@ -8,4 +9,6 @@ public interface OTELookup {
void addServer(OTELookupServerEntry server);
void removeServer(OTELookupServerEntry server);
+
+ void removeServer(UUID fromString);
}
diff --git a/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/internal/OTELookupImpl.java b/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/internal/OTELookupImpl.java
index b1360fd67f..5807f9323d 100644
--- a/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/internal/OTELookupImpl.java
+++ b/plugins/org.eclipse.osee.ote.master/src/org/eclipse/osee/ote/master/internal/OTELookupImpl.java
@@ -2,6 +2,7 @@ package org.eclipse.osee.ote.master.internal;
import java.util.Date;
import java.util.List;
+import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -58,6 +59,15 @@ public class OTELookupImpl implements OTELookup {
return null;
}
+ private OTELookupServerEntry find(UUID otherEntry) {
+ for (OTELookupServerEntry entry : servers) {
+ if (entry.getUUID().equals(otherEntry)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+
public void start(){
executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
@@ -80,4 +90,12 @@ public class OTELookupImpl implements OTELookup {
this.timeoutSeconds = timeoutSeconds;
}
+ @Override
+ public void removeServer(UUID serverid) {
+ OTELookupServerEntry oldone = find(serverid);
+ if (oldone != null) {
+ servers.remove(oldone);
+ }
+ }
+
}

Back to the top