API: registry
Source:
platform/registry.ts
Provides a set of utilities and data structures for interacting with the platform's Registry/Repository, which manages files and directories (Artefacts and Collections).
Usage
import { registry } from "sdk/platform";
import { response } from "sdk/http";
let text = registry.getText("modules/src/platform/registry.ts");
response.println(text);
response.flush();
response.close();Classes
Registry
@class Registry
@description Static utility class providing high-level access to the RegistryFacade for
retrieving content and metadata by path.
Methods
getContent
getContent (path:string):any[]Retrieves the content of a registry resource at the given path, converting it into a
JavaScript-friendly byte array format.
@param {string} path The absolute path to the resource (e.g., "/registry/public/myFile.txt").
@returns {any[]} The resource content as a JavaScript byte array.
getContentNative
getContentNative (path:string):any[]Retrieves the content of a registry resource at the given path in its native Java byte array format.
@param {string} path The absolute path to the resource.
@returns {any[]} The resource content as a native Java byte array.
getText
getText (path:string):stringRetrieves the content of a registry resource at the given path as a string.
@param {string} path The absolute path to the resource.
@returns {string} The resource content as plain text.
find
find (path:string, pattern:string):string[]Searches the registry starting from a given path for resources matching a glob pattern.
@param {string} path The starting path for the search.
@param {string} pattern The glob pattern to match resource names against (e.g., "*.js").
@returns {string[]} An array of registry paths (strings) that match the search criteria.
getRoot
getRoot ():DirectoryGets the root directory object for the public registry space.
@returns {Directory} A Directory instance representing the root public collection.
Artefact
@class Artefact
@description Represents a file or resource (non-collection) within the Registry.
Methods
getName
getName ():stringGets the name of the artefact (file name).
@returns {string} The name.
getPath
getPath ():stringGets the full registry path of the artefact.
@returns {string} The registry path.
getParent
getParent ():DirectoryGets the parent directory of this artefact.
@returns {Directory} The parent Directory instance.
getInformation
getInformation ():ArtefactInformationGets detailed metadata about the artefact.
@returns {ArtefactInformation} The metadata object.
exists
exists ():booleanChecks if the artefact currently exists in the registry.
@returns {boolean} True if the artefact exists, false otherwise.
isEmpty
isEmpty ():booleanChecks if the artefact (file) is empty (has zero size).
@returns {boolean} True if the content is empty, false otherwise.
getText
getText ():stringGets the content of the artefact as a text string.
@returns {string} The text content.
getContent
getContent ():any[]Gets the content of the artefact as a JavaScript-friendly byte array.
@returns {any[]} The content bytes.
getContentNative
getContentNative ():any[]Gets the content of the artefact as its native Java byte array representation.
@returns {any[]} The content bytes.
isBinary
isBinary ():booleanChecks if the artefact content is determined to be binary.
@returns {boolean} True if binary, false if text.
getContentType
getContentType ():stringGets the content type (MIME type) of the artefact.
@returns {string} The content type string.
Directory
@class Directory
@description Represents a collection or folder within the Registry.
Methods
getName
getName ():stringGets the name of the directory (folder name).
@returns {string} The name.
getPath
getPath ():stringGets the full registry path of the directory.
@returns {string} The registry path.
getParent
getParent ():DirectoryGets the parent directory.
@returns {Directory} The parent Directory instance.
getInformation
getInformation ():ArtefactInformationGets detailed metadata about the directory.
@returns {ArtefactInformation} The metadata object.
exists
exists ():booleanChecks if the directory currently exists in the registry.
@returns {boolean} True if the directory exists, false otherwise.
isEmpty
isEmpty ():booleanChecks if the directory is empty (contains no files or sub-directories).
@returns {boolean} True if empty, false otherwise.
getDirectoriesNames
getDirectoriesNames ():string[]Gets the names of all sub-directories within this directory.
@returns {string[]} An array of sub-directory names.
getDirectory
getDirectory (name:string):DirectoryGets a specific sub-directory by name.
@param {string} name The name of the sub-directory.
@returns {Directory} The child Directory instance.
getArtefactsNames
getArtefactsNames ():string[]Gets the names of all files (artefacts) within this directory.
@returns {string[]} An array of artefact names.
getArtefact
getArtefact (name:string):ArtefactGets a specific file (artefact) by name.
@param {string} name The name of the artefact.
@returns {Artefact} The child Artefact instance.
ArtefactInformation
@class ArtefactInformation
@description Represents detailed metadata (creation date, size, permissions, etc.) for a
Directory or Artefact.
Methods
getName
getName ():stringGets the name of the resource.
@returns {string} The name.
getPath
getPath ():stringGets the full registry path of the resource.
@returns {string} The registry path.
getPermissions
getPermissions ():numberGets the access permissions for the resource (typically an integer bitmask).
@returns {number} The permissions value.
getSize
getSize ():numberGets the size of the resource content in bytes.
@returns {number} The size in bytes.
getCreatedBy
getCreatedBy ():stringGets the user who created the resource.
@returns {string} The creator's name.
getCreatedAt
getCreatedAt ():DateGets the creation timestamp.
@returns {Date} The creation date and time.
getModifiedBy
getModifiedBy ():stringGets the user who last modified the resource.
@returns {string} The modifier's name.
getModifiedAt
getModifiedAt ():DateGets the last modification timestamp.
@returns {Date} The modification date and time.