Brightspot Integrations Guide

Configuring the JSReport integration


There are two alternatives for configuring the JSReport integration within Brightspot, providing flexibility to accommodate various project requirements.

  • Out-of-the-Box Configuration—This approach simplifies the initial configuration process and leverages environment variables to seamlessly provide essential details for the JSReport integration. The required configuration parameters include the JSReport server's URL, username, password, and optional timeout configurations. This straightforward method ensures a quick and efficient setup for users seeking a hassle-free configuration experience
  • Custom Configuration API—Recognizing the diverse needs of projects, Brightspot provides an API that allows users to implement bespoke ways of supplying JSReport configuration details. This empowers developers to choose the most suitable configuration approach that best fits the project's unique needs.

Out-of-the-Box Configuration

For the out-of-the-box configuration, the following environment variables need to be supplied:

KeyTypeDescription
brightspot/jsreport/defaultjava.lang.StringName of the default configuration to use. Swap in this value for {configName} for the other keys.
brightspot/jsreport/config/{configName}/classjava.lang.StringJava class name of the JsReportServiceProvider to use. For this out-of-the-box solution the value should be com.psddev.jsreport.DefaultJsReportServiceProvider.
brightspot/jsreport/config/{configName}/endpointjava.lang.StringURL used to connect to the JSReport server.
brightspot/jsreport/config/{configName}/usernamejava.lang.StringUsername used to authenticate with JSReport.
brightspot/jsreport/config/{configName}/passwordjava.lang.StringPassword used to authenticate with JSReport.
brightspot/jsreport/config/{configName}/callTimeoutjava.lang.StringAPI Call Timeout in seconds.
brightspot/jsreport/config/{configName}/connectTimeoutjava.lang.StringAPI Connect Timeout in seconds.
brightspot/jsreport/config/{configName}/writeTimeoutjava.lang.StringAPI Write Timeout in seconds.
brightspot/jsreport/config/{configName}/readTimeoutjava.lang.StringAPI Read Timeout in seconds.

For additional details on environment settings, see Configuring Dari.

Custom Configuration API

To implement the Custom Configuration API for JSReport integration in Brightspot, you extend the provided JsReportServiceProvider abstract class. This class allows you to define your own method of supplying a JSReport configuration, offering flexibility to adapt to project-specific needs. Below is an example of implementing a JsReportServiceProvider in which the configuration comes from fields in Brightspot's Sites & Settings admin area.

import com.psddev.cms.db.ToolUi;
import com.psddev.cms.tool.CmsTool;
import com.psddev.dari.db.Modification;
import com.psddev.dari.db.Recordable;

@Recordable.FieldInternalNamePrefix("jsreport.")
public class JsReportGlobalSettings extends Modification<CmsTool> {

    private static final String TAB = "Integrations";
    private static final String CLUSTER = "JS Report";

    @ToolUi.Tab(TAB)
    @ToolUi.Cluster(CLUSTER)
    private String endpoint;

    @ToolUi.Tab(TAB)
    @ToolUi.Cluster(CLUSTER)
    private String username;

    @ToolUi.Tab(TAB)
    @ToolUi.Cluster(CLUSTER)
    @ToolUi.Secret
    private String password;

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}

import java.time.Duration;

import com.psddev.cms.tool.CmsTool;
import com.psddev.dari.db.Singleton;
import com.psddev.jsreport.JsReportServiceProvider;
import net.jsreport.java.service.JsReportService;
import net.jsreport.java.service.JsReportServiceImpl;
import net.jsreport.java.service.ServiceTimeout;

public class JsReportGlobalSettingsServiceProvider extends JsReportServiceProvider {

    @Override
    public JsReportService getJsReportService() {
        JsReportGlobalSettings settings = Singleton.getInstance(CmsTool.class).as(JsReportGlobalSettings.class);
        if (settings != null && settings.getEndpoint() != null && settings.getUsername() != null && settings.getPassword() != null) {
            ServiceTimeout serviceTimeout = new ServiceTimeout();
            serviceTimeout.setCallTimeout(Duration.ofMinutes(1));
            serviceTimeout.setConnectTimeout(Duration.ofMinutes(1));
            serviceTimeout.setWriteTimeout(Duration.ofMinutes(1));
            serviceTimeout.setReadTimeout(Duration.ofMinutes(1));
            return new JsReportServiceImpl(
                settings.getEndpoint(),
                settings.getUsername(),
                settings.getPassword(),
                serviceTimeout);
        }
        return null;
    }
}
  • A Modification on CMSTool allows us to add new fields to the Sites & Settings admin area. The class contains fields for configuring:
    • Endpoint URL
    • Username
    • Password
  • An extension of JsReportServiceProvider allows us to create custom solution for providing configuration for JsReport.
  • The JsReportGlobalSettings object is retrieved using the BSP Singleton API.
  • A JsReportServiceImpl object is created with the configuration from the JsReportGlobalSettings object.

This custom configuration supplier can then be enabled via the following environment variables:

KeyTypeDescription
brightspot/jsreport/defaultjava.lang.StringName of the default configuration to use. Swap in this value for {configName} for the other keys.
brightspot/jsreport/config/{configName}/classjava.lang.StringJava class name of the JsReportServiceProvider to use. For this out-of-the-box solution the value should be com.yourcompany.JsReportGlobalSettingsServiceProvider.
Previous Topic
JSReport
Next Topic
JSReport document generation API
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

Asset types
Module types
Page types
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

Content types
Modules
Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

Dashboards
Publishing
Workflows
Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

Field types
Content modeling
Rich-text elements
Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

Google Analytics
Shopify
Apple News