diff --git a/lib/derby.jar b/lib/derby.jar new file mode 100644 index 0000000..4ee3505 Binary files /dev/null and b/lib/derby.jar differ diff --git a/lib/derbytools.jar b/lib/derbytools.jar new file mode 100644 index 0000000..5dd1657 Binary files /dev/null and b/lib/derbytools.jar differ diff --git a/lib/log4j-1.2.16.jar b/lib/log4j-1.2.16.jar new file mode 100644 index 0000000..3f9d847 Binary files /dev/null and b/lib/log4j-1.2.16.jar differ diff --git a/lib/quartz-all-2.0.1.jar b/lib/quartz-all-2.0.1.jar new file mode 100644 index 0000000..ab10284 Binary files /dev/null and b/lib/quartz-all-2.0.1.jar differ diff --git a/src/java/log4j.properties b/src/java/log4j.properties new file mode 100644 index 0000000..5d834a8 --- /dev/null +++ b/src/java/log4j.properties @@ -0,0 +1,12 @@ + +log4j.rootLogger=DEBUG, A1 +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout + +# Print the date in ISO 8601 format +log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c{2} - %m%n + +# Print only messages of level WARN or above in the package com.foo. +log4j.logger.net.brutex.xservices=DEBUG + +log4j.logger.org.springframework=INFO \ No newline at end of file diff --git a/src/java/net/brutex/xservices/types/ReturnCode.java b/src/java/net/brutex/xservices/types/ReturnCode.java index e742890..6a46094 100644 --- a/src/java/net/brutex/xservices/types/ReturnCode.java +++ b/src/java/net/brutex/xservices/types/ReturnCode.java @@ -86,4 +86,6 @@ public class ReturnCode { } return null; } + + public String getStdOut() { return this.stdOut; } } diff --git a/src/java/net/brutex/xservices/types/ScheduledJob.java b/src/java/net/brutex/xservices/types/ScheduledJob.java new file mode 100644 index 0000000..7573965 --- /dev/null +++ b/src/java/net/brutex/xservices/types/ScheduledJob.java @@ -0,0 +1,135 @@ +/* + * Copyright 2011 Brian Rosenberger (Brutex Network) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.brutex.xservices.types; + +import java.util.GregorianCalendar; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import net.brutex.xservices.util.BrutexNamespaces; + +/** + * Scheduled job type + * + * @author Brian Rosenberger + * @since 0.5.0 + * + */ +@XmlType(namespace=BrutexNamespaces.WS_XSERVICES) +@XmlAccessorType(XmlAccessType.FIELD) +public class ScheduledJob { + + @XmlElement(required=true,name="name") + private String name; + + @XmlElement(required=false, name="description") + private String description; + + @XmlElement(required=true, name="datetime") + private GregorianCalendar date; + + @XmlElement(name="script") + private String script; + + /** + * Create a new scheduled job. + * + * @param name Job name. + * @param datetime Scheduled date and time. + * @param script The script to execute. + */ + public ScheduledJob(String name, GregorianCalendar datetime, String script) { + this.name = name; + this.date = datetime; + this.script = script; + this.description = null; + } + + /** + * Create a new scheduled job. + * + * @param name Job name. + * @param datetime Scheduled date and time. + * @param script The script to execute. + * @param description Job description. + */ + public ScheduledJob(String name, GregorianCalendar datetime, String script, String description) { + this.name = name; + this.date = datetime; + this.script = script; + this.description = description; + } + + /** + * Create a new scheduled job. + */ + public ScheduledJob() { + this.name = null; + this.date=null; + this.script=null; + } + + /** + * Set name of the job. + * @param name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get name of the job. + * @return job name + */ + public String getName() { + return name; + } + + /** + * Set scheduled date. + * @param date + */ + public void setDate(GregorianCalendar date) { + this.date = date; + } + + /** + * get scheduled date. + * @return date + */ + public GregorianCalendar getDate() { + return date; + } + + public void setScript(String script) { + this.script = script; + } + + public String getScript() { + return script; + } + + public void setDescription(String desc) { + this.description = desc; + } + + public String getDescription() { + return description; + } +} diff --git a/src/java/net/brutex/xservices/util/BrutexQuartzConnectionProvider.java b/src/java/net/brutex/xservices/util/BrutexQuartzConnectionProvider.java new file mode 100644 index 0000000..37fb7bf --- /dev/null +++ b/src/java/net/brutex/xservices/util/BrutexQuartzConnectionProvider.java @@ -0,0 +1,181 @@ +/* + * Copyright 2011 Brian Rosenberger (Brutex Network) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.brutex.xservices.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.quartz.utils.ConnectionProvider; + +/** + * @author Brian Rosenberger + * + */ +public class BrutexQuartzConnectionProvider implements ConnectionProvider { + + private Connection conn = null; + private final Logger logger = Logger.getLogger(this.getClass().getCanonicalName()); + + + public Connection getConnection() throws SQLException { + if( conn!= null && conn.isValid(5)) { + logger.debug("Checking tables on pre-exisiting database connection."); + checkTables(); + return conn; + } + try { + // Class.forName("org.hsqldb.jdbc.JDBCDriver" ); + Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); + } catch (Exception e) { + logger.fatal("Failed to load Derby JDBC driver."); + e.printStackTrace(); + return null; + } + + if(isConnected(false)) { + checkTables(); + } else { + return null; + } + + return conn; + } + + public void shutdown() throws SQLException { + try { + // Class.forName("org.hsqldb.jdbc.JDBCDriver" ); + Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); + } catch (Exception e) { + System.err.println("ERROR: failed to load Derby JDBC driver."); + e.printStackTrace(); + return; + } + String t = this.getClass().getClassLoader().getResource("/").toString() + .substring(6); + t += "../data/db"; + System.out.println("Shut down embedded database now."); + Connection c = DriverManager.getConnection("jdbc:derby:" + t + + ";shutdown=true;"); + + } + + private synchronized void recursiveDelete(File dbDir) { + File[] files = dbDir.listFiles(); + for (int i = 0; i < files.length; i++) { + if (files[i].isFile()) { + files[i].delete(); + } else { + recursiveDelete(files[i]); + files[i].delete(); + } + } + dbDir.delete(); + } + + private synchronized void checkTables() throws SQLException { + logger.debug("Checking QUARTZ database schema."); + if(!isConnected(false)) { + logger.error("Failed to validate QUARTZ database schema."); + return; + } + List ddl_list = new ArrayList(11); + ddl_list.add("QRTZ_JOB_DETAILS"); + ddl_list.add("QRTZ_TRIGGERS"); + ddl_list.add("QRTZ_SIMPLE_TRIGGERS"); + ddl_list.add("QRTZ_CRON_TRIGGERS"); + ddl_list.add("QRTZ_SIMPROP_TRIGGERS"); + ddl_list.add("QRTZ_BLOB_TRIGGERS"); + ddl_list.add("QRTZ_CALENDARS"); + ddl_list.add("QRTZ_PAUSED_TRIGGER_GRPS"); + ddl_list.add("QRTZ_FIRED_TRIGGERS"); + ddl_list.add("QRTZ_SCHEDULER_STATE"); + ddl_list.add("QRTZ_LOCKS"); + + String ddl = this.getClass().getClassLoader().getResource("/").toString() + .substring(6)+ "../data/"; + + DatabaseMetaData dmd = conn.getMetaData(); + for (String tbl : ddl_list) { + ResultSet rs = dmd.getTables(null, "APP", tbl, null); + if (!rs.next()) { + logger.log(Level.INFO, "Adding DDL for table "+ tbl); + Statement st = conn.createStatement(); + File ddlFile = new File(ddl + tbl + ".ddl"); + String create = ""; + try { + BufferedReader r = new BufferedReader(new FileReader(ddlFile)); + while (r.ready()) { + create += r.readLine() + "\n"; + } + create.trim(); + if( st.execute(create)) { + logger.log(Level.INFO, "Table " + tbl + " created."); + } + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (SQLException ex) { + logger.log(Level.ERROR, "Error executing statement "+ create ); + System.out.println(ex.getMessage()); + } + } else { + logger.trace("Table "+tbl+" exists."); + } + } + } + + private synchronized boolean isConnected(boolean fail) throws SQLException { + if(conn!=null && conn.isValid(5)) { + return true; + } else { + String t = this.getClass().getClassLoader().getResource("/").toString().substring(6); // WEB-INF/classes + t += "../data/db"; + logger.debug("Database directory is set to '" + t + "'"); + try { + this.conn = DriverManager.getConnection("jdbc:derby:" + t + ";create=true;"); + } catch (SQLException ex) { + logger.error(ex.getMessage(), ex); + if(!fail) { + logger.warn("Deleting database directory."); + recursiveDelete(new File(t)); + logger.warn("Retrying to connect to database."); + return isConnected(true); + } else { + return false; + } + } + } + return false; + } +} + + diff --git a/src/java/net/brutex/xservices/util/JobWrapper.java b/src/java/net/brutex/xservices/util/JobWrapper.java new file mode 100644 index 0000000..8ec7ae1 --- /dev/null +++ b/src/java/net/brutex/xservices/util/JobWrapper.java @@ -0,0 +1,96 @@ +/* + * Copyright 2011 Brian Rosenberger (Brutex Network) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.brutex.xservices.util; + +import java.io.Serializable; +import java.util.Date; + +import org.mozilla.javascript.Context; +import org.mozilla.javascript.Scriptable; +import org.quartz.Job; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * Wrapper for jobs that can be executed through quartz scheduler. + * + * @author Brian Rosenberger, bru@brutex.de + * @since 0.5.0 + * + */ +public class JobWrapper implements Job, Serializable { + + public void execute(JobExecutionContext jcontext) + + throws JobExecutionException { + try { + + System.out.println("Executing scheduled job '"+jcontext.getJobDetail().getKey().getName()+"' at " + new Date()); + + JobDataMap jdMap = jcontext.getJobDetail().getJobDataMap(); + String script = jdMap.getString("script"); + + // Create and enter a Context. A Context stores information about + // the execution environment of a script. + Context cx = Context.enter(); + cx.setOptimizationLevel(0); + cx.setLanguageVersion(Context.VERSION_1_7); + // cx is the Context instance you're using to run scripts + /* + * cx.setClassShutter(new ClassShutter() { public boolean + * visibleToScripts(String className) { + * if(className.startsWith("adapter")) return true; + * if(className.startsWith("java.lang.System") || + * className.startsWith + * ("org.apache.tomcat.util.log.SystemLogHandler")) return true; + * System.out.println(className + " is blocked."); return false; } + * }); + */ + + // Initialise the standard objects (Object, Function, etc.). This + // must be done before scripts can be + // executed. The null parameter tells initStandardObjects + // to create and return a scope object that we use + // in later calls. + Scriptable scope = cx.initStandardObjects(); + //Object wrappedOut = Context.javaToJS(System.out, scope); + //Object wrappedOut2 = Context.javaToJS(this, scope); + //scope.put("out", scope, wrappedOut); + //scope.put("exe", scope, wrappedOut2); + + // Execute the script + // cx.evaluateString(scope, "importClass('java.lang.System');\n", + // "head", 1, null); + // cx.evaluateString(scope, "importPackage('java.util');\n", "head", + // 2, null); + Object obj = cx + .evaluateString(scope, script, "TestScript", 1, null); + + + } catch (Exception e) { + System.out.println(e.getMessage()); + } finally { + // Exit the Context. This removes the association between the + // Context and the current thread and is an + // essential cleanup action. There should be a call to exit for + // every call to enter. + Context.exit(); + } + + } +} \ No newline at end of file diff --git a/src/java/net/brutex/xservices/ws/DateService.java b/src/java/net/brutex/xservices/ws/DateService.java index 0263d3a..3aec090 100644 --- a/src/java/net/brutex/xservices/ws/DateService.java +++ b/src/java/net/brutex/xservices/ws/DateService.java @@ -144,12 +144,29 @@ public interface DateService { @WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal, @WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format) throws XServicesFault; + /** + * Converts a string into date using pre-defined date formats. + * + * @param s Date/ time as string + * @param format date format + * @param timezone timezone + * @return XML Date + * @throws XServicesFault + */ @WebMethod(operationName=OPERATION_PARSEDATE) public abstract GregorianCalendar parseDate( @WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s, @WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format, @WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault; + /** + * Converts a string into date using any format. + * @param s date/ time as string + * @param format date format + * @param timezone timezone + * @return XML Date + * @throws XServicesFault + */ @WebMethod(operationName=OPERATION_PARSEDATEADVANCED) public abstract GregorianCalendar parseDateAdvanced( @WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s, diff --git a/src/java/net/brutex/xservices/ws/ExecuteService.java b/src/java/net/brutex/xservices/ws/ExecuteService.java index 67b9e85..644a77c 100644 --- a/src/java/net/brutex/xservices/ws/ExecuteService.java +++ b/src/java/net/brutex/xservices/ws/ExecuteService.java @@ -19,6 +19,7 @@ package net.brutex.xservices.ws; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; import net.brutex.xservices.types.HostConnection; import net.brutex.xservices.types.ReturnCode; @@ -26,6 +27,7 @@ import net.brutex.xservices.util.BrutexNamespaces; /** * Task execution web service + * * @author Brian Rosenberger * @since 0.1.0 * @@ -130,5 +132,14 @@ public interface ExecuteService { @WebParam(name = "command") String cmd, @WebParam(name = "expect") String expect, @WebParam(name = "timeout") long timeout); + + /** + * @param script + * @throws XServicesFault + */ + @WebMethod(operationName = "runJavaScript") + public abstract void runJScript( + @WebParam(name = "script") @XmlElement(required=true) String script) throws XServicesFault; + } \ No newline at end of file diff --git a/src/java/net/brutex/xservices/ws/FileService.java b/src/java/net/brutex/xservices/ws/FileService.java index 7dc5548..bfe811b 100644 --- a/src/java/net/brutex/xservices/ws/FileService.java +++ b/src/java/net/brutex/xservices/ws/FileService.java @@ -26,8 +26,6 @@ import javax.xml.bind.annotation.XmlElement; import org.apache.cxf.annotations.WSDLDocumentation; import org.apache.cxf.annotations.WSDLDocumentationCollection; -import com.sun.xml.internal.ws.api.model.wsdl.WSDLDescriptorKind; - import net.brutex.xservices.types.ArchiveResource; import net.brutex.xservices.types.AttachmentType; import net.brutex.xservices.types.FileResource; @@ -37,7 +35,10 @@ import net.brutex.xservices.types.ReturnCode; import net.brutex.xservices.util.BrutexNamespaces; import net.brutex.xservices.util.XServicesDocumentation; /** + * File related web service operations. + * * @author Brian Rosenberger + * @since 0.3.0 * */ @WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES) @@ -48,20 +49,24 @@ import net.brutex.xservices.util.XServicesDocumentation; ) public interface FileService { - public static final String OPERATION_BASENAME ="basename"; - public static final String OPERATION_DOWNLOADFILE ="downloadFile"; - public static final String OPERATION_UPLOADFILE ="uploadFile"; - public static final String OPERATION_COPY ="copy"; - public static final String OPERATION_COPYFILE ="copyFile"; - public static final String OPERATION_LOADRESOURCE = "loadResource"; - public static final String OPERATION_LOADRESOURCEFROMARCHIVE = "loadResourceFromArchive"; - public static final String OPERATION_ECHOTOFILE = "echoToFile"; - public static final String OPERATION_CHANGEOWNER = "changeOwner"; - public static final String OPERATION_CHANGEMODE = "changeMode"; - public static final String OPERATION_CHANGEGROUP = "changeGroup"; - public static final String OPERATION_REPLACEINFILE = "replaceInFile"; - public static final String OPERATION_REPLACEINFILE2 = "replaceInFile2"; - public static final String OPERATION_REPLACEINFILEREGEX = "replaceInFileRegEx"; + final String OPERATION_BASENAME ="basename"; + final String OPERATION_DOWNLOADFILE ="downloadFile"; + final String OPERATION_UPLOADFILE ="uploadFile"; + final String OPERATION_COPY ="copy"; + final String OPERATION_COPYFILE ="copyFile"; + final String OPERATION_LOADRESOURCE = "loadResource"; + final String OPERATION_LOADRESOURCEFROMARCHIVE = "loadResourceFromArchive"; + final String OPERATION_ECHOTOFILE = "echoToFile"; + final String OPERATION_CHANGEOWNER = "changeOwner"; + final String OPERATION_CHANGEMODE = "changeMode"; + final String OPERATION_CHANGEGROUP = "changeGroup"; + final String OPERATION_REPLACEINFILE = "replaceInFile"; + final String OPERATION_REPLACEINFILE2 = "replaceInFile2"; + final String OPERATION_REPLACEINFILEREGEX = "replaceInFileRegEx"; + + final String PARAM_FILE = "file"; + final String PARAM_ENCODING = "encoding"; + final String PARAM_OVERRIDE = "override"; /** * @param filename @@ -71,7 +76,7 @@ public interface FileService { @WSDLDocumentation(value = "The base name of the given file excluding the suffix.") @WebMethod(operationName = OPERATION_BASENAME) public abstract String basename( - @WebParam(name = "file") @XmlElement(required=true) String filename, + @WebParam(name = PARAM_FILE) @XmlElement(required=true) String filename, @WebParam(name = "suffix") String suffix); /** @@ -92,7 +97,7 @@ public interface FileService { @WSDLDocumentation(XServicesDocumentation.SERVICE_OPERATION_UPLOADFILE) @WebMethod(operationName = OPERATION_UPLOADFILE) public abstract String uploadFile( - @WebParam(name = "file") AttachmentType file) throws XServicesFault; + @WebParam(name = PARAM_FILE) AttachmentType file) throws XServicesFault; /** * @param src @@ -109,8 +114,8 @@ public interface FileService { @WebParam(name = FileSetResource.XML_NAME) @XmlElement(required=true) FileSetResource src, @WebParam(name = "todir") @XmlElement(required=true) String todir, @WebParam(name = "preservelastmodified") boolean plm, - @WebParam(name = "overwrite") boolean overwrite, - @WebParam(name = "encoding") String encoding) throws XServicesFault; + @WebParam(name = PARAM_OVERRIDE) boolean overwrite, + @WebParam(name = PARAM_ENCODING) String encoding) throws XServicesFault; /** * @param fromFile @@ -124,7 +129,7 @@ public interface FileService { public abstract ReturnCode copyFile( @WebParam(name = "fromFile") @XmlElement(required=true) String fromFile, @WebParam(name = "toFile") @XmlElement(required=true) String tofile, - @WebParam(name = "overwrite") boolean overwrite) throws XServicesFault; + @WebParam(name = PARAM_OVERRIDE) boolean overwrite) throws XServicesFault; /** * @param res @@ -136,7 +141,7 @@ public interface FileService { @WebMethod(operationName = OPERATION_LOADRESOURCE) public abstract String loadRes( @WebParam(name = FileResource.XML_NAME) FileResource res, - @WebParam(name = "encoding") String encoding) throws XServicesFault; + @WebParam(name = PARAM_ENCODING) String encoding) throws XServicesFault; /** * @param res @@ -148,7 +153,7 @@ public interface FileService { @WebMethod(operationName = OPERATION_LOADRESOURCEFROMARCHIVE) public abstract String loadResFromArchive( @WebParam(name = "archiveresource") ArchiveResource res, - @WebParam(name = "encoding") String encoding) throws XServicesFault; + @WebParam(name = PARAM_ENCODING) String encoding) throws XServicesFault; /** * @param message @@ -162,14 +167,18 @@ public interface FileService { @WebMethod(operationName = OPERATION_ECHOTOFILE) public abstract ReturnCode echo2file( @WebParam(name = "message") @XmlElement(required=true) String message, - @WebParam(name = "file") @XmlElement(required=true) String file, - @WebParam(name = "encoding") String encoding, + @WebParam(name = PARAM_FILE) @XmlElement(required=true) String file, + @WebParam(name = PARAM_ENCODING) String encoding, @WebParam(name = "append") boolean append) throws XServicesFault; /** - * @param res - * @param owner - * @return + * Changes the owner of a file or all files inside specified directories. + * Right now it has effect only under Unix/ Linux as it is implemented through + * the 'chown' command. + * + * @param res Collection of files/ directories + * @param owner Identifier of the new owner + * @return */ @WebMethod(operationName = OPERATION_CHANGEOWNER) public abstract ReturnCode changeOwner( @@ -177,8 +186,12 @@ public interface FileService { @WebParam(name = "owner") @XmlElement(required=true) String owner); /** - * @param res - * @param group + * Changes the group owner of a file or all files inside specified directories. + * Right now it has effect only under Unix/ Linux as it is implemented through + * the 'chgrp' command. + * + * @param res Collection of files/ directories + * @param group Identifier of the new group owner * @return */ @WebMethod(operationName = OPERATION_CHANGEGROUP) diff --git a/src/java/net/brutex/xservices/ws/JobService.java b/src/java/net/brutex/xservices/ws/JobService.java new file mode 100644 index 0000000..2bb4309 --- /dev/null +++ b/src/java/net/brutex/xservices/ws/JobService.java @@ -0,0 +1,102 @@ +/* + * Copyright 2011 Brian Rosenberger (Brutex Network) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.brutex.xservices.ws; + +import java.math.BigInteger; +import java.util.GregorianCalendar; +import java.util.List; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; + +import net.brutex.xservices.types.DateFormatType; +import net.brutex.xservices.types.DateTimeUnits; +import net.brutex.xservices.types.ScheduledJob; +import net.brutex.xservices.util.BrutexNamespaces; + +import org.apache.cxf.annotations.WSDLDocumentation; +import org.apache.cxf.annotations.WSDLDocumentationCollection; + +/** + * Job management services. + * @author Brian Rosenberger + * @since 0.5.0 + * + */ +@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES) +public interface JobService { + + public static final String SERVICE_NAME = "JobService"; + final String OPERATION_GETJOBLIST = "getJobs"; + final String OPERATION_SCHEDULEJOB = "scheduleJob"; + final String OPERATION_GETJOB = "getJob"; + final String OPERATION_DELETEJOB = "deleteJob"; + + final String PARAM_JOB = "job"; + + + /** + * Get a full list of all scheduled jobs. + * + * @return List of scheduled jobs + * @throws XServicesFault + */ + @WebMethod(operationName=OPERATION_GETJOBLIST) + @WSDLDocumentation(value="Get list of scheduled jobs") + public abstract List getJobList() throws XServicesFault; + + /** + * Add a job to the scheduler. + * + * @param job + * @return The unique identifier of the job. + * @throws XServicesFault + */ + @WebMethod(operationName=OPERATION_SCHEDULEJOB) + @WSDLDocumentation(value="Schedule a job") + public abstract String scheduleJob( + @WebParam(name=PARAM_JOB) @XmlElement(required=true) ScheduledJob job) + throws XServicesFault; + + /** + * Get a job by id. + * + * @param uuid + * @return Job details + * @throws XServicesFault + */ + @WebMethod(operationName=OPERATION_GETJOB) + @WSDLDocumentation(value="Get a job by id") + public abstract ScheduledJob getJob( + @WebParam(name="id") @XmlElement(required=true) String uuid) throws XServicesFault; + + /** + * Delete a job from scheduler. + * + * @param uuid Id of the job that should be deleted + * @throws XServicesFault + */ + @WebMethod(operationName=OPERATION_DELETEJOB) + @WSDLDocumentation(value="Delete a scheduled job.") + public abstract void deleteJob( + @WebParam(name="id") @XmlElement(required=true) String uuid) throws XServicesFault; + + + +} diff --git a/src/java/net/brutex/xservices/ws/MiscService.java b/src/java/net/brutex/xservices/ws/MiscService.java index 1a814ea..7b69fd6 100644 --- a/src/java/net/brutex/xservices/ws/MiscService.java +++ b/src/java/net/brutex/xservices/ws/MiscService.java @@ -28,6 +28,7 @@ import org.apache.cxf.annotations.WSDLDocumentation; /** * * @author Brian Rosenberger, bru@brutex.de + * @since 0.4.0 */ @WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES) public interface MiscService { diff --git a/src/java/net/brutex/xservices/ws/impl/ArchiveServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/ArchiveServiceImpl.java index 6a1a7b0..88865d1 100644 --- a/src/java/net/brutex/xservices/ws/impl/ArchiveServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/ArchiveServiceImpl.java @@ -22,9 +22,7 @@ import javax.jws.WebService; import net.brutex.xservices.types.ArchiveResource; import net.brutex.xservices.types.CompressionType; import net.brutex.xservices.types.FileResource; -import net.brutex.xservices.types.FileSetResource; import net.brutex.xservices.types.ResourceInterface; -import net.brutex.xservices.types.ResourceSetInterface; import net.brutex.xservices.types.ReturnCode; import net.brutex.xservices.util.BrutexNamespaces; import net.brutex.xservices.util.RunTask; @@ -52,7 +50,6 @@ public class ArchiveServiceImpl implements ArchiveService { /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#bzip2(net.brutex.xservices.types.FileResource, java.lang.String) */ - @Override @WebMethod(operationName = WS_OPERATION_BZIP2, action = WS_OPERATION_BZIP2) public ReturnCode bzip2(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src, @WebParam(name = WS_PARAM_DESTFILE) String file) { @@ -62,7 +59,7 @@ public class ArchiveServiceImpl implements ArchiveService { /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#bzip2FromArchive(net.brutex.xservices.types.ArchiveResource, java.lang.String) */ - @Override + @WebMethod(operationName = WS_OPERATION_BZIP2_ARCHIVE, action = WS_OPERATION_BZIP2_ARCHIVE) public ReturnCode bzip2FromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src, @WebParam(name = WS_PARAM_DESTFILE) String file) { @@ -72,7 +69,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#gzip(net.brutex.xservices.types.FileResource, java.lang.String) */ - @Override + @WebMethod(operationName = WS_OPERATION_GZIP, action = WS_OPERATION_GZIP) public ReturnCode gzip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src, @WebParam(name = WS_PARAM_DESTFILE) String file) { @@ -82,7 +79,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#gzipFromArchive(net.brutex.xservices.types.ArchiveResource, java.lang.String) */ - @Override + @WebMethod(operationName = WS_OPERATION_GZIP_ARCHIVE, action = WS_OPERATION_GZIP_ARCHIVE) public ReturnCode gzipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src, @WebParam(name = WS_PARAM_DESTFILE) String file) { @@ -92,7 +89,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#gunzip(java.lang.String, java.lang.String) */ - @Override + @WebMethod(operationName = WS_OPERATION_GUNZIP, action = WS_OPERATION_GUNZIP) public ReturnCode gunzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, @WebParam(name = WS_PARAM_DESTDIR) String dest) { @@ -106,7 +103,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#bunzip2(java.lang.String, java.lang.String) */ - @Override + @WebMethod(operationName = WS_OPERATION_BUNZIP2) public ReturnCode bunzip2(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, @WebParam(name = WS_PARAM_DESTDIR) String dest) { @@ -120,7 +117,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#gunzipFromURL(java.lang.String, java.lang.String) */ - @Override + @WebMethod(operationName = "gunzipFromURL") public ReturnCode gunzipFromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src, @WebParam(name = WS_PARAM_DESTDIR) String dest) { @@ -134,7 +131,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#bunzip2FromURL(java.lang.String, java.lang.String) */ - @Override + @WebMethod(operationName = "bunzip2FromURL") public ReturnCode bunzip2FromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src, @WebParam(name = WS_PARAM_DESTDIR) String dest) { @@ -148,7 +145,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#zip(net.brutex.xservices.types.FileResource, java.lang.String, boolean, java.lang.String, int) */ - @Override + @WebMethod(operationName = "zip") public ReturnCode zip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src, @WebParam(name = WS_PARAM_DESTFILE) String file, @@ -167,7 +164,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#zipFromArchive(net.brutex.xservices.types.ArchiveResource, java.lang.String, boolean, java.lang.String, int) */ - @Override + @WebMethod(operationName = "zipFromArchive") public ReturnCode zipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src, @WebParam(name = WS_PARAM_DESTFILE) String file, @@ -180,7 +177,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#unzip(java.lang.String, java.lang.String, boolean, java.lang.String) */ - @Override + @WebMethod(operationName = "unzip") public ReturnCode unzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, @WebParam(name = WS_PARAM_DESTDIR) String dest, @@ -192,7 +189,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#unrar(java.lang.String, java.lang.String) */ - @Override + @WebMethod(operationName = "unrar") public ReturnCode unrar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, @WebParam(name = WS_PARAM_DESTDIR) String dest) { @@ -202,7 +199,7 @@ return null;// return bzip(src, new File(file)); /* (non-Javadoc) * @see net.brutex.xservices.ws.ArchiveService#untar(java.lang.String, java.lang.String, boolean, net.brutex.xservices.types.CompressionType) */ - @Override + @WebMethod(operationName = "untar") public ReturnCode untar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, @WebParam(name = WS_PARAM_DESTDIR) String dest, diff --git a/src/java/net/brutex/xservices/ws/impl/DateServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/DateServiceImpl.java index bb4769c..99d933b 100644 --- a/src/java/net/brutex/xservices/ws/impl/DateServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/DateServiceImpl.java @@ -44,7 +44,7 @@ public class DateServiceImpl implements DateService { private static String ERR_INVALIDFORMAT = "Invalid format pattern."; private static String ERR_INVALIDTIMEZONE = "Invalid timezone."; - @Override + public GregorianCalendar getDate(String timezone) throws XServicesFault { if (! isValidTimezone(timezone) ) { String valid_ids = ""; @@ -60,7 +60,7 @@ public class DateServiceImpl implements DateService { return c; } - @Override + public BigInteger getTimestamp() { Date d = new Date(); long l = d.getTime(); @@ -68,7 +68,7 @@ public class DateServiceImpl implements DateService { return timestamp; } - @Override + public GregorianCalendar getInTimezone(GregorianCalendar cal, String timezone) throws XServicesFault { if(! isValidTimezone(timezone)) throw new XServicesFault(ERR_INVALIDTIMEZONE); @@ -77,12 +77,12 @@ public class DateServiceImpl implements DateService { return c; } - @Override + public String formatDate(GregorianCalendar cal, DateFormatType format) throws XServicesFault { return formatDateAdvanced(cal, format.format()); } - @Override + public String formatDateAdvanced(GregorianCalendar cal, String format) throws XServicesFault { String result= null; @@ -95,12 +95,12 @@ public class DateServiceImpl implements DateService { return result; } - @Override + public GregorianCalendar parseDate(String s, DateFormatType format, String timezone) throws XServicesFault { return parseDateAdvanced(s, format.format(), timezone); } - @Override + public GregorianCalendar parseDateAdvanced(String s, String format, String timezone) throws XServicesFault { SimpleDateFormat f = null; Date date = null; @@ -121,7 +121,7 @@ public class DateServiceImpl implements DateService { return cal; } - @Override + public BigInteger dateTimeDiff(GregorianCalendar fromCal, GregorianCalendar toCal) throws XServicesFault { long diff = toCal.getTimeInMillis() - fromCal.getTimeInMillis(); @@ -129,7 +129,7 @@ public class DateServiceImpl implements DateService { return d; } - @Override + public BigInteger dateTimeDiff2(GregorianCalendar fromCal, GregorianCalendar toCal, DateTimeUnits unit) throws XServicesFault { BigInteger d = dateTimeDiff(fromCal, toCal); @@ -149,7 +149,7 @@ public class DateServiceImpl implements DateService { return d; } - @Override + public GregorianCalendar dateAdd(GregorianCalendar cal, BigInteger value, DateTimeUnits unit) throws XServicesFault { switch (unit) { diff --git a/src/java/net/brutex/xservices/ws/impl/ExecuteServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/ExecuteServiceImpl.java index 6c63c2a..d5cc249 100644 --- a/src/java/net/brutex/xservices/ws/impl/ExecuteServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/ExecuteServiceImpl.java @@ -17,282 +17,338 @@ package net.brutex.xservices.ws.impl; import java.io.File; +import java.util.UUID; + import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import net.brutex.xservices.types.HostConnection; import net.brutex.xservices.types.ReturnCode; import net.brutex.xservices.util.BrutexNamespaces; +import net.brutex.xservices.util.JobWrapper; import net.brutex.xservices.util.RunTask; import net.brutex.xservices.ws.ExecuteService; +import net.brutex.xservices.ws.XServicesFault; import org.apache.tools.ant.taskdefs.ExecTask; import org.apache.tools.ant.taskdefs.optional.net.RExecTask; import org.apache.tools.ant.taskdefs.optional.net.TelnetTask; import org.apache.tools.ant.taskdefs.optional.ssh.SSHExec; import org.apache.tools.ant.types.Commandline; +import org.mozilla.javascript.Context; +import org.mozilla.javascript.Scriptable; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.Trigger; +import static org.quartz.TriggerBuilder.*; +import static org.quartz.SimpleScheduleBuilder.*; +import org.quartz.TriggerUtils; +import org.quartz.impl.StdSchedulerFactory; +import org.quartz.impl.triggers.SimpleTriggerImpl; /** - * + * * @author Brian Rosenberger, bru@brutex.de */ -@WebService( - targetNamespace=BrutexNamespaces.WS_XSERVICES, - endpointInterface="net.brutex.xservices.ws.ExecuteService", - serviceName="ExecuteService" - ) +@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.ExecuteService", serviceName = "ExecuteService") public class ExecuteServiceImpl implements ExecuteService { - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#runCommand(java.lang.String, java.lang.String, long) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#runCommand(java.lang.String, + * java.lang.String, long) */ - @Override @WebMethod(operationName = "runCommand") - public ReturnCode runCommand(@WebParam(name = "executable") String cmd, - @WebParam(name = "argline") String args, - @WebParam(name = "timeout") long timeout) { + public ReturnCode runCommand(@WebParam(name = "executable") String cmd, + @WebParam(name = "argline") String args, + @WebParam(name = "timeout") long timeout) { - return executeCommand(cmd, - Commandline.translateCommandline(args), - null, - false, - null, - false, - true, - false, - timeout); - } + return executeCommand(cmd, Commandline.translateCommandline(args), + null, false, null, false, true, false, timeout); + } - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#runCommandWithArgs(java.lang.String, java.lang.String[], long) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#runCommandWithArgs(java.lang + * .String, java.lang.String[], long) */ - @Override + @WebMethod(operationName = "runCommandWithArgs") - public ReturnCode runCommandWithArgs(@WebParam(name = "executable") String cmd, - @WebParam(name = "arg") String[] args, - @WebParam(name = "timeout") long timeout) { + public ReturnCode runCommandWithArgs( + @WebParam(name = "executable") String cmd, + @WebParam(name = "arg") String[] args, + @WebParam(name = "timeout") long timeout) { - return executeCommand(cmd, - args, - null, - false, - null, - false, - true, - false, - timeout); - } + return executeCommand(cmd, args, null, false, null, false, true, false, + timeout); + } - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#runCommandAsync(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#runCommandAsync(java.lang + * .String, java.lang.String) */ - @Override + @WebMethod(operationName = "runCommandAsync") - public ReturnCode runCommandAsync(@WebParam(name = "executable") String cmd, - @WebParam(name = "argline") String args) { + public ReturnCode runCommandAsync( + @WebParam(name = "executable") String cmd, + @WebParam(name = "argline") String args) { - return executeCommand(cmd, - Commandline.translateCommandline(args), - null, - true, - null, - false, - true, - false, - 0); - } + return executeCommand(cmd, Commandline.translateCommandline(args), + null, true, null, false, true, false, 0); + } - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#runCommandAsyncWithArgs(java.lang.String, java.lang.String[]) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#runCommandAsyncWithArgs(java + * .lang.String, java.lang.String[]) */ - @Override + @WebMethod(operationName = "runCommandAsyncWithArgs") - public ReturnCode runCommandAsyncWithArgs(@WebParam(name = "executable") String cmd, - @WebParam(name = "arg") String[] args) { + public ReturnCode runCommandAsyncWithArgs( + @WebParam(name = "executable") String cmd, + @WebParam(name = "arg") String[] args) { - return executeCommand(cmd, - args, - null, - true, - null, - false, - true, - false, - 0); - } + return executeCommand(cmd, args, null, true, null, false, true, false, + 0); + } - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#runCommandWithSSH(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, long) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#runCommandWithSSH(java.lang + * .String, int, java.lang.String, java.lang.String, java.lang.String, long) */ - @Override + @WebMethod(operationName = "runCommandWithSSH") - public ReturnCode runCommandWithSSH(@WebParam(name = "host") HostConnection host, - @WebParam(name = "command") String cmd, - @WebParam(name = "timeout") long timeout) { + public ReturnCode runCommandWithSSH( + @WebParam(name = "host") HostConnection host, + @WebParam(name = "command") String cmd, + @WebParam(name = "timeout") long timeout) { - return sshExec(host.hostname, host.user, host.password, host.port, cmd, timeout); - } + return sshExec(host.hostname, host.user, host.password, host.port, cmd, + timeout); + } - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#runCommandWithSSHKeyAuth(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, long) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#runCommandWithSSHKeyAuth( + * java.lang.String, int, java.lang.String, java.lang.String, + * java.lang.String, java.lang.String, long) */ - @Override + @WebMethod(operationName = "runCommandWithSSHKeyAuth") - public ReturnCode runCommandWithSSHKeyAuth(@WebParam(name = "host") HostConnection host, - @WebParam(name = "keyfile") String keyfile, - @WebParam(name = "command") String cmd, - @WebParam(name = "timeout") long timeout) { + public ReturnCode runCommandWithSSHKeyAuth( + @WebParam(name = "host") HostConnection host, + @WebParam(name = "keyfile") String keyfile, + @WebParam(name = "command") String cmd, + @WebParam(name = "timeout") long timeout) { - return sshExecWithCert(host.hostname, host.user, host.password, keyfile, host.port, cmd, timeout); - } + return sshExecWithCert(host.hostname, host.user, host.password, + keyfile, host.port, cmd, timeout); + } - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#rExec(net.brutex.xservices.types.HostConnection, java.lang.String, long) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#rExec(net.brutex.xservices + * .types.HostConnection, java.lang.String, long) */ - @Override + @WebMethod(operationName = "rExec") - public ReturnCode rExec(@WebParam(name = "host") HostConnection host, - @WebParam(name = "command") String cmd, - @WebParam(name = "timeout") long timeout) { - return rexec(host.hostname, host.port, host.user, host.password, cmd, timeout); - } + public ReturnCode rExec(@WebParam(name = "host") HostConnection host, + @WebParam(name = "command") String cmd, + @WebParam(name = "timeout") long timeout) { + return rexec(host.hostname, host.port, host.user, host.password, cmd, + timeout); + } - /* (non-Javadoc) - * @see net.brutex.xservices.ws.impl.ExecuteService#runTelnet(net.brutex.xservices.types.HostConnection, java.lang.String, java.lang.String, java.lang.String, long) + /* + * (non-Javadoc) + * + * @see + * net.brutex.xservices.ws.impl.ExecuteService#runTelnet(net.brutex.xservices + * .types.HostConnection, java.lang.String, java.lang.String, + * java.lang.String, long) */ - @Override + @WebMethod(operationName = "telnet") - public ReturnCode runTelnet(@WebParam(name = "host") HostConnection host, - @WebParam(name = "prompt") String prompt, - @WebParam(name = "command") String cmd, - @WebParam(name = "expect") String expect, - @WebParam(name = "timeout") long timeout) { - return telnet(host.hostname, host.port, host.user, host.password, cmd, timeout, prompt, expect); - } + public ReturnCode runTelnet(@WebParam(name = "host") HostConnection host, + @WebParam(name = "prompt") String prompt, + @WebParam(name = "command") String cmd, + @WebParam(name = "expect") String expect, + @WebParam(name = "timeout") long timeout) { + return telnet(host.hostname, host.port, host.user, host.password, cmd, + timeout, prompt, expect); + } - @WebMethod(exclude = true) - private ReturnCode executeCommand(String executable, - String[] args, - File dir, - boolean spawn, - String inputstring, - boolean newenvironment, - boolean vmlauncher, - boolean searchpath, - long timeout) { - ExecTask exe = new ExecTask(); - RunTask runner = new RunTask(exe); + + public void runJScript(String script) throws XServicesFault { - /* - Commandline cmdl = new Commandline(); - cmdl.setExecutable(executable); - cmdl.addArguments(args); - System.out.println(cmdl.describeCommand()); - */ - - exe.setExecutable(executable); - for (String s : args) { - exe.createArg().setValue(s); - } + try { + // Create and enter a Context. A Context stores information about + // the execution environment of a script. + Context cx = Context.enter(); + cx.setOptimizationLevel(0); + cx.setLanguageVersion(Context.VERSION_1_7); + // cx is the Context instance you're using to run scripts + /* + * cx.setClassShutter(new ClassShutter() { public boolean + * visibleToScripts(String className) { + * if(className.startsWith("adapter")) return true; + * if(className.startsWith("java.lang.System") || + * className.startsWith + * ("org.apache.tomcat.util.log.SystemLogHandler")) return true; + * System.out.println(className + " is blocked."); return false; } + * }); + */ - exe.setDir(dir); - if (spawn) { - exe.setSpawn(spawn); - } else { - exe.setTimeout(timeout); - exe.setInputString(inputstring); - exe.setOutputproperty("ExecuteService.stdout"); - exe.setErrorProperty("ExecuteService.stderr"); - exe.setResultProperty("ExecuteService.result"); - } + // Initialise the standard objects (Object, Function, etc.). This + // must be done before scripts can be + // executed. The null parameter tells initStandardObjects + // to create and return a scope object that we use + // in later calls. + Scriptable scope = cx.initStandardObjects(); + // Object wrappedOut = Context.javaToJS(System.out, scope); + // Object wrappedOut2 = Context.javaToJS(this, scope); + // scope.put("out", scope, wrappedOut); + // scope.put("exe", scope, wrappedOut2); - exe.setNewenvironment(newenvironment); - exe.setVMLauncher(vmlauncher); - exe.setSearchPath(searchpath); + // Execute the script + // cx.evaluateString(scope, "importClass('java.lang.System');\n", + // "head", 1, null); + // cx.evaluateString(scope, "importPackage('java.util');\n", "head", + // 2, null); + Object obj = cx + .evaluateString(scope, script, "TestScript", 1, null); - return runner.postTask(); - } + } catch (Exception e) { + System.out.println(e.getMessage()); + } finally { + // Exit the Context. This removes the association between the + // Context and the current thread and is an + // essential cleanup action. There should be a call to exit for + // every call to enter. + Context.exit(); + } - @WebMethod(exclude = true) - private ReturnCode sshExec(String host, - String username, - String password, - int port, - String command, - long timeout) { - SSHExec sshexec = new SSHExec(); - RunTask runner = new RunTask(sshexec); - sshexec.setHost(host); - sshexec.setUsername(username); - sshexec.setPassword(password); - sshexec.setPort(port); - sshexec.setCommand(command); - sshexec.setTrust(true); - sshexec.setTimeout(timeout); - sshexec.setOutputproperty("SSHExec.stdout"); - return runner.postTask(); - } + } - @WebMethod(exclude = true) - private ReturnCode sshExecWithCert(String host, - String username, - String passphrase, - String keyfile, - int port, - String command, - long timeout) { - SSHExec sshexec = new SSHExec(); - RunTask runner = new RunTask(sshexec); - sshexec.setHost(host); - sshexec.setUsername(username); - sshexec.setKeyfile(keyfile); - sshexec.setPassphrase(passphrase); - sshexec.setPort(port); - sshexec.setCommand(command); - sshexec.setTrust(true); - sshexec.setTimeout(timeout); - sshexec.setOutputproperty("SSHExec.stdout"); - return runner.postTask(); - } + @WebMethod(exclude = true) + private ReturnCode executeCommand(String executable, String[] args, + File dir, boolean spawn, String inputstring, + boolean newenvironment, boolean vmlauncher, boolean searchpath, + long timeout) { + ExecTask exe = new ExecTask(); + RunTask runner = new RunTask(exe); - @WebMethod(exclude = true) - private ReturnCode rexec(String host, - int port, - String username, - String password, - String command, - long timeout) { - RExecTask rexec = new RExecTask(); - RunTask runner = new RunTask(rexec); - rexec.setServer(host); - rexec.setPort(port); - rexec.setUserid(username); - rexec.setPassword(password); - rexec.setCommand(command); - rexec.setTimeout((int) Math.round(timeout)); + /* + * Commandline cmdl = new Commandline(); cmdl.setExecutable(executable); + * cmdl.addArguments(args); System.out.println(cmdl.describeCommand()); + */ - return runner.postTask(); - } + exe.setExecutable(executable); + for (String s : args) { + exe.createArg().setValue(s); + } - @WebMethod(exclude = true) - private ReturnCode telnet(String host, - int port, - String username, - String password, - String command, - long timeout, String prompt, String expect) { - TelnetTask rexec = new TelnetTask(); - RunTask runner = new RunTask(rexec); - rexec.setServer(host); - rexec.setPort(port); - rexec.setUserid(username); - rexec.setPassword(password); - rexec.setTimeout((int) Math.round(timeout)); - - rexec.createRead().addText(prompt); - rexec.createWrite().addText(command); - rexec.createRead().addText(expect); + exe.setDir(dir); + if (spawn) { + exe.setSpawn(spawn); + } else { + exe.setTimeout(timeout); + exe.setInputString(inputstring); + exe.setOutputproperty("ExecuteService.stdout"); + exe.setErrorProperty("ExecuteService.stderr"); + exe.setResultProperty("ExecuteService.result"); + } - return runner.postTask(); - } + exe.setNewenvironment(newenvironment); + exe.setVMLauncher(vmlauncher); + exe.setSearchPath(searchpath); + + return runner.postTask(); + } + + @WebMethod(exclude = true) + private ReturnCode sshExec(String host, String username, String password, + int port, String command, long timeout) { + SSHExec sshexec = new SSHExec(); + RunTask runner = new RunTask(sshexec); + sshexec.setHost(host); + sshexec.setUsername(username); + sshexec.setPassword(password); + sshexec.setPort(port); + sshexec.setCommand(command); + sshexec.setTrust(true); + sshexec.setTimeout(timeout); + sshexec.setOutputproperty("SSHExec.stdout"); + return runner.postTask(); + } + + @WebMethod(exclude = true) + private ReturnCode sshExecWithCert(String host, String username, + String passphrase, String keyfile, int port, String command, + long timeout) { + SSHExec sshexec = new SSHExec(); + RunTask runner = new RunTask(sshexec); + sshexec.setHost(host); + sshexec.setUsername(username); + sshexec.setKeyfile(keyfile); + sshexec.setPassphrase(passphrase); + sshexec.setPort(port); + sshexec.setCommand(command); + sshexec.setTrust(true); + sshexec.setTimeout(timeout); + sshexec.setOutputproperty("SSHExec.stdout"); + return runner.postTask(); + } + + @WebMethod(exclude = true) + private ReturnCode rexec(String host, int port, String username, + String password, String command, long timeout) { + RExecTask rexec = new RExecTask(); + RunTask runner = new RunTask(rexec); + rexec.setServer(host); + rexec.setPort(port); + rexec.setUserid(username); + rexec.setPassword(password); + rexec.setCommand(command); + rexec.setTimeout((int) Math.round(timeout)); + + return runner.postTask(); + } + + @WebMethod(exclude = true) + private ReturnCode telnet(String host, int port, String username, + String password, String command, long timeout, String prompt, + String expect) { + TelnetTask rexec = new TelnetTask(); + RunTask runner = new RunTask(rexec); + rexec.setServer(host); + rexec.setPort(port); + rexec.setUserid(username); + rexec.setPassword(password); + rexec.setTimeout((int) Math.round(timeout)); + + rexec.createRead().addText(prompt); + rexec.createWrite().addText(command); + rexec.createRead().addText(expect); + + return runner.postTask(); + } } diff --git a/src/java/net/brutex/xservices/ws/impl/FileServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/FileServiceImpl.java index 7fb6f18..53f4495 100644 --- a/src/java/net/brutex/xservices/ws/impl/FileServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/FileServiceImpl.java @@ -64,7 +64,7 @@ public class FileServiceImpl implements FileService { * @see net.brutex.xservices.ws.impl.FileService#basename(java.lang.String, * java.lang.String) */ - @Override + public String basename(String filename, String suffix) { final String BASENAME_VALUE = "basename.value"; Basename basename = new Basename(); @@ -139,7 +139,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#base64Encode(net.brutex.xservices * .types.FileSetResource) */ - @Override + public AttachmentType downloadFile(FileResource res) throws XServicesFault { InputStream is = null; try { @@ -163,7 +163,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#base64Decode(net.brutex.xservices * .types.AttachmentType) */ - @Override + public String uploadFile(AttachmentType file) throws XServicesFault { DataHandler h = file.getContent(); File f = new File(file.getFilename()); @@ -188,7 +188,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#copy(net.brutex.xservices.types * .FileSetResource, java.lang.String, boolean, boolean, java.lang.String) */ - @Override + public ReturnCode copy(FileSetResource src, String todir, boolean plm, boolean overwrite, String encoding) throws XServicesFault { Copy copy = new Copy(); @@ -213,7 +213,7 @@ public class FileServiceImpl implements FileService { return runner.postTask(); } - @Override + public ReturnCode copyFile(String fromFile, String tofile, boolean overwrite) throws XServicesFault { Copy copy = new Copy(); @@ -235,7 +235,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#loadRes(net.brutex.xservices * .types.FileResource, java.lang.String) */ - @Override + public String loadRes(FileResource res, String encoding) throws XServicesFault { if (encoding == null || encoding.equals("")) { @@ -259,7 +259,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#loadResFromArchive(net.brutex * .xservices.types.ArchiveResource, java.lang.String) */ - @Override + public String loadResFromArchive(ArchiveResource res, String encoding) { if (encoding == null || encoding.equals("")) { encoding = System.getProperty("file.encoding"); @@ -282,7 +282,7 @@ public class FileServiceImpl implements FileService { * @see net.brutex.xservices.ws.impl.FileService#echo2file(java.lang.String, * java.lang.String, java.lang.String, boolean) */ - @Override + public ReturnCode echo2file(String message, String file, String encoding, boolean append) throws XServicesFault { @@ -316,7 +316,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#changeOwner(net.brutex.xservices * .types.FileSetResource, java.lang.String) */ - @Override + public ReturnCode changeOwner(FileSetResource res, String owner) { Chown chown = new Chown(); chown.setTaskName("Chown"); @@ -335,7 +335,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#changeGroup(net.brutex.xservices * .types.FileSetResource, java.lang.String) */ - @Override + public ReturnCode changeGroup(FileSetResource res, String group) { Chgrp chgrp = new Chgrp(); chgrp.setTaskName("Chgrp"); @@ -354,7 +354,7 @@ public class FileServiceImpl implements FileService { * net.brutex.xservices.ws.impl.FileService#changeMode(net.brutex.xservices * .types.FileSetResource, java.lang.String) */ - @Override + public ReturnCode changeMode(FileSetResource res, String perm) { Chmod chmod = new Chmod(); chmod.setTaskName("Chmod"); diff --git a/src/java/net/brutex/xservices/ws/impl/JobServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/JobServiceImpl.java new file mode 100644 index 0000000..846d966 --- /dev/null +++ b/src/java/net/brutex/xservices/ws/impl/JobServiceImpl.java @@ -0,0 +1,151 @@ +/* + * Copyright 2011 Brian Rosenberger (Brutex Network) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.brutex.xservices.ws.impl; + +import static org.quartz.TriggerBuilder.newTrigger; + +import java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Set; +import java.util.TimeZone; +import java.util.UUID; + +import javax.jws.WebService; + +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.SimpleTrigger; +import org.quartz.Trigger; +import org.quartz.TriggerKey; +import org.quartz.impl.StdSchedulerFactory; +import org.quartz.impl.matchers.GroupMatcher; + +import net.brutex.xservices.types.ScheduledJob; +import net.brutex.xservices.util.BrutexNamespaces; +import net.brutex.xservices.util.JobWrapper; +import net.brutex.xservices.ws.JobService; +import net.brutex.xservices.ws.XServicesFault; + +/** + * @author Brian Rosenberger + * @since 0.5.0 + * + */ +@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.JobService", serviceName = JobService.SERVICE_NAME) +public class JobServiceImpl implements JobService { + + + public List getJobList() throws XServicesFault { + List joblist = new ArrayList(); + try { + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + List jobgroups = scheduler.getJobGroupNames(); + for (String g : jobgroups) { + GroupMatcher m = GroupMatcher.groupContains(g); + Set keyset = scheduler.getJobKeys(m); + for (JobKey key : keyset) { + JobDataMap detail = scheduler.getJobDetail(key) + .getJobDataMap(); + ScheduledJob job = new ScheduledJob(key.getName(), + (GregorianCalendar) detail.get("date"), + detail.getString("script")); + joblist.add(job); + } + + } + + } catch (SchedulerException e) { + throw new XServicesFault(e); + } + return joblist; + } + + + public ScheduledJob getJob(String uuid) throws XServicesFault { + try { + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + JobDetail job = scheduler.getJobDetail(new JobKey(uuid, "DEFAULT")); + if (job == null) + throw new XServicesFault("Job not found."); + Trigger t = scheduler.getTrigger(new TriggerKey(uuid)); + GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault()); + cal.setTime(t.getStartTime()); + return new ScheduledJob(uuid, cal, job.getJobDataMap().getString( + "script"), job.getDescription()); + } catch (SchedulerException e) { + e.printStackTrace(); + throw new XServicesFault(e); + } + } + + + public void deleteJob(String uuid) throws XServicesFault { + try { + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + JobKey key = new JobKey(uuid, "DEFAULT"); + JobDetail job = scheduler.getJobDetail(key); + if (job == null) + throw new XServicesFault("Job not found."); + Trigger t = scheduler.getTrigger(new TriggerKey(uuid)); + scheduler.deleteJob(key); + } catch (SchedulerException e) { + throw new XServicesFault(e); + } + + } + + + public String scheduleJob(ScheduledJob job) throws XServicesFault { + try { + // Grab the Scheduler instance from the Factory + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + + // and start it off + + if (!scheduler.isStarted()) + scheduler.start(); + if (scheduler.isInStandbyMode()) + scheduler.resumeAll(); + + String identity = UUID.randomUUID().toString(); + //String identity = "test"; + JobDetail job2 = JobBuilder.newJob(JobWrapper.class) + .withIdentity(identity).build(); + + + job2.getJobDataMap().put("script", job.getScript()); + job2.getJobDataMap().put("description", job.getDescription()); + job2.getJobDataMap().put("date", job.getDate()); + + SimpleTrigger t = (SimpleTrigger) newTrigger() + .withIdentity(identity).startAt(job.getDate().getTime()) + .build(); + ; + + scheduler.scheduleJob(job2, t); + return identity; + } catch (SchedulerException e) { + e.printStackTrace(); + throw new XServicesFault(e); + } + } + +} diff --git a/src/java/quartz.properties b/src/java/quartz.properties new file mode 100644 index 0000000..4da9062 --- /dev/null +++ b/src/java/quartz.properties @@ -0,0 +1,17 @@ +org.quartz.scheduler.instanceName = XServicesScheduler +org.quartz.threadPool.threadCount = 3 +org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore +#org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX +#org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.CloudscapeDelegate +#org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate +#org.quartz.jobStore.dataSource = QUARTZ + +#org.quartz.dataSource.QUARTZ.driver = org.hsqldb.jdbcDriver +#org.quartz.dataSource.QUARTZ.URL = jdbc:hsqldb:file:quartz_store;shutdown=true; +#org.quartz.dataSource.QUARTZ.user = sa +#org.quartz.dataSource.QUARTZ.connectionProvider.class = net.brutex.xservices.util.BrutexQuartzConnectionProvider + +#String url = “jdbc:hsqldb:file:/path/to/database/file”; +#String user = “sa”; +#String password = “”; +#Connection c = DriverManager.getConnection(url, user, password); \ No newline at end of file diff --git a/test/DateService-soapui-project.xml b/test/DateService-soapui-project.xml index 2c4964c..02a27b5 100644 --- a/test/DateService-soapui-project.xml +++ b/test/DateService-soapui-project.xml @@ -1,5 +1,5 @@ -http://localhost:8080/XServices/DateService?wsdl +http://localhost:8080/XServices/DateService?wsdl /* * Copyright 2010 Brian Rosenberger (Brutex Network) * @@ -14,410 +14,410 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. -*/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Add or substract a time span from a date. - - - - - - Get current date and time. - - - - - - - - - - - - - - - - Get elapsed time between to dates. - - - - - - - - - - - - - - - - - - - - - Get milliseconds since 01.01.1970 (Unix timestap). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +*/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Add or substract a time span from a date. + + + + + + Get current date and time. + + + + + + + + + + + + + + + + Get elapsed time between to dates. + + + + + + + + + + + + + + + + + + + + + Get milliseconds since 01.01.1970 (Unix timestap). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]>http://schemas.xmlsoap.org/wsdl/http://localhost:8080/XServices/DateService<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -445,14 +445,14 @@ ISO 8601 -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService - - - - 2011-05-24T17:22:42+02:00 - mmddyyyy-WW - - +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService + + + + 2011-05-24T17:22:42+02:00 + mmddyyyy-WW + + ]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -461,22 +461,22 @@ dd.mm.yyyy -]]>UTF-8http://localhost:8080/XServices/DateService - - - - ? - ? - - -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService - - - - 2011-05-24T19:59:29.233+02:00 - 2011-05-24T19:59:34.233+03:00 - - +]]>UTF-8http://localhost:8080/XServices/DateService + + + + ? + ? + + +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService + + + + 2011-05-24T19:59:29.233+02:00 + 2011-05-24T19:59:34.233+03:00 + + ]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -485,13 +485,13 @@ 2011-06-24T21:01:59.234+02:00 -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService - - - - 2012-05-24T19:59:29.233+02:00 - 365 - hours - - +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService + + + + 2012-05-24T19:59:29.233+02:00 + 365 + hours + + ]]> \ No newline at end of file diff --git a/test/ExecuteService-soapui-project.xml b/test/ExecuteService-soapui-project.xml index 044ed47..41907e8 100644 --- a/test/ExecuteService-soapui-project.xml +++ b/test/ExecuteService-soapui-project.xml @@ -1,21 +1,488 @@ - +http://localhost:8080/XServices/ExecuteService?wsdl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]>http://schemas.xmlsoap.org/wsdl/http://localhost:8080/XServices/ExecuteServiceUTF-8http://localhost:8080/XServices/ExecuteService + + + + + + ? + ? + + ? + + ? + + + ? + ? + + +]]>UTF-8http://localhost:8080/XServices/ExecuteService + + + + + ? + + ? + ? + + +]]>UTF-8http://localhost:8080/XServices/ExecuteService + + + + + ? + + ? + + +]]>UTF-8http://localhost:8080/XServices/ExecuteService + + + + + ? + + ? + + +]]>UTF-8http://localhost:8080/XServices/ExecuteService + + + + + ? + + ? + ? + + +]]>UTF-8http://localhost:8080/XServices/ExecuteService + + + + + + ? + ? + + ? + + ? + + + ? + ? + + +]]>UTF-8http://localhost:8080/XServices/ExecuteService + + + + + + ? + ? + + ? + + ? + + + ? + + ? + ? + + +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/ExecuteService + + + + + + + +]]>UTF-8http://localhost:8080/XServices/ExecuteService - localhost - 23 + ? + ? - brosenberger + ? - + ? - C:\Users\brosenberger> - dir c:\ - enberger> - 30000 + + ? + + ? + + ? + ? - \ No newline at end of file +]]> \ No newline at end of file diff --git a/test/JobServices-soapui-project.xml b/test/JobServices-soapui-project.xml new file mode 100644 index 0000000..c45dea2 --- /dev/null +++ b/test/JobServices-soapui-project.xml @@ -0,0 +1,232 @@ + +http://localhost:8080/XServices/JobServices?wsdl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get list of scheduled jobs + + + + + + Get a job by id + + + + + + Delete a scheduled job. + + + + + + Schedule a job + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]>http://schemas.xmlsoap.org/wsdl/http://localhost:8080/XServices/JobServices<xml-fragment/>UTF-8http://localhost:8080/XServices/JobServices + + + + +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/JobServices + + + + 6b3da1f0-ff1c-4422-b2ce-17a6d1c2a990 + + +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/JobServices + + + + + + 2011-06-06T17:00:00+02:00 + + + + + +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/JobServices + + + + 6b3da1f0-ff1c-4422-b2ce-17a6d1c2a990 + + +]]> \ No newline at end of file diff --git a/web/WEB-INF/cxf-beans.xml b/web/WEB-INF/cxf-beans.xml index b5662af..9ab7dde 100644 --- a/web/WEB-INF/cxf-beans.xml +++ b/web/WEB-INF/cxf-beans.xml @@ -40,7 +40,11 @@ - + + + + diff --git a/web/WEB-INF/data/QRTZ_BLOB_TRIGGERS.ddl b/web/WEB-INF/data/QRTZ_BLOB_TRIGGERS.ddl new file mode 100644 index 0000000..9b7a369 --- /dev/null +++ b/web/WEB-INF/data/QRTZ_BLOB_TRIGGERS.ddl @@ -0,0 +1,8 @@ +create table qrtz_blob_triggers( +sched_name varchar(120) not null, +trigger_name varchar(200) not null, +trigger_group varchar(200) not null, +blob_data blob, +primary key (sched_name,trigger_name,trigger_group), +foreign key (sched_name,trigger_name,trigger_group) references qrtz_triggers(sched_name,trigger_name,trigger_group) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_CALENDARS.ddl b/web/WEB-INF/data/QRTZ_CALENDARS.ddl new file mode 100644 index 0000000..779406c --- /dev/null +++ b/web/WEB-INF/data/QRTZ_CALENDARS.ddl @@ -0,0 +1,6 @@ +create table qrtz_calendars( +sched_name varchar(120) not null, +calendar_name varchar(200) not null, +calendar blob not null, +primary key (sched_name,calendar_name) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_CRON_TRIGGERS.ddl b/web/WEB-INF/data/QRTZ_CRON_TRIGGERS.ddl new file mode 100644 index 0000000..8b9dfab --- /dev/null +++ b/web/WEB-INF/data/QRTZ_CRON_TRIGGERS.ddl @@ -0,0 +1,9 @@ +create table qrtz_cron_triggers( +sched_name varchar(120) not null, +trigger_name varchar(200) not null, +trigger_group varchar(200) not null, +cron_expression varchar(120) not null, +time_zone_id varchar(80), +primary key (sched_name,trigger_name,trigger_group), +foreign key (sched_name,trigger_name,trigger_group) references qrtz_triggers(sched_name,trigger_name,trigger_group) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_FIRED_TRIGGERS.ddl b/web/WEB-INF/data/QRTZ_FIRED_TRIGGERS.ddl new file mode 100644 index 0000000..51c4137 --- /dev/null +++ b/web/WEB-INF/data/QRTZ_FIRED_TRIGGERS.ddl @@ -0,0 +1,15 @@ +create table qrtz_fired_triggers( +sched_name varchar(120) not null, +entry_id varchar(95) not null, +trigger_name varchar(200) not null, +trigger_group varchar(200) not null, +instance_name varchar(200) not null, +fired_time bigint not null, +priority integer not null, +state varchar(16) not null, +job_name varchar(200), +job_group varchar(200), +is_nonconcurrent varchar(5), +requests_recovery varchar(5), +primary key (sched_name,entry_id) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_JOB_DETAILS.ddl b/web/WEB-INF/data/QRTZ_JOB_DETAILS.ddl new file mode 100644 index 0000000..d337693 --- /dev/null +++ b/web/WEB-INF/data/QRTZ_JOB_DETAILS.ddl @@ -0,0 +1,13 @@ +create table qrtz_job_details ( +sched_name varchar(120) not null, +job_name varchar(200) not null, +job_group varchar(200) not null, +description varchar(250) , +job_class_name varchar(250) not null, +is_durable varchar(5) not null, +is_nonconcurrent varchar(5) not null, +is_update_data varchar(5) not null, +requests_recovery varchar(5) not null, +job_data blob, +primary key (sched_name,job_name,job_group) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_LOCKS.ddl b/web/WEB-INF/data/QRTZ_LOCKS.ddl new file mode 100644 index 0000000..132fd41 --- /dev/null +++ b/web/WEB-INF/data/QRTZ_LOCKS.ddl @@ -0,0 +1,6 @@ +create table qrtz_locks + ( + sched_name varchar(120) not null, + lock_name varchar(40) not null, +primary key (sched_name,lock_name) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_PAUSED_TRIGGER_GRPS.ddl b/web/WEB-INF/data/QRTZ_PAUSED_TRIGGER_GRPS.ddl new file mode 100644 index 0000000..c29165c --- /dev/null +++ b/web/WEB-INF/data/QRTZ_PAUSED_TRIGGER_GRPS.ddl @@ -0,0 +1,6 @@ +create table qrtz_paused_trigger_grps + ( + sched_name varchar(120) not null, + trigger_group varchar(200) not null, +primary key (sched_name,trigger_group) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_SCHEDULER_STATE.ddl b/web/WEB-INF/data/QRTZ_SCHEDULER_STATE.ddl new file mode 100644 index 0000000..315cfc3 --- /dev/null +++ b/web/WEB-INF/data/QRTZ_SCHEDULER_STATE.ddl @@ -0,0 +1,8 @@ +create table qrtz_scheduler_state + ( + sched_name varchar(120) not null, + instance_name varchar(200) not null, + last_checkin_time bigint not null, + checkin_interval bigint not null, +primary key (sched_name,instance_name) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_SIMPLE_TRIGGERS.ddl b/web/WEB-INF/data/QRTZ_SIMPLE_TRIGGERS.ddl new file mode 100644 index 0000000..161224b --- /dev/null +++ b/web/WEB-INF/data/QRTZ_SIMPLE_TRIGGERS.ddl @@ -0,0 +1,10 @@ +create table qrtz_simple_triggers( +sched_name varchar(120) not null, +trigger_name varchar(200) not null, +trigger_group varchar(200) not null, +repeat_count bigint not null, +repeat_interval bigint not null, +times_triggered bigint not null, +primary key (sched_name,trigger_name,trigger_group), +foreign key (sched_name,trigger_name,trigger_group) references qrtz_triggers(sched_name,trigger_name,trigger_group) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_SIMPROP_TRIGGERS.ddl b/web/WEB-INF/data/QRTZ_SIMPROP_TRIGGERS.ddl new file mode 100644 index 0000000..65c6c90 --- /dev/null +++ b/web/WEB-INF/data/QRTZ_SIMPROP_TRIGGERS.ddl @@ -0,0 +1,19 @@ +CREATE TABLE qrtz_simprop_triggers ( + sched_name varchar(120) not null, + TRIGGER_NAME VARCHAR(200) NOT NULL, + TRIGGER_GROUP VARCHAR(200) NOT NULL, + STR_PROP_1 VARCHAR(512), + STR_PROP_2 VARCHAR(512), + STR_PROP_3 VARCHAR(512), + INT_PROP_1 INT, + INT_PROP_2 INT, + LONG_PROP_1 BIGINT, + LONG_PROP_2 BIGINT, + DEC_PROP_1 NUMERIC(13,4), + DEC_PROP_2 NUMERIC(13,4), + BOOL_PROP_1 varchar(5), + BOOL_PROP_2 varchar(5), + PRIMARY KEY (sched_name,TRIGGER_NAME,TRIGGER_GROUP), + FOREIGN KEY (sched_name,TRIGGER_NAME,TRIGGER_GROUP) + REFERENCES QRTZ_TRIGGERS(sched_name,TRIGGER_NAME,TRIGGER_GROUP) +) \ No newline at end of file diff --git a/web/WEB-INF/data/QRTZ_TRIGGERS.ddl b/web/WEB-INF/data/QRTZ_TRIGGERS.ddl new file mode 100644 index 0000000..49df524 --- /dev/null +++ b/web/WEB-INF/data/QRTZ_TRIGGERS.ddl @@ -0,0 +1,20 @@ +create table qrtz_triggers( +sched_name varchar(120) not null, +trigger_name varchar(200) not null, +trigger_group varchar(200) not null, +job_name varchar(200) not null, +job_group varchar(200) not null, +description varchar(250), +next_fire_time bigint, +prev_fire_time bigint, +priority integer, +trigger_state varchar(16) not null, +trigger_type varchar(8) not null, +start_time bigint not null, +end_time bigint, +calendar_name varchar(200), +misfire_instr smallint, +job_data blob, +primary key (sched_name,trigger_name,trigger_group), +foreign key (sched_name,job_name,job_group) references qrtz_job_details(sched_name,job_name,job_group) +) \ No newline at end of file diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 1ce0252..f26529e 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -2,16 +2,51 @@ contextConfigLocation - WEB-INF/cxf-beans.xml + /WEB-INF/cxf-beans.xml + + + quartz:config-file + quartz.properties + + + quartz:shutdown-on-unload + true + + + quartz:wait-on-shutdown + false + + + quartz:start-scheduler-on-load + true + + org.springframework.web.context.ContextLoaderListener + + + org.quartz.ee.servlet.QuartzInitializerListener + + XServices org.apache.cxf.transport.servlet.CXFServlet 1 + + + QuartzInitializer + org.quartz.ee.servlet.QuartzInitializerServlet + + + shutdown-on-unload + true + + 2 + + XServices /*