This is a Polarion extension which provides common part to other extensions reducing code duplication. | Read-only mirror of https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.generic — SBB. Issues & pull requests at the source.
  • Java 99.5%
  • HTML 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
github-actions[bot] 85974e6488
chore(main): release 17.0.2-SNAPSHOT (#794)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-12-03 11:37:15 +01:00
.github fix: upload release assets only from main and release-v* (#789) 2026-12-02 22:40:39 +01:00
.idea/codeStyles
.mvn build!: clean up the POM after the move to JFrog (#778) 2026-12-02 12:58:29 +00:00
app chore(main): release 17.0.2-SNAPSHOT (#794) 2026-12-03 11:37:15 +01:00
.gitignore fix: require bundle jakarta servlet api (#660) 2026-08-13 15:20:04 +00:00
.pre-commit-config.yaml chore(deps): update pre-commit hook commitizen-tools/commitizen to v4.20.1 (#772) 2026-12-01 03:44:33 +00:00
.yamlfix.toml
CHANGELOG.md chore(main): release 17.0.1 (#791) 2026-12-03 11:35:13 +01:00
CLAUDE.md ci: deploy the artifacts of the build job to JFrog (#783) 2026-12-02 20:18:15 +01:00
CODING_STANDARDS.md ci: replace S3 bucket with jfrog.io for private artefacts (#300) 2025-06-09 17:50:41 +02:00
CONTRIBUTING.md chore: sync from template (workflows, docs, license layout) (#406) 2026-05-06 16:23:01 +02:00
DCO chore: sync from template (workflows, docs, license layout) (#406) 2026-05-06 16:23:01 +02:00
DEVELOPMENT.md refactor: rename maven profiles to one naming scheme (#683) 2026-08-24 08:07:01 +02:00
LICENSE chore: sync from template (workflows, docs, license layout) (#406) 2026-05-06 16:23:01 +02:00
lombok.config
NOTICE chore: sync from template (workflows, docs, license layout) (#406) 2026-05-06 16:23:01 +02:00
pom.xml chore(main): release 17.0.2-SNAPSHOT (#794) 2026-12-03 11:37:15 +01:00
README.md feat!: rename the release profile and skipJsTests (#784) 2026-12-02 14:48:45 +01:00
RELEASE.md feat(ci): release to the public JFrog repository instead of Maven Central (#770) 2026-12-02 10:55:06 +01:00
renovate.json fix: manage the commons-logging version of Polarion 2612 (#793) 2026-12-03 11:32:20 +01:00
zizmor.yml chore: sync pre-commit config + zizmor from template (#404) 2026-05-06 14:59:04 +02:00

Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Reliability Rating Security Rating Maintainability Rating Vulnerabilities

Generic extension of Polarion ALM

This is a Polarion extension which provides common part to other extensions reducing code duplication.

An extension which inherits from this generic extension will automatically get following functionality:

  • An "about" page on administrative section of Polarion with basic information about this extension
  • API to manipulate settings of this extension - to read, save settings and reverting them to default values as well as getting list of settings history revisions
  • API to serialize/deserialize XML data (JAXBUtils)
  • REST application and end points giving access to settings functionality described above as well as access to extension information and version
  • OpenAPI specification endpoint at /rest/api/openapi.json providing machine-readable API documentation
  • Swagger UI page listing information about REST API provided
  • Some utility classes and methods to simplify development of new extensions
  • Some test classes to simplify testing of new extensions using JUnit and Mockito

Important

Starting from version 8.0.0 only latest version of Polarion is supported. Right now it is Polarion 2512.

Important

This extension is Java and backend only. Since 16.0.0 it ships no front-end asset of its own: no .js, .css or image file anywhere in the tree. What is left is the Swagger UI page, which is markup with an inline script that loads Swagger's own bundle from Polarion. The shared front end lives in react-sbb-polarion (npm @sbb-polarion/react-sbb-polarion): components, the --sbb-* design tokens, every control style and the control icons, bundled into one style.css. An extension takes it from npm and fetches nothing from this webapp. See UI components.

How to use

To properly inherit from this generic extension and to take advantage of all mentioned above functionality out of the box certain steps should be done, see below.

pom.xml

Maven's pom.xml should contain following content:

  • Reference to parent POM (don't forget to use proper version of it):
<parent>
    <groupId>ch.sbb.polarion.extensions</groupId>
    <artifactId>ch.sbb.polarion.extension.generic</artifactId>
    <version><!-- version goes here --></version>
</parent>
  • Reference to the public JFrog repository, which serves the releases of generic. Maven reads it for the parent POM as well, so no settings.xml entry is needed:
<repositories>
    <repository>
        <id>polarion-opensource</id>
        <url>https://sbb.jfrog.io/artifactory/polarion-opensource-mvn</url>
    </repository>
</repositories>
  • Specify extension context, automatic module name, discover base package, web application name and extension-specific Require-Bundle entries in POM's properties:
<properties>
    <maven-jar-plugin.Extension-Context>pdf-exporter</maven-jar-plugin.Extension-Context>
    <maven-jar-plugin.Automatic-Module-Name>ch.sbb.polarion.extension.pdf_exporter</maven-jar-plugin.Automatic-Module-Name>
    <maven-jar-plugin.Discover-Base-Package>ch.sbb.polarion.extension.pdf_exporter</maven-jar-plugin.Discover-Base-Package>
    <maven-jar-plugin.Configuration-Properties-Prefix>ch.sbb.polarion.extension.pdf-exporter</maven-jar-plugin.Configuration-Properties-Prefix>
    <web.app.name>${maven-jar-plugin.Extension-Context}</web.app.name>

    <!-- Extension-specific Require-Bundle (in addition to common ones from parent POM):
        com.polarion.alm.wiki
        org.jsoup
    -->
    <maven-jar-plugin.Require-Bundle.extension>com.polarion.alm.wiki,org.jsoup</maven-jar-plugin.Require-Bundle.extension>
    <maven-jar-plugin.Require-Bundle>${maven-jar-plugin.Require-Bundle.common},${maven-jar-plugin.Require-Bundle.extension}</maven-jar-plugin.Require-Bundle>
</properties>
  • Reference or extend following build plugins:
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>ch.sbb.maven.plugins</groupId>
            <artifactId>markdown2html-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <configuration>
                <outputFormat>YAML</outputFormat>
                <resourcePackages>
                    <package>ch.sbb.polarion.extension.generic.rest.controller.info</package>
                    <package>ch.sbb.polarion.extension.generic.rest.controller.settings</package>
                    <package>ch.sbb.polarion.extension.generic.rest.model</package>
                    <package>ch.sbb.polarion.extension.pdf_exporter.rest.controller</package>
                    <package>ch.sbb.polarion.extension.pdf_exporter.rest.model</package>
                </resourcePackages>
            </configuration>
        </plugin>

    </plugins>
</build>

Optional: OpenAPI JSON formatting

To automatically format docs/openapi.json using pre-commit hooks, add the following plugin configuration:

<plugin>
    <groupId>io.github.grigoriev</groupId>
    <artifactId>pre-commit-run-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>format-openapi-json</id>
            <phase>process-classes</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <hooks>
                    <hook>pretty-format-openapi-json</hook>
                    <hook>mixed-line-ending-openapi-json</hook>
                </hooks>
                <files>
                    <file>docs/openapi.json</file>
                </files>
            </configuration>
        </execution>
    </executions>
</plugin>

The process-classes phase runs right after compile phase where swagger-maven-plugin generates the file.

This ensures consistent JSON formatting with proper key ordering (openapi, info, servers, paths, components) and line endings across all extensions.

Publishing to Maven Central

Generic publishes to the public JFrog repository and no longer provides a central-publishing profile. An extension that publishes to Maven Central declares the plugin in its own POM. With the profile id below, mvn -P release-sign-artifacts-with-gpg,central-publishing deploy publishes a signed release; release-sign-artifacts-with-gpg, the sources JAR and the javadoc JAR come from generic:

<profiles>
    <profile>
        <id>central-publishing</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.sonatype.central</groupId>
                    <artifactId>central-publishing-maven-plugin</artifactId>
                    <version><!-- version goes here --></version>
                    <extensions>true</extensions>
                    <configuration>
                        <publishingServerId>sonatype-central</publishingServerId>
                        <autoPublish>true</autoPublish>
                        <waitUntil>published</waitUntil>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

The plugin replaces the deploy step, so the distributionManagement inherited from generic is not used.

Polarion compatibility check

Polarion 2606 refuses to start when an installed extension bundles a class, an OSGi manifest header or a deployment descriptor naming a javax package that moved to jakarta. Extension sources break at compile time against the new API, but a bundled dependency does not: a version bump can reintroduce such a package with no source change, and the failure then shows up on the server rather than in the build.

Opt in by naming the plugin. Its version and execution come from the parent POM:

<plugin>
    <groupId>com.intechcore</groupId>
    <artifactId>polarion-compatibility-maven-plugin</artifactId>
</plugin>

The goal binds to verify and scans the assembled bundle together with every jar nested inside it. When a dependency carries a forbidden reference, the build fails and names the jar, the class and the package:

[ERROR] Forbidden packages found in ch.sbb.polarion.extension.pdf-exporter-13.7.1-SNAPSHOT.jar
[ERROR]   javax.annotation  ->  jakarta.annotation
[ERROR]     in tika-core-4.0.0.jar
[ERROR]       org.apache.tika.annotation.TikaComponentProcessor  (javax.annotation.processing.AbstractProcessor)

Use <excludedJars> for a jar whose reference is unreachable at runtime, or -Dpolarion.compatibility.failOnViolation=false to survey a project without breaking it. The plugin documents the remaining parameters through mvn polarion-compatibility:help -Ddetail=true.

MANIFEST.MF

File MANIFEST.MF should be created in src/main/resources/META-INF/MANIFEST.MF with only extension-specific entries.

The following entries are managed by the parent POM via <manifestEntries> and must NOT be added to the static MANIFEST.MF file (they will be silently overridden if present):

Entry POM Property Default Value
Require-Bundle maven-jar-plugin.Require-Bundle 17 common bundles (see below)
Support-Email maven-jar-plugin.Support-Email polarion-opensource@sbb.ch
Bundle-ActivationPolicy maven-jar-plugin.Bundle-ActivationPolicy lazy
Import-Package maven-jar-plugin.Import-Package + maven-jar-plugin.Import-Package.required org.osgi.framework plus the always-appended jakarta.annotation pin

Common Require-Bundle bundles defined in the parent POM (maven-jar-plugin.Require-Bundle.common): jakarta.servlet-api, com.polarion.alm.ui, jakarta.inject-api, jakarta.annotation-api, jakarta.ws.rs-api, jakarta.xml.bind-api, jakarta.activation-api, org.glassfish.jersey, com.fasterxml.jackson.core, com.fasterxml.jackson.databind, com.fasterxml.jackson.annotations, com.fasterxml.jackson.module.jakarta.xmlbind.annotations, org.apache.commons.logging, commons-io, slf4j.api, org.springframework.spring.core, org.springframework.spring.web, com.polarion.alm.tracker, com.polarion.platform.guice

To add extension-specific bundles, set maven-jar-plugin.Require-Bundle.extension and override maven-jar-plugin.Require-Bundle in the extension's pom.xml:

<!-- Extension-specific Require-Bundle (in addition to common ones from parent POM):
    com.polarion.alm.wiki
    org.jsoup
-->
<maven-jar-plugin.Require-Bundle.extension>com.polarion.alm.wiki,org.jsoup</maven-jar-plugin.Require-Bundle.extension>
<maven-jar-plugin.Require-Bundle>${maven-jar-plugin.Require-Bundle.common},${maven-jar-plugin.Require-Bundle.extension}</maven-jar-plugin.Require-Bundle>

To override Import-Package (e.g. to add org.osgi.util.tracker), set maven-jar-plugin.Import-Package in the extension's pom.xml:

<maven-jar-plugin.Import-Package>org.osgi.framework,org.osgi.util.tracker</maven-jar-plugin.Import-Package>

The parent POM always appends maven-jar-plugin.Import-Package.required to the generated entry, so overriding the property above cannot drop it. It currently pins jakarta.annotation to the jakarta.annotation-api bundle: Tomcat exports the same package unversioned, and binding to Tomcat's copy makes Jersey miss @Priority on request filters, which leaves the authentication and authorization filters in a per-JVM-start order. Do not override this property.

The static MANIFEST.MF should only contain:

  • Bundle-Name — extension display name:
Bundle-Name: PDF Exporter Extension for Polarion ALM
  • Bundle-Activator — if the bundle has a form extension, registered either using custom org.osgi.framework.BundleActivator or ch.sbb.polarion.extension.generic.GenericBundleActivator:
Bundle-Activator: ch.sbb.polarion.extension.pdf_exporter.ExtensionBundleActivator

Subclass GenericBundleActivator and return your form extensions from getExtensions():

public class ExtensionBundleActivator extends GenericBundleActivator {
    @Override
    protected Map<String, IFormExtension> getExtensions() {
        return Map.of(MyFormExtension.ID, new MyFormExtension());
    }
}

Deferred registration (why it is not done inline in start()). Polarion's FormExtensionsRegistry is a lazily-initialized singleton: on its first getInstance() it injects Polarion's own Guice-bound form extensions (velocity_form, oslc, execute-test, linkedResources, workflow-signatures widget, gitlab, …). If that first touch happens during OSGi bundle activation — before Polarion has built its global Guice injector — GuicePlatform.tryInjectMembers injects nothing, the singleton is created empty of all core contributions, and every Polarion-provided form extension is lost for the whole server lifetime (typical symptom: "Form extension 'velocity_form' was not found" on a document/work item form). To avoid poisoning the registry, GenericBundleActivator runs its startup on a daemon thread that first waits for the global Guice injector to become available; Polarion then loads its core extensions first and ours are added on top. The onStart(BundleContext) hook runs on that same deferred thread (after the injector is ready, not synchronously during activation), so a subclass hook may safely touch Polarion's platform. This is transparent to subclasses — just implement getExtensions() and, if needed, override onStart().

  • Export-Package — if the extension exports packages for use by other bundles:
Export-Package: ch.sbb.polarion.extension.pdf_exporter,
 ch.sbb.polarion.extension.pdf_exporter.converter
  • Any other extension-specific entries (e.g. Guice-Modules)

Setting classes

If new extension should provide functionality to manipulate its settings, settings classes should be implemented extending GenericNamedSettings<T extends SettingsModel>, eg:

public class CssSettings extends GenericSettings<CssModel> {
    private static final String FEATURE_NAME = "css";

    public CssSettings() {
        super(FEATURE_NAME);
    }

    public CssSettings(SettingsService settingsService) {
        super(FEATURE_NAME, settingsService);
    }

    @Override
    public @NotNull CssModel defaultValues() {
        return CssModel.builder().css(ScopeUtils.getFileContent("default/dle-pdf-export.css")).build();
    }
}

...and settings model class from example above like this:

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CssModel extends SettingsModel {

    public static final String CSS = "CSS";

    private String css;

    @Override
    protected String serializeModelData() {
        return serializeEntry(CSS, css);
    }

    @Override
    protected void deserializeModelData(String serializedString) {
        css = deserializeEntry(CSS, serializedString);
    }
}

Settings validation

The settings API includes built-in validation to ensure data integrity:

Duplicate setting names detection

If multiple settings files contain the same name (in the -----BEGIN NAME----- block), the API will return HTTP 409 Conflict error. This can happen when settings files are manually created or imported via SVN.

Example error response:

{
  "message": "Multiple settings files contain the same name: Default (68d0a695-9865-4612-a6ab-e6102bc8d1e1, 3ea1190b-adb9-4cda-8906-953030327958)"
}

The message includes the setting name and the file IDs (UUIDs) of the conflicting files. If multiple duplicate names exist, they will all be listed:

Multiple settings files contain the same name: ConfigA (id1, id2), ConfigB (id3, id4, id5)

This validation is triggered on all settings operations: read, save, delete, list names, and list revisions.

REST application

REST application class should inherit from GenericRestApplication of generic extension, registering settings classes and extending classes of REST controller, web application filters and exception mappers:

public class PdfExporterRestApplication extends GenericRestApplication {
    private final Logger logger = Logger.getLogger(PdfExporterRestApplication.class);

    public PdfExporterRestApplication() {
        logger.debug("Creating PDF-Exporter REST Application...");

        try {
            NamedSettingsRegistry.INSTANCE.register(
                    Arrays.asList(
                            new StylePackageSettings(),
                            new HeaderFooterSettings(),
                            new CssSettings(),
                            new LocalizationSettings(),
                            new CoverPageSettings(),
                            new FileNameTemplateSettings()
                    )
            );
        } catch (Exception e) {
            logger.error("Error during registration of named settings", e);
        }

        logger.debug("PDF-Exporter REST Application has been created");
    }
...
}

REST architecture: /internal vs /api

Extensions built on top of this generic extension expose REST endpoints under two distinct URL spaces with different security models. Understanding the split is important - they are not interchangeable, and @Secured is intentionally applied to one but not the other.

URL space Intended caller Authentication Authorization CSRF protection
/rest/internal/* The extension's own UI, running inside an authenticated Polarion session Servlet container (<security-constraint> in web.xml with <role-name>user</role-name>, FORM-based login against PolarionRealm); Polarion's DoAsFilter then propagates the session's Subject to the request thread Real Polarion user from the session - operations run under that user's permissions No server-side token check - X-Polarion-REST-Token is not validated on /internal/*. Defence relies on (a) the container session being required, (b) browser SameSite=Lax cookie default, which prevents cookie-bearing cross-site <form> POST/PUT/DELETE, and (c) the REST convention that state-changing methods are POST/PUT/DELETE, not GET
/rest/api/* External clients. Mirrors Polarion's own public REST API authentication model (see AccessTokenAuthenticator) @Secured filter (AuthenticationFilter), validating either Authorization: Bearer <PAT> or X-Polarion-REST-Token Wrapped in polarionService.callPrivileged(...) - the PAT principal has no Polarion subject, so calls run with elevated privileges Custom-header requirement is itself a CSRF defence per OWASP - browsers cannot attach custom headers to cookie-only cross-origin requests without a CORS preflight

The controller pattern that implements this split is illustrated by NamedSettingsInternalController and NamedSettingsApiController:

  • NamedSettingsInternalController - @Path("/internal"), no @Secured. Container-level auth already gates the endpoint.
  • NamedSettingsApiController extends NamedSettingsInternalController - @Path("/api"), @Secured, each method overridden to wrap the inherited logic in polarionService.callPrivileged(...).

Each consuming extension's web.xml must declare both constraints - the role-protected one for /* and an open one for /rest/api/* so the container does not interfere with @Secured:

<!-- Container-level auth: everything except /rest/api/* requires a Polarion session -->
<security-constraint>
    <web-resource-collection>
        <web-resource-name>All</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>user</role-name>
    </auth-constraint>
</security-constraint>

<!-- /rest/api/* is opened at the container level - auth happens in @Secured (AuthenticationFilter) -->
<security-constraint>
    <web-resource-collection>
        <web-resource-name>All</web-resource-name>
        <url-pattern>/rest/api/*</url-pattern>
    </web-resource-collection>
    <auth-constraint/>
</security-constraint>

<!--
    Note on the empty <auth-constraint/>: per the Servlet spec this would deny all access, but
    Polarion's `PolarionRealm` (com.polarion.platform/.../PolarionRealm.java) overrides
    `hasResourcePermission()` to always return `true`, disabling container-level role enforcement.
    In this stack the empty constraint effectively means "open at the container level".
-->

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>PolarionRealm</realm-name>
    <form-login-config>
        <form-login-page>/login/login</form-login-page>
        <form-error-page>/login/error</form-error-page>
    </form-login-config>
</login-config>

Consequences of this design:

  • Do not add @Secured to /internal/* controllers. It is redundant with the container's <security-constraint>, and it would break the extension's UI flow, which authenticates via the Polarion session, not via PAT.
  • Do not call /internal/* from external clients. It is not a public API. External integrations must use /rest/api/*.

UI servlet class

If new extension will contain UI parts/pages/artifacts, UI servlet class should be created extending GenericUiServlet simply specifying servlet name in constructor:

public class PdfExporterAppServlet extends GenericUiServlet {

    @Serial
    private static final long serialVersionUID = -6337912330074718317L;

    public PdfExporterAppServlet() {
        super("pdf-exporter-app");
    }
}

UI components (JavaScript / CSS)

Moved to react-sbb-polarion. Generic shipped the vanilla SearchableDropdown, the createSearchableSelect factory, ensureSharedStyles, the shared control stylesheets (control-tokens.css, checkboxes.css, radios.css, inputs.css, searchable-dropdown.css, buttons.css, alerts.css), their 24 SVG icons and github-markdown-light.css until 16.0.0. From that version on this webapp serves no JavaScript, CSS or images of its own, and a page that still fetches /polarion/<extension>/ui/generic/{js,css}/… gets a 404.

Extension UIs are React apps built on react-sbb-polarion (npm @sbb-polarion/react-sbb-polarion). That package owns the combobox - SearchableSelect, plus createEditableSelect for the free-text variant - the --sbb-* design tokens and every control style, all bundled in its style.css. An app imports that stylesheet once; nothing is fetched from this webapp at runtime.

GenericUiServlet serves /polarion/<extension>/ui/… from the extension's own webapp, and nothing else. Until 16.0.0 a path under generic/ took a second route: the servlet read it as an entry of generic.app.jar, which is how the shared assets above were delivered. That route is gone with them, so such a request is now looked up in the extension's webapp like any other and answers 404.

Configuration pane styling

The admin "choose a configuration" pane is ConfigurationsPane in react-sbb-polarion, and its styling now travels with it in that package's bundled style.css. Generic shipped css/configurations.css until 16.0.0; from that version on the file is gone, and a page that still links it 404s.

Modal dialogs

Generic ships no dialog CSS. Use react-sbb-polarion's Modal, which renders a <dialog> styled by its own bundled Modal.css (.rsp-modal* classes). The Micromodal library and the micromodal.css that styled its .modal__* markup were both removed in 16.0.0.

.modal__container survives only as one of the wrapper scopes on which react-sbb-polarion's bundled style.css declares the --sbb-* custom properties, alongside .standard-admin-page, .form-wrapper and .sbb-ui. It no longer carries any dialog styling of its own.

BreadcrumbBridge — app-header breadcrumb for topic extensions

Moved to react-sbb-polarion. RSP builds it into dist/breadcrumb-bridge.js, which each extension copies next to its own app bundle; its BreadcrumbInjector component loads it from there and takes marker, title, icon and an optional parent (for the "Parent › [icon] Title" sub-topic form). Nothing is fetched from this webapp for it any more. See "Shell scripts" in react-sbb-polarion's README.

Checkboxes

The Polarion 2606 checkbox look - nine states, drawn from inline-SVG control tokens - lives in react-sbb-polarion's bundled style.css and applies on the .sbb-ui, .standard-admin-page, .form-wrapper and .modal__container scopes. Generic shipped it as checkboxes.css plus the --sbb-checkbox-* tokens in control-tokens.css until 16.0.0.

The indeterminate state has no HTML attribute, so set it from JS (e.g. a React ref): ref={(el) => { if (el) el.indeterminate = someButNotAll; }}.

Custom extension configuration

In order to register additional configuration properties a subclass of ExtensionConfiguration must be marked with the @Discoverable:

@Discoverable
public class PdfExporterExtensionConfiguration extends ExtensionConfiguration {
    @Override
    public @NotNull List<String> getSupportedProperties() {
        List<String> supportedProperties = new ArrayList<>(super.getSupportedProperties());
        supportedProperties.add("weasyprint.service");
        ...
        return supportedProperties;
    }
    ...
}

Reading a document in a baseline or a collection

A document opened from a baseline or from a collection is not the document at HEAD, and the address of the page is all that says so (.../baseline/<revision>/wiki/..., .../collection/<collection>/wiki/...). A REST endpoint of an extension gets neither for free: pass what the address names along with the request, and wrap the code which reads and renders the document.

PolarionBaselineExecutor.executeInBaseline runs a callable in the baseline of a revision, or as it is where the revision is null.

PolarionCollectionExecutor does the two things Polarion does for a document of a collection:

  • resolveDocument returns the document at the revision the collection, or a collection upstream of it, holds it at. Where the collection takes the document at HEAD, or no collection is named, the document is returned as it was given.
  • executeInCollection runs a callable in the context of the collection. Polarion's renderers read that context: a linked work item is shown at the revision the collection holds its document at, and one whose document is not part of the collection is not shown. Opening the context does not select the revision of the document itself, so both calls are needed.
TransactionalExecutor.executeSafelyInReadOnlyTransaction(
        transaction -> PolarionCollectionExecutor.executeInCollection(projectId, collection, transaction,
                () -> PolarionBaselineExecutor.executeInBaseline(baselineRevision, transaction, () -> {
                    DocumentReference document = DocumentReference.fromPath(projectId + "/" + locationPath);
                    // A revision the request names wins over the one the collection holds the document at
                    document = revision != null
                            ? document.getWithRevision(revision)
                            : PolarionCollectionExecutor.resolveDocument(projectId, collection, document, transaction);
                    return render(document.getOriginal(transaction));
                })));

The collection is named the way Polarion names one relative to a project: 3, otherProject/3 for a collection of another project, and 3~1234 for a collection opened at a revision. The address of the page carries the same name between /collection/ and /wiki/, except that it doubles the slash (otherProject//3); undo that before naming the collection. A collection which does not exist is refused with an IllegalArgumentException: ignoring it would read the document at HEAD without any sign of it.

A checked exception of the callable is thrown as BaselineExecutionException or CollectionExecutionException, an unchecked one as it is.

Document (DLE) editor toolbar button

Moved to react-sbb-polarion. The self-healing toolbar engine and its .dleToolBar* stylesheet are no longer shipped here: RSP builds them into dist/dle-toolbar-starter.js, which each extension copies next to its own app bundle and loads from there. An extension's whole toolbar integration is now one small js/dle-toolbar.js that appends that script with the button's title, icon and click action on data-* attributes. See "Shell scripts" in react-sbb-polarion's README.

Bulk export widget

A report page widget that lists what its data set finds, with a checkbox per row. The extension exports the selected rows. The server side lives here, the React side in react-sbb-polarion (BulkExportWidget).

  1. Extend AbstractBulkExportWidget. Name the allowed prototypes and return your renderer.
  2. Extend AbstractBulkExportWidgetRenderer. Render the loader of your widget app module in renderWidgetAppLoader.
  3. Register the widget in hivemodule.xml, as any other rich page widget.
  4. Register BulkExportWidgetApiController and BulkExportWidgetInternalController in your REST application.
  5. Add ch.sbb.polarion.extension.generic.rest.controller.widgets to the resourcePackages of the OpenAPI plugin.
public class BulkMyExportWidget extends AbstractBulkExportWidget {
    @Override
    protected @NotNull List<PrototypeEnum> getAllowedPrototypes() {
        return List.of(PrototypeEnum.Document);
    }

    @Override
    protected @NotNull AbstractBulkExportWidgetRenderer createRenderer(@NotNull RichPageWidgetRenderingContext context) {
        return new BulkMyExportWidgetRenderer(context);
    }
    ...
}

The renderer emits a shim element, and the extension's loader after it. The shim carries the resolved data set as a signed descriptor (WidgetDescriptorSigner). The app posts it back to /widgets/bulk-export/items, which rejects a descriptor this server did not sign. The rows come back with the cells Polarion rendered.

generic carries no JavaScript, so the loader lives in the extension. It imports the widget app and calls it with the selector of the shim. Add BundleCacheKey.forModule(...) to the module URL: it is a hash of the module in the jar, so a rebuild of one version still reaches the browser. Use it for any module a server-side surface imports by a fixed name.