com.dtolabs.rundeck.core.execution.script
Class ScriptfileUtils

java.lang.Object
  extended by com.dtolabs.rundeck.core.execution.script.ScriptfileUtils

public class ScriptfileUtils
extends java.lang.Object

Utility methods for writing temp files for scripts and setting file permissions.


Constructor Summary
ScriptfileUtils()
           
 
Method Summary
static java.io.File createTempFile(Framework framework)
          Create a temp file in the framework
static void setExecutePermissions(java.io.File scriptfile)
          Set the executable flag on a file if supported by the OS
static java.io.File writeScriptTempfile(Framework framework, java.io.File sourcefile)
          Copy a source file to a tempfile for script execution
static java.io.File writeScriptTempfile(Framework framework, java.io.InputStream stream)
          Copy a source stream to a tempfile for script execution
static java.io.File writeScriptTempfile(Framework framework, java.io.Reader source)
          Copy reader content to a tempfile for script execution
static java.io.File writeScriptTempfile(Framework framework, java.lang.String source)
          Copy string content to a tempfile for script execution
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptfileUtils

public ScriptfileUtils()
Method Detail

writeScriptTempfile

public static java.io.File writeScriptTempfile(Framework framework,
                                               java.io.File sourcefile)
                                        throws java.io.IOException
Copy a source file to a tempfile for script execution

Parameters:
framework - framework
sourcefile - source file
Returns:
tempfile
Throws:
java.io.IOException - if an error occurs

writeScriptTempfile

public static java.io.File writeScriptTempfile(Framework framework,
                                               java.io.InputStream stream)
                                        throws java.io.IOException
Copy a source stream to a tempfile for script execution

Parameters:
framework - framework
stream - source
Returns:
tempfile
Throws:
java.io.IOException - if an error occurs

writeScriptTempfile

public static java.io.File writeScriptTempfile(Framework framework,
                                               java.lang.String source)
                                        throws java.io.IOException
Copy string content to a tempfile for script execution

Parameters:
framework - framework
source - string content
Returns:
tempfile
Throws:
java.io.IOException - if an error occurs

writeScriptTempfile

public static java.io.File writeScriptTempfile(Framework framework,
                                               java.io.Reader source)
                                        throws java.io.IOException
Copy reader content to a tempfile for script execution

Parameters:
framework - framework
source - string content
Returns:
tempfile
Throws:
java.io.IOException - if an error occurs

createTempFile

public static java.io.File createTempFile(Framework framework)
                                   throws java.io.IOException
Create a temp file in the framework

Throws:
java.io.IOException

setExecutePermissions

public static void setExecutePermissions(java.io.File scriptfile)
                                  throws java.io.IOException
Set the executable flag on a file if supported by the OS

Parameters:
scriptfile - target file
Throws:
java.io.IOException - if an error occurs