- Java 99.5%
- HTML 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
| .github | ||
| .idea/codeStyles | ||
| .mvn | ||
| app | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| .yamlfix.toml | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| CODING_STANDARDS.md | ||
| CONTRIBUTING.md | ||
| DCO | ||
| DEVELOPMENT.md | ||
| LICENSE | ||
| lombok.config | ||
| NOTICE | ||
| pom.xml | ||
| README.md | ||
| RELEASE.md | ||
| renovate.json | ||
| zizmor.yml | ||
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.jsonproviding 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,.cssor 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 onestyle.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.xmlentry 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-Bundleentries 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 customorg.osgi.framework.BundleActivatororch.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'sFormExtensionsRegistryis a lazily-initialized singleton: on its firstgetInstance()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.tryInjectMembersinjects 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,GenericBundleActivatorruns 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. TheonStart(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 implementgetExtensions()and, if needed, overrideonStart().
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 inpolarionService.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
@Securedto/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:
resolveDocumentreturns 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.executeInCollectionruns 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).
- Extend
AbstractBulkExportWidget. Name the allowed prototypes and return your renderer. - Extend
AbstractBulkExportWidgetRenderer. Render the loader of your widget app module inrenderWidgetAppLoader. - Register the widget in
hivemodule.xml, as any other rich page widget. - Register
BulkExportWidgetApiControllerandBulkExportWidgetInternalControllerin your REST application. - Add
ch.sbb.polarion.extension.generic.rest.controller.widgetsto theresourcePackagesof 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.