Class: Branch

Gitana. Branch

Branch


new Branch(repository [, Object])

Parameters:
Name Type Argument Description
repository Gitana.Repository
Object <optional>

object json object (if no callback required for populating)

Source:

Extends

Methods


__copyState()

Override the Chain.__copyState method so that it utilizes a base method that we can override
on a per-class basis.

Inherited From:
Source:

archive(callback)

Archives the branch.

Parameters:
Name Type Description
callback
Source:
Returns:
Type
*

associate(sourceNode, targetNode, object)

Creates an association between the source node and the target node of the given type.

Parameters:
Name Type Description
sourceNode
targetNode
object

(or string identifying type)

Source:

chainCopyState(otherObject)

Override to include:

__system

Parameters:
Name Type Description
otherObject
Inherited From:
Source:

chainCreate(chainable, object, uri, params)

Creates an object on the server (write + read).
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
object
uri
params
Inherited From:
Source:

chainCreateEx(chainable, object, createUri, readUri)

Creates an object on the server using one URL and then reads it back using another URL.
This exists because the security responses don't include _doc fields like other responses.

Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
object
createUri
readUri
Inherited From:
Source:

chainDelete(chainable, uri, params)

Executes an HTTP delete for this object and continues the chain with the chainable.

Parameters:
Name Type Description
chainable
uri
params
Inherited From:
Source:

chainGet(chainable, uri, params)

Performs a GET from the server and populates the chainable.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
Inherited From:
Source:

chainGetResponse(chainable, uri, params)

Performs a GET to the server and pushes the response into the chain.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
Inherited From:
Source:

chainGetResponseRows(chainable, uri, params)

Performs a GET to the server and pushes the "rows" response attribute into the chain.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
Inherited From:
Source:

chainGetResponseText(chainable, uri, params)

Performs a GET to the server and pushes the text response to the callback.

Parameters:
Name Type Description
chainable
uri
params
Inherited From:
Source:

chainHasResponseRow(chainable, uri, value)

Performs a GET to the server and checks whether the "rows" array attribute of the response
has the given value.

Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
value
Inherited From:
Source:

chainPatch(chainable, uri, params, payload)

Performs a PATCH to the server and populates the chainable with results.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
payload
Inherited From:
Source:

chainPost(chainable, uri, params, payload)

Performs a POST to the server and populates the chainable with results.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
payload
Inherited From:
Source:

chainPostEmpty(chainable, uri, params, payload, contentType)

Performs a POST to the server. The response is not handled.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
payload

(optional)

contentType

(optional) - example "text/plain"

Inherited From:
Source:

chainPostResponse(chainable, uri, params)

Performs a POST to the server and pushes the response into the chain.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
Inherited From:
Source:

chainReload(uri, params)

Reloads this object from the server and then passes control to the chainable.

Parameters:
Name Type Description
uri
params
Inherited From:
Source:

chainUpdate(chainable, uri, params)

Executes an update (write + read) of this object and then passes control to the chainable.

Parameters:
Name Type Description
chainable
uri
params
Inherited From:
Source:

chainUpload(chainable, uri, params, contentType, payload)

Performs a POST to the server. The response is not handled.
Proceeds with the chain as bound to the chainable.

Parameters:
Name Type Description
chainable
uri
params
contentType

(optional) - example "text/plain"

payload

(optional)

Inherited From:
Source:

checkAuthority(principal, authorityId, callback)

Checks whether the given principal has a granted authority for this object.
This passes the result (true/false) to the chaining function.

Parameters:
Name Type Description
principal Gitana.DomainPrincipal | String

the principal or the principal id

authorityId String

the id of the authority

callback
Inherited From:
Source:

checkNodeAuthorities(checks, callback)

Performs a bulk check of authorities against permissioned objects of type node.

Example of checks array:

[{
"permissionedId": "",
"principalId": "",
"authorityId": ""
}]

The callback receives an array of results, example:

[{
"permissionedId": "",
"principalId": "",
"authorityId": "",
"result": true
}]

The order of elements in the array will be the same for checks and results.

Parameters:
Name Type Description
checks
callback
Source:

checkNodePermissions(checks, callback)

Performs a bulk check of permissions against permissioned objects of type node.

Example of checks array:

[{
"permissionedId": "",
"principalId": "",
"permissionId": ""
}]

The callback receives an array of results, example:

[{
"permissionedId": "",
"principalId": "",
"permissionId": "",
"result": true
}]

The order of elements in the array will be the same for checks and results.

Parameters:
Name Type Description
checks
callback
Source:

checkPermission(principal, permissionId, callback)

Checks whether the given principal has a permission against this object.
This passes the result (true/false) to the chaining function.

Parameters:
Name Type Description
principal Gitana.DomainPrincipal | String

the principal or the principal id

permissionId String

the id of the permission

callback
Inherited From:
Source:

clone()

Source:

copy(target, asynchronous, config)

Copies this object into the target.

Parameters:
Name Type Description
target
asynchronous
config
Inherited From:
Source:

createContainer( [Object])

Creates a container node.

This is a convenience function that simply applies the container feature to the object
ahead of calling createNode.

Parameters:
Name Type Argument Description
Object <optional>

object JSON object

Source:

createNode( [Object] [, Object|String])

Create a node

Parameters:
Name Type Argument Description
Object <optional>

object JSON object

Object|String <optional>

options a JSON object providing the configuration for the create operation.
If a string, must follow format (/)

Source:

del()

Delete

Inherited From:
Source:

deleteNodes(nodeIds)

Deletes the nodes described the given array of node ids.

Parameters:
Name Type Description
nodeIds
Source:
Returns:

Gitana.Branch


exportArchive(settings)

Exports an archive.

Parameters:
Name Type Description
settings Object
Inherited From:
Source:

extractPrincipalDomainQualifiedId(principal)

Helper to gets the principal id for a principal object, json structure or principal id itself.
This returns something like "domainId/principalId"

Parameters:
Name Type Description
principal
Inherited From:
Source:

extractPrincipalIdentifiers(principal, defaultDomainId)

Helper to gets the principal id for a principal object, json structure or principal id itself.
This returns something like "domainId/principalId"

Parameters:
Name Type Description
principal

principal object or string (principal id or domain qualified principal id)

defaultDomainId
Inherited From:
Source:

find(config)

Finds nodes within a branch

Parameters:
Name Type Description
config Object

search configuration

Source:

findNodes(config, pagination)

Another way to access the find() method that is more consistent with the API
that would be expected.

Parameters:
Name Type Description
config
pagination
Source:
Returns:
Type
*

generateQName(object)

Determines an available QName on this branch given some input.
This makes a call to the repository and asks it to provide a valid QName.

The valid QName is passed as an argument to the next method in the chain.

Note: This QName is a recommended QName that is valid at the time of the call.

If another thread writes a node with the same QName after this call but ahead of this thread
attempting to commit, an invalid qname exception may still be thrown back.

Parameters:
Name Type Description
object Object

an object with "title" or "description" fields to base generation upon

Source:

get(key)

Get a json property

Parameters:
Name Type Description
key
Inherited From:
Source:

getBranchType()

Source:
Returns:

the type of branch ("master" or "custom")

Type
String

getDescription()

The description for the object.

Inherited From:
Source:
Returns:

the description

Type
String

getId()

Hands back the ID ("_doc") of this object.

Inherited From:
Source:
Returns:

id

Type
String

getProxiedUri()

Hands back the URI of this object as referenced by the browser.

Inherited From:
Source:

getRepository()

Gets the Gitana Repository object.

Inherited From:
Source:
Returns:

The Gitana Repository object

Type
Gitana.Repository

getRepositoryId()

Gets the Gitana Repository id.

Inherited From:
Source:
Returns:

The Gitana Repository id

Type
String

getSystemMetadata()

Hands back the system metadata for this object.

Inherited From:
Source:
Returns:

system metadata

Type
Gitana.SystemMetadata

getTip()

Source:
Returns:

the tip changeset of the branch

Type
String

getTitle()

The title for the object.

Inherited From:
Source:
Returns:

the title

Type
String

getType()

Inherited From:
Overrides:
Source:

getUri()

Inherited From:
Overrides:
Source:

grantAuthority(principal, authorityId)

Grants an authority to a principal against this object.

Parameters:
Name Type Description
principal Gitana.DomainPrincipal | String

the principal or the principal id

authorityId String

the id of the authority

Inherited From:
Source:

graphqlQuery(query, operationName, variables, callback)

Process a GraphQL query to the branch.

Parameters:
Name Type Description
query
operationName
variables
callback

function(result)

Source:
Returns:

result


graphqlSchema(callback)

Fetch the GraphQL schema for the branch.

Parameters:
Name Type Description
callback

function(schema)

Source:
Returns:

String


handleResponse(response)

Parameters:
Name Type Description
response
Inherited From:
Source:

handleSystemProperties()

Gets called after the response is handled and allows the object to pull out special values from
the "object" field so that they don't sit on the JSON object

Inherited From:
Source:

importArchive(settings [, Function])

Imports an archive.

Parameters:
Name Type Argument Description
settings Object
Function <optional>

reportFn

Inherited From:
Source:

isMaster()

Source:
Returns:

whether this is the master branch

Type
Boolean

json()

Hands back a cleanup, properties-only JSON simple object.

Inherited From:
Source:

listAuthorities(principal, callback)

Retrieve list of authorities and pass into chaining method.

Parameters:
Name Type Description
principal Gitana.DomainPrincipal | String

the principal or the principal id

callback
Inherited From:
Source:

listDefinitions( [String] [, Object])

Acquire a list of definitions.

Parameters:
Name Type Argument Description
String <optional>

filter Optional filter of the kind of definition to fetch - "association", "type" or "feature"

Object <optional>

pagination Optional pagination

Source:

listItems(listKey [, Object])

List the items in a node list.

Parameters:
Name Type Argument Description
listKey String
Object <optional>

pagination

Source:

listMounts( [Object])

Acquires a list of mount nodes under the root of the repository.

Parameters:
Name Type Argument Description
Object <optional>

pagination

Source:

loadACL(callback)

Retrieve full ACL and pass into chaining method.

Parameters:
Name Type Description
callback
Inherited From:
Source:

loadAuthorityGrants(callback)

Loads the authority grants for a given set of principals.

Parameters:
Name Type Description
callback
Inherited From:
Source:

loadForms(filter, callback)

Loads all of the definitions, forms and key mappings on this branch.

Parameters:
Name Type Description
filter
callback
Source:

loadFrom(anotherObject)

Helper method that loads this object from another object of the same type.

For example, loading a node from another loaded node.

Parameters:
Name Type Description
anotherObject
Inherited From:
Source:

loadHistoryChangesets(config, pagination, callback)

Loads the historic changesets for a branch.

The config is optional and can specify "root" and "tip" changeset ids.

Parameters:
Name Type Description
config
pagination

(optional)

callback
Source:
Returns:
Type
*

loadHistoryNodeDiffs(config, pagination, callback)

Loads the history node differences for a branch.

The config is optional and can specify "root" and "tip" changeset ids.

Parameters:
Name Type Description
config
pagination

(optional)

callback
Source:
Returns:
Type
*

loadInfo(callback)

Loads information about the branch.

Parameters:
Name Type Description
callback
Source:

loadSchema(qname)

Reads a schema by qname.

Parameters:
Name Type Description
qname String

the qname

Source:

loadSchemas( [String], callback)

Loads a list of schemas for an optional given type.

Parameters:
Name Type Argument Description
String <optional>

filter Optional filter of the kind of definition to fetch - "association", "type" or "feature"

callback function
Source:

purgeAllDeletions()

Purges all deletions.

Source:

queryDeletions(query [, Object])

Queries for deletions on the branch.

Config should be:

{
Gitana query configs
}

Parameters:
Name Type Argument Description
query Object
Object <optional>

pagination

Source:

queryItems(listKey, query [, Object])

Queries for items in a node list.

Parameters:
Name Type Argument Description
listKey String
query Object
Object <optional>

pagination

Source:

queryNodes(query [, Object])

Queries for nodes on the branch.

Config should be:

{
Gitana query configs
}

Parameters:
Name Type Argument Description
query Object
Object <optional>

pagination

Source:

queryOne(query, errHandler)

Queries for a single matching node to a query on the branch.

Parameters:
Name Type Description
query
errHandler
Source:
Returns:

Gitana.Node


readDefinition(qname)

Reads a definition by qname.

Parameters:
Name Type Description
qname String

the qname

Source:

readDeletion(nodeId)

Reads a deletion.

Parameters:
Name Type Description
nodeId String

the node id

Source:

readGroupNode(group [, Boolean])

Reads the group object for a security group.

Parameters:
Name Type Argument Description
group Object

eitehr the group id, group name or the group object

Boolean <optional>

createIfNotFound whether to create the group object if it isn't found

Source:

readNode(nodeId [, String] [, String])

Reads a node.

Parameters:
Name Type Argument Description
nodeId String

the node id

String <optional>

offset path

String <optional>

params

Source:

readPersonNode(user [, Boolean])

Reads the person object for a security user.

Parameters:
Name Type Argument Description
user Object

either the user id, user name or the user object

Boolean <optional>

createIfNotFound whether to create the person object if it isn't found

Source:

ref()

Inherited From:
Source:
Returns:

a string denoting a reference to this object.

Type
String

reload()

Reload

Inherited From:
Source:

replacePropertiesWith(object)

Replaces all of the properties of this object with those of the given object.
This method should be used to update the state of this object.

Any functions from the incoming object will not be copied.

Parameters:
Name Type Description
object Object

object containing the properties

Inherited From:
Source:

revokeAllAuthorities(principal)

Revokes all authorities for a principal against the server.

Parameters:
Name Type Description
principal Gitana.Principal | String

the principal or the principal id

Inherited From:
Source:

revokeAuthority(principal, authorityId)

Revokes an authority from a principal against this object.

Parameters:
Name Type Description
principal Gitana.DomainPrincipal | String

the principal or the principal id

authorityId String

the id of the authority

Inherited From:
Source:

rootNode()

Reads the root node.

Source:

searchNodes(search [, Object])

Searches the branch.

Parameters:
Name Type Argument Description
search
Object <optional>

pagination

Source:

set(key, value)

Set a json property

Parameters:
Name Type Description
key
value
Inherited From:
Source:

stringify(pretty)

Helper function to convert the object portion to JSON

Parameters:
Name Type Description
pretty
Inherited From:
Source:

traverse(node, config)

Traverses around the given node.

Note: This is a helper function provided for convenience that delegates off to the node to do the work.

Parameters:
Name Type Description
node

or node id

config
Source:

unarchive(callback)

Unarchives the branch.

Parameters:
Name Type Description
callback
Source:
Returns:
Type
*

update()

Update

Inherited From:
Source: