Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel3

An asset type , which is also referred to as an artifact type, is a resource in that is used in the Publisher and Store. WSO2 Enterprise Store (ES) ships some default assets: Gadgets and Sites. An asset extension allows you to define a new asset type with a set of custom behaviors and views. The behaviors defined within an asset extension are only applicable for that specific asset type.

When should I use an

...

asset extension?

ES automatically generates a set of basic views and provides generic business logic for CRUD (create, read, update and delete), lifecycle and subscription operations. However, the generic behavior may not always be sufficient, and you may want to define your own business logic for a CRUD operation or change a generic view. For example:

  • Changing an asset view - Modifying the way the asset listing page appears.
  • Changing CRUD behavior of an asset - Calling an external end-point endpoint after creating an asset instance.

Therefore, you need to create a new Asset Extension asset extension in such instances to be able to add a new customized asset type to ES. 

Overall structure of an

...

asset extension

The Asset Extensions asset extensions are maintained in a single folder, namely the assets directory. The asset extension directories for the Publisher and Store are as follows:

ES ComponentDirectory
Publisher<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/assets
Store<ES_HOME>/repository/deployment/server/jaggeryapps/store/extensions/assets

The following diagram explained the folder structure of the assets directory. This diagram shows a number of asset extensions along with the default extension. The default directory contains sub-folders that handle the behavior and views of a generic asset type. In addition, the default directory provides an example of the directory structure that should be maintained for you need to maintain when adding an asset extension. However, note that each of the listed items are optional. Therefore, an asset extension need not have all of the items indicated in the following diagram. The ES extension model will automatically inherit the CRUD logic and pages from the default extension folder.

Asset Extension Folder Structure

Asset

...

extension components

The following diagram illustrates the structure of an asset extension:

An Asset Extension asset extension may contain one or more of the following elements:

...

    • Define a callback method that allows the CRUD logic to be modified.
    • Define new pages and APIs.
    • Override the current pages and APIs.
    • Change the RXT properties of an asset.
    • Define a callback method, which is called on the asset data prior to rendering.
      For more information, see asset.js Script.
  • A themes directory
    • Any partials, JS scripts or CSS files for new or overridden pages are added in this directory.
    • This directory is used to customize the view in ES. For more information, see Asset ExtensionCustomizing the view.
  • An apis directory
    • Controllers, which either override the existing APIs or add new endpoints, are added in this directory.
    • The APIs defined in the asset.js asset.server callback method are looked up in this folder.
  • A pages directory
    • Controllers, which either override the existing pages or add new pages, are added to this directory.
    • The pages defined in the asset.js asset.server callback method are looked up in this folder.

Customizing the view

The themes directory is used to customize the view. ES views are rendered using the Caramel MVC framework. The Extension Model works extension model works together with the Caramel framework, to determine from which location a view should be loaded. When a resource is consumed by the Caramel framework, the Extension Model extension model examines the request URI to determine if the request originated for a particular asset type. Thereafter, it will attempt to locate the resource from within the Asset Extension asset extension directory. This allows any of the corresponding partials of a view to be overridden individually, based on a specific asset type. However, if needed you can also override the partials of a view globally, so that it affects all the asset types.

Child pages (Children Display)