com.tle.common.scripting.objects
Interface FileScriptObject
Declaration: public interface FileScriptObject extends ScriptObject
All Superinterfaces: ScriptObject, java.io.Serializable

 

Referenced by the 'staging' variable in script

 

 

Fields Summary
static java.lang.String DEFAULT_VARIABLE
    

 

 

Methods Summary
abstract FileHandleScriptType copy(java.lang.String src, java.lang.String dest)
    
Copy a file from dest to src within the staging folder.
abstract FileHandleScriptType createFolder(java.lang.String path)
    
Creates a new folder, creating any required parent folders.
abstract void deleteFile(java.lang.String filename)
    
Remove a file from the staging folder system.
abstract boolean exists(java.lang.String filename)
    
Determine if the specified filename exists.
abstract long fileLength(java.lang.String filename)
    
Gets the size (in bytes) of the file specified by filename.
abstract FileHandleScriptType getFileHandle(ItemScriptType item, java.lang.String filename)
    
Get a read-only file handle from a arbitrary item for use in other script functions.
abstract FileHandleScriptType getFileHandle(java.lang.String filename)
    
Get a file handle for use in other script functions.
abstract boolean isAvailable()
    
Determines if the staging file system is available.
abstract long lastModified(java.lang.String filename)
    
Get the last modified date of the file specified by filename.
abstract java.util.List<java.lang.String> list(java.lang.String folder, java.lang.String pattern)
    
Returns a list of files (including folders) within the specified folder.
abstract java.util.List<java.lang.String> listFiles(java.lang.String folder, java.lang.String pattern)
    
Returns a list of files (NOT including folders) within the specified folder.
abstract FileHandleScriptType move(java.lang.String src, java.lang.String dest)
    
Move a file from dest to src within the staging folder.
abstract java.lang.String readTextFile(java.lang.String filename)
    
Read text from a file in the staging folder specified by filename.
abstract FileHandleScriptType writeBinaryFile(java.lang.String filename, BinaryDataScriptType data)
    
Write the data to a file in the staging folder specified by filename.
abstract FileHandleScriptType writeTextFile(java.lang.String filename, java.lang.String text)
    
Write the text to a file in the staging folder specified by filename.

 

Methods inherited from interface: com.tle.common.scripting.ScriptObject
scriptEnter, scriptExit

 

 

 

 

DEFAULT_VARIABLE

 

public static final java.lang.String DEFAULT_VARIABLE

 

See also: Constants

 

 

 

 

isAvailable

 

public abstract boolean isAvailable( )

 

Determines if the staging file system is available. During certain workflow operations there will be no staging file system (e.g. Delete) Note that attempting to use a staging object when it is not available will result in an exception being thrown.

 

Returns:
true if there is a staging object,

 

 

 

list

 

public abstract java.util.List<java.lang.String> list( java.lang.String folder,
java.lang.String pattern)

 

Returns a list of files (including folders) within the specified folder. The folder path is relative to the current item.

 

Parameters:
folder-
The folder to list the contents of.
pattern-
An ant style file pattern. See http://ant.apache.org/manual/dirtasks.html
Returns:
A list of filenames

 

 

 

listFiles

 

public abstract java.util.List<java.lang.String> listFiles( java.lang.String folder,
java.lang.String pattern)

 

Returns a list of files (NOT including folders) within the specified folder. The folder path is relative to the current item.

 

Parameters:
folder-
The folder to list the contents of
pattern-
An ant style file pattern. See http://ant.apache.org/manual/dirtasks.html
Returns:
A list of filenames

 

 

 

exists

 

public abstract boolean exists( java.lang.String filename)

 

Determine if the specified filename exists. The filename path is relative to the current item.

 

Parameters:
filename-
The path of the file, relative to the item
Returns:
true if the file exists

 

 

 

fileLength

 

public abstract long fileLength( java.lang.String filename)

 

Gets the size (in bytes) of the file specified by filename. Will return a size of -1 if the file cannot be found. The filename path is relative to the current item.

 

Parameters:
filename-
The path of the file, relative to the item
Returns:
The size in bytes of the file

 

 

 

lastModified

 

public abstract long lastModified( java.lang.String filename)

 

Get the last modified date of the file specified by filename. The date is in milliseconds since 1-Jan-1970. The filename path is relative to the current item.

 

Parameters:
filename-
The file to check
Returns:
The last modified date of the file

 

 

 

deleteFile

 

public abstract void deleteFile( java.lang.String filename)

 

Remove a file from the staging folder system. The filename path is relative to the current item.

 

Parameters:
filename-
The file to delete

 

 

 

move

 

public abstract FileHandleScriptType move( java.lang.String src,
java.lang.String dest)

 

Move a file from dest to src within the staging folder. The dest and src paths are relative to the current item. E.g. staging.move('file.jpg', 'folder/subfolder/file.jpg');

 

Parameters:
src-
The source file path
dest-
The destination file path
Returns:
A file handle of the destination

 

 

 

copy

 

public abstract FileHandleScriptType copy( java.lang.String src,
java.lang.String dest)

 

Copy a file from dest to src within the staging folder. The dest and src paths are relative to the current item. E.g. staging.copy('file.jpg', 'file copy.jpg'); staging.copy('other.jpg', 'folder/other.jpg');

 

Parameters:
src-
The source file path
dest-
The destination file path
Returns:
A file handle of the destination

 

 

 

createFolder

 

public abstract FileHandleScriptType createFolder( java.lang.String path)

 

Creates a new folder, creating any required parent folders. The path is relative to the item. E.g. staging.createFolder('folder/subfolder');

 

Parameters:
path-
The path of the new folder
Returns:
A file handle of the new folder

 

 

 

writeTextFile

 

public abstract FileHandleScriptType writeTextFile( java.lang.String filename,
java.lang.String text)

 

Write the text to a file in the staging folder specified by filename. The filename path is relative to the current item. This method will always create a new file regardless of whether there is an existing one or not.

 

Parameters:
filename-
The file to write to
text-
The text to write
Returns:
A file handle of the new file

 

 

 

readTextFile

 

public abstract java.lang.String readTextFile( java.lang.String filename)

 

Read text from a file in the staging folder specified by filename. The filename path is relative to the current item.

 

Parameters:
filename-
The file to read
Returns:
The text content of the file. null if file is not found.

 

 

 

writeBinaryFile

 

public abstract FileHandleScriptType writeBinaryFile( java.lang.String filename,
BinaryDataScriptType data)

 

Write the data to a file in the staging folder specified by filename. The filename path is relative to the current item. This method will always create a new file regardless of whether there is an existing one or not.

 

Parameters:
filename-
The file to write to
data-
The binary data to write
Returns:
A file handle of the new file

 

 

 

getFileHandle

 

public abstract FileHandleScriptType getFileHandle( java.lang.String filename)

 

Get a file handle for use in other script functions. The file specified by filename may or may not exist. The filename path is relative to the current item.

 

Parameters:
filename-
The file to use
Returns:
A file handle

 

 

 

getFileHandle

 

public abstract FileHandleScriptType getFileHandle( ItemScriptType item,
java.lang.String filename)

 

Get a read-only file handle from a arbitrary item for use in other script functions. The file specified by filename may or may not exist. The filename path is relative to the supplied item parameter.

 

Parameters:
item-
The item to use as a reference point. i.e. the filename is relative to this item
filename-
The file to use
Returns:
A file handle