Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies {
implementation 'com.epam.reportportal:service-api'
annotationProcessor 'com.epam.reportportal:service-api'
} else {
implementation 'com.github.reportportal:service-api:3e34a90'
annotationProcessor 'com.github.reportportal:service-api:3e34a90'
implementation 'com.github.reportportal:service-api:a47f5cf'
annotationProcessor 'com.github.reportportal:service-api:a47f5cf'
}
implementation 'jakarta.el:jakarta.el-api:6.0.1'
implementation 'org.glassfish:jakarta.el:4.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import com.epam.reportportal.extension.PluginCommand;
import com.epam.reportportal.extension.ReportPortalExtensionPoint;
import com.epam.reportportal.extension.common.IntegrationTypeProperties;
import com.epam.reportportal.extension.event.PluginEvent;
import com.epam.reportportal.extension.event.StartLaunchEvent;
import com.epam.reportportal.core.events.domain.PluginUploadedEvent;
import com.epam.reportportal.extension.jira.command.GetIssueCommand;
import com.epam.reportportal.extension.jira.command.GetIssueFieldsCommand;
import com.epam.reportportal.extension.jira.command.GetIssueTypesCommand;
Expand All @@ -34,16 +33,13 @@
import com.epam.reportportal.extension.jira.command.UserSearchCommand;
import com.epam.reportportal.extension.jira.command.utils.CloudJiraClientProvider;
import com.epam.reportportal.extension.jira.command.utils.JIRATicketDescriptionService;
import com.epam.reportportal.extension.jira.event.launch.StartLaunchEventListener;
import com.epam.reportportal.extension.jira.event.plugin.PluginEventHandlerFactory;
import com.epam.reportportal.extension.jira.event.plugin.PluginEventListener;
import com.epam.reportportal.extension.jira.event.plugin.PluginLoadedEventListener;
import com.epam.reportportal.extension.jira.info.impl.PluginInfoProviderImpl;
import com.epam.reportportal.extension.jira.utils.MemoizingSupplier;
import com.epam.reportportal.extension.util.RequestEntityConverter;
import com.epam.reportportal.infrastructure.persistence.binary.DataStoreService;
import com.epam.reportportal.infrastructure.persistence.dao.IntegrationRepository;
import com.epam.reportportal.infrastructure.persistence.dao.IntegrationTypeRepository;
import com.epam.reportportal.infrastructure.persistence.dao.LaunchRepository;
import com.epam.reportportal.infrastructure.persistence.dao.LogRepository;
import com.epam.reportportal.infrastructure.persistence.dao.ProjectRepository;
import com.epam.reportportal.infrastructure.persistence.dao.TestItemRepository;
Expand Down Expand Up @@ -98,8 +94,7 @@ public class CloudJiraExtension implements ReportPortalExtensionPoint, Disposabl
private final ObjectMapper objectMapper;
private final RequestEntityConverter requestEntityConverter;

private final Supplier<ApplicationListener<PluginEvent>> pluginLoadedListenerSupplier;
private final Supplier<ApplicationListener<StartLaunchEvent>> startLaunchEventListenerSupplier;
private final Supplier<ApplicationListener<PluginUploadedEvent>> pluginLoadedListenerSupplier;

private final Supplier<CloudJiraClientProvider> cloudJiraClientProviderSupplier;

Expand All @@ -122,9 +117,6 @@ public class CloudJiraExtension implements ReportPortalExtensionPoint, Disposabl
@Autowired
private OrganizationRepositoryCustom organizationRepository;

@Autowired
private LaunchRepository launchRepository;

@Autowired
private LogRepository logRepository;

Expand All @@ -143,12 +135,10 @@ public CloudJiraExtension(Map<String, Object> initParams) {
.orElse("");
objectMapper = configureObjectMapper();

pluginLoadedListenerSupplier = new MemoizingSupplier<>(() -> new PluginEventListener(
PLUGIN_ID, new PluginEventHandlerFactory(integrationTypeRepository, integrationRepository,
pluginLoadedListenerSupplier = new MemoizingSupplier<>(() -> new PluginLoadedEventListener(
PLUGIN_ID, integrationTypeRepository, integrationRepository,
new PluginInfoProviderImpl(resourcesDir, BINARY_DATA_PROPERTIES_FILE_ID)
)));
startLaunchEventListenerSupplier =
new MemoizingSupplier<>(() -> new StartLaunchEventListener(launchRepository));
));

requestEntityConverter = new RequestEntityConverter(objectMapper);

Expand Down Expand Up @@ -204,7 +194,6 @@ private void initListeners() {
ApplicationEventMulticaster.class
);
applicationEventMulticaster.addApplicationListener(pluginLoadedListenerSupplier.get());
applicationEventMulticaster.addApplicationListener(startLaunchEventListenerSupplier.get());
}

@Override
Expand All @@ -218,7 +207,6 @@ private void removeListeners() {
ApplicationEventMulticaster.class
);
applicationEventMulticaster.removeApplicationListener(pluginLoadedListenerSupplier.get());
applicationEventMulticaster.removeApplicationListener(startLaunchEventListenerSupplier.get());
}

private Map<String, CommonPluginCommand<?>> getCommonCommands() {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.epam.reportportal.extension.jira.event.handler.plugin;
package com.epam.reportportal.extension.jira.event.plugin;

import com.epam.reportportal.extension.event.PluginEvent;
import com.epam.reportportal.extension.jira.event.handler.EventHandler;
import com.epam.reportportal.core.events.domain.PluginUploadedEvent;
import com.epam.reportportal.extension.jira.info.PluginInfoProvider;
import com.epam.reportportal.infrastructure.persistence.dao.IntegrationRepository;
import com.epam.reportportal.infrastructure.persistence.dao.IntegrationTypeRepository;
Expand All @@ -26,32 +25,48 @@
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
import org.springframework.context.ApplicationListener;

/**
* Event listener for plugin loaded events.
* Updates integration type information when the Jira Cloud plugin is uploaded.
*
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
public class PluginLoadedEventHandler implements EventHandler<PluginEvent> {
public class PluginLoadedEventListener implements ApplicationListener<PluginUploadedEvent> {

private final String pluginId;
private final IntegrationTypeRepository integrationTypeRepository;
private final IntegrationRepository integrationRepository;
private final PluginInfoProvider pluginInfoProvider;

public PluginLoadedEventHandler(IntegrationTypeRepository integrationTypeRepository,
public PluginLoadedEventListener(String pluginId,
IntegrationTypeRepository integrationTypeRepository,
IntegrationRepository integrationRepository,
PluginInfoProvider pluginInfoProvider) {
this.pluginId = pluginId;
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
this.pluginInfoProvider = pluginInfoProvider;
}

@Override
public void handle(PluginEvent event) {
integrationTypeRepository.findByName(event.getPluginId()).ifPresent(integrationType -> {
createIntegration(event.getPluginId(), integrationType);
public void onApplicationEvent(PluginUploadedEvent event) {
if (!supports(event)) {
return;
}

String eventPluginId = event.getPluginActivityResource().getName();
integrationTypeRepository.findByName(eventPluginId).ifPresent(integrationType -> {
createIntegration(eventPluginId, integrationType);
integrationTypeRepository.save(pluginInfoProvider.provide(integrationType));
});
}

private boolean supports(PluginUploadedEvent event) {
return pluginId.equals(event.getPluginActivityResource().getName());
}

private void createIntegration(String name, IntegrationType integrationType) {
List<Integration> integrations = integrationRepository.findAllGlobalByType(integrationType);
if (integrations.isEmpty()) {
Expand All @@ -65,5 +80,4 @@ private void createIntegration(String name, IntegrationType integrationType) {
integrationRepository.save(integration);
}
}

}