com.tle.common.scripting.types
Interface AttachmentScriptType
Declaration: public interface AttachmentScriptType extends java.io.Serializable
All Superinterfaces: java.io.Serializable

 

The Attachment object type as used by scripts. This is an abstraction away from the real Attachment object used internally on the server.

 

 

Methods Summary
abstract java.util.List<java.lang.String> getAllCustomDisplayProperties()
    
Returns a list of all the keys used for custom metadata display
abstract java.lang.Object getCustomDisplayProperty(java.lang.String key)
    
Gets a specific custom display property or null if it does not exist
abstract java.lang.Object getCustomProperty(java.lang.String propertyName)
    
For attachments of type CUSTOM, get the value of the given property (if any).
abstract java.lang.String getCustomType()
    
The type of this custom attachment, for example, "flickr".
abstract java.lang.String getDescription()
    
abstract java.lang.String getFilename()
    
Get the path to the physical file, relative to the item it is attached to.
abstract long getSize()
    
Size in bytes for physical files, or zero for an attachment type with no physical file (E.g.
abstract java.lang.String getThumbnail()
    
The path to the thumbnail image file.
abstract java.lang.String getType()
    
The type of the attachment.
abstract java.lang.String getUrl()
    
Get the URL for a Link attachment E.g.
abstract java.lang.String getUuid()
    
abstract void setCustomDisplayProperty(java.lang.String key, java.lang.Object value)
    
Used to display custom metadata on the attachments dropdown.
abstract void setCustomIntegerProperty(java.lang.String propertyName, int propertyValue)
    
For attachments of type CUSTOM, set the value of the given property.
abstract void setCustomProperty(java.lang.String propertyName, java.lang.Object propertyValue)
    
For attachments of type CUSTOM, set the value of the given property.
abstract void setDescription(java.lang.String description)
    
abstract void setThumbnail(java.lang.String path)
    
Sets the path to the thumbnail for the attachment.
abstract void setUrl(java.lang.String url)
    
Sets the URL for a Link attachment.

 

 

 

 

getFilename

 

public abstract java.lang.String getFilename( )

 

Get the path to the physical file, relative to the item it is attached to. E.g. 'attachments/myfile.jpg' Note that if you invoke this method on a Link attachment, the URL will be returned.

 

Returns:
The path to the physical file, relative to the item.

 

 

 

getUrl

 

public abstract java.lang.String getUrl( )

 

Get the URL for a Link attachment E.g. 'http://www.google.com.au' Note that if you invoke this method on a File attachment, the path to the file will be returned as in getFilename().

 

Returns:
The URL of the link attachment.

 

 

 

setUrl

 

public abstract void setUrl( java.lang.String url)

 

Sets the URL for a Link attachment. Do not call this method on a File attachment as the path to the file will be overwritten by the URL.

 

Parameters:
url-

 

 

 

getUuid

 

public abstract java.lang.String getUuid( )

 

Returns:
The UUID of the attachment, generated by the system.

 

 

 

getDescription

 

public abstract java.lang.String getDescription( )

 

Returns:
The text to display as a link to this attachment

 

 

 

setDescription

 

public abstract void setDescription( java.lang.String description)

 

Parameters:
description-
The text to display as a link to this attachment. E.g. 'My Text File'

 

 

 

getType

 

public abstract java.lang.String getType( )

 

The type of the attachment. The most common types will be FILE, LINK, ZIP and IMS

 

Returns:
FILE, ITEM, ZIP, LINK, IMS, ACTIVITY, IMSRES, CUSTOM or HTML

 

 

 

getSize

 

public abstract long getSize( )

 

Size in bytes for physical files, or zero for an attachment type with no physical file (E.g. a Link attachment).

 

Returns:
The file size in bytes.

 

 

 

getThumbnail

 

public abstract java.lang.String getThumbnail( )

 

The path to the thumbnail image file. This may be a system thumbnail (based on the MIME type of the attachment) If this attachment is an image, a thumbnail of the image will be generated and this method will return the path to that thumbnail.

 

Returns:
The path to this attachment's thumbnail

 

 

 

setThumbnail

 

public abstract void setThumbnail( java.lang.String path)

 

Sets the path to the thumbnail for the attachment. The path should be a relative path from the item's filestore location. Use 'suppress' as the path to stop the automatic generation of thumbnails for image attachments.

 

 

 

getCustomType

 

public abstract java.lang.String getCustomType( )

 

The type of this custom attachment, for example, "flickr". This will throw an error unless getType() returns CUSTOM.

 

Returns:
The type of this custom attachment.

 

 

 

getCustomProperty

 

public abstract java.lang.Object getCustomProperty( java.lang.String propertyName)

 

For attachments of type CUSTOM, get the value of the given property (if any). If the attachment is not of type CUSTOM an exception will be thrown.

 

Parameters:
propertyName-
The name of the custom property.
Returns:
The value of the property, or null if not found.

 

 

 

setCustomProperty

 

public abstract void setCustomProperty( java.lang.String propertyName,
java.lang.Object propertyValue)

 

For attachments of type CUSTOM, set the value of the given property. If the attachment is not of type CUSTOM an exception will be thrown. Due to all numbers being represented as "double" (decimal point numbers) in Javascript, you should use the setCustomIntegerProperty(String, int) method if you need to the values of integer properties, otherwise your property will become a decimal type.

 

Parameters:
propertyName-
The name of the custom property.
propertyValue-
The new value of the custom property.

 

 

 

setCustomIntegerProperty

 

public abstract void setCustomIntegerProperty( java.lang.String propertyName,
int propertyValue)

 

For attachments of type CUSTOM, set the value of the given property. If the attachment is not of type CUSTOM an exception will be thrown.

 

Parameters:
propertyName-
The name of the custom property.
propertyValue-
The new integer (whole number) value of the custom property, e.g. 3

 

 

 

setCustomDisplayProperty

 

public abstract void setCustomDisplayProperty( java.lang.String key,
java.lang.Object value)

 

Used to display custom metadata on the attachments dropdown. All display properties will be ordered as they are inserted during scripting. If value is null the custom field will be removed. The key makes up the label that will be displayed in the user interface so it should be a human readable string for example: setCustomDisplayProperty('Author', 'John Doe'); will create the following on an attachment 'Author: John Doe'

 

Parameters:
key-
The name of the custom property
value-
The value of the custom property

 

 

 

getCustomDisplayProperty

 

public abstract java.lang.Object getCustomDisplayProperty( java.lang.String key)

 

Gets a specific custom display property or null if it does not exist

 

Parameters:
key-
The key of the custom property
Returns:
The value of the property

 

 

 

getAllCustomDisplayProperties

 

public abstract java.util.List<java.lang.String> getAllCustomDisplayProperties( )

 

Returns a list of all the keys used for custom metadata display

 

Returns:
a list of all keys