Zimlet JavaScript API Reference - ZmMetaData

Class ZmMetaData


This class provides a general way to store per-user data using arbitrary key/value pairs. NOTE: the server does not support modifying data so if there are any changes, *all* the data must be re-set per section. Data can be written on the mailbox or on an individual mailbox item. If the constructor receives an itemId, then data will be retrieved/written via [Get|Set]CustomMetadataRequest.

The section data is mapped into ZmSettings (based on the key name) to allow for easy access. When creating/setting a *new* key/value, naming conventions should be followed as defined by prefs in ZmSettings. For example, if adding a new key called "foo", the name for the key should be "zimbraPrefFoo" and should be added to the list of settings in ZmSettings with type set to ZmSetting.T_METADATA

Defined in: ZmMetaData.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
ZmMetaData(account, itemId)
Stores generic data to the server via <Set[Mailbox|Custom]MetadataRequest> and <Get[Mailbox|Custom]MetadataRequest>.
Method Summary
Method Attributes Method Name and Description
 
get(section, batchCommand, callback, errorCallback)
Fetches the given section name from the server unless its already been fetched (and therefore cached)
 
load(sections, callback, batchCommand)
Loads meta data from the server
 
modify(section, data, batchCommand, callback, errorCallback)
Modifies the given section with new key/value pairs
 
save(sections, callback, batchCommand)
Saves all data within the given section out to the server.
 
set(section, data, batchCommand, callback, errorCallback, sensitive)
Saves the given section and corresponding key/value pair to the server.
 
Returns a string representation of the object.
 
update(section, key, value)
Updates the local section cache with the given key/value pair.
Class Detail
ZmMetaData(account, itemId)
Stores generic data to the server via <Set[Mailbox|Custom]MetadataRequest> and <Get[Mailbox|Custom]MetadataRequest>.
Author: Parag Shah.
Parameters:
{ZmAccount} account
Optional. The account this meta data belongs to
{String} itemId
Optional. If specified, (custom) meta data will be saved on the item
Method Detail
get(section, batchCommand, callback, errorCallback)
Fetches the given section name from the server unless its already been fetched (and therefore cached)
Parameters:
{String} section
section of meta data to fetch
{ZmBatchCommand} batchCommand
if part of a separate batch command
{AjxCallback} callback
the callback to trigger once meta data is fetched
{AjxCallback} errorCallback
the error callback to trigger on error

load(sections, callback, batchCommand)
Loads meta data from the server
Parameters:
{Array} sections
the sections to load
{AjxCallback} callback
the callback
{ZmBatchCommand} batchCommand
if part of batch command

modify(section, data, batchCommand, callback, errorCallback)
Modifies the given section with new key/value pairs
Parameters:
{Array} section
the section to modify
{Object} data
the list of key/value pairs
{ZmBatchCommand} batchCommand
Optional. the batch command the request should be a part of
{AjxCallback} callback
the callback called on successful modify
{AjxCallback} errorCallback
the error callback to trigger on error

save(sections, callback, batchCommand)
Saves all data within the given section out to the server. If section is not provided, all sections are saved.
Parameters:
{Array} sections
the sections to save
{AjxCallback} callback
the callback called on successful save
{ZmBatchCommand} batchCommand
the batch command the request should be a part of

set(section, data, batchCommand, callback, errorCallback, sensitive)
Saves the given section and corresponding key/value pair to the server.
Parameters:
{String} section
the name of the section to save
{Object} data
the list of key/value pairs
{ZmBatchCommand} batchCommand
if part of a batch command
{AjxCallback} callback
the callback to trigger on successful save
{AjxCallback} errorCallback
the error callback to trigger on error
{Boolean} sensitive
if true, attempt to use secure conn to protect data

{String} toString()
Returns a string representation of the object.
Returns:
{String} a string representation of the object

update(section, key, value)
Updates the local section cache with the given key/value pair.
Parameters:
{String} section
the section to update
{String} key
the key to update
{String} value
the new value

Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:38 GMT-0400 (EDT)