From bc3807c4b4f6b70dd8e0a410f7e8a5fb158dfc0d Mon Sep 17 00:00:00 2001 From: Sergey Grigoriev Date: Wed, 12 Jun 2024 17:26:41 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20hook=20samples=20migrated=20to=20the?= =?UTF-8?q?=20separate=20repo=20https://github.com/=E2=80=A6=20(#45)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit chore: hook samples migrated to the separate repo https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.interceptor.hook-samples --- hooks/module-save-time-logger/.gitignore | 31 --- hooks/module-save-time-logger/README.md | 19 -- hooks/module-save-time-logger/pom.xml | 159 ---------------- .../ModuleSaveTimeHook.java | 52 ----- .../src/main/resources/META-INF/MANIFEST.MF | 2 - hooks/only-assignee-can-delete/.gitignore | 31 --- hooks/only-assignee-can-delete/README.md | 19 -- hooks/only-assignee-can-delete/pom.xml | 165 ---------------- .../OnlyAssigneeCanDeleteHook.java | 79 -------- .../src/main/resources/META-INF/MANIFEST.MF | 2 - hooks/plan-save/.gitignore | 31 --- hooks/plan-save/README.md | 19 -- hooks/plan-save/pom.xml | 159 ---------------- .../plan_save/PlanSaveHook.java | 68 ------- .../src/main/resources/META-INF/MANIFEST.MF | 2 - hooks/single-assignee/.gitignore | 31 --- hooks/single-assignee/README.md | 19 -- hooks/single-assignee/pom.xml | 159 ---------------- .../single_assignee/SingleAssigneeHook.java | 62 ------ .../src/main/resources/META-INF/MANIFEST.MF | 2 - hooks/testrun/.gitignore | 31 --- hooks/testrun/README.md | 19 -- hooks/testrun/pom.xml | 177 ------------------ .../testrun/TestRunHook.java | 87 --------- .../src/main/resources/META-INF/MANIFEST.MF | 2 - hooks/title-length-check/.gitignore | 31 --- hooks/title-length-check/README.md | 19 -- hooks/title-length-check/pom.xml | 159 ---------------- .../title_length_check/TitleLengthHook.java | 52 ----- .../src/main/resources/META-INF/MANIFEST.MF | 2 - 30 files changed, 1690 deletions(-) delete mode 100644 hooks/module-save-time-logger/.gitignore delete mode 100644 hooks/module-save-time-logger/README.md delete mode 100644 hooks/module-save-time-logger/pom.xml delete mode 100644 hooks/module-save-time-logger/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/module_save_time_logger/ModuleSaveTimeHook.java delete mode 100644 hooks/module-save-time-logger/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 hooks/only-assignee-can-delete/.gitignore delete mode 100644 hooks/only-assignee-can-delete/README.md delete mode 100644 hooks/only-assignee-can-delete/pom.xml delete mode 100644 hooks/only-assignee-can-delete/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/only_assignee_can_delete/OnlyAssigneeCanDeleteHook.java delete mode 100644 hooks/only-assignee-can-delete/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 hooks/plan-save/.gitignore delete mode 100644 hooks/plan-save/README.md delete mode 100644 hooks/plan-save/pom.xml delete mode 100644 hooks/plan-save/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/plan_save/PlanSaveHook.java delete mode 100644 hooks/plan-save/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 hooks/single-assignee/.gitignore delete mode 100644 hooks/single-assignee/README.md delete mode 100644 hooks/single-assignee/pom.xml delete mode 100644 hooks/single-assignee/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/single_assignee/SingleAssigneeHook.java delete mode 100644 hooks/single-assignee/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 hooks/testrun/.gitignore delete mode 100644 hooks/testrun/README.md delete mode 100644 hooks/testrun/pom.xml delete mode 100644 hooks/testrun/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/testrun/TestRunHook.java delete mode 100644 hooks/testrun/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 hooks/title-length-check/.gitignore delete mode 100644 hooks/title-length-check/README.md delete mode 100644 hooks/title-length-check/pom.xml delete mode 100644 hooks/title-length-check/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/title_length_check/TitleLengthHook.java delete mode 100644 hooks/title-length-check/src/main/resources/META-INF/MANIFEST.MF diff --git a/hooks/module-save-time-logger/.gitignore b/hooks/module-save-time-logger/.gitignore deleted file mode 100644 index 824ec60..0000000 --- a/hooks/module-save-time-logger/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# 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 diff --git a/hooks/module-save-time-logger/README.md b/hooks/module-save-time-logger/README.md deleted file mode 100644 index 9266d0d..0000000 --- a/hooks/module-save-time-logger/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# 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.-.jar` should be copied to `/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. diff --git a/hooks/module-save-time-logger/pom.xml b/hooks/module-save-time-logger/pom.xml deleted file mode 100644 index 3a7f6e1..0000000 --- a/hooks/module-save-time-logger/pom.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - 4.0.0 - - ch.sbb.polarion.extensions.interceptor-hooks - ch.sbb.polarion.extension.interceptor-hooks.module-save-time-logger - 2.0.1-SNAPSHOT - jar - - - 2.0.0 - - ch.sbb.polarion.extension.interceptor_hooks.module_save_time_logger - module-save-time-logger - - ch.sbb.polarion.extension.interceptor - hooks - - 17 - 17 - 2404 - - UTF-8 - yyyy-MM-dd HH:mm - - - 3.3.2 - 3.4.1 - 3.6.1 - - - 24.0.1 - - - ${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}.${project.artifact.selectedVersion.incrementalVersion} - - - - - install-to-local-polarion - - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - *${maven-jar-plugin.Extension-Context}*.jar - - false - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - copy-to-local-polarion - install - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - - - - - - - - - - - - ch.sbb.polarion.extensions - ch.sbb.polarion.extension.interceptor - ${ch.sbb.polarion.extension.interceptor.version} - provided - - - - - com.polarion.alm.projects - projects - ${polarion.version} - provided - - - com.polarion.alm.tracker - tracker - ${polarion.version} - provided - - - com.polarion.platform.persistence - platform-persistence - ${polarion.version} - provided - - - com.polarion.core.util - util - ${polarion.version} - provided - - - - - org.jetbrains - annotations - ${jetbrains.api.version} - provided - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - src/main/resources/META-INF/MANIFEST.MF - - - - - - - - diff --git a/hooks/module-save-time-logger/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/module_save_time_logger/ModuleSaveTimeHook.java b/hooks/module-save-time-logger/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/module_save_time_logger/ModuleSaveTimeHook.java deleted file mode 100644 index 3e77eac..0000000 --- a/hooks/module-save-time-logger/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/module_save_time_logger/ModuleSaveTimeHook.java +++ /dev/null @@ -1,52 +0,0 @@ -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))); - } - } -} diff --git a/hooks/module-save-time-logger/src/main/resources/META-INF/MANIFEST.MF b/hooks/module-save-time-logger/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 2cb9b6a..0000000 --- a/hooks/module-save-time-logger/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Name: Title length hook for Polarion ALM Interceptor plugin -Main-Class: ch.sbb.polarion.extension.interceptor_hooks.module_save_time_logger.ModuleSaveTimeHook diff --git a/hooks/only-assignee-can-delete/.gitignore b/hooks/only-assignee-can-delete/.gitignore deleted file mode 100644 index 824ec60..0000000 --- a/hooks/only-assignee-can-delete/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# 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 diff --git a/hooks/only-assignee-can-delete/README.md b/hooks/only-assignee-can-delete/README.md deleted file mode 100644 index 4a5e965..0000000 --- a/hooks/only-assignee-can-delete/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Hook example for Polarion Interceptor extension - -This hook validates that only assignee allowed to delete workitem. - -## 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.-.jar` should be copied to `/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. diff --git a/hooks/only-assignee-can-delete/pom.xml b/hooks/only-assignee-can-delete/pom.xml deleted file mode 100644 index 997bb45..0000000 --- a/hooks/only-assignee-can-delete/pom.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - 4.0.0 - - ch.sbb.polarion.extensions.interceptor-hooks - ch.sbb.polarion.extension.interceptor-hooks.only-assignee-can-delete - 2.0.1-SNAPSHOT - jar - - - 2.0.0 - - ch.sbb.polarion.extension.interceptor_hooks.only_assignee_can_delete - only-assignee-can-delete - - ch.sbb.polarion.extension.interceptor - hooks - - 17 - 17 - 2404 - - UTF-8 - yyyy-MM-dd HH:mm - - - 3.3.2 - 3.4.1 - 3.6.1 - - - 24.0.1 - - - ${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}.${project.artifact.selectedVersion.incrementalVersion} - - - - - install-to-local-polarion - - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - *${maven-jar-plugin.Extension-Context}*.jar - - false - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - copy-to-local-polarion - install - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - - - - - - - - - - - - ch.sbb.polarion.extensions - ch.sbb.polarion.extension.interceptor - ${ch.sbb.polarion.extension.interceptor.version} - provided - - - - - com.polarion.alm.projects - projects - ${polarion.version} - provided - - - com.polarion.alm.tracker - tracker - ${polarion.version} - provided - - - com.polarion.platform - platform - ${polarion.version} - provided - - - com.polarion.platform.persistence - platform-persistence - ${polarion.version} - provided - - - com.polarion.core.util - util - ${polarion.version} - provided - - - - - org.jetbrains - annotations - ${jetbrains.api.version} - provided - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - src/main/resources/META-INF/MANIFEST.MF - - - - - - - - diff --git a/hooks/only-assignee-can-delete/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/only_assignee_can_delete/OnlyAssigneeCanDeleteHook.java b/hooks/only-assignee-can-delete/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/only_assignee_can_delete/OnlyAssigneeCanDeleteHook.java deleted file mode 100644 index 27607c8..0000000 --- a/hooks/only-assignee-can-delete/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/only_assignee_can_delete/OnlyAssigneeCanDeleteHook.java +++ /dev/null @@ -1,79 +0,0 @@ -package ch.sbb.polarion.extension.interceptor_hooks.only_assignee_can_delete; - -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.alm.projects.model.IUser; -import com.polarion.alm.tracker.ITrackerService; -import com.polarion.alm.tracker.model.IWorkItem; -import com.polarion.core.util.logging.Logger; -import com.polarion.platform.core.PlatformContext; -import com.polarion.platform.persistence.model.IPObject; -import com.polarion.platform.persistence.model.IPObjectList; -import org.jetbrains.annotations.NotNull; - -import java.util.Iterator; - -@SuppressWarnings({"unused", "unchecked", "rawtypes"}) -public class OnlyAssigneeCanDeleteHook extends ActionHook implements HookExecutor { - - private static final String SETTINGS_PROJECTS = "projects"; - private static final String SETTINGS_ERROR_MESSAGE = "errorMessage"; - private static final String SETTINGS_DELETE_UNASSIGNED = "deleteUnassigned"; - private static final boolean DEFAULT_DELETE_UNASSIGNED = true; - private static final String DEFAULT_ERROR_MESSAGE = "Only assignee user can delete WI!"; - private static final String VERSION = "2.0.0"; - private static final ITrackerService trackerService = PlatformContext.getPlatform().lookupService(ITrackerService.class); - private static final Logger logger = Logger.getLogger(OnlyAssigneeCanDeleteHook.class); - - public OnlyAssigneeCanDeleteHook() { - super(ItemType.WORKITEM, ActionType.DELETE, VERSION, "Control that only assignee user can delete WI." + - " If Wi is unassigned then it can be removed or not dependent on value property " + SETTINGS_DELETE_UNASSIGNED); - } - - @Override - public String preAction(@NotNull IPObject object) { - boolean deleteUnassigned = DEFAULT_DELETE_UNASSIGNED; - String deleteUnassignedStringValue = getSettingsValue(SETTINGS_DELETE_UNASSIGNED); - try { - deleteUnassigned = Boolean.parseBoolean(deleteUnassignedStringValue); - } catch (NumberFormatException e) { - logger.error("Cannot parse boolean value '%s'".formatted(deleteUnassignedStringValue), e); - } - - IWorkItem workItem = (IWorkItem) object; - String returnMessage = null; - if (workItem.getType() != null && workItem.getId() != null && isCommaSeparatedSettingsHasItem(workItem.getProjectId(), SETTINGS_PROJECTS)) { - boolean allowToDelete = false; - String currentUser = trackerService.getDataService().getSecurityService().getCurrentUser(); - IPObjectList assignees = workItem.getAssignees(); - if (assignees.isEmpty()) { - allowToDelete = deleteUnassigned; - } else { - for (Iterator i = assignees.iterator(); i.hasNext() && !allowToDelete; ) { - IPObject user = i.next(); - allowToDelete = currentUser.equals(((IUser) user).getId()); - } - } - if (!allowToDelete) { - returnMessage = getSettingsValue(SETTINGS_ERROR_MESSAGE); - } - } - - return returnMessage; - } - - @Override - public @NotNull HookExecutor getExecutor() { - return this; //there is no need to create a separate executor instance coz only 'pre' action used - } - - @Override - public String getDefaultSettings() { - return PropertiesUtils.build( - SETTINGS_PROJECTS, ALL_WILDCARD, - SETTINGS_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE, - SETTINGS_DELETE_UNASSIGNED, String.valueOf(DEFAULT_DELETE_UNASSIGNED) - ); - } -} diff --git a/hooks/only-assignee-can-delete/src/main/resources/META-INF/MANIFEST.MF b/hooks/only-assignee-can-delete/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 8f26899..0000000 --- a/hooks/only-assignee-can-delete/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Name: WorkItem deletion hook for Polarion ALM Interceptor plugin -Main-Class: ch.sbb.polarion.extension.interceptor_hooks.only_assignee_can_delete.OnlyAssigneeCanDeleteHook diff --git a/hooks/plan-save/.gitignore b/hooks/plan-save/.gitignore deleted file mode 100644 index 824ec60..0000000 --- a/hooks/plan-save/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# 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 diff --git a/hooks/plan-save/README.md b/hooks/plan-save/README.md deleted file mode 100644 index 2d26d14..0000000 --- a/hooks/plan-save/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Hook example for Polarion Interceptor extension - -This hook adds workitems to parent plan during save operation. - -## 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.-.jar` should be copied to `/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. diff --git a/hooks/plan-save/pom.xml b/hooks/plan-save/pom.xml deleted file mode 100644 index 21dc64f..0000000 --- a/hooks/plan-save/pom.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - 4.0.0 - - ch.sbb.polarion.extensions.interceptor-hooks - ch.sbb.polarion.extension.interceptor-hooks.plan-save - 2.0.1-SNAPSHOT - jar - - - 2.0.0 - - ch.sbb.polarion.extension.interceptor_hooks.plan_save - plan-save - - ch.sbb.polarion.extension.interceptor - hooks - - 17 - 17 - 2404 - - UTF-8 - yyyy-MM-dd HH:mm - - - 3.3.2 - 3.4.1 - 3.6.1 - - - 24.0.1 - - - ${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}.${project.artifact.selectedVersion.incrementalVersion} - - - - - install-to-local-polarion - - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - *${maven-jar-plugin.Extension-Context}*.jar - - false - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - copy-to-local-polarion - install - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - - - - - - - - - - - - ch.sbb.polarion.extensions - ch.sbb.polarion.extension.interceptor - ${ch.sbb.polarion.extension.interceptor.version} - provided - - - - - com.polarion.alm.projects - projects - ${polarion.version} - provided - - - com.polarion.alm.tracker - tracker - ${polarion.version} - provided - - - com.polarion.platform.persistence - platform-persistence - ${polarion.version} - provided - - - com.polarion.core.util - util - ${polarion.version} - provided - - - - - org.jetbrains - annotations - ${jetbrains.api.version} - provided - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - src/main/resources/META-INF/MANIFEST.MF - - - - - - - - diff --git a/hooks/plan-save/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/plan_save/PlanSaveHook.java b/hooks/plan-save/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/plan_save/PlanSaveHook.java deleted file mode 100644 index d34d0db..0000000 --- a/hooks/plan-save/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/plan_save/PlanSaveHook.java +++ /dev/null @@ -1,68 +0,0 @@ -package ch.sbb.polarion.extension.interceptor_hooks.plan_save; - -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.alm.tracker.model.IPlan; -import com.polarion.alm.tracker.model.IWorkItem; -import com.polarion.core.util.logging.Logger; -import com.polarion.platform.persistence.model.IPObject; -import org.jetbrains.annotations.NotNull; - -import java.util.LinkedHashSet; - -@SuppressWarnings("unused") -public class PlanSaveHook extends ActionHook implements HookExecutor { - - private static final String SETTINGS_PROJECTS = "projects"; - private static final String SETTINGS_TEMPLATES = "templates"; - private static final String VERSION = "2.0.0"; - private static final Logger logger = Logger.getLogger(PlanSaveHook.class); - - public PlanSaveHook() { - super(ItemType.PLAN, ActionType.SAVE, VERSION, "Hook intercepting Plan save operation for adding WIs to parent plan (propagating)"); - } - - @Override - public void postAction(@NotNull IPObject object) { - IPlan plan = (IPlan) object; - - logger.debug("Processing Plan: " + plan.getId()); - if (!plan.isTemplate() && isCommaSeparatedSettingsHasItem(plan.getProjectId(), SETTINGS_PROJECTS)) { - if (plan.getTemplate() != null && isCommaSeparatedSettingsHasItem(plan.getTemplate().getId(), SETTINGS_TEMPLATES) - && plan.getParent() != null && plan.getParent().getTemplate() != null && isCommaSeparatedSettingsHasItem(plan.getParent().getTemplate().getId(), SETTINGS_TEMPLATES)) { - IPlan parentPlan = plan.getParent(); - logger.debug("Parent Plan: " + parentPlan.getId()); - LinkedHashSet parentPlanItems = parentPlan.getItems(); - boolean isModified = false; - for (IWorkItem wi : plan.getItems()) { - if (!parentPlanItems.contains(wi)) { - logger.debug("Adding WI: " + wi.getId()); - parentPlan.addRecord(wi); - isModified = true; - } - } - if (isModified) { - parentPlan.save(); - } - } else { - logger.debug("Unsupported plan type: " + plan.getTemplate().getId() + " Supporting: " + getSettingsValue(SETTINGS_TEMPLATES)); - } - } else { - logger.debug("Unsupported project: " + plan.getProjectId() + " Supporting: " + getSettingsValue(SETTINGS_PROJECTS)); - } - } - - @Override - public @NotNull HookExecutor getExecutor() { - return this; //there is no need to create a separate executor instance coz only 'post' action used - } - - @Override - public String getDefaultSettings() { - return PropertiesUtils.build( - SETTINGS_PROJECTS, ALL_WILDCARD, - SETTINGS_TEMPLATES, ALL_WILDCARD - ); - } -} diff --git a/hooks/plan-save/src/main/resources/META-INF/MANIFEST.MF b/hooks/plan-save/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index fb0e8c8..0000000 --- a/hooks/plan-save/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Name: Plan save hook for Polarion ALM Interceptor plugin -Main-Class: ch.sbb.polarion.extension.interceptor_hooks.plan_save.PlanSaveHook diff --git a/hooks/single-assignee/.gitignore b/hooks/single-assignee/.gitignore deleted file mode 100644 index 824ec60..0000000 --- a/hooks/single-assignee/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# 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 diff --git a/hooks/single-assignee/README.md b/hooks/single-assignee/README.md deleted file mode 100644 index e0e3e40..0000000 --- a/hooks/single-assignee/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Hook example for Polarion Interceptor extension - -This hook checks that only single assignee can be added to workitems. - -## 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.-.jar` should be copied to `/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. diff --git a/hooks/single-assignee/pom.xml b/hooks/single-assignee/pom.xml deleted file mode 100644 index 848844a..0000000 --- a/hooks/single-assignee/pom.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - 4.0.0 - - ch.sbb.polarion.extensions.interceptor-hooks - ch.sbb.polarion.extension.interceptor-hooks.single-assignee - 2.0.1-SNAPSHOT - jar - - - 2.0.0 - - ch.sbb.polarion.extension.interceptor_hooks.single_assignee - single-assignee - - ch.sbb.polarion.extension.interceptor - hooks - - 17 - 17 - 2404 - - UTF-8 - yyyy-MM-dd HH:mm - - - 3.3.2 - 3.4.1 - 3.6.1 - - - 24.0.1 - - - ${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}.${project.artifact.selectedVersion.incrementalVersion} - - - - - install-to-local-polarion - - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - *${maven-jar-plugin.Extension-Context}*.jar - - false - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - copy-to-local-polarion - install - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - - - - - - - - - - - - ch.sbb.polarion.extensions - ch.sbb.polarion.extension.interceptor - ${ch.sbb.polarion.extension.interceptor.version} - provided - - - - - com.polarion.alm.projects - projects - ${polarion.version} - provided - - - com.polarion.alm.tracker - tracker - ${polarion.version} - provided - - - com.polarion.platform.persistence - platform-persistence - ${polarion.version} - provided - - - com.polarion.core.util - util - ${polarion.version} - provided - - - - - org.jetbrains - annotations - ${jetbrains.api.version} - provided - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - src/main/resources/META-INF/MANIFEST.MF - - - - - - - - diff --git a/hooks/single-assignee/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/single_assignee/SingleAssigneeHook.java b/hooks/single-assignee/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/single_assignee/SingleAssigneeHook.java deleted file mode 100644 index 296ae1b..0000000 --- a/hooks/single-assignee/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/single_assignee/SingleAssigneeHook.java +++ /dev/null @@ -1,62 +0,0 @@ -package ch.sbb.polarion.extension.interceptor_hooks.single_assignee; - -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.alm.tracker.model.IWorkItem; -import com.polarion.core.util.logging.Logger; -import com.polarion.platform.persistence.model.IPObject; -import org.jetbrains.annotations.NotNull; - -/** - * Save hook for control that user can add only single assignee to WI. PS-1695 - */ -@SuppressWarnings("unused") -public class SingleAssigneeHook extends ActionHook implements HookExecutor { - - private static final String SETTINGS_PROJECTS_DESCRIPTION = "Comma-separated list of projects. Use * to process all."; - private static final String SETTINGS_PROJECTS = "projects"; - private static final String SETTINGS_TYPES_DESCRIPTION = "Comma-separated list of types for particular project (e.g.: types.projectId1=task,defect). Use * to wildcard all projects or types (e.g. types.*=*)."; - private static final String SETTINGS_TYPES = "types"; - private static final String SETTINGS_ERROR_MESSAGE = "errorMessage"; - private static final String SETTINGS_ERROR_MESSAGE_DESCRIPTION = "Message which will be displayed in the negative case."; - private static final String DEFAULT_ERROR_MESSAGE = "Only single assignee can be added to Work Item according project settings!"; - private static final String VERSION = "2.0.0"; - private static final Logger logger = Logger.getLogger(SingleAssigneeHook.class); - - public SingleAssigneeHook() { - super(ItemType.WORKITEM, ActionType.SAVE, VERSION, "Save hook for control that user can add only single assignee to WI. PS-1695"); - } - - @Override - public String preAction(@NotNull IPObject object) { - String returnMessage = null; - IWorkItem workItem = (IWorkItem) object; - if (workItem.getType() != null && workItem.getId() != null && !workItem.isUnresolvable() && workItem.isModified() && workItem.getAssignees().size() > 1) { - try { - if (isCommaSeparatedSettingsHasItem(workItem.getProjectId(), SETTINGS_PROJECTS) && isCommaSeparatedSettingsHasItem(workItem.getType().getId(), SETTINGS_TYPES, workItem.getProjectId())) { - returnMessage = getSettingsValue(SETTINGS_ERROR_MESSAGE); - } - } catch (Exception e) { - returnMessage = "Cannot update WI due to Exception: " + (e.getMessage() != null ? e.getMessage() : e.getClass()); - logger.error("Hook processing error", e); - } - } - - return returnMessage; - } - - @Override - public @NotNull HookExecutor getExecutor() { - return this; //there is no need to create a separate executor instance coz only 'pre' action used - } - - @Override - public String getDefaultSettings() { - return PropertiesUtils.buildWithDescription( - SETTINGS_PROJECTS_DESCRIPTION, SETTINGS_PROJECTS, ALL_WILDCARD, - SETTINGS_TYPES_DESCRIPTION, SETTINGS_TYPES + DOT + ALL_WILDCARD, ALL_WILDCARD, - SETTINGS_ERROR_MESSAGE_DESCRIPTION, SETTINGS_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE - ); - } -} diff --git a/hooks/single-assignee/src/main/resources/META-INF/MANIFEST.MF b/hooks/single-assignee/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 8d6e663..0000000 --- a/hooks/single-assignee/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Name: Single assignee hook for Polarion ALM Interceptor plugin -Main-Class: ch.sbb.polarion.extension.interceptor_hooks.single_assignee.SingleAssigneeHook diff --git a/hooks/testrun/.gitignore b/hooks/testrun/.gitignore deleted file mode 100644 index 824ec60..0000000 --- a/hooks/testrun/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# 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 diff --git a/hooks/testrun/README.md b/hooks/testrun/README.md deleted file mode 100644 index bf1eab8..0000000 --- a/hooks/testrun/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Hook example for Polarion Interceptor extension - -This hook does not allow mark test case as passed if any test steps not passed. - -## 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.-.jar` should be copied to `/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. diff --git a/hooks/testrun/pom.xml b/hooks/testrun/pom.xml deleted file mode 100644 index 8cda882..0000000 --- a/hooks/testrun/pom.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - 4.0.0 - - ch.sbb.polarion.extensions.interceptor-hooks - ch.sbb.polarion.extension.interceptor-hooks.testrun - 2.0.1-SNAPSHOT - jar - - - 2.0.0 - - ch.sbb.polarion.extension.interceptor_hooks.testrun - testrun - - ch.sbb.polarion.extension.interceptor - hooks - - 17 - 17 - 2404 - - UTF-8 - yyyy-MM-dd HH:mm - - - 3.3.2 - 3.4.1 - 3.6.1 - - - 24.0.1 - - - ${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}.${project.artifact.selectedVersion.incrementalVersion} - - - - - install-to-local-polarion - - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - *${maven-jar-plugin.Extension-Context}*.jar - - false - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - copy-to-local-polarion - install - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - - - - - - - - - - - - ch.sbb.polarion.extensions - ch.sbb.polarion.extension.interceptor - ${ch.sbb.polarion.extension.interceptor.version} - provided - - - - - com.polarion.alm.projects - projects - ${polarion.version} - provided - - - com.polarion.alm.tracker - tracker - ${polarion.version} - provided - - - com.polarion.platform - platform - ${polarion.version} - provided - - - com.polarion.platform.persistence - platform-persistence - ${polarion.version} - provided - - - com.polarion.core.util - util - ${polarion.version} - provided - - - com.polarion.subterra.base - subterra-base-core - ${polarion.version} - provided - - - com.polarion.subterra.base - subterra-base-data - ${polarion.version} - provided - - - - - org.jetbrains - annotations - ${jetbrains.api.version} - provided - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - src/main/resources/META-INF/MANIFEST.MF - - - - - - - - diff --git a/hooks/testrun/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/testrun/TestRunHook.java b/hooks/testrun/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/testrun/TestRunHook.java deleted file mode 100644 index d244415..0000000 --- a/hooks/testrun/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/testrun/TestRunHook.java +++ /dev/null @@ -1,87 +0,0 @@ -package ch.sbb.polarion.extension.interceptor_hooks.testrun; - -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.alm.tracker.ITrackerService; -import com.polarion.alm.tracker.model.ITestRecord; -import com.polarion.alm.tracker.model.ITestRun; -import com.polarion.alm.tracker.model.ITestStepResult; -import com.polarion.core.util.logging.Logger; -import com.polarion.platform.core.PlatformContext; -import com.polarion.platform.persistence.IEnumOption; -import com.polarion.platform.persistence.model.IPObject; -import org.jetbrains.annotations.NotNull; - -import java.util.Iterator; -import java.util.List; - -/** - * WorkItemActionInterceptor hook for handling changes in TestRun: - * - Does not allow mark test case as passed if any of step not passed - */ -@SuppressWarnings("unused") -public class TestRunHook extends ActionHook implements HookExecutor { - - private static final String SETTINGS_PROJECTS = "projects"; - private static final String SETTINGS_ERROR_MESSAGE = "errorMessage"; - private static final String TEST_CASE_ID_VARIABLE = "{testCaseId}"; - private static final String STEP_NUMBER_VARIABLE = "{stepNumber}"; - private static final String DEFAULT_ERROR_MESSAGE = "Cannot save execution results for TC " + TEST_CASE_ID_VARIABLE + " as Passed because it does not match to result in step N" + STEP_NUMBER_VARIABLE; - private static final String VERSION = "2.0.0"; - private static final ITrackerService trackerService = PlatformContext.getPlatform().lookupService(ITrackerService.class); - private static final Logger logger = Logger.getLogger(TestRunHook.class); - - public TestRunHook() { - super(ItemType.TESTRUN, ActionType.SAVE, VERSION, "Does not allow mark test case as passed if any of step not passed"); - } - - @Override - public String preAction(@NotNull IPObject object) { - String returnMessage = null; - ITestRun testRun = (ITestRun) object; - try { - if (!testRun.isUnresolvable() && !testRun.isTemplate() && isCommaSeparatedSettingsHasItem(testRun.getProjectId(), SETTINGS_PROJECTS)) { - List testRecords = testRun.getAllRecords(); - List actualTestRecords = ((ITestRun) trackerService.getDataService().getInstance(testRun.getUri())).getAllRecords(); - if (!testRecords.equals(actualTestRecords)) { //Check if records was changed - Iterator testRecordsIterator = testRecords.iterator(); - Iterator actualTestRecordsIterator = actualTestRecords.iterator(); - while (testRecordsIterator.hasNext() && actualTestRecordsIterator.hasNext() && returnMessage == null) { - ITestRecord newRecord = testRecordsIterator.next(); - if (!newRecord.equals(actualTestRecordsIterator.next()) && newRecord.getResult() != null && newRecord.getResult().getId().equals("passed")) { - IEnumOption result = newRecord.getResult(); - java.util.List testStepResults = newRecord.getTestStepResults(); - int i = 0; - for (Iterator iterator = testStepResults.iterator(); iterator.hasNext() && returnMessage == null; i++) { - ITestStepResult stepResult = iterator.next(); - if (stepResult.getResult() != result) { - returnMessage = getSettingsValue(SETTINGS_ERROR_MESSAGE).replace(TEST_CASE_ID_VARIABLE, newRecord.getTestCase().getId()).replace(STEP_NUMBER_VARIABLE, String.valueOf(i + 1)); - } - } - } - } - } - } - } catch (IllegalStateException e) { - //ignore - trying to update new TR - } catch (Exception e) { - logger.error("Error processing hook", e); - returnMessage = "Cannot update TestRun due to Exception: " + (e.getMessage() != null ? e.getMessage() : e.getClass()); - } - return returnMessage; - } - - @Override - public @NotNull HookExecutor getExecutor() { - return this; //there is no need to create a separate executor instance coz only 'pre' action used - } - - @Override - public String getDefaultSettings() { - return PropertiesUtils.build( - SETTINGS_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE, - SETTINGS_PROJECTS, ALL_WILDCARD - ); - } -} diff --git a/hooks/testrun/src/main/resources/META-INF/MANIFEST.MF b/hooks/testrun/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index c9b7bd4..0000000 --- a/hooks/testrun/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Name: TestRun validation hook for Polarion ALM Interceptor plugin -Main-Class: ch.sbb.polarion.extension.interceptor_hooks.testrun.TestRunHook diff --git a/hooks/title-length-check/.gitignore b/hooks/title-length-check/.gitignore deleted file mode 100644 index 824ec60..0000000 --- a/hooks/title-length-check/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# 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 diff --git a/hooks/title-length-check/README.md b/hooks/title-length-check/README.md deleted file mode 100644 index 52a401d..0000000 --- a/hooks/title-length-check/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Hook example for Polarion Interceptor extension - -This hook validates the length of title for workitems and documents. - -## 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.-.jar` should be copied to `/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. diff --git a/hooks/title-length-check/pom.xml b/hooks/title-length-check/pom.xml deleted file mode 100644 index 8107109..0000000 --- a/hooks/title-length-check/pom.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - 4.0.0 - - ch.sbb.polarion.extensions.interceptor-hooks - ch.sbb.polarion.extension.interceptor-hooks.title-length-check - 2.0.1-SNAPSHOT - jar - - - 2.0.0 - - ch.sbb.polarion.extension.interceptor_hooks.title_length_check - title-length-check - - ch.sbb.polarion.extension.interceptor - hooks - - 17 - 17 - 2404 - - UTF-8 - yyyy-MM-dd HH:mm - - - 3.3.2 - 3.4.1 - 3.6.1 - - - 24.0.1 - - - ${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}.${project.artifact.selectedVersion.incrementalVersion} - - - - - install-to-local-polarion - - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - *${maven-jar-plugin.Extension-Context}*.jar - - false - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - copy-to-local-polarion - install - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ${env.POLARION_HOME}/polarion/extensions/${interceptor.artifactId}/eclipse/plugins/${hooks.folder.name} - - - - - - - - - - - - - ch.sbb.polarion.extensions - ch.sbb.polarion.extension.interceptor - ${ch.sbb.polarion.extension.interceptor.version} - provided - - - - - com.polarion.alm.projects - projects - ${polarion.version} - provided - - - com.polarion.alm.tracker - tracker - ${polarion.version} - provided - - - com.polarion.platform.persistence - platform-persistence - ${polarion.version} - provided - - - com.polarion.core.util - util - ${polarion.version} - provided - - - - - org.jetbrains - annotations - ${jetbrains.api.version} - provided - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - src/main/resources/META-INF/MANIFEST.MF - - - - - - - - diff --git a/hooks/title-length-check/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/title_length_check/TitleLengthHook.java b/hooks/title-length-check/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/title_length_check/TitleLengthHook.java deleted file mode 100644 index a21e01e..0000000 --- a/hooks/title-length-check/src/main/java/ch/sbb/polarion/extension/interceptor_hooks/title_length_check/TitleLengthHook.java +++ /dev/null @@ -1,52 +0,0 @@ -package ch.sbb.polarion.extension.interceptor_hooks.title_length_check; - -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.alm.tracker.model.IWorkItem; -import com.polarion.core.util.logging.Logger; -import com.polarion.platform.persistence.model.IPObject; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -@SuppressWarnings("unused") -public class TitleLengthHook extends ActionHook implements HookExecutor { - - private static final String SETTINGS_ERROR_MESSAGE = "errorMessage"; - private static final String SETTINGS_MAX_LENGTH = "titleMaxLength"; - private static final String MAX_LENGTH_VARIABLE = "{%s}".formatted(SETTINGS_MAX_LENGTH); - private static final String DEFAULT_ERROR_MESSAGE = "Title length is over the limit (" + MAX_LENGTH_VARIABLE + " symbols). Please correct it before saving"; - private static final int DEFAULT_MAX_LENGTH = 256; - private static final String VERSION = "2.0.0"; - private static final Logger logger = Logger.getLogger(TitleLengthHook.class); - - public TitleLengthHook() { - super(List.of(ItemType.WORKITEM, ItemType.MODULE), ActionType.SAVE, VERSION, "Validates title length"); - } - - @Override - public String preAction(@NotNull IPObject object) { - int maxLength = DEFAULT_MAX_LENGTH; - String maxLengthStringValue = getSettingsValue(SETTINGS_MAX_LENGTH); - try { - maxLength = Integer.parseInt(maxLengthStringValue); - } catch (NumberFormatException e) { - logger.error("Cannot parse max length value '%s'".formatted(maxLengthStringValue), e); - } - return ((IWorkItem) object).getTitle().length() > maxLength ? getSettingsValue(SETTINGS_ERROR_MESSAGE).replace(MAX_LENGTH_VARIABLE, String.valueOf(maxLength)) : null; - } - - @Override - public @NotNull HookExecutor getExecutor() { - return this; //there is no need to create a separate executor instance coz only 'pre' action used - } - - @Override - public String getDefaultSettings() { - return PropertiesUtils.build( - SETTINGS_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE, - SETTINGS_MAX_LENGTH, String.valueOf(DEFAULT_MAX_LENGTH) - ); - } -} diff --git a/hooks/title-length-check/src/main/resources/META-INF/MANIFEST.MF b/hooks/title-length-check/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index a3c7b06..0000000 --- a/hooks/title-length-check/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Name: Title length hook for Polarion ALM Interceptor plugin -Main-Class: ch.sbb.polarion.extension.interceptor_hooks.title_length_check.TitleLengthHook