This Polarion extension lets you easily run custom Java code (via Hooks), before Polarion saves/deletes a Work Item, Plan or Test Run.
It is a powerful way to interact with or interrupt these actions when you need to.
Example: A Hook can be implemented that checks all possible conditions when a user is about to delete or modify a Work Item. These Hooks can harness all the capabilities found within Polarion's Java API.
Building
- A .jar file must contain a META-INF folder with the hivemodule.xml and MANIFEST.MF files copied from the project.
- Due to an issue with Eclipse, you may need to add these files manually to replace the versions that are generated automatically.
Installation
- To install the extension just copy its files to the Polarion extensions folder.
- Hooks can be added at any time by copying .jar files to the extension's hooks subfolder.
- If a Hook is added while Polarion is running, the management page can be used to reload the Hooks.
(See below for details.)
|- actions_interceptor
|- eclipse
|- plugins
|- com.adva.polarion.interceptor.jar
|- hook.properties
|- META-INF
|- MANIFEST.MF
|- hooks
|- only_assignee_can_delete.jar
|- title_length_check.jar
|- plan_save.jar
|- single_assignee.jar
|- testrun.jar
Interceptor Management Page
Users control what the extension does through a Wiki Page by invoking the following in a Velocity script:
workItemActionInterceptorManager
On any Wiki Page you can:
- Reload Hooks
- Edit the Hook .jars. (Add, delete, replace or edit while the Polarion server is running.)
- When triggered, the extension will use the most recent version of a Hook's code.
- Reload Properties
- You can update and reload the extension's properties file. (hook.properties)
- Control Extension Functions
- You can enable\disable interceptions for actions.
- If the extension is disabled, no Hooks will be invoked.
- Request a List of Loaded Hooks
- Request the Currently Set Properties
A sample of the Interceptor Management Page is in the following extension archive file:
manager_page.wiki.
Hooks
A Hook is a Java class that implements a special interface (IActionHook) that's stored as a separate .jar file in the hooks folder. The Jar Manifest file must contain the Main-Class attribute.
The extension archive already contains several sample Hooks (with sources and the Eclipse project file) to help you easily build your own.
- ControlTitleLengthHook
- Makes sure the length for the Title field does not exceed a defined number of characters.
- OnlyAssigneeCanDeleteHook
- Makes sure that only the current Assignee can delete a Work Item.
- Hook archives (folder samples) also contain an Ant file for creating a delivery jar. (Ant Release)
- Note: Because this Hook modifies the Work Item, a special "polarion" user must have write permissions in the current project.
- PlanSaveHook
- Adds all Work Items added to child Plans to their parent Plan.
- SingleAssigneeHook
- It only allows a single Assignee to be assigned a Work Item.
- TestRunHook
- Makes sure that a Test Case result is not set to "Passed" if one of the Test Step results has "Failed".
WARNING: Do not forget to modify the hook.properties file (in the extension's root folder) to activate the Hooks for your projects. (See details in the Hooks section of the README.TXT file.)