-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: save/delete methods proxy calls improvement, introduced separa… (
#39) feat!: save/delete methods proxy calls improvement, introduced separate pre&post hook methods
- Loading branch information
Showing
23 changed files
with
529 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
.idea/* | ||
|
||
# code style config | ||
!.idea/codeStyles | ||
.idea/codeStyles/* | ||
!.idea/codeStyles/Project.xml | ||
!.idea/codeStyles/codeStyleConfig.xml | ||
|
||
target/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Hook example for Polarion Interceptor extension | ||
|
||
This hook writes to log module save time. | ||
|
||
## Build | ||
|
||
This hook can be produced using maven: | ||
``` | ||
mvn clean package | ||
``` | ||
|
||
## Installation to Polarion | ||
|
||
To install this hook to Polarion `ch.sbb.polarion.extension.interceptor-hooks.<hookname>-<version>.jar` should be copied to `<polarion_home>/polarion/extensions/ch.sbb.polarion.extension.interceptor/eclipse/plugins/hooks`. | ||
It can be done manually or automated using maven build: | ||
``` | ||
mvn clean install -P install-to-local-polarion | ||
``` | ||
For automated installation with maven env variable `POLARION_HOME` should be defined and point to folder where Polarion is installed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>ch.sbb.polarion.extensions.interceptor-hooks</groupId> | ||
<artifactId>ch.sbb.polarion.extension.interceptor-hooks.module-save-time-logger</artifactId> | ||
<version>1.1.2-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<ch.sbb.polarion.extension.interceptor.version>2.0.0</ch.sbb.polarion.extension.interceptor.version> | ||
|
||
<maven-jar-plugin.Automatic-Module-Name>ch.sbb.polarion.extension.interceptor_hooks.module_save_time_logger</maven-jar-plugin.Automatic-Module-Name> | ||
<maven-jar-plugin.Extension-Context>module-save-time-logger</maven-jar-plugin.Extension-Context> | ||
|
||
<interceptor.artifactId>ch.sbb.polarion.extension.interceptor</interceptor.artifactId> | ||
<hooks.folder.name>hooks</hooks.folder.name> | ||
|
||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<polarion.version>2404</polarion.version> | ||
|
||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> | ||
|
||
<!-- Maven plugins --> | ||
<maven-clean-plugin.version>3.3.2</maven-clean-plugin.version> | ||
<maven-jar-plugin.version>3.4.1</maven-jar-plugin.version> | ||
<maven-dependency-plugin.version>3.6.1</maven-dependency-plugin.version> | ||
|
||
<!-- Others --> | ||
<jetbrains.api.version>24.0.1</jetbrains.api.version> | ||
|
||
<!--suppress UnresolvedMavenProperty --> | ||
<maven-jar-plugin.Bundle-Version>${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}.${project.artifact.selectedVersion.incrementalVersion}</maven-jar-plugin.Bundle-Version> | ||
</properties> | ||
|
||
<profiles> | ||
<profile> | ||
<id>install-to-local-polarion</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>${maven-clean-plugin.version}</version> | ||
<configuration> | ||
<filesets> | ||
<fileset> | ||
<directory>${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name}</directory> | ||
<includes> | ||
<include>*${maven-jar-plugin.Extension-Context}*.jar</include> | ||
</includes> | ||
<followSymlinks>false</followSymlinks> | ||
</fileset> | ||
</filesets> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>${maven-dependency-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>copy-to-local-polarion</id> | ||
<phase>install</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${project.artifactId}</artifactId> | ||
<version>${project.version}</version> | ||
<type>${project.packaging}</type> | ||
</artifactItem> | ||
</artifactItems> | ||
<outputDirectory>${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name}</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>ch.sbb.polarion.extensions</groupId> | ||
<artifactId>ch.sbb.polarion.extension.interceptor</artifactId> | ||
<version>${ch.sbb.polarion.extension.interceptor.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Polarion artifacts --> | ||
<dependency> | ||
<groupId>com.polarion.alm.projects</groupId> | ||
<artifactId>projects</artifactId> | ||
<version>${polarion.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.polarion.alm.tracker</groupId> | ||
<artifactId>tracker</artifactId> | ||
<version>${polarion.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.polarion.platform.persistence</groupId> | ||
<artifactId>platform-persistence</artifactId> | ||
<version>${polarion.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.polarion.core.util</groupId> | ||
<artifactId>util</artifactId> | ||
<version>${polarion.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Others --> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
<version>${jetbrains.api.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>${maven-dependency-plugin.version}</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>${maven-jar-plugin.version}</version> | ||
<configuration> | ||
<archive> | ||
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
52 changes: 52 additions & 0 deletions
52
.../sbb/polarion/extension/interceptor_hooks/module_save_time_logger/ModuleSaveTimeHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package ch.sbb.polarion.extension.interceptor_hooks.module_save_time_logger; | ||
|
||
import ch.sbb.polarion.extension.interceptor.model.ActionHook; | ||
import ch.sbb.polarion.extension.interceptor.model.HookExecutor; | ||
import ch.sbb.polarion.extension.interceptor.util.PropertiesUtils; | ||
import com.polarion.core.util.logging.Logger; | ||
import com.polarion.platform.persistence.model.IPObject; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@SuppressWarnings("unused") | ||
public class ModuleSaveTimeHook extends ActionHook implements HookExecutor { | ||
|
||
public static final String SETTINGS_LOG_MESSAGE = "logMessage"; | ||
public static final String SETTINGS_TIME = "time"; | ||
public static final String TIME_VARIABLE = "{%s}".formatted(SETTINGS_TIME); | ||
public static final String DEFAULT_LOG_MESSAGE = "Module saved in " + TIME_VARIABLE + "ms"; | ||
public static final String VERSION = "1.0.0"; | ||
public static final Logger logger = Logger.getLogger(ModuleSaveTimeHook.class); | ||
|
||
public ModuleSaveTimeHook() { | ||
super(ItemType.MODULE, ActionType.SAVE, VERSION, "Logs module save time"); | ||
} | ||
|
||
@Override | ||
public @NotNull HookExecutor getExecutor() { | ||
return new SaveTimeLoggerExecutor(); | ||
} | ||
|
||
@Override | ||
public String getDefaultSettings() { | ||
return PropertiesUtils.build( | ||
SETTINGS_LOG_MESSAGE, DEFAULT_LOG_MESSAGE | ||
); | ||
} | ||
|
||
public class SaveTimeLoggerExecutor implements HookExecutor { | ||
|
||
private long startTime; | ||
|
||
@Override | ||
public String preAction(@NotNull IPObject polarionObject) { | ||
startTime = System.currentTimeMillis(); | ||
return null; | ||
} | ||
|
||
@Override | ||
public void postAction(@NotNull IPObject polarionObject) { | ||
logger.info(getSettingsValue(SETTINGS_LOG_MESSAGE) | ||
.replace(TIME_VARIABLE, String.valueOf(System.currentTimeMillis() - startTime))); | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
hooks/module-save-time-logger/src/main/resources/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Name: Title length hook for Polarion ALM Interceptor plugin | ||
Main-Class: ch.sbb.polarion.extension.interceptor_hooks.module_save_time_logger.ModuleSaveTimeHook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.