API Docs for: 0.8.2
Show:

ItemMirror Class

ItemMirror represents an Item according to the XooML2 specification.

It can be instantiated using one of the following two cases based on the given arguments.

  1. XooMLFragment already exists. Given xooMLFragmentURI and xooMLDriver.
  2. The XooMLFragment is created from an existing groupingItemURI (e.g., a dropbox folder). Given a groupingItemURI, itemDriver, and a xooMLDriver a new itemMirror will be constructed for given groupingItemURI.

Throws NullArgumentException when options is null.

Throws MissingParameterException when options is not null and a required argument is missing.

Constructor

ItemMirror

(
  • options
  • callback
)

Parameters:

  • options Object

    Data to construct a new ItemMirror with

    • groupingItemURI String

      URI to the grouping item. Required for all cases.

    • itemDriver String

      Data for the ItemDriver to construct ItemMirror with. Required for cases 2 & 3 Can contain any amount of optional key/value pairs for the various Driver implementations.

      • driverURI String
        URI of the driver.
    • xooMLDriver String

      Data for the XooMLDriver to construct ItemMirror with. Required for all cases. Can contain any amount of optional key/value pairs for the various Driver implementations.

      • driverURI String
        URI of the driver.
    • syncDriver String

      Data for the SyncDriver to construct ItemMirror with. Required Case 2 & 3. Can contain any amount of optional key/value pairs for the various Driver implementations.

      • driverURI String
        URI of the driver.
    • readIfExists Boolean

      True if ItemMirror should create an ItemMirror if it does not exist, else false. Required for Case 2 & 3.

    • creator ItemMirror

      If being created from another itemMirror, specifies that itemMirror which it comes from.

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error has occurred in executing this function, else an contains an object with the error that occurred.

    • itemMirror ItemMirror

      Newly constructed ItemMirror

Methods

_isURL

(
  • URL
)
Boolean private

Checks if the AssociatedItem String passed into it is a URL or not.

Parameters:

Returns:

Boolean:

True if it is an HTTP URL, false otherwise (HTTPS will fail)

_unsafeWrite

(
  • callback
  • calback.error
)

A special method that is used for certain file operations where calling a sync won't work. Essentially it is the save function, sans syncing. This should never be called be an application.

Parameters:

addAssociationNamespaceAttribute

(
  • attributeName
  • attributeValue
  • GUID
  • uri
)

Adds the given attributeName to the association with the given GUID and namespaceURI.

Throws NullArgumentException if attributeName, GUID, or namespaceURI is null.
Throws InvalidTypeException if attributeName, GUID, or namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Throws an InvalidStateException when the given attributeName has already been added.

Parameters:

  • attributeName String

    Name of the attribute.

  • attributeValue String

    Value of the attribe to be set

  • GUID String

    GUID of the association.

  • uri String

    Namespace URI

addFragmentNamespaceAttribute

(
  • attributeName
  • uri
)

Adds the given attributeName to the fragment's current namespace

Throws an InvalidStateException when the attribute already exists

Parameters:

  • attributeName String

    Name of the attribute.

  • uri String

    Namespace URI

copyAssociation

(
  • GUID
  • ItemMirror
  • callback
)

Duplicates (copies) an association to another ItemMirror Object (representing a grouping item)

Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the association you wish to copy/duplicate

  • ItemMirror ItemMirror

    ItemMirror representing the grouping item you want to move the GUID object to

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error Null if no error has occurred in executing this function, else it contains an object with the error that occurred.

createAssociation

(
  • options
  • callback
)

Creates an association based on the given options and the following cases.

Cases 1, 2, 7 implemented. All else are not implemented.

  1. Simple text association declared phantom.
  2. Link to existing non-grouping item, phantom. This can be a URL
  3. Link to existing non-grouping item, real.
  4. Link to existing grouping item, phantom.
  5. Link to existing grouping item, real.
  6. Create new local non-grouping item.
  7. Create new local grouping item.

Throws NullArgumentException when options, or callback is null.
Throws InvalidTypeException when options is not an object and callback is not a function.
Throws MissingParameterException when an argument is missing for an expected case.

Parameters:

  • options Object

    Data to create an new association for.

    • displayText String

      Display text for the association. Required in all cases.

    • itemURI String

      URI of the item. Required for case 2 & 3. Note: Please ensure "http://" prefix exists at the beginning of the string when referencing a Web URL and not an Item.

    • localItemRequested Boolean

      True if the local item is requested, else false. Required for cases 2 & 3.

    • groupingItemURI String

      URI of the grouping item. Required for cases 4 & 5.

    • xooMLDriverURI String

      URI of the XooML driver for the association. Required for cases 4 & 5.

    • localItem String

      URI of the new local non-grouping/grouping item. Required for cases 6 & 7.

    • isGroupingItem String

      True if the item is a grouping item, else false. Required for cases 6 & 7.

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error has occurred in executing this function, else an contains an object with the error that occurred.

    • GUID String

      GUID of the association created.

createItemMirrorForAssociatedGroupingItem

(
  • GUID
)
ItemMirror

Creates an ItemMirror from the associated grouping item represented by the given GUID.

Throws NullArgumentException if GUID or callback is null.
Throws InvalidTypeException if GUID is not a string, and callback is not a function.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the association to create the ItemMirror from.

Returns:

ItemMirror:

Possibly return an itemMirror if the GUID is a grouping item

deleteAssociation

(
  • GUID
  • callback
)

Deletes the association represented by the given GUID.

Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the association to be deleted.

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error has occurred in executing this function, else an contains an object with the error that occurred.

getAssociationAssociatedItem

(
  • GUID
)
String

Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the association to get.

Returns:

String:

The associated item for the association with the given GUID.

getAssociationDisplayText

(
  • GUID
)
String

Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID representing the desired association.

Returns:

String:

The display text for the association with the given GUID.

getAssociationLocalItem

(
  • GUID
)
String

Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the association to get.

Returns:

String:

The local item for the association with the given GUID.

getAssociationNamespaceAttribute

(
  • attributeName
  • GUID
  • uri
)
String

Throws NullArgumentException if attributeName, GUID, or namespaceURI is null.
Throws InvalidTypeException if attributeName, GUID, or namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • attributeName String

    Name of the attribute to be returned.

  • GUID String

    GUID of the association to return attribute from.

  • uri String

    Namspace URI

Returns:

String:

The association namespace attribute with the given attributeName and the given namespaceURI within the association with the given GUID.

getAssociationNamespaceData

(
  • GUID
  • uri
)
String

Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the association namespace data to returned.

  • uri String

    Namespace URI

Returns:

String:

The association namespace data for an association with the given GUID and the given namespaceURI.

getCreator

() Object

Returns:

Object:

The itemMirror that created this current itemMirror, if it has one. Note that this isn't the same as asking for a 'parent,' since multiple itemMirrors can possibly link to the same one

getDisplayName

() String

Returns:

String:

The display name of the fragment.

getFragmentNamespaceAttribute

(
  • attributeName
  • uri
)
String

Parameters:

  • attributeName String

    Name of the attribute to be returned.

  • uri String

    Namespace URI

Returns:

String:

Returns the value of the given attributeName for the fragmentNamespaceData with the given namespaceURI.

getFragmentNamespaceData

(
  • uri
)
String

Parameters:

Returns:

String:

The fragment namespace data with the given namespace URI.

getSchemaLocation

() String

Returns:

String:

XooML schema location.

getSchemaVersion

() String

Returns:

String:

XooML schema version.

getURIforItemDescribed

() String

Returns URI pointing to item described by the metadata of a fragment. A URI might point to just about anything that can be interpreted as a grouping item. For example: a conventional file system folder or a “tag as supported by any of several applications.

Returns:

String:

A URI pointing to item described by the metadata of a fragment if it exists, else returns null.

hasAssociationNamespace

(
  • GUID
  • uri
)
Boolean

Parameters:

  • GUID String

    GUID of the association.

  • uri String

    Namespace URI

Returns:

Boolean:

True if the association has the given namespaceURI, else false.

hasFragmentNamespace

(
  • uri
)
Boolean

Checks if the fragment has the given namespaceURI.

Currently cannot find a way to list the namespaces (no DOM standard method for doing so). So this fuction will ALWAYS RETURN FALSE for now.

Parameters:

  • uri String

    URI of the namespace for the association.

Returns:

Boolean:

True if the fragment has the given namespaceURI, otherwise false.

isAssociationAssociatedItemGrouping

(
  • GUID
)
Boolean

Checks if an association's associatedItem is a grouping item

Throws NullArgumentException if GUID, callback is null.
Throws InvalidTypeException if GUID is not a String, and if callback is not an function.

Parameters:

  • GUID String

    GUID of the association to be to be checked.

Returns:

Boolean:

True if the association with the given GUID's associatedItem is a grouping item, otherwise false.

isAssociationPhantom

(
  • guid
)
Boolean

Parameters:

Returns:

Boolean:

True if the association of the given GUID is a phantom association. False otherwise.

listAssociationNamespaceAttributes

(
  • GUID
  • uri
)
String[]

Throws NullArgumentException if GUID, namespaceURI is null.
Throws InvalidTypeException if GUID, namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of association to list attributes for.

  • uri String

    Namespace URI

Returns:

String[]:

An array of the association namespace attributes with the given attributeName and the given namespaceURI within the association with the given GUID.

listAssociations

() String[]

Lists the GUIDs of each association.

Returns:

String[]:

Array of the GUIDs of each association

listFragmentNamespaceAttributes

(
  • uri
)
String[]

Parameters:

Returns:

String[]:

An array of the attributes within the fragmentNamespaceData with the given namespaceURI.

moveAssociation

(
  • GUID
  • ItemMirror
  • callback
)

Moves an association to another ItemMirror Object (representing a grouping item)

Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the item you want to paste or move

  • ItemMirror ItemMirror

    ItemMirror representing the grouping item you want to move the GUID object to

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error Null if no error has occurred in executing this function, else it contains an object with the error that occurred.

refresh

(
  • callback
)

Reloads the XooML Fragment

Parameters:

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error has occurred in executing this function, else an contains an object with the error that occurred.

removeAssociationNamespaceAttribute

(
  • attributeName
  • GUID
  • uri
)

Removes the given attributeName to the association with the given GUID and namespaceURI.

Throws NullArgumentException if attributeName, GUID, or namespaceURI is null.
Throws InvalidTypeException if attributeName, GUID, or namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Throws an InvalidStateException when the given attributeName is not an attribute.

Parameters:

  • attributeName String

    Name of the attribute.

  • GUID String

    GUID of the association.

  • uri String

    Namespace URI

removeFragmentNamespaceAttribute

(
  • attributeName
  • uri
)

Removes the fragment namespace attribute with the given namespaceURI.

Throws NullArgumentException if attributeName, or namespaceURI is null.
Throws InvalidTypeException if attributeName, or namespaceURI is not a String.
Throws an InvalidStateException when the given attributeName is not an attribute.

Parameters:

  • attributeName String

    Name of the attribute.

  • uri String

    Namespace URI

renameAssocaitionLocalItem

(
  • GUID
  • String
  • callback
)

Renames the local item for the association with the given GUID.

Throws NullArgumentException if GUID, callback is null.
Throws InvalidTypeException if GUID is not a String, and if callback is not a function.

Parameters:

  • GUID String

    GUID of the association.

  • String String

    String Name you want to rename the file to (including file extension)

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error has occurred in executing this function, else an contains an object with the error that occurred.

    • GUID String

      The GUID of the association that was updated.

save

(
  • callback
)

Saves the itemMirror object, writing it out to the fragment. Fails if the GUID generated on last write for the itemMirror and the XooML fragment don't match.

Parameters:

  • callback Object
    • error

      Returns false if everything went ok, otherwise returns the error

setAssociationDisplayText

(
  • GUID
  • displayText
)

Sets the display text for the association with the given GUID.

Throws NullArgumentException if GUID or displayName is null.
Throws InvalidTypeException if GUID or displayName is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • GUID String

    GUID of the association to set.

  • displayText String

    Display text to be set.

setAssociationNamespaceAttribute

(
  • attributeName
  • attributeValue
  • GUID
  • uri
)

Sets the association namespace attribute with the given attributeName and the given namespaceURI within the association with the given GUID.

Throws NullArgumentException if attributeName, attributeValue, GUID, or namespaceURI is null.
Throws InvalidTypeException if attributeName, attributeValue, GUID, or namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • attributeName String

    Name of the attribute to be set.

  • attributeValue String

    Value of the attribute to be set

  • GUID String

    GUID of association to set attribute for.

  • uri String

    Namespace URI

setAssociationNamespaceData

(
  • data
  • GUID
)

Sets the association namespace data for an association with the given GUID and given namespaceURI using the given data.

Throws NullArgumentException if data, GUID, or namespaceURI is null.
Throws InvalidTypeException if data, GUID, or namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.

Parameters:

  • data String

    Association namespace data to set. Must be valid fragmentNamespaceData.

  • GUID String

    GUID of the association namespace data to set.

setDisplayName

(
  • name
)

Parameters:

  • name String

    The display text to set for the fragment

setFragmentNamespaceAttribute

(
  • attributeName
  • attributeValue
  • uri
)

Sets the value of the given attributeName with the given attributeValue for the fragmentNamespaceData with the given namespaceURI.

Throws NullArgumentException if attributeName, attributeValue, or namespaceURI is null.
Throws InvalidTypeException if attributeName, attributeValue, or namespaceURI is not a String.

Parameters:

  • attributeName String

    Name of the attribute to be set.

  • attributeValue String

    Value of the attribute to be set.

  • uri String

    Namespace URI

setFragmentNamespaceData

(
  • data
  • uri
)

Sets the fragment namespace data with the given namespaceURI.

Parameters:

  • data String

    Fragment namespace data to be set.

  • uri String

    Namespace URI

sync

(
  • callback
)
private

Uses the specified ItemDriver and SyncDriver to synchronize the local ItemMirror object changes. This is an implmentation of Synchronization Driver which modifies the XooML Fragment according to the real structure under the item described.

Parameters:

  • callback Function

    Function to execute once finished.

    • error Object

      Null if no error has occurred in executing this function, else an contains an object with the error that occurred.

upgradeAssociation

(
  • options
  • callback
)

Upgrades a given association without a local item. Local item is named by a truncated form of the display name of this ItemMirror if the localItemURI is not given, else uses given localItemURI. Always truncated to 50 characters.

ONLY SUPPORTS SIMPLE PHANTOM ASSOCIATION TO ASSOCIATION WITH GROUPING ITEM

Throws NullArgumentException when options is null.
Throws MissingParameterException when options is not null and a required argument is missing.
Throws InvalidTypeException if GUID is not a string, and if callback is not a function.
Throws InvalidState if the association with the given GUID cannot be upgraded.

Parameters:

  • options Object

    Data to construct a new ItemMirror with

    • GUID String

      of the association to be upgraded. Required

    • localItemURI String

      URI of the local item to be used if a truncated display name is not the intended behavior. Optional.

  • callback Function

    Function to execute once finished.

    • error String

      Null if no error has occurred in executing this function, else an contains an object with the error that occurred.