|
1 |
| -# Polarion ALM extension to <...> |
| 1 | +# Generic extension of Polarion ALM |
2 | 2 |
|
3 |
| -This Polarion extension provides possibility to <...> |
4 |
| -## Build |
| 3 | +This is a Polarion extension which provides common part to other extensions reducing code duplication. |
5 | 4 |
|
6 |
| -This extension can be produced using maven: |
| 5 | +An extension which inherits from this generic extension will automatically get following functionality: |
| 6 | + |
| 7 | +* An "about" page on administrative section of Polarion with basic information about this extension |
| 8 | +* API to manipulate settings of this extension - to read, save settings and reverting them to default values |
| 9 | + as well as getting list of settings history revisions |
| 10 | +* API to serialize/deserialize XML data (`JAXBUtils`) |
| 11 | +* REST application and end points giving access to settings functionality described above as well as access |
| 12 | + to extension information and version |
| 13 | +* Swagger UI page listing information about REST API provided |
| 14 | + |
| 15 | +## Ho to use |
| 16 | + |
| 17 | +To properly inherit from this generic extension and to take advantage of all mentioned above functionality |
| 18 | +out of the box certain steps should be done, see below. |
| 19 | + |
| 20 | +### pom.xml |
| 21 | + |
| 22 | +Maven's `pom.xml` should contain following content: |
| 23 | + |
| 24 | +* Reference to parent POM (don't forget to use proper version of it): |
| 25 | + |
| 26 | +```xml |
| 27 | +<parent> |
| 28 | + <groupId>ch.sbb.polarion.extensions</groupId> |
| 29 | + <artifactId>ch.sbb.polarion.extension.generic.parent-pom</artifactId> |
| 30 | + <version>1.1.5</version> |
| 31 | +</parent> |
| 32 | +``` |
| 33 | + |
| 34 | +* Specify extension context, automatic module name and web application name in POM's properties: |
| 35 | + |
| 36 | +```xml |
| 37 | +<properties> |
| 38 | + <maven-jar-plugin.Extension-Context>pdf-exporter</maven-jar-plugin.Extension-Context> |
| 39 | + <maven-jar-plugin.Automatic-Module-Name>ch.sbb.polarion.extension.pdf_exporter</maven-jar-plugin.Automatic-Module-Name> |
| 40 | + <web.app.name>${maven-jar-plugin.Extension-Context}</web.app.name> |
| 41 | +</properties> |
| 42 | +``` |
| 43 | + |
| 44 | +* Reference or extend following build plugins: |
| 45 | + |
| 46 | +```xml |
| 47 | +<build> |
| 48 | + <plugins> |
| 49 | + <plugin> |
| 50 | + <groupId>org.apache.maven.plugins</groupId> |
| 51 | + <artifactId>maven-dependency-plugin</artifactId> |
| 52 | + </plugin> |
| 53 | + |
| 54 | + <plugin> |
| 55 | + <groupId>org.apache.maven.plugins</groupId> |
| 56 | + <artifactId>maven-jar-plugin</artifactId> |
| 57 | + </plugin> |
| 58 | + |
| 59 | + <plugin> |
| 60 | + <groupId>org.apache.maven.plugins</groupId> |
| 61 | + <artifactId>maven-surefire-plugin</artifactId> |
| 62 | + </plugin> |
| 63 | + |
| 64 | + <plugin> |
| 65 | + <groupId>org.jacoco</groupId> |
| 66 | + <artifactId>jacoco-maven-plugin</artifactId> |
| 67 | + </plugin> |
| 68 | + |
| 69 | + </plugins> |
| 70 | +</build> |
| 71 | +``` |
| 72 | + |
| 73 | +### MANIFEST.MF |
| 74 | + |
| 75 | +File `MANIFEST.MF` should be created in `src/main/resources/META-INF/MANIFEST.MF` with following content: |
| 76 | + |
| 77 | +* Property `Bundle-Name` should contain extension name, eg. |
| 78 | + |
| 79 | +```properties |
| 80 | +Bundle-Name: PDF Exporter Extension for Polarion ALM |
| 81 | +``` |
| 82 | + |
| 83 | +* Property `Require-Bundle` should list all bundles from which this extension depends, eg. |
| 84 | + |
| 85 | +```properties |
| 86 | +Require-Bundle: com.polarion.portal.tomcat, |
| 87 | + com.polarion.alm.ui, |
| 88 | + com.polarion.platform.guice, |
| 89 | + com.polarion.alm.tracker, |
| 90 | + org.glassfish.jersey, |
| 91 | + com.fasterxml.jackson, |
| 92 | + com.fasterxml.jackson.jaxrs, |
| 93 | + io.swagger, |
| 94 | + org.apache.commons.logging, |
| 95 | + slf4j.api, |
| 96 | + org.springframework.spring-core, |
| 97 | + org.springframework.spring-web |
7 | 98 | ```
|
8 |
| -mvn clean package |
| 99 | + |
| 100 | +* If Polarion's form extension is implemented, property `Guice-Modules` should specify a class which does this, eg. |
| 101 | + |
| 102 | +```properties |
| 103 | +Guice-Modules: ch.sbb.polarion.extension.pdf.exporter.PdfExporterModule |
9 | 104 | ```
|
10 | 105 |
|
11 |
| -## Installation to Polarion |
| 106 | +### Setting classes |
| 107 | + |
| 108 | +If new extension should provide functionality to manipulate its settings, settings classes should be implemented extending |
| 109 | +`GenericNamedSettings<T extends SettingsModel>`, eg: |
| 110 | + |
| 111 | +```java |
| 112 | +public class CssSettings extends GenericSettings<CssModel> { |
| 113 | + private static final String FEATURE_NAME = "css"; |
| 114 | + |
| 115 | + public CssSettings() { |
| 116 | + super(FEATURE_NAME); |
| 117 | + } |
12 | 118 |
|
13 |
| -To install the extension to Polarion `ch.sbb.polarion.extension.<extension_name>-<version>.jar` |
14 |
| -should be copied to `<polarion_home>/polarion/extensions/ch.sbb.polarion.extension.<extension_name>/eclipse/plugins` |
15 |
| -It can be done manually or automated using maven build: |
| 119 | + public CssSettings(SettingsService settingsService) { |
| 120 | + super(FEATURE_NAME, settingsService); |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + public @NotNull CssModel defaultValues() { |
| 125 | + return CssModel.builder().css(ScopeUtils.getFileContent("default/dle-pdf-export.css")).build(); |
| 126 | + } |
| 127 | +} |
16 | 128 | ```
|
17 |
| -mvn clean install -P polarion2304,install-to-local-polarion |
| 129 | + |
| 130 | +...and settings model class from example above like this: |
| 131 | + |
| 132 | +```java |
| 133 | +@Data |
| 134 | +@Builder |
| 135 | +@NoArgsConstructor |
| 136 | +@AllArgsConstructor |
| 137 | +@ToString |
| 138 | +@EqualsAndHashCode(callSuper = false) |
| 139 | +@JsonInclude(JsonInclude.Include.NON_NULL) |
| 140 | +public class CssModel extends SettingsModel { |
| 141 | + |
| 142 | + public static final String CSS = "CSS"; |
| 143 | + |
| 144 | + private String css; |
| 145 | + |
| 146 | + @Override |
| 147 | + protected String serializeModelData() { |
| 148 | + return serializeEntry(CSS, css); |
| 149 | + } |
| 150 | + |
| 151 | + @Override |
| 152 | + protected void deserializeModelData(String serializedString) { |
| 153 | + css = deserializeEntry(CSS, serializedString); |
| 154 | + } |
| 155 | +} |
18 | 156 | ```
|
19 |
| -For automated installation with maven env variable `POLARION_HOME` should be defined and point to folder where Polarion is installed. |
20 | 157 |
|
21 |
| -Changes only take effect after restart of Polarion. |
| 158 | +### Rest application |
22 | 159 |
|
23 |
| -## Polarion configuration |
| 160 | +Rest application class should inherit from `GenericRestApplication` of generic extension, |
| 161 | +registering settings classes and extending classes of REST controller, web application filters and exception mappers: |
24 | 162 |
|
25 |
| -<...> |
| 163 | +```java |
| 164 | +public class PdfExporterRestApplication extends GenericRestApplication { |
26 | 165 |
|
| 166 | + public PdfExporterRestApplication() { |
| 167 | + SettingsRegistry.INSTANCE.register(Arrays.asList(new CssSettings(), new HeaderFooterSettings(), new LocalizationSettings())); |
| 168 | + } |
27 | 169 |
|
28 |
| -## Extension Configuration |
| 170 | + @Override |
| 171 | + @NotNull |
| 172 | + protected Set<Class<?>> getControllerClasses() { |
| 173 | + final Set<Class<?>> controllerClasses = super.getControllerClasses(); |
| 174 | + controllerClasses.addAll(Set.of( |
| 175 | + ApiController.class, |
| 176 | + InternalController.class |
| 177 | + )); |
| 178 | + return controllerClasses; |
| 179 | + } |
29 | 180 |
|
30 |
| -<...> |
| 181 | + // potentially override also methods |
| 182 | + // protected @NotNull Set<Class<?>> getExceptionMappers() |
| 183 | + // and |
| 184 | + // protected @NotNull Set<Class<?>> getFilters() |
| 185 | +} |
| 186 | +``` |
31 | 187 |
|
| 188 | +### UI servlet class |
32 | 189 |
|
33 |
| -## Usage |
| 190 | +If new extension will contain UI parts/pages/artifacts, UI servlet class should be created extending `GenericUiServlet` |
| 191 | +simply specifying servlet name in constructor: |
| 192 | + |
| 193 | +```java |
| 194 | +public class PdfAdminUiServlet extends GenericUiServlet { |
| 195 | + public PdfAdminUiServlet() { |
| 196 | + super("pdf-exporter-admin"); |
| 197 | + } |
| 198 | +} |
| 199 | +``` |
34 | 200 |
|
35 |
| -<...> |
| 201 | +## Changelog |
36 | 202 |
|
| 203 | +| Version | Changes | |
| 204 | +|---------|-------------------------------------------------------------------------------------------------------------------------------------------| |
| 205 | +| v4.8.1 | SonarQube fixes | |
| 206 | +| v4.8.0 | Polarion 2404 is supported | |
| 207 | +| v4.7.0 | * Added/Improved logging.<br/>* Display baseline in the revisions table | |
| 208 | +| v4.6.0 | Utility class HtmlUtils is introduced | |
| 209 | +| v4.5.0 | * User-friendly message about deactivated configuration properties on the Swagger UI page.<br/> * Logging in ExceptionMappers | |
| 210 | +| v4.4.0 | About page refactored and support email added | |
| 211 | +| v4.3.0 | About page supports configuration help and icon | |
| 212 | +| v4.2.5 | dummy delivery-sbb and delivery-external maven profiles added | |
| 213 | +| v4.2.4 | Methods for getting entities by revision now properly return objects for already deleted entities | |
| 214 | +| v4.2.3 | Fix saving default settings in read only transaction | |
| 215 | +| v4.2.2 | Extended LogoutFilter with async skip request property | |
| 216 | +| v4.2.1 | Fix exception during save operation in nested transaction | |
| 217 | +| v4.2.0 | Added methods for getting fields values<br/> Proper users/assignee fields processing | |
| 218 | +| v4.1.0 | CORS filter for REST application implemented | |
| 219 | +| v4.0.7 | Made timed hiding of alert messages optional | |
| 220 | +| v4.0.6 | Update maven dependencies | |
| 221 | +| v4.0.5 | * Fixed scope agnostic controller<br/> * Added display config properties in "about page" | |
| 222 | +| v4.0.4 | Added ability to set nulls to fields<br/> * Multi-value enum support | |
| 223 | +| v4.0.3 | Added boolean field converter | |
| 224 | +| v4.0.2 | Changed CSS tweaks | |
| 225 | +| v4.0.1 | Removed 8px margin from code-input | |
| 226 | +| v4.0.0 | * Upgrade code-input component to v2.1.0<br/> * Reworking and polishing JS code<br/> * Refactoring | |
| 227 | +| v3.0.7 | Converters generic types improvement | |
| 228 | +| v3.0.6 | Moved generic methods/converters for settings fields | |
| 229 | +| v3.0.5 | Fix for default-settings | |
| 230 | +| v3.0.4 | Changed configuration pre-delete callback | |
| 231 | +| v3.0.3 | Added configuration delete callback into JS component | |
| 232 | +| v3.0.2 | Added API to save directly byte array | |
| 233 | +| v3.0.1 | Refactored polarion 2310 profile | |
| 234 | +| v3.0.0 | * Settings id/name usage improvement<br/> * Fixed messages clearing<br/> * Refactoring | |
| 235 | +| v2.2.0 | * Fixed revisions list in case when setting renamed<br/> * Fixed UI of custom select<br/> * Refactoring | |
| 236 | +| v2.1.1 | * Fixed reading setting and revert to revision urls<br/> * Unified reading revisions calls | |
| 237 | +| v2.1.0 | * Extended custom select element<br/> * Added function to check if it contains certain option | |
| 238 | +| v2.0.0 | * Changed polarion version to 2310<br/> * Update maven dependencies<br/> * Refactoring | |
| 239 | +| v1.1.20 | Extend functionality | |
| 240 | +| v1.1.19 | * Added custom select<br/> * Added getters for PolarionService | |
| 241 | +| v1.1.18 | * Refactoring<br/> * Update maven dependencies | |
| 242 | +| v1.1.17 | * Added GenericSettings afterSave action call<br/> * Update log4j.version to v2.21.0 | |
| 243 | +| v1.1.16 | * PolarionService has been introduced<br/> * Added unit tests for PolarionService | |
| 244 | +| v1.1.15 | Added settings move logic | |
| 245 | +| v1.1.14 | Refactoring | |
| 246 | +| v1.1.13 | Added SBB extension config using polarion.properties | |
| 247 | +| v1.1.12 | Added utils of getting system parameters | |
| 248 | +| v1.1.11 | * Added generic method for deserialization<br/> * Added unit tests for serialization and deserialization<br/> * Update maven dependencies | |
| 249 | +| v1.1.10 | * Fixed maven dependencies versions<br/> * Fixed CSS | |
| 250 | +| v1.1.9 | Added jobs logger | |
| 251 | +| v1.1.8 | Added API to delete location from repository | |
| 252 | +| v1.1.7 | * Added CRUD for cookies<br/> * Added validate projectId for context before using<br/> * Added font for option | |
| 253 | +| v1.1.6 | * Added Readme<br/> * Refactoring settings | |
| 254 | +| v1.1.5 | * Added NotAuthorizedExceptionMapper<br/> * Refactoring settings | |
| 255 | +| v1.1.4 | * Added OpenAPI annotations<br/> * Added settings-related java classes<br/> * Added generic settings controllers | |
| 256 | +| v1.1.3 | * Multiple web apps fix<br/> * Bundle symbolic name | |
| 257 | +| v1.1.2 | Sonarqube fixes | |
| 258 | +| v1.1.1 | Hide context from swagger | |
| 259 | +| v1.1.0 | Context has been introduced | |
| 260 | +| v1.0.0 | Initial release | |
0 commit comments