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.


Nested Class Summary
static class ScriptfileUtils.LineEndingStyle
          Line ending style
 
Constructor Summary
ScriptfileUtils()
           
 
Method Summary
static java.io.File createTempFile(Framework framework)
          Create a temp file in the framework
static ScriptfileUtils.LineEndingStyle lineEndingStyleForNode(INodeEntry node)
          Return the line ending style for the node, based on the osFamily, or use LOCAL if undetermined
static void setExecutePermissions(java.io.File scriptfile)
          Set the executable flag on a file if supported by the OS
static void writeScriptFile(java.io.InputStream stream, java.lang.String scriptString, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style, java.io.File scriptfile)
          Write script content to a destination file from one of the sources
static java.io.File writeScriptTempfile(Framework framework, java.io.File sourcefile)
          Deprecated.  
static java.io.File writeScriptTempfile(Framework framework, java.io.InputStream stream)
          Deprecated.  
static java.io.File writeScriptTempfile(Framework framework, java.io.InputStream stream, java.lang.String source, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style)
          Copy a source stream or string content to a tempfile for script execution
static java.io.File writeScriptTempfile(Framework framework, java.io.Reader source)
          Deprecated.  
static java.io.File writeScriptTempfile(Framework framework, java.io.Reader source, ScriptfileUtils.LineEndingStyle style)
          Copy reader content to a tempfile for script execution
static java.io.File writeScriptTempfile(Framework framework, java.lang.String source)
          Deprecated.  
 
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

lineEndingStyleForNode

public static ScriptfileUtils.LineEndingStyle lineEndingStyleForNode(INodeEntry node)
Return the line ending style for the node, based on the osFamily, or use LOCAL if undetermined

Parameters:
node -
Returns:

writeScriptTempfile

public static java.io.File writeScriptTempfile(Framework framework,
                                               java.io.File sourcefile)
                                        throws java.io.IOException
Deprecated. 

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
Deprecated. 

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
Deprecated. 

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
Deprecated. 

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

writeScriptTempfile

public static java.io.File writeScriptTempfile(Framework framework,
                                               java.io.Reader source,
                                               ScriptfileUtils.LineEndingStyle style)
                                        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

writeScriptTempfile

public static java.io.File writeScriptTempfile(Framework framework,
                                               java.io.InputStream stream,
                                               java.lang.String source,
                                               java.io.Reader reader,
                                               ScriptfileUtils.LineEndingStyle style)
                                        throws java.io.IOException
Copy a source stream or string content to a tempfile for script execution

Parameters:
framework - framework
stream - source stream
source - content
style - file line ending style to use
reader -
Returns:
tempfile
Throws:
java.io.IOException - if an error occurs

writeScriptFile

public static void writeScriptFile(java.io.InputStream stream,
                                   java.lang.String scriptString,
                                   java.io.Reader reader,
                                   ScriptfileUtils.LineEndingStyle style,
                                   java.io.File scriptfile)
                            throws java.io.IOException
Write script content to a destination file from one of the sources

Parameters:
stream - stream source
scriptString - script content
reader - reader source
style - line ending style
scriptfile - destination file
Throws:
java.io.IOException

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