Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M Finkbeiner2013-06-03 20:46:24 +0000
committerGerrit Code Review @ Eclipse.org2013-06-24 17:05:18 +0000
commitec2a4b213f464cff38204510d91c150cf3d5e479 (patch)
treef4d98cc762997ae3d6e1a15526fbfe13d91c2027 /plugins/org.eclipse.osee.ote.master.rest
parent70e46b9f76a0a8032cf9cc2c1581acddded94061 (diff)
downloadorg.eclipse.osee-ec2a4b213f464cff38204510d91c150cf3d5e479.tar.gz
org.eclipse.osee-ec2a4b213f464cff38204510d91c150cf3d5e479.tar.xz
org.eclipse.osee-ec2a4b213f464cff38204510d91c150cf3d5e479.zip
feature[ats_LJNN0]: Update OTE Server Lookup
Initial commit of ote master server. This is a rest server that will be used for server lookup. This commit includes the rest implementation a rest client api and the backing service. Change-Id: If9113aacaf32bc5379a5b17d42b0b2f41706e6b9
Diffstat (limited to 'plugins/org.eclipse.osee.ote.master.rest')
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/.classpath7
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/.project33
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/OSGI-INF/ote.master.rest.application.xml9
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/build.properties6
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/plugin.xml33
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java63
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEMasterApplication.java22
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTERestApplication.java39
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/Util.java49
10 files changed, 275 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ote.master.rest/.classpath b/plugins/org.eclipse.osee.ote.master.rest/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.ote.master.rest/.project b/plugins/org.eclipse.osee.ote.master.rest/.project
new file mode 100644
index 00000000000..ee8542e45be
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.ote.master.rest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.ote.master.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.master.rest/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..5c3bd315d55
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Rest
+Bundle-SymbolicName: org.eclipse.osee.ote.master.rest;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: javax.ws.rs,
+ javax.ws.rs.core,
+ javax.ws.rs.ext,
+ org.eclipse.osee.ote.master,
+ org.eclipse.osee.ote.master.rest.model
+Service-Component: OSGI-INF/*.xml
diff --git a/plugins/org.eclipse.osee.ote.master.rest/OSGI-INF/ote.master.rest.application.xml b/plugins/org.eclipse.osee.ote.master.rest/OSGI-INF/ote.master.rest.application.xml
new file mode 100644
index 00000000000..f9649cdd48f
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/OSGI-INF/ote.master.rest.application.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" immediate="true" name="org.eclipse.osee.ote.rest.internal.OTERestApplication">
+ <implementation class="org.eclipse.osee.ote.master.rest.internal.OTERestApplication"/>
+ <service>
+ <provide interface="javax.ws.rs.core.Application"/>
+ </service>
+ <property name="context.name" type="String" value="otemaster"/>
+ <reference bind="bindOTELookup" cardinality="1..1" interface="org.eclipse.osee.ote.master.OTELookup" name="OTELookup" policy="static" unbind="unbindOTELookup"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.ote.master.rest/build.properties b/plugins/org.eclipse.osee.ote.master.rest/build.properties
new file mode 100644
index 00000000000..3e5f9ad7d0d
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ OSGI-INF/
diff --git a/plugins/org.eclipse.osee.ote.master.rest/plugin.xml b/plugins/org.eclipse.osee.ote.master.rest/plugin.xml
new file mode 100644
index 00000000000..b2deffde7fd
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/plugin.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ id="OTEMasterServerProduct"
+ name="OTE Master Server Product"
+ point="org.eclipse.core.runtime.products">
+ <product
+ application="org.eclipse.osee.ote.master.app"
+ description="OTE Master Server"
+ name="OteMasterProduct">
+ <property
+ name="appName"
+ value="OteMasterProduct">
+ </property>
+
+ </product>
+ </extension>
+ <extension
+ id="org.eclipse.osee.ote.master.app"
+ name="OTE Master Server"
+ point="org.eclipse.core.runtime.applications">
+ <application
+ cardinality="singleton-global"
+ thread="main"
+ visible="true">
+ <run
+ class="org.eclipse.osee.ote.master.rest.internal.OTEMasterApplication">
+ </run>
+ </application>
+ </extension>
+
+</plugin>
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
new file mode 100644
index 00000000000..036e5c72a5b
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java
@@ -0,0 +1,63 @@
+package org.eclipse.osee.ote.master.rest.internal;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+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.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;
+
+@Path("servers")
+public class OTEAvailableServersResource {
+
+ // Allows to insert contextual objects into the class,
+ // e.g. ServletContext, Request, Response, UriInfo
+ @Context
+ UriInfo uriInfo;
+ @Context
+ Request request;
+
+ @GET
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public List<OTEServer> getOTEServers() throws MalformedURLException, IllegalArgumentException, UriBuilderException, InterruptedException, ExecutionException {
+ OTELookup oteLookup = OTERestApplication.getOTELookup();
+ List<OTELookupServerEntry> availableServers = oteLookup.getAvailableServers();
+ List<OTEServer> servers = new ArrayList<OTEServer>();
+ for(OTELookupServerEntry entry:availableServers){
+ servers.add(Util.convert(entry));
+ }
+ return servers;
+ }
+
+ @POST
+ @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public void updateServer(OTEServer server) throws IOException, InterruptedException, ExecutionException, ParseException, URISyntaxException {
+ OTELookup oteLookup = OTERestApplication.getOTELookup();
+ oteLookup.addServer(Util.convert(server));
+ }
+
+ @DELETE
+ @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public void removeServer(OTEServer server) throws IOException, InterruptedException, ExecutionException, ParseException, URISyntaxException {
+ OTELookup oteLookup = OTERestApplication.getOTELookup();
+ oteLookup.removeServer(Util.convert(server));
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEMasterApplication.java b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEMasterApplication.java
new file mode 100644
index 00000000000..bdf922bd79a
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEMasterApplication.java
@@ -0,0 +1,22 @@
+package org.eclipse.osee.ote.master.rest.internal;
+
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+
+public class OTEMasterApplication implements IApplication {
+
+ @Override
+ public Object start(IApplicationContext context) throws Exception {
+ Object obj = new Object();
+ synchronized (obj) {
+ obj.wait();
+ }
+ return IApplication.EXIT_OK;
+ }
+
+ @Override
+ public void stop() {
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTERestApplication.java b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTERestApplication.java
new file mode 100644
index 00000000000..4381c2c1b6a
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTERestApplication.java
@@ -0,0 +1,39 @@
+package org.eclipse.osee.ote.master.rest.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+import org.eclipse.osee.ote.master.OTELookup;
+
+public class OTERestApplication extends Application {
+
+ private static OTELookup oteLookup;
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(OTEAvailableServersResource.class);
+ return classes;
+ }
+
+ public void start(){
+ }
+
+ public void stop(){
+ }
+
+ public void bindOTELookup(OTELookup oteLookupSrv){
+ OTERestApplication.oteLookup = oteLookupSrv;
+ }
+
+ public void unbindOTELookup(OTELookup oteLookupSrv){
+ OTERestApplication.oteLookup = null;
+ }
+
+ static OTELookup getOTELookup(){
+ return oteLookup;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/Util.java b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/Util.java
new file mode 100644
index 00000000000..86c27a553e7
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/Util.java
@@ -0,0 +1,49 @@
+package org.eclipse.osee.ote.master.rest.internal;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+import org.eclipse.osee.ote.master.OTELookupServerEntry;
+import org.eclipse.osee.ote.master.OTEServerType;
+import org.eclipse.osee.ote.master.rest.model.OTEServer;
+
+class Util {
+
+
+ static OTEServer convert(OTELookupServerEntry entry){
+ OTEServer server = new OTEServer();
+ server.setName(entry.getName());
+ server.setStartTime(entry.getStartTime().toString());
+ server.setType(entry.getType().getName());
+ server.setUri(entry.getURI().toString());
+ return server;
+ }
+
+ public static OTELookupServerEntry convert(OTEServer server) throws ParseException, URISyntaxException {
+ UUID uuid = UUID.fromString(server.getUUID());
+ URI uri = new URI(server.getUri());
+ DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
+ Date date = df.parse(server.getStartTime());
+
+ OTELookupServerEntry entry = new OTELookupServerEntry(uuid, uri, server.getName(), new OTEServerTypeGeneric(server.getType()) ,date);
+ return entry;
+ }
+
+ private static class OTEServerTypeGeneric implements OTEServerType{
+ private final String type;
+
+ public OTEServerTypeGeneric(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String getName(){
+ return this.type;
+ }
+ }
+}

Back to the top