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

 

Referenced by the 'attachments' variable in script

 

 

Fields Summary
static java.lang.String DEFAULT_VARIABLE
    

 

 

Methods Summary
abstract AttachmentScriptType add(AttachmentScriptType attachment)
    
Adds an attachment object to the item.
abstract AttachmentScriptType addExistingFileAsAttachment(java.lang.String filename, java.lang.String description)
    
Links a file already in the staging area to the item as an attachment.
abstract void clear()
    
Remove all attachments from the item.
abstract AttachmentScriptType createBinaryFileAttachment(java.lang.String filename, java.lang.String description, BinaryDataScriptType contents)
    
Creates an attachment for the given binary data contents Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.
abstract AttachmentScriptType createCustomAttachment(java.lang.String customType, java.lang.String description)
    
Creates an attachment of type CUSTOM.
abstract AttachmentScriptType createHtmlAttachment(java.lang.String filename, java.lang.String description, java.lang.String contents)
    
Creates an HTML attachment for the given text contents.
abstract AttachmentScriptType createLinkAttachment(java.lang.String url, java.lang.String description)
    
Creates a link to an external URL Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.
abstract AttachmentScriptType createResourceAttachment(java.lang.String itemUuid, int itemVersion, java.lang.String attachmentUuid, java.lang.String description)
    
Creates a resource attachment (as created by the EQUELLA Resource option on the Attachments control)
abstract AttachmentScriptType createTextFileAttachment(java.lang.String filename, java.lang.String description, java.lang.String contents)
    
Creates an attachment for the given text contents Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.
abstract AttachmentScriptType editTextFileAttachment(AttachmentScriptType attachment, java.lang.String newContents)
    
Sets the text contents of the supplied attachment.
abstract java.util.List<ItemScriptType> getAttachedItemResources()
    
Gets a list of any linked items (e.g.
abstract AttachmentScriptType getByFilename(java.lang.String filename)
    
Gets an attachment based on the filename of the attachment.
abstract AttachmentScriptType getByUuid(java.lang.String uuid)
    
Gets an attachment based on the uuid of the attachment.
abstract java.util.List<AttachmentScriptType> list()
    
Lists all attachments on the item, this will include any attachments you have added.
abstract java.util.List<AttachmentScriptType> listForItem(ItemScriptType item)
    
Lists all attachments on the given item
abstract java.lang.String readTextFileAttachment(AttachmentScriptType attachment)
    
Returns the content of the attachment in plain text.
abstract java.lang.String readTextFileAttachmentWithEncoding(AttachmentScriptType attachment, java.lang.String encoding)
    
Same as readTextFileAttachment but you can specify the encoding, e.g.
abstract XmlScriptType readXmlFileAttachment(AttachmentScriptType attachment)
    
Returns the content of the attachment as an XML document.
abstract void remove(AttachmentScriptType attachment)
    
Removes an attachment from the item.

 

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

 

 

 

 

DEFAULT_VARIABLE

 

public static final java.lang.String DEFAULT_VARIABLE

 

See also: Constants

 

 

 

 

add

 

public abstract AttachmentScriptType add( AttachmentScriptType attachment)

 

Adds an attachment object to the item. Obtain this object using createTextFileAttachment or createLinkAttachment

 

Parameters:
attachment-
The attachment to add to the item.
Returns:
The attachment you added.

 

 

 

addExistingFileAsAttachment

 

public abstract AttachmentScriptType addExistingFileAsAttachment( java.lang.String filename,
java.lang.String description)

 

Links a file already in the staging area to the item as an attachment. If the filename specified cannot be found an exception will be thrown. Use FileScriptingObject.exists(String) to determine if the file can be found.

 

Parameters:
filename-
The path to the file, relative to the item
description-
The text to display as a link to this attachment
Returns:
The new attachment

 

 

 

remove

 

public abstract void remove( AttachmentScriptType attachment)

 

Removes an attachment from the item. If the attachment is a physical file, it does not delete the file from the file system. Use FileScriptingObject.deleteFile(String) to delete the actual file.

 

Parameters:
attachment-
The attachment to remove from the item.

 

 

 

clear

 

public abstract void clear( )

 

Remove all attachments from the item. If any of the attachments are a physical file, it does not delete the file from the file system. Use FileScriptingObject.deleteFile(String) to delete the actual files.

 

 

 

list

 

public abstract java.util.List<AttachmentScriptType> list( )

 

Lists all attachments on the item, this will include any attachments you have added.

 

Returns:
A list of attachments

 

 

 

listForItem

 

public abstract java.util.List<AttachmentScriptType> listForItem( ItemScriptType item)

 

Lists all attachments on the given item

 

Parameters:
item-
The item to list the attachments of
Returns:
A list of attachments

 

 

 

getByUuid

 

public abstract AttachmentScriptType getByUuid( java.lang.String uuid)

 

Gets an attachment based on the uuid of the attachment.

 

Parameters:
uuid-
The system generated UUID for the attachment.
Returns:
The attachment with the specified UUID, or null if not found.

 

 

 

getByFilename

 

public abstract AttachmentScriptType getByFilename( java.lang.String filename)

 

Gets an attachment based on the filename of the attachment. Does not look in the staging directory, only on attachments that are added to the item.

 

Parameters:
filename-
The filename of the attachment (AttachmentScriptType.getFilename() or AttachmentScriptType.getUrl())
Returns:
The attachment with the specified filename or URL, or null if not found.

 

 

 

createTextFileAttachment

 

public abstract AttachmentScriptType createTextFileAttachment( java.lang.String filename,
java.lang.String description,
java.lang.String contents)

 

Creates an attachment for the given text contents Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.

 

Parameters:
filename-
The filename of the attachment, relative to the item.
description-
The text to display as a link to this attachment.
contents-
The text contents of the file.
Returns:
An attachment of type FILE.

 

 

 

createHtmlAttachment

 

public abstract AttachmentScriptType createHtmlAttachment( java.lang.String filename,
java.lang.String description,
java.lang.String contents)

 

Creates an HTML attachment for the given text contents. Much the same as createTextFileAttachment(String,String,String) but the attachments created by this method can be used in conjuction with a My Pages control. Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.

 

Parameters:
filename-
The filename of the attachment, relative to the item.
description-
The text to display as a link to this attachment.
contents-
The text contents of the file.
Returns:
An attachment of type FILE.

 

 

 

createBinaryFileAttachment

 

public abstract AttachmentScriptType createBinaryFileAttachment( java.lang.String filename,
java.lang.String description,
BinaryDataScriptType contents)

 

Creates an attachment for the given binary data contents Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.

 

Parameters:
filename-
The filename of the attachment, relative to the item.
description-
The text to display as a link to this attachment.
contents-
The binary contents of the file. At this stage, a BinaryDataScriptType may only be retrieved from a ResponseScriptType.
Returns:
An attachment of type FILE.

 

 

 

editTextFileAttachment

 

public abstract AttachmentScriptType editTextFileAttachment( AttachmentScriptType attachment,
java.lang.String newContents)

 

Sets the text contents of the supplied attachment. If you attempt to edit an attachment that is not of type FILE, HTML or IMSRES then an exception will be thrown.

 

Parameters:
attachment-
An attachment of type FILE, HTML or IMSRES with text content.
newContents-
The new text contents of the file associated with this attachment.
Returns:
The attachment that was edited

 

 

 

createLinkAttachment

 

public abstract AttachmentScriptType createLinkAttachment( java.lang.String url,
java.lang.String description)

 

Creates a link to an external URL Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.

 

Parameters:
url-
The URL of the link
description-
A display name for the link
Returns:
An attachment of type LINK

 

 

 

createCustomAttachment

 

public abstract AttachmentScriptType createCustomAttachment( java.lang.String customType,
java.lang.String description)

 

Creates an attachment of type CUSTOM.

Based on the customType specified you can set certain custom properties on the returned attachment. For instance:
googlebook has the following properties: "thumbWidth", "thumbHeight", "thumbUrl", "url", "bookId"
youtube has the following properties: "thumbWidth", "thumbHeight", "thumbUrl", "playUrl"
itunesu has the following properties: "trackUrl"
resource has the following properties: "uuid", "version", "type"

These properties are not officially supported.

Does not add this attachment to the item, you must explicitly call attachments.add(XX) to do so.

 

Parameters:
customType-
The custom type name. Recognised types are "googlebook", "youtube", "itunesu", "resource".
description-
A display name for the custom attachment
Returns:
A new CUSTOM type attachment.

 

 

 

createResourceAttachment

 

public abstract AttachmentScriptType createResourceAttachment( java.lang.String itemUuid,
int itemVersion,
java.lang.String attachmentUuid,
java.lang.String description)

 

Creates a resource attachment (as created by the EQUELLA Resource option on the Attachments control)

 

Parameters:
itemUuid-
The UUID of the item to link to
itemVersion-
The version of the item to link to
attachmentUuid-
Optional. If omitted the returned resource attachment will link to the item summary.
description-
A display name for the resource attachment
Returns:
A new CUSTOM type attachment.

 

 

 

readTextFileAttachment

 

public abstract java.lang.String readTextFileAttachment( AttachmentScriptType attachment)

 

Returns the content of the attachment in plain text. Don't read large or binary files with this method!! If you attempt to read an attachment that is not of type FILE, HTML or IMSRES then an exception will be thrown. The file is assumed to be UTF-8 encoded, if this is not the case then you should use readTextFileAttachmentWithEncoding(AttachmentScriptType, String)

 

Parameters:
attachment-
An attachment of type FILE, HTML or IMSRES with text content.
Returns:
The text content of the attachment.

 

 

 

readTextFileAttachmentWithEncoding

 

public abstract java.lang.String readTextFileAttachmentWithEncoding( AttachmentScriptType attachment,
java.lang.String encoding)

 

Same as readTextFileAttachment but you can specify the encoding, e.g. UTF-8.

 

Parameters:
attachment-
An attachment of type FILE, HTML or IMSRES with text content.
encoding-
An encoding type
Returns:
The text content of the attachment.

 

 

 

readXmlFileAttachment

 

public abstract XmlScriptType readXmlFileAttachment( AttachmentScriptType attachment)

 

Returns the content of the attachment as an XML document. Don't read large or binary files with this method!! If you attempt to read an attachment that is not of type FILE, HTML or IMSRES then an exception will be thrown. The file is assumed to be UTF-8 encoded.

 

Parameters:
attachment-
An attachment of type FILE, HTML or IMSRES with XML content.
Returns:
An XML document with the attachment content.

 

 

 

getAttachedItemResources

 

public abstract java.util.List<ItemScriptType> getAttachedItemResources( )

 

Gets a list of any linked items (e.g. with Resource Selector). See com.tle.common.scripting.ItemScriptType for the type of object returned in this list.

 

Returns:
A list of ItemScriptType objects