arrow-down
    1. Widgets
  1. IAM
    1. Virtual apps
    1. Projects
    2. Layers
        1. AttachmentUploader
        2. Checkbox
        3. Combobox
        4. ContentSelector
        5. ContentTypeFilter
        6. CustomSelector
        7. Date
        8. DateTime
        9. Double
        10. GeoPoint
        11. HtmlArea
        12. ImageSelector
        13. Long
        14. MediaSelector
        15. Radiobutton
        16. Tag
        17. TextArea
        18. TextLine
        19. Time
      1. Field set
      2. Item set
      3. Option set
      4. Mixins
      5. Localization
    3. Content Types
    4. X-data
    5. Macros
    6. Custom styles
    7. Sites
      1. Regions
      2. Part component
      3. Layout component
      4. Text component
      5. Fragments
      6. Filtering
      7. Component indexing
      8. Visual editor
    8. Page templates
    1. Sandboxes
    2. Code
    3. Building
    4. Configuration
    1. Globals
    2. HTTP
    3. Controllers
    4. Filters
    5. Events
    6. Websocket
    7. Error handler
    8. ID provider
    9. Tasks
    10. Localization
    11. Mappings
    12. Components
    13. Processors
    14. Contributions
    15. Templating
    16. Main controller
    17. Java bridge
      1. Webapp Engine
        1. Image service
        2. Component service
      2. Admin Engine
      3. Asset service
      4. HTTP service
      5. IDprovider service
    1. Task engine
    2. Management Endpoint
    3. Statistics Endpoint
    1. Nodes and repos
    2. Properties
    3. Indexing
    4. Branches
    5. Queries (NoQL)
    6. Queries (DSL)
    7. Filters
    8. Aggregations
    9. Highlighting
    10. Editors
    1. Strategies
    2. Distributions
    3. Docker image
    4. Vhosts
    5. Configuration
    6. Backup & restore
    7. Systemd
    8. Clustering
    1. Admin API
    2. Application API
    3. Auditlog API
    4. Authentication API
    5. Cluster API
    6. Common API
    7. Content API
    8. Context API
    9. Event API
    10. Export API
    11. Grid API
    12. I18N API
    13. IO API
    14. Mail API
    15. Node API
    16. Portal API
    17. Project API
    18. Repo API
    19. Scheduler API
    20. Schema API
    21. Tasks API
    22. Value API
    23. VHost API
    24. Websocket API
  2. Audit Logs
    1. Upgrade Notes
    2. Upgrading Apps

Application API

Contents

XP XP 7.11.0 7.11.0 API for fetching and manipulating applications.

Usage

Add the following to your build.gradle file:

dependencies {
  include "com.enonic.xp:lib-app:${xpVersion}"
}

Add the import statement to your controller:

import appLib from '/lib/xp/app';

You are now ready to use the API.

Functions

get

Returns an installed application. If a local and a virtual app are both installed with the specified key, then the local one will take precedence and will be returned in the result.

Parameters

Name Type Description

params

object

JSON with parameters

Properties
Name Type Description

key

string

Application key

Returns

object : (Application) Property object of an installed application with the specified key, or null if the application was not found.

Example

Fetches an application:
import {get as getApp} from '/lib/xp/app';

const application = getApp({key: 'my-app-key'});

if (application) {
  log.info('Application name = %s', application.displayName);
} else {
  log.info('Application not found');
}
Return value:
const expected = {
    key: 'my-app',
    displayName: 'app display name',
    vendorName: 'vendor name',
    vendorUrl: 'https://vendor.url',
    url: 'https://myapp.url',
    version: '1.0.0',
    systemVersion: '4.2.3-SNAPSHOT',
    minSystemVersion: '2.0.0',
    maxSystemVersion: '3.0.0',
    modifiedTime: '2020-09-25T10:00:00Z',
    started: true,
    system: false
};

list

Fetches all installed applications. If a local and a virtual app are both installed with the same key, then the local one will take precedence and will be returned in the result.

Returns

object[] : (Application[]) Array of applications' property objects, or an empty array if there are no installed applications.

Example

Fetching all applications:
import {list} from '/lib/xp/app';
const apps = list();
Return value:
const expected = [
    {
        key: 'app1',
        displayName: 'app display name',
        vendorName: 'vendor name',
        vendorUrl: 'https://vendor.url',
        url: 'https://myapp.url',
        version: '1.0.0',
        systemVersion: '1.21.3',
        minSystemVersion: '2.0.0',
        maxSystemVersion: '3.0.0',
        modifiedTime: '2020-09-25T10:00:00Z',
        started: true,
        system: false
    },
    {
        key: 'app2',
        displayName: 'app display name 2',
        vendorName: 'vendor name 2',
        vendorUrl: 'https://vendor2.url',
        url: 'https://myapp2.url',
        version: '4.1.2',
        systemVersion: '1.2.33-SNAPSHOT',
        minSystemVersion: '5.3.11',
        maxSystemVersion: '3.0.6',
        modifiedTime: '2021-09-25T10:00:00Z',
        started: false,
        system: true
    }
];

getDescriptor

Returns descriptor of an installed application.

Parameters

Name Type Description

params

object

JSON with parameters

Properties
Name Type Description

key

string

Application key

Returns

object : (ApplicationDescriptor) Application descriptor.

Example

Fetches application descriptor:
import {getDescriptor} from '/lib/xp/app';
const descriptor = getDescriptor({key: 'my-app-key'});
Return value:
const expected = {
    key: 'my-app',
    description: 'my app description',
    icon: {
        data: {},
        mimeType: 'image/png',
        modifiedTime: '2021-12-03T10:15:30Z'
    }
};

createVirtualApplication

Creates a virtual application (along with its schema repository nodes) with the specified key.

Parameters

Name Type Description

params

object

JSON with params

Properties
Name Type Description

key

string

Application key

Returns

object : (Application) Property object of the created application.

Example

creates an app with my-app-key key:
import {createVirtualApplication} from '/lib/xp/app';

const app = createVirtualApplication({
    key:'my-app-key'
});

deleteVirtualApplication

Removes a virtual application with the specified key.

Parameters

Name Type Description

params

object

JSON with params

Properties
Name Type Description

key

string

Application key

Returns

boolean : true if deletion succeeded, otherwise false.

Example

removes an app with my-app-key key:
import {deleteVirtualApplication} from '/lib/xp/app';

const result = deleteVirtualApplication({
    key:'my-app-key'
});

getApplicationMode

Fetches mode of an application with the specified key.

Parameters

Name Type Description

params

object

JSON with params

Properties
Name Type Description

key

string

Application key

Returns

string : Application mode. Can be one of the following types:

  • bundled - an installed and active application, no virtual app with the same key exists;

  • virtual - a "virtual", node-based application, no bundled app with the same key exists;

  • augmented - both bundled and virtual application co-exist with the same application key.

Installed but disabled bundled applications are considered missing.

Example

fetches mode of an application with my-app-key key:
import {getApplicationMode} from '/lib/xp/app';
const result = getApplicationMode({
    key:'my-app-key'
});

Type Definitions

Application

Type

object

Properties

Name Type Description

key

string

Application key

displayName

string

Display name

vendorName

string

Vendor name

vendorUrl

string

Vendor url

url

string

Url

version

string

Version

systemVersion

string

System version

minSystemVersion

string

Min system version

maxSystemVersion

string

Max system version

modifiedTime

object

Modified time

started

boolean

true if the application is started. Virtual applications are always started

system

boolean

true for a system application

ApplicationDescriptor

Type

object

Properties

Name Type Description

key

string

Application key

description

`string

Application description

icon

Icon

Application icon

Icon

Type

object

Properties

Name Type Description

data

object

icon stream data

mimeType

string

icon mime type

modifiedTime

string

icon modified time


Contents

Contents

AI-powered search

Juke AI