@@ -1,4 +1,43 @@ |
<?xml version="1.0" encoding="UTF-8"?> |
+<!-- |
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
+ |
+Copyright (c) 2006, 2016 Oracle and/or its affiliates. All rights reserved. |
+ |
+Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
+Other names may be trademarks of their respective owners. |
+ |
+The contents of this file are subject to the terms of either the GNU |
+General Public License Version 2 only ("GPL") or the Common |
+Development and Distribution License("CDDL") (collectively, the |
+"License"). You may not use this file except in compliance with the |
+License. You can obtain a copy of the License at |
+http://www.netbeans.org/cddl-gplv2.html |
+or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
+specific language governing permissions and limitations under the |
+License. When distributing the software, include this License Header |
+Notice in each file and include the License file at |
+nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
+particular file as subject to the "Classpath" exception as provided |
+by Oracle in the GPL Version 2 section of the License file that |
+accompanied this code. If applicable, add the following below the |
+License Header, with the fields enclosed by brackets [] replaced by |
+your own identifying information: |
+"Portions Copyrighted [year] [name of copyright owner]" |
+ |
+If you wish your version of this file to be governed by only the CDDL |
+or only the GPL Version 2, indicate your decision by adding |
+"[Contributor] elects to include this software in this distribution |
+under the [CDDL or GPL Version 2] license." If you do not indicate a |
+single choice of license, a recipient has the option to distribute |
+your version of this file under either the CDDL, the GPL Version 2 or |
+to extend the choice of license to its licensees as provided above. |
+However, if you add GPL Version 2 code and therefore, elected the GPL |
+Version 2 license, then the option applies only if the new code is |
+made subject to such option by the copyright holder. |
+ |
+Contributor(s): |
+--> |
<project default="-deploy-ant" basedir="."> |
<target name="-init" if="deploy.ant.enabled"> |
<property file="${deploy.ant.properties.file}"/> |
@@ -16,7 +55,7 @@ |
<isset property="tomcat.password"/> |
</not> |
</condition> |
- </fail> |
+ </fail> |
</target> |
<target name="-deploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials"> |
<echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/> |
@@ -5,39 +5,49 @@ |
package m.oms; |
|
import csip.Config; |
+import csip.ContextConfig; |
import java.util.Set; |
+import javax.servlet.ServletContext; |
import javax.ws.rs.core.Application; |
-import org.glassfish.jersey.media.multipart.MultiPartFeature; |
+import javax.ws.rs.core.Context; |
|
/** |
* |
- * @author User |
+ * @author Olaf David |
*/ |
@javax.ws.rs.ApplicationPath("") |
public class ApplicationConfig extends Application { |
|
- @Override |
- public Set<Class<?>> getClasses() { |
- Set<Class<?>> resources = new java.util.HashSet<Class<?>>(); |
- resources.add(MultiPartFeature.class); |
- addRestResourceClasses(resources); |
- Config.registry().register(resources); |
- return resources; |
- } |
+ @Context |
+ private ServletContext context; |
|
- /** |
- * Do not modify addRestResourceClasses() method. |
- * It is automatically re-generated by NetBeans REST support to populate |
- * given list with all resources defined in the project. |
- */ |
- private void addRestResourceClasses(Set<Class<?>> resources) { |
- resources.add(csip.ArchiveService.class); |
- resources.add(csip.CatalogService.class); |
- resources.add(csip.ControlService.class); |
- resources.add(csip.QueryService.class); |
- resources.add(csip.ReportService.class); |
- resources.add(csip.UIService.class); |
- resources.add(m.oms.dsl.V1_0.class); |
- } |
- |
+ |
+ @Override |
+ public Set<Class<?>> getClasses() { |
+ Set<Class<?>> resources = new java.util.HashSet<>(); |
+ addRestResourceClasses(resources); |
+ ContextConfig.filterServices(context, resources); |
+ Config.register(resources); |
+ return resources; |
+ } |
+ |
+ |
+ /** |
+ * Do not modify addRestResourceClasses() method. It is automatically |
+ * re-generated by NetBeans REST support to populate given list with all |
+ * resources defined in the project. |
+ */ |
+ private void addRestResourceClasses(Set<Class<?>> resources) { |
+ resources.add(csip.ArchiveService.class); |
+ resources.add(csip.CatalogService.class); |
+ resources.add(csip.ControlService.class); |
+ resources.add(csip.DynamicPyModelDataService.class); |
+ resources.add(csip.QueryService.class); |
+ resources.add(csip.QueueingModelDataService.class); |
+ resources.add(csip.ReportService.class); |
+ resources.add(csip.UIService.class); |
+ resources.add(m.oms.ages.V1_0.class); |
+ resources.add(m.oms.dsl.V1_0.class); |
+ } |
+ |
} |
@@ -9,16 +9,13 @@ |
import csip.ServiceException; |
import csip.annotations.*; |
import csip.utils.Binaries; |
-import csip.utils.ZipFiles; |
+//import csip.utils.ZipFiles; |
import java.io.File; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
import javax.ws.rs.Path; |
-import oms3.annotations.Description; |
-import oms3.annotations.Name; |
-import oms3.annotations.VersionInfo; |
import org.apache.commons.io.FileUtils; |
import org.apache.commons.lang.ArrayUtils; |
|
@@ -39,69 +36,68 @@ |
@Resource(file = "java-stdout.txt java-stderr.txt", type = ResourceType.OUTPUT) |
public class V1_0 extends ModelDataService { |
|
- // parameter keys |
- static final String KEY_SCRIPT = "dsl"; |
- static final String KEY_LOGLEVEL = "loglevel"; |
- static final String KEY_OPTIONS = "java.options"; |
+ // parameter keys |
+ static final String KEY_SCRIPT = "dsl"; |
+ static final String KEY_LOGLEVEL = "loglevel"; |
+ static final String KEY_OPTIONS = "java.options"; |
|
|
- @Override |
- public void doProcess() throws Exception { |
- String dsl = getStringParam(KEY_SCRIPT); |
- String loglevel = getStringParam(KEY_LOGLEVEL, "INFO"); |
- String options = getStringParam(KEY_OPTIONS, ""); |
+ @Override |
+ public void doProcess() throws Exception { |
+ String dsl = parameter().getString(KEY_SCRIPT); |
+ String loglevel = parameter().getString(KEY_LOGLEVEL, "INFO"); |
+ String options = parameter().getString(KEY_OPTIONS, ""); |
+ runSim(dsl, loglevel, options); |
+ } |
|
- runSim(dsl, loglevel, options); |
+ |
+ @Override |
+ protected void postProcess() throws Exception { |
+// ZipFiles.zip(getWorkspaceFile("output")); |
+// results().put(new File(getWorkspaceDir(), "output")); |
+ results().put(getWorkspaceFile("output")); |
+ } |
+ |
+ |
+ private void runSim(String dsl, String loglevel, String options) throws Exception { |
+ Map sysprops = new HashMap(); |
+ sysprops.put("oms3.work", getWorkspaceDir().toString()); |
+ sysprops.put("oms.csip.server", "true"); |
+ |
+ getWorkspaceFile("output").mkdirs(); |
+ |
+ // Create a Process. |
+ Executable p = createProcess(loglevel, dsl, sysprops, options); |
+ |
+ int result = p.exec(); |
+ if (result != 0) { |
+ File err = getWorkspaceFile("java-stderr.txt"); |
+ if (err.exists()) { |
+ throw new ServiceException(FileUtils.readFileToString(err)); |
+ } |
+ throw new ServiceException("General Error." + result); |
} |
+ } |
|
|
- @Override |
- protected void postProcess() throws Exception { |
- ZipFiles.zip(new File(getWorkspaceDir(), "output")); |
- putResult(new File(getWorkspaceDir(), "output.zip")); |
+ private Executable createProcess(String loglevel, String dsl, |
+ Map<String, String> sysprops, String options) throws Exception { |
+ File ws = getWorkspaceDir(); |
+ List<File> jars = new ArrayList<>(); |
+ jars.add(resources().getFile("oms_jar")); |
+ jars.add(resources().getFile("jfreechart_jar")); |
+ jars.add(resources().getFile("groovy_jar")); |
+ jars.add(resources().getFile("jcommon_jar")); |
+ |
+ jars.addAll(Binaries.getJars(getWorkspaceFile("dist"))); |
+ jars.addAll(Binaries.getJars(getWorkspaceFile("lib"))); |
+ jars.addAll(Binaries.getJars(ws)); |
+ |
+ String[] sp = Binaries.asSysProps(sysprops); |
+ if (options != null && !options.isEmpty()) { |
+ String[] opt = options.split("\\s+"); |
+ sp = (String[]) ArrayUtils.addAll(sp, opt); |
} |
- |
- |
- private void runSim(String dsl, String loglevel, String options) throws Exception { |
- Map sysprops = new HashMap(); |
- sysprops.put("oms3.work", getWorkspaceDir().toString()); |
- sysprops.put("oms.csip.server", "true"); |
- |
- new File(getWorkspaceDir(), "output").mkdirs(); |
- |
- // Create a Process. |
- Executable p = createProcess(loglevel, dsl, sysprops, options); |
- |
- int result = p.exec(); |
- if (result != 0) { |
- File err = new File(getWorkspaceDir(), "java-stderr.txt"); |
- if (err.exists()) { |
- throw new ServiceException(FileUtils.readFileToString(err)); |
- } |
- throw new ServiceException("General Error." + result); |
- } |
- } |
- |
- |
- private Executable createProcess(String loglevel, String dsl, Map<String, String> sysprops, String options) throws Exception { |
- File ws = getWorkspaceDir(); |
- List<File> jars = new ArrayList<>(); |
- jars.add(getResourceFile("oms_jar")); |
- jars.add(getResourceFile("jfreechart_jar")); |
- jars.add(getResourceFile("groovy_jar")); |
- jars.add(getResourceFile("jcommon_jar")); |
- |
- jars.addAll(Binaries.getJars(new File(ws, "dist"))); |
- jars.addAll(Binaries.getJars(new File(ws, "lib"))); |
- jars.addAll(Binaries.getJars(ws)); |
- |
- String[] sp = Binaries.asSysProps(sysprops); |
- if (options != null && !options.isEmpty()) { |
- String[] opt = options.split("\\s+"); |
- sp = (String[]) ArrayUtils.addAll(sp, opt); |
- } |
- |
- Executable e = Binaries.getResourceOMSDSL(new File(ws, dsl), sp, ws, jars, loglevel, LOG); |
- return e; |
- } |
+ return Binaries.getResourceOMSDSL(getWorkspaceFile(dsl), sp, ws, jars, loglevel, LOG); |
+ } |
} |