Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan E. Cook2017-08-23 19:00:38 -0400
committerMorgan Cook2017-09-01 12:22:56 -0400
commit168d2552e90981e3fb0b72e16eab83a639805578 (patch)
tree933c743ac3c093448c243997466216748ebb9ac7
parentd8bb07912f399554605d3cb12dafa5176462a259 (diff)
downloadorg.eclipse.osee-168d2552e90981e3fb0b72e16eab83a639805578.tar.gz
org.eclipse.osee-168d2552e90981e3fb0b72e16eab83a639805578.tar.xz
org.eclipse.osee-168d2552e90981e3fb0b72e16eab83a639805578.zip
refactor: Cleanup OrcsScriptEndpoint
Signed-off-by: Morgan E. Cook <morgan.e.cook@boeing.com> Change-Id: Ic7ec4a37b272836d0af3efcf000fc79e8a3bff43
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsScriptEndpoint.java44
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsScriptEndpointImpl.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsScriptResource.java)31
3 files changed, 52 insertions, 29 deletions
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsScriptEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsScriptEndpoint.java
new file mode 100644
index 0000000000..3003d42598
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsScriptEndpoint.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.model;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("script")
+public interface OrcsScriptEndpoint {
+
+ @GET
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
+ public Response getScriptResult(@Context HttpHeaders httpHeaders, @DefaultValue("") @QueryParam("script") String script, //
+ @DefaultValue("") @QueryParam("parameters") String parameters, //
+ @DefaultValue("") @QueryParam("filename") String filename, //
+ @DefaultValue("false") @QueryParam("debug") boolean debug);
+
+ @POST
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
+ public Response postScript(@Context HttpHeaders httpHeaders, @DefaultValue("") @FormParam("script") String script, //
+ @DefaultValue("") @FormParam("parameters") String parameters, //
+ @DefaultValue("") @FormParam("filename") String filename, //
+ @DefaultValue("false") @FormParam("debug") boolean debug);
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
index 908ac49f35..5a14b1a65e 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
@@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.rest.internal;
import java.util.HashSet;
import java.util.Set;
-import javax.script.ScriptEngine;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import org.eclipse.osee.activity.api.ActivityLog;
@@ -65,11 +64,8 @@ public class OrcsApplication extends Application {
}
public void start() {
- ScriptEngine engine = orcsApi.getScriptEngine();
- resources.add(new OrcsScriptResource(engine));
-
classes.add(BranchesResource.class);
-
+ resources.add(new OrcsScriptEndpointImpl(orcsApi.getScriptEngine()));
resources.add(new BranchEndpointImpl(orcsApi, resourceManager, activityLog));
resources.add(new OrcsWriterEndpointImpl(orcsApi));
resources.add(new TransactionEndpointImpl(orcsApi));
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsScriptResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsScriptEndpointImpl.java
index 5565e2c7c0..4af6533f9a 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsScriptResource.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsScriptEndpointImpl.java
@@ -23,14 +23,7 @@ import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
@@ -40,37 +33,27 @@ import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.StreamingOutput;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.rest.model.OrcsScriptEndpoint;
/**
* @author Roberto E. Escobar
*/
@Path("script")
-public class OrcsScriptResource {
+public class OrcsScriptEndpointImpl implements OrcsScriptEndpoint {
private final ScriptEngine engine;
- public OrcsScriptResource(ScriptEngine engine) {
+ public OrcsScriptEndpointImpl(ScriptEngine engine) {
this.engine = engine;
}
- @GET
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
- public Response getScriptResult(@Context HttpHeaders httpHeaders, //
- @DefaultValue("") @QueryParam("script") String script, //
- @DefaultValue("") @QueryParam("parameters") String parameters, //
- @DefaultValue("") @QueryParam("filename") String filename, //
- @DefaultValue("false") @QueryParam("debug") boolean debug) {
+ @Override
+ public Response getScriptResult(HttpHeaders httpHeaders, String script, String parameters, String filename, boolean debug) {
return evaluateScript(httpHeaders, script, parameters, filename, debug);
}
- @POST
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
- public Response postScript(@Context HttpHeaders httpHeaders, //
- @DefaultValue("") @FormParam("script") String script, //
- @DefaultValue("") @FormParam("parameters") String parameters, //
- @DefaultValue("") @FormParam("filename") String filename, //
- @DefaultValue("false") @FormParam("debug") boolean debug) {
+ @Override
+ public Response postScript(HttpHeaders httpHeaders, String script, String parameters, String filename, boolean debug) {
return evaluateScript(httpHeaders, script, parameters, filename, debug);
}

Back to the top