ActiveUI

ActiveUI

  • User Guide
  • Developer Documentation

›Advanced

About

  • Introduction
  • Changelog

Getting Started

  • Step by Step
  • Development Environment
  • Artifacts
  • ActiveUI Application
  • Usage as an npm Dependency
  • Initialization
  • Project Architecture

Guides

  • Adding KaTex fonts
  • Adding Servers
  • Authentication
  • Bookmark favorites
  • Charts
  • Configuring Widget Handlers and Actions
  • Container
  • Custom UI components with Ant Design
  • Data manipulation
  • Debugging
  • Deployment
  • Internationalization
  • MDX Manipulation
  • Plugins
  • Reporting
  • Settings
  • Tabular View and Pivot Tables
  • Testing

Reference

  • API Reference
  • Default Widget Bookmarks
  • Plugins
  • Settings

Advanced

  • Content Server Setup
  • Experimental Features
  • Maven Integration
  • Offline Installation
  • Script-based Integration

Content Server Setup

ActiveUI relies on the Content Server to persist bookmarks and settings. Everything related to ActiveUI is located under the /ui directory.

Initialization

When starting a fresh Content Server for the first time, the /ui directory has not yet been created. It will be created along with the /ui/bookmarks and /ui/settings directories and their specific underlying structure. The Content Server can be initialized for ActiveUI in two ways:

  • Client Side
  • Server Side

Client-side

Open ActiveUI, add a Content Server and log in with a user that has the ROLE_CS_ROOT role.

You must have the ROLE_CS_ROOT role because the /ui directory needs its owners roles to be ["ROLE_CS_ROOT"] to prevent regular users from being able to delete it.

Once logged in, ActiveUI will detect that the /ui directory is missing and will issue several requests to create all the required directories and files. When this process is finished, it is possible to log out and log back in again as a regular user (without the ROLE_CS_ROOT role) and start saving bookmarks and editing settings.

Server-side

The initialization process explained above works especially well during the development phase of your project. However, you need to have a user with the ROLE_CS_ROOT role configured in your security layer, allowing you to launch a browser and open your ActiveUI application to make it work.

The Content Server can also be initialized server-side using the Export and Import feature detailed below. In particular, the use cases might prove useful.

Exporting and Importing

The following paragraphs refer to server-side classes, interfaces and methods. Their names might change in future releases of the Content Server.

The next Java code blocks have been tested against the 5.6.1 server-side stack which uses version 3 of the Content Server REST API.

The ContentServiceSnapshotter class can export and import subtrees of the Content Server structure. The only object needed to create a ContentServiceSnapshotter is an implementation of IContentService. Thus, you can instantiate a ContentServiceSnapshotter during the Content Server startup process or later on in a small class with a static main by using a RemoteContentService.

Exporting

Once you have created the bookmarks and configured the settings in the Content Server according to your project requirements, call:

contentServiceSnapshotter.export("/ui", Paths.get("ActiveUI.json"));

It will create an ActiveUI.json file containing all the entries (owners and readers roles included) under the /ui directory.

Importing

When you want to import the structure saved in ActiveUI.json into a fresh Content Server, call:

contentServiceSnapshotter.importSafely("/ui", Paths.get("ActiveUI.json"));

It will recreate the whole structure if there is nothing at the target path (/ui) yet. If it does already exist, the import will be aborted and nothing will change.

There is a similar eraseAndImport method that will first erase everything under the target path and call importSafely afterwards. Use it with caution!

Use cases

Working on a Project: Erasing and Importing in the Bean Generation

If you want your project to always start with the same bookmarks and settings: add the ActiveUI.json to Git and call eraseAndImport with its path during the Content Server startup process.

public class LocalContentServiceConfig {
  // ...
  @Bean
  @Override
  public IContentService contentService() {
    IContentService contentService = activePivotContentService().getContentService().getUnderlying();
    ContentServiceSnapshotter snapshotter = new ContentServiceSnapshotter(contentService.withRootPrivileges());

    // StoreActiveUI.json with your project resources to have it bundled into the .war file.
    Path fileToImport = Paths.get(getClass().getClassLoader().getResource("ActiveUI.json").toURI());
    snapshotter.eraseAndImport("/ui", fileToImport);

    return contentService;
  }
  // ...
}

Deploying to Production: Safely Importing in the Bean Generation

Similar to the situation above but this time you want to make sure to call importSafely so that the modifications made by your production users to bookmarks and settings won't be lost.

public class RemoteContentServiceConfig {
  // ...
  @Bean
  @Override
  public IContentService contentService() {
    IContentService contentService = activePivotContentService().getContentService().getUnderlying();
    ContentServiceSnapshotter snapshotter = new ContentServiceSnapshotter(contentService.withRootPrivileges());

    // StoreActiveUI.json with your project resources to have it bundled into the .war file.
    Path fileToImport = Paths.get(getClass().getClassLoader().getResource("ActiveUI.json").toURI());
    snapshotter.importSafely("/ui", fileToImport);

    return contentService;
  }
  // ...
}

Modifying a Running Content Server: Importing with a RemoteContentService

public class ImportOnServerAlreadyRunning {
  public static void main(String[] args) {
    String url = "http://localhost:9090/content";

    // The credentials used here must be those of a user with the ROLE_CS_ROOT role.
    UserAuthenticator adminAuth = new UserAuthenticator("admin", "admin");

    RemoteContentService contentService = new RemoteContentService(url, adminAuth, adminAuth);
    ContentServiceSnapshotter snapshotter = new ContentServiceSnapshotter(contentService);

    snapshotter.eraseAndImport("/ui", Paths.get("ActiveUI.json"));
  }
}
← SettingsExperimental Features →
  • Initialization
    • Client-side
    • Server-side
  • Exporting and Importing
    • Exporting
    • Importing
    • Use cases
Copyright © 2020 ActiveViam