From 5915db70b05e84a082c4d053749d18e7f5ffa325 Mon Sep 17 00:00:00 2001
From: Azmi TOUIL <42934070+AzmiTouil@users.noreply.github.com>
Date: Fri, 16 Aug 2024 15:59:16 +0200
Subject: [PATCH] feat: Upgrade Service to Spring - MEED-6830 -
Meeds-io/MIPs#132 (#192)
This change will upgrade services to use spring instead of Kernel & WS.
---
gamification-github-services/pom.xml | 8 +-
.../gamification/github/dao/WebHookDAO.java | 53 ---
.../github/plugin/IssueTriggerPlugin.java | 75 ----
.../PullRequestReviewTriggerPlugin.java | 59 ---
.../github/rest/HooksManagementRest.java | 296 -------------
.../cached/GithubConsumerCachedStorage.java | 109 -----
.../github/storage/cached/model/CacheKey.java | 71 ----
.../github/gamification/dao/WebHookDAO.java | 27 ++
.../gamification}/entity/WebhookEntity.java | 10 +-
.../exception/GithubConnectionException.java | 2 +-
.../listener/GithubEventsListener.java | 24 +-
.../gamification}/model/Event.java | 2 +-
.../model/GithubAccessTokenContext.java | 2 +-
.../model/RemoteOrganization.java | 2 +-
.../gamification}/model/RemoteRepository.java | 2 +-
.../gamification}/model/TokenStatus.java | 2 +-
.../gamification}/model/WebHook.java | 2 +-
.../CommentPullRequestTriggerPlugin.java | 27 +-
.../plugin/CommentTriggerPlugin.java | 27 +-
.../plugin/GithubConnectorPlugin.java | 39 +-
.../plugin/GithubEventPlugin.java | 17 +-
.../plugin/GithubTriggerPlugin.java | 8 +-
.../plugin/IssueTriggerPlugin.java | 95 +++++
.../PullRequestReviewTriggerPlugin.java | 79 ++++
.../plugin/PullRequestTriggerPlugin.java | 27 +-
.../plugin/PushCodeTriggerPlugin.java | 29 +-
.../gamification}/rest/GithubWebHookRest.java | 32 +-
.../rest/HooksManagementRest.java | 263 ++++++++++++
.../rest/builder/WebHookBuilder.java | 22 +-
.../rest/model/RepositoryList.java | 4 +-
.../rest/model/RepositoryRestEntity.java | 2 +-
.../gamification}/rest/model/WebHookList.java | 2 +-
.../rest/model/WebHookRestEntity.java | 4 +-
.../scheduling/SchedulingConfig.java | 26 ++
.../task/GitHubWebHookForceUpdateTask.java} | 29 +-
.../services/GithubConsumerService.java | 17 +-
.../services/GithubTriggerService.java | 6 +-
.../services/WebhookService.java | 63 +--
.../impl/GithubConsumerServiceImpl.java | 29 +-
.../impl/GithubTriggerServiceImpl.java | 45 +-
.../services/impl/WebhookServiceImpl.java | 96 ++---
.../storage/GithubConsumerStorage.java | 30 +-
.../gamification}/storage/WebHookStorage.java | 58 ++-
.../storage/mapper/WebHookMapper.java | 15 +-
.../utils/StringListConverter.java | 2 +-
.../gamification}/utils/Utils.java | 2 +-
.../resources/conf/portal/configuration.xml | 95 -----
...ification-github-storage-configuration.xml | 79 ----
.../src/main/resources/jpa-entities.idx | 2 +-
.../gamification/github/BaseGithubTest.java | 141 -------
.../github/dao/WebHookDAOTest.java | 85 ----
.../github/mock/ConnectorServiceMock.java | 68 ---
.../mock/ConnectorSettingServiceMock.java | 63 ---
.../github/mock/EventServiceMock.java | 83 ----
.../github/mock/IdentityManagerMock.java | 237 -----------
.../github/mock/RuleServiceMock.java | 97 -----
.../github/mock/TriggerServiceMock.java | 39 --
.../github/service/WebhookServiceTest.java | 197 ---------
.../listener/GithubEventsListenerTest.java | 70 ++++
.../plugin/GithubConnectorPluginTest.java | 40 ++
.../plugin/GithubEventPluginTest.java | 25 +-
.../rest/GithubWebHookRestTest.java | 81 ++++
.../rest/HooksManagementRestTest.java | 390 ++++++++++++++++++
.../service/WebhookServiceTest.java | 209 ++++++++++
.../storage/WebHookStorageTest.java | 134 ++++++
.../conf/portal/github-test-configuration.xml | 12 +-
gamification-github-webapp/pom.xml | 5 +
.../GamificationGithubApplication.java | 44 ++
.../src/main/resources/github.properties | 20 +
.../webapp/html/gitHubWebHookManagement.html | 7 -
.../skin/less/gitHubWebHookManagement.less | 144 -------
.../components/GithubEventForm.vue | 7 +-
.../GithubAdminConnectorHookList.vue | 9 +-
.../initComponents.js | 2 +-
.../js/GithubConnectorService.js | 49 +--
75 files changed, 1914 insertions(+), 2361 deletions(-)
delete mode 100644 gamification-github-services/src/main/java/io/meeds/gamification/github/dao/WebHookDAO.java
delete mode 100644 gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/IssueTriggerPlugin.java
delete mode 100644 gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/PullRequestReviewTriggerPlugin.java
delete mode 100644 gamification-github-services/src/main/java/io/meeds/gamification/github/rest/HooksManagementRest.java
delete mode 100644 gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/GithubConsumerCachedStorage.java
delete mode 100644 gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/model/CacheKey.java
create mode 100644 gamification-github-services/src/main/java/io/meeds/github/gamification/dao/WebHookDAO.java
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/entity/WebhookEntity.java (83%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/exception/GithubConnectionException.java (96%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/listener/GithubEventsListener.java (77%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/model/Event.java (96%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/model/GithubAccessTokenContext.java (97%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/model/RemoteOrganization.java (96%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/model/RemoteRepository.java (96%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/model/TokenStatus.java (96%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/model/WebHook.java (97%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/plugin/CommentPullRequestTriggerPlugin.java (70%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/plugin/CommentTriggerPlugin.java (78%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/plugin/GithubConnectorPlugin.java (82%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/plugin/GithubEventPlugin.java (87%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/plugin/GithubTriggerPlugin.java (86%)
create mode 100644 gamification-github-services/src/main/java/io/meeds/github/gamification/plugin/IssueTriggerPlugin.java
create mode 100644 gamification-github-services/src/main/java/io/meeds/github/gamification/plugin/PullRequestReviewTriggerPlugin.java
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/plugin/PullRequestTriggerPlugin.java (85%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/plugin/PushCodeTriggerPlugin.java (68%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/rest/GithubWebHookRest.java (61%)
create mode 100644 gamification-github-services/src/main/java/io/meeds/github/gamification/rest/HooksManagementRest.java
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/rest/builder/WebHookBuilder.java (79%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/rest/model/RepositoryList.java (91%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/rest/model/RepositoryRestEntity.java (95%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/rest/model/WebHookList.java (96%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/rest/model/WebHookRestEntity.java (96%)
create mode 100644 gamification-github-services/src/main/java/io/meeds/github/gamification/scheduling/SchedulingConfig.java
rename gamification-github-services/src/main/java/io/meeds/{gamification/github/scheduled/GitHubWebHookForceUpdate.java => github/gamification/scheduling/task/GitHubWebHookForceUpdateTask.java} (58%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/services/GithubConsumerService.java (89%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/services/GithubTriggerService.java (92%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/services/WebhookService.java (80%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/services/impl/GithubConsumerServiceImpl.java (81%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/services/impl/GithubTriggerServiceImpl.java (84%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/services/impl/WebhookServiceImpl.java (82%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/storage/GithubConsumerStorage.java (94%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/storage/WebHookStorage.java (58%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/storage/mapper/WebHookMapper.java (87%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/utils/StringListConverter.java (97%)
rename gamification-github-services/src/main/java/io/meeds/{gamification/github => github/gamification}/utils/Utils.java (99%)
delete mode 100644 gamification-github-services/src/main/resources/conf/portal/gamification-github-storage-configuration.xml
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/BaseGithubTest.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/dao/WebHookDAOTest.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/mock/ConnectorServiceMock.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/mock/ConnectorSettingServiceMock.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/mock/EventServiceMock.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/mock/IdentityManagerMock.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/mock/RuleServiceMock.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/mock/TriggerServiceMock.java
delete mode 100644 gamification-github-services/src/test/java/io/meeds/gamification/github/service/WebhookServiceTest.java
create mode 100644 gamification-github-services/src/test/java/io/meeds/github/gamification/listener/GithubEventsListenerTest.java
create mode 100644 gamification-github-services/src/test/java/io/meeds/github/gamification/plugin/GithubConnectorPluginTest.java
rename gamification-github-services/src/test/java/io/meeds/{gamification/github => github/gamification}/plugin/GithubEventPluginTest.java (84%)
create mode 100644 gamification-github-services/src/test/java/io/meeds/github/gamification/rest/GithubWebHookRestTest.java
create mode 100644 gamification-github-services/src/test/java/io/meeds/github/gamification/rest/HooksManagementRestTest.java
create mode 100644 gamification-github-services/src/test/java/io/meeds/github/gamification/service/WebhookServiceTest.java
create mode 100644 gamification-github-services/src/test/java/io/meeds/github/gamification/storage/WebHookStorageTest.java
create mode 100644 gamification-github-webapp/src/main/java/io/meeds/github/gamification/GamificationGithubApplication.java
create mode 100644 gamification-github-webapp/src/main/resources/github.properties
delete mode 100644 gamification-github-webapp/src/main/webapp/html/gitHubWebHookManagement.html
delete mode 100644 gamification-github-webapp/src/main/webapp/skin/less/gitHubWebHookManagement.less
diff --git a/gamification-github-services/pom.xml b/gamification-github-services/pom.xml
index b4398559a..9bd9f3e06 100644
--- a/gamification-github-services/pom.xml
+++ b/gamification-github-services/pom.xml
@@ -32,13 +32,17 @@
jar
Gamification - Github Connector - Services
- 0.24
+ 0.30
+
+ io.meeds.social
+ social-component-core
+ provided
+
io.meeds.social
social-component-oauth-auth
- provided
io.meeds.gamification
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/dao/WebHookDAO.java b/gamification-github-services/src/main/java/io/meeds/gamification/github/dao/WebHookDAO.java
deleted file mode 100644
index 406b2fb87..000000000
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/dao/WebHookDAO.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * This file is part of the Meeds project (https://meeds.io/).
- *
- * Copyright (C) 2020 - 2023 Meeds Lab contact@meedslab.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package io.meeds.gamification.github.dao;
-
-import org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl;
-import io.meeds.gamification.github.entity.WebhookEntity;
-
-import jakarta.persistence.NoResultException;
-import jakarta.persistence.TypedQuery;
-import java.util.List;
-
-public class WebHookDAO extends GenericDAOJPAImpl {
-
- public static final String ORGANIZATION_ID = "organizationId";
-
- public WebhookEntity getWebhookByOrganizationId(long organizationId) {
- TypedQuery query = getEntityManager().createNamedQuery("GitHubWebhooks.getWebhookByOrganizationId",
- WebhookEntity.class);
- query.setParameter(ORGANIZATION_ID, organizationId);
- try {
- return query.getSingleResult();
- } catch (NoResultException e) {
- return null;
- }
- }
-
- public List getWebhookIds(int offset, int limit) {
- TypedQuery query = getEntityManager().createNamedQuery("GitHubWebhooks.getWebhookIds", Long.class);
- if (offset > 0) {
- query.setFirstResult(offset);
- }
- if (limit > 0) {
- query.setMaxResults(limit);
- }
- return query.getResultList();
- }
-}
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/IssueTriggerPlugin.java b/gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/IssueTriggerPlugin.java
deleted file mode 100644
index e081a6a07..000000000
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/IssueTriggerPlugin.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * This file is part of the Meeds project (https://meeds.io/).
- *
- * Copyright (C) 2020 - 2023 Meeds Lab contact@meedslab.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package io.meeds.gamification.github.plugin;
-
-import io.meeds.gamification.github.model.Event;
-import static io.meeds.gamification.github.utils.Utils.*;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-public class IssueTriggerPlugin extends GithubTriggerPlugin {
-
- @Override
- public List getEvents(Map payload) {
- String issueState = extractSubItem(payload, ACTION);
- String objectId = extractSubItem(payload, ISSUE, HTML_URL);
- String userId = extractSubItem(payload, SENDER, LOGIN);
- if (Objects.equals(issueState, OPENED)) {
- return Collections.singletonList(new Event(CREATE_ISSUE_EVENT_NAME,
- userId,
- userId,
- objectId,
- ISSUE_TYPE,
- extractSubItem(payload, "organization", "id"),
- extractSubItem(payload, "repository", "id")));
- } else if (Objects.equals(issueState, CLOSED)) {
- if (Objects.equals(extractSubItem(payload, ISSUE, STATE_REASON), NOT_PLANNED)) {
- return Collections.singletonList(new Event(CLOSE_ISSUE_EVENT_NAME,
- userId,
- userId,
- objectId,
- ISSUE_TYPE,
- extractSubItem(payload, "organization", "id"),
- extractSubItem(payload, "repository", "id")));
- }
- return Collections.emptyList();
- } else if (Objects.equals(issueState, LABELED)) {
- objectId = objectId + "?label=" + extractSubItem(payload, LABEL, NAME);
- return Collections.singletonList(new Event(ADD_ISSUE_LABEL_EVENT_NAME,
- userId,
- userId,
- objectId,
- ISSUE_TYPE,
- extractSubItem(payload, ORGANIZATION, ID),
- extractSubItem(payload, REPOSITORY, ID)));
- } else if (Objects.equals(issueState, UNLABELED)) {
- objectId = objectId + "?label=" + extractSubItem(payload, LABEL, NAME);
- return Collections.singletonList(new Event(DELETE_ISSUE_LABEL_EVENT_NAME,
- userId,
- userId,
- objectId,
- ISSUE_TYPE,
- extractSubItem(payload, ORGANIZATION, ID),
- extractSubItem(payload, REPOSITORY, ID)));
- }
- return Collections.emptyList();
- }
-}
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/PullRequestReviewTriggerPlugin.java b/gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/PullRequestReviewTriggerPlugin.java
deleted file mode 100644
index b2b471127..000000000
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/plugin/PullRequestReviewTriggerPlugin.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of the Meeds project (https://meeds.io/).
- *
- * Copyright (C) 2020 - 2023 Meeds Lab contact@meedslab.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package io.meeds.gamification.github.plugin;
-
-import io.meeds.gamification.github.model.Event;
-import static io.meeds.gamification.github.utils.Utils.*;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-public class PullRequestReviewTriggerPlugin extends GithubTriggerPlugin {
-
- @Override
- public List getEvents(Map payload) {
- String pullState = extractSubItem(payload, PULL_REQUEST_REVIEW, STATE);
- if (pullState != null && pullState.equals(PULL_REQUEST_COMMENTED)) {
- return Collections.singletonList(new Event(REVIEW_PULL_REQUEST_EVENT_NAME,
- extractSubItem(payload, PULL_REQUEST_REVIEW, USER, LOGIN),
- extractSubItem(payload, PULL_REQUEST_REVIEW, USER, LOGIN),
- extractSubItem(payload, PULL_REQUEST_REVIEW, HTML_URL),
- PR_TYPE,
- extractSubItem(payload, ORGANIZATION, ID),
- extractSubItem(payload, REPOSITORY, ID)));
- } else if (pullState != null && pullState.equals(PULL_REQUEST_VALIDATED)) {
- return Arrays.asList(new Event(PULL_REQUEST_VALIDATED_EVENT_NAME,
- extractSubItem(payload, PULL_REQUEST, USER, LOGIN),
- extractSubItem(payload, PULL_REQUEST, USER, LOGIN),
- extractSubItem(payload, PULL_REQUEST_REVIEW, HTML_URL),
- PR_TYPE,
- extractSubItem(payload, ORGANIZATION, ID),
- extractSubItem(payload, REPOSITORY, ID)),
- new Event(VALIDATE_PULL_REQUEST_EVENT_NAME,
- extractSubItem(payload, PULL_REQUEST_REVIEW, USER, LOGIN),
- extractSubItem(payload, PULL_REQUEST_REVIEW, USER, LOGIN),
- extractSubItem(payload, PULL_REQUEST_REVIEW, HTML_URL),
- PR_TYPE,
- extractSubItem(payload, ORGANIZATION, ID),
- extractSubItem(payload, REPOSITORY, ID)));
- }
- return Collections.emptyList();
- }
-}
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/rest/HooksManagementRest.java b/gamification-github-services/src/main/java/io/meeds/gamification/github/rest/HooksManagementRest.java
deleted file mode 100644
index 1fbf91efc..000000000
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/rest/HooksManagementRest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * This file is part of the Meeds project (https://meeds.io/).
- *
- * Copyright (C) 2020 - 2022 Meeds Lab contact@meedslab.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package io.meeds.gamification.github.rest;
-
-import javax.annotation.security.RolesAllowed;
-import javax.ws.rs.*;
-import javax.ws.rs.core.*;
-
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.responses.ApiResponses;
-import org.apache.commons.lang3.StringUtils;
-
-import org.exoplatform.commons.ObjectAlreadyExistsException;
-import org.exoplatform.commons.exception.ObjectNotFoundException;
-import io.meeds.gamification.github.model.RemoteRepository;
-import io.meeds.gamification.github.model.WebHook;
-import io.meeds.gamification.github.rest.builder.WebHookBuilder;
-import io.meeds.gamification.github.rest.model.RepositoryList;
-import io.meeds.gamification.github.rest.model.WebHookList;
-import io.meeds.gamification.github.rest.model.WebHookRestEntity;
-import io.meeds.gamification.github.services.GithubConsumerService;
-import io.meeds.gamification.github.services.WebhookService;
-import org.exoplatform.services.rest.http.PATCH;
-import org.exoplatform.services.rest.resource.ResourceContainer;
-import org.exoplatform.services.security.ConversationState;
-
-import java.util.Collection;
-import java.util.List;
-
-import static io.meeds.gamification.utils.Utils.getCurrentUser;
-
-@Path("/gamification/connectors/github/hooks")
-public class HooksManagementRest implements ResourceContainer {
-
- public static final String GITHUB_HOOK_NOT_FOUND = "The GitHub hook doesn't exit";
-
- private final WebhookService webhookService;
-
- private final GithubConsumerService githubConsumerService;
-
- public HooksManagementRest(WebhookService webhookService, GithubConsumerService githubConsumerService) {
- this.webhookService = webhookService;
- this.githubConsumerService = githubConsumerService;
- }
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @RolesAllowed("users")
- @Operation(summary = "Retrieves the list GitHub webHooks", method = "GET")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Request fulfilled"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"), })
- public Response getWebHooks(@QueryParam("offset") int offset,
- @Parameter(description = "Query results limit", required = true) @QueryParam("limit") int limit,
- @Parameter(description = "WebHook total size") @Schema(defaultValue = "false") @QueryParam("returnSize") boolean returnSize) {
-
- String currentUser = getCurrentUser();
- List webHookRestEntities;
- try {
- WebHookList webHookList = new WebHookList();
- webHookRestEntities = getWebHookRestEntities(currentUser);
- if (returnSize) {
- int webHookSize = webhookService.countWebhooks(currentUser, false);
- webHookList.setSize(webHookSize);
- }
- webHookList.setWebhooks(webHookRestEntities);
- webHookList.setOffset(offset);
- webHookList.setLimit(limit);
- return Response.ok(webHookList).build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).build();
- }
- }
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Path("{webHookId}")
- @RolesAllowed("users")
- @Operation(summary = "Retrieves a webHook by its technical identifier", method = "GET")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Request fulfilled"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"),
- @ApiResponse(responseCode = "400", description = "Invalid query input"),
- @ApiResponse(responseCode = "404", description = "Not found"),
- @ApiResponse(responseCode = "500", description = "Internal server error"), })
- public Response getWebHookById(@Parameter(description = "WebHook technical identifier", required = true) @PathParam("webHookId") long webHookId) {
- if (webHookId == 0) {
- return Response.status(Response.Status.BAD_REQUEST).entity("WebHook Id must be not null").build();
- }
- String currentUser = getCurrentUser();
- try {
- WebHook webHook = webhookService.getWebhookId(webHookId, currentUser);
- return Response.ok(WebHookBuilder.toRestEntity(webhookService, githubConsumerService, webHook)).build();
- } catch (IllegalArgumentException e) {
- return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).entity(e.getMessage()).build();
- } catch (ObjectNotFoundException e) {
- return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
- }
- }
-
- @POST
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @RolesAllowed("users")
- @Operation(summary = "Create a organization webhook for Remote GitHub connector.", description = "Create a organization webhook for Remote GitHub connector.", method = "POST")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Request fulfilled"),
- @ApiResponse(responseCode = "400", description = "Invalid query input"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"),
- @ApiResponse(responseCode = "500", description = "Internal server error") })
- public Response createWebhookHook(@Parameter(description = "GitHub organization name", required = true) @FormParam("organizationName") String organizationName,
- @Parameter(description = "GitHub personal access token", required = true) @FormParam("accessToken") String accessToken) {
-
- if (StringUtils.isBlank(organizationName)) {
- return Response.status(Response.Status.BAD_REQUEST).entity("'organizationName' parameter is mandatory").build();
- }
- if (StringUtils.isBlank(accessToken)) {
- return Response.status(Response.Status.BAD_REQUEST).entity("'accessToken' parameter is mandatory").build();
- }
- String currentUser = ConversationState.getCurrent().getIdentity().getUserId();
- try {
- webhookService.createWebhook(organizationName, accessToken, currentUser);
- return Response.status(Response.Status.CREATED).build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).entity(e.getMessage()).build();
- } catch (ObjectAlreadyExistsException e) {
- return Response.status(Response.Status.CONFLICT).entity(e.getMessage()).build();
- } catch (ObjectNotFoundException e) {
- return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
- }
- }
-
- @PATCH
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @RolesAllowed("users")
- @Operation(summary = "Update a organization webhook personal access token.", description = "Update a organization webhook personal access token.", method = "PATCH")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Request fulfilled"),
- @ApiResponse(responseCode = "400", description = "Invalid query input"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"),
- @ApiResponse(responseCode = "500", description = "Internal server error") })
- public Response updateWebHookAccessToken(@Parameter(description = "webHook id", required = true) @FormParam("webHookId") long webHookId,
- @Parameter(description = "GitHub personal access token", required = true) @FormParam("accessToken") String accessToken) {
-
- if (webHookId <= 0) {
- return Response.status(Response.Status.BAD_REQUEST).entity("'webHookId' must be positive").build();
- }
- if (StringUtils.isBlank(accessToken)) {
- return Response.status(Response.Status.BAD_REQUEST).entity("'accessToken' parameter is mandatory").build();
- }
- String currentUser = ConversationState.getCurrent().getIdentity().getUserId();
- try {
- webhookService.updateWebHookAccessToken(webHookId, accessToken, currentUser);
- return Response.status(Response.Status.CREATED).build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).entity(e.getMessage()).build();
- } catch (ObjectNotFoundException e) {
- return Response.status(Response.Status.NOT_FOUND).entity(GITHUB_HOOK_NOT_FOUND).build();
- }
- }
-
- @DELETE
- @Path("{organizationId}")
- @RolesAllowed("users")
- @Operation(summary = "Deletes gitHub organization webhook", description = "Deletes gitHub organization webhook", method = "DELETE")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "204", description = "Request fulfilled"),
- @ApiResponse(responseCode = "400", description = "Bad request"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"),
- @ApiResponse(responseCode = "500", description = "Internal server error"), })
- public Response deleteWebhookHook(@Parameter(description = "GitHub organization id", required = true) @PathParam("organizationId") long organizationId) {
- if (organizationId <= 0) {
- return Response.status(Response.Status.BAD_REQUEST).entity("'hookName' parameter is mandatory").build();
- }
- String currentUser = ConversationState.getCurrent().getIdentity().getUserId();
- try {
- webhookService.deleteWebhook(organizationId, currentUser);
- return Response.noContent().build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
- } catch (ObjectNotFoundException e) {
- return Response.status(Response.Status.NOT_FOUND).entity(GITHUB_HOOK_NOT_FOUND).build();
- }
- }
-
- @GET
- @Path("{organizationId}/repos")
- @Produces(MediaType.APPLICATION_JSON)
- @RolesAllowed("users")
- @Operation(summary = "Retrieves the list GitHub organization repositories", method = "GET")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Request fulfilled"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"), })
- public Response getWebHookRepos(@Parameter(description = "GitHub organization id", required = true) @PathParam("organizationId") long organizationId,
- @Parameter(description = "Query page number", required = true) @QueryParam("page") int page,
- @Parameter(description = "Query item per page", required = true) @QueryParam("perPage") int perPage,
- @Parameter(description = "Keyword to search in repositories title", required = true) @QueryParam("keyword") String keyword) {
-
- String currentUser = getCurrentUser();
- List remoteRepositories;
- try {
- RepositoryList repositoryList = new RepositoryList();
- remoteRepositories = webhookService.retrieveOrganizationRepos(organizationId, currentUser, page, perPage, keyword);
- repositoryList.setRemoteRepositories(remoteRepositories);
- repositoryList.setPage(page);
- repositoryList.setPerPage(perPage);
- return Response.ok(repositoryList).build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).build();
- } catch (ObjectNotFoundException e) {
- return Response.status(Response.Status.NOT_FOUND).entity(GITHUB_HOOK_NOT_FOUND).build();
- }
- }
-
- @Path("repo/status")
- @POST
- @RolesAllowed("users")
- @Operation(summary = "enables/disables webhook repository.", description = "enables/disables webhook repository", method = "POST")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "204", description = "Request fulfilled"),
- @ApiResponse(responseCode = "400", description = "Bad request"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"),
- @ApiResponse(responseCode = "500", description = "Internal server error"), })
- public Response updateWebHookRepoStatus(@Parameter(description = "GitHub organization remote Id", required = true) @FormParam("organizationId") long organizationId,
- @Parameter(description = "Organization repository remote Id", required = true) @FormParam("repositoryId") long repositoryId,
- @Parameter(description = "Organization repository status enabled/disabled. possible values: true for enabled, else false", required = true) @FormParam("enabled") boolean enabled) {
-
- String currentUser = getCurrentUser();
- try {
- webhookService.setWebHookRepositoryEnabled(organizationId, repositoryId, enabled, currentUser);
- return Response.noContent().build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
- }
- }
-
- @Path("watchScope/status")
- @POST
- @RolesAllowed("users")
- @Operation(summary = "Limit webhook watch scope or not", description = "Limit webhook watch scope or not", method = "POST")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "204", description = "Request fulfilled"),
- @ApiResponse(responseCode = "400", description = "Bad request"),
- @ApiResponse(responseCode = "401", description = "Unauthorized operation"),
- @ApiResponse(responseCode = "500", description = "Internal server error"), })
- public Response updateWebHookWatchScope(@Parameter(description = "GitHub organization remote Id", required = true) @FormParam("organizationId") long organizationId,
- @Parameter(description = "webhook watch scope limited status enabled/disabled. possible values: true for enabled, else false", required = true) @FormParam("enabled") boolean enabled) {
-
- String currentUser = getCurrentUser();
- try {
- webhookService.setWebHookWatchLimitEnabled(organizationId, enabled, currentUser);
- return Response.noContent().build();
- } catch (IllegalAccessException e) {
- return Response.status(Response.Status.UNAUTHORIZED).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
- }
- }
-
- @Path("forceUpdate")
- @PATCH
- @RolesAllowed("users")
- @Operation(summary = "Force Update a github stored webhooks", description = "Force Update a github stored webhooks", method = "PATCH")
- @ApiResponses(value = { @ApiResponse(responseCode = "500", description = "Internal server error") })
- public Response forceUpdateWebhooks() {
- try {
- webhookService.forceUpdateWebhooks();
- return Response.noContent().build();
- } catch (Exception e) {
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
- }
- }
-
- private List getWebHookRestEntities(String username) throws IllegalAccessException {
- Collection webHooks = webhookService.getWebhooks(username, 0, 20, false);
- return WebHookBuilder.toRestEntities(webhookService, githubConsumerService, webHooks);
- }
-}
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/GithubConsumerCachedStorage.java b/gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/GithubConsumerCachedStorage.java
deleted file mode 100644
index e67d93a26..000000000
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/GithubConsumerCachedStorage.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * This file is part of the Meeds project (https://meeds.io/).
- *
- * Copyright (C) 2020 - 2023 Meeds Lab contact@meedslab.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package io.meeds.gamification.github.storage.cached;
-
-import io.meeds.gamification.github.model.RemoteOrganization;
-import io.meeds.gamification.github.model.WebHook;
-import io.meeds.gamification.github.storage.cached.model.CacheKey;
-import org.exoplatform.commons.cache.future.FutureExoCache;
-import io.meeds.gamification.github.model.RemoteRepository;
-import io.meeds.gamification.github.model.TokenStatus;
-import io.meeds.gamification.github.storage.GithubConsumerStorage;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
-
-import java.io.Serializable;
-import java.util.*;
-
-public class GithubConsumerCachedStorage extends GithubConsumerStorage {
-
- public static final String GITHUB_CACHE_NAME = "github.connector";
-
- private static final int ORG_REPOS_CONTEXT = 0;
-
- private static final int ORG_BY_ID_CONTEXT = 1;
-
- private static final int TOKEN_STATUS_CONTEXT = 2;
-
- private final FutureExoCache githubFutureCache;
-
- public GithubConsumerCachedStorage(CacheService cacheService) {
- ExoCache cacheInstance = cacheService.getCacheInstance(GITHUB_CACHE_NAME);
- this.githubFutureCache = new FutureExoCache<>((context, key) -> {
- if (ORG_REPOS_CONTEXT == context.getContext()) {
- return GithubConsumerCachedStorage.super.retrieveOrganizationRepos(context.getOrganizationName(),
- context.getAccessToken(),
- context.getPage(),
- context.getPerPage(),
- context.getKeyword());
- } else if (ORG_BY_ID_CONTEXT == context.getContext()) {
- return GithubConsumerCachedStorage.super.retrieveRemoteOrganization(context.getOrganizationId(),
- context.getAccessToken());
- } else if (TOKEN_STATUS_CONTEXT == context.getContext()) {
- return GithubConsumerCachedStorage.super.checkGitHubTokenStatus(context.getAccessToken());
- } else {
- throw new UnsupportedOperationException();
- }
- }, cacheInstance);
- }
-
- @Override
- public String deleteWebhookHook(WebHook webHook) {
- try {
- return super.deleteWebhookHook(webHook);
- } finally {
- clearCache(webHook);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public List retrieveOrganizationRepos(String organizationName,
- String accessToken,
- int page,
- int perPage,
- String keyword) {
- CacheKey cacheKey = new CacheKey(ORG_REPOS_CONTEXT, organizationName, accessToken, page, perPage, keyword);
- List remoteRepositories =
- (List) this.githubFutureCache.get(cacheKey, cacheKey.hashCode());
- return remoteRepositories == null ? Collections.emptyList() : remoteRepositories;
- }
-
- @Override
- public RemoteOrganization retrieveRemoteOrganization(long organizationId, String accessToken) {
- CacheKey cacheKey = new CacheKey(ORG_BY_ID_CONTEXT, organizationId, accessToken);
- return (RemoteOrganization) this.githubFutureCache.get(cacheKey, cacheKey.hashCode());
- }
-
- @Override
- public TokenStatus checkGitHubTokenStatus(String token) {
- CacheKey cacheKey = new CacheKey(TOKEN_STATUS_CONTEXT, token);
- return (TokenStatus) this.githubFutureCache.get(cacheKey, cacheKey.hashCode());
- }
-
- @Override
- public void clearCache() {
- this.githubFutureCache.clear();
- }
-
- @Override
- public void clearCache(WebHook webHook) {
- this.githubFutureCache.remove(new CacheKey(ORG_BY_ID_CONTEXT, webHook.getOrganizationId(), webHook.getToken()).hashCode());
- this.githubFutureCache.remove(new CacheKey(TOKEN_STATUS_CONTEXT, webHook.getToken()).hashCode());
- }
-}
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/model/CacheKey.java b/gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/model/CacheKey.java
deleted file mode 100644
index 7a0186e47..000000000
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/storage/cached/model/CacheKey.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file is part of the Meeds project (https://meeds.io/).
- *
- * Copyright (C) 2022 Meeds Lab contact@meedslab.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package io.meeds.gamification.github.storage.cached.model;
-
-import java.io.Serializable;
-
-import io.meeds.gamification.model.filter.ProgramFilter;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@AllArgsConstructor
-@NoArgsConstructor
-@Data
-public class CacheKey implements Serializable {
-
- private static final long serialVersionUID = -8995567724453740730L;
-
- private ProgramFilter programFilter;
-
- private int page;
-
- private int perPage;
-
- private long organizationId;
-
- private String organizationName;
-
- private String accessToken;
-
- private String keyword;
-
- private Integer context;
-
- public CacheKey(Integer context, String organizationName, String accessToken, int page, int perPage, String keyword) {
- this.organizationName = organizationName;
- this.accessToken = accessToken;
- this.page = page;
- this.perPage = perPage;
- this.keyword = keyword;
- this.context = context;
- }
-
- public CacheKey(Integer context, long organizationId, String accessToken) {
- this.organizationId = organizationId;
- this.accessToken = accessToken;
- this.context = context;
- }
-
- public CacheKey(Integer context, String accessToken) {
- this.accessToken = accessToken;
- this.context = context;
- }
-
-}
diff --git a/gamification-github-services/src/main/java/io/meeds/github/gamification/dao/WebHookDAO.java b/gamification-github-services/src/main/java/io/meeds/github/gamification/dao/WebHookDAO.java
new file mode 100644
index 000000000..7ed22a753
--- /dev/null
+++ b/gamification-github-services/src/main/java/io/meeds/github/gamification/dao/WebHookDAO.java
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the Meeds project (https://meeds.io/).
+ *
+ * Copyright (C) 2020 - 2023 Meeds Lab contact@meedslab.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package io.meeds.github.gamification.dao;
+
+import io.meeds.github.gamification.entity.WebhookEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface WebHookDAO extends JpaRepository {
+
+ WebhookEntity findWebhookEntityByOrganizationId(long organizationId);
+}
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/entity/WebhookEntity.java b/gamification-github-services/src/main/java/io/meeds/github/gamification/entity/WebhookEntity.java
similarity index 83%
rename from gamification-github-services/src/main/java/io/meeds/gamification/github/entity/WebhookEntity.java
rename to gamification-github-services/src/main/java/io/meeds/github/gamification/entity/WebhookEntity.java
index 75c8ca471..0e8ce2cc3 100644
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/entity/WebhookEntity.java
+++ b/gamification-github-services/src/main/java/io/meeds/github/gamification/entity/WebhookEntity.java
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package io.meeds.gamification.github.entity;
+package io.meeds.github.gamification.entity;
import java.io.Serializable;
import java.util.Date;
@@ -29,12 +29,6 @@
@Entity(name = "GitHubWebhooks")
@Table(name = "GITHUB_WEBHOOKS")
-@NamedQuery(name = "GitHubWebhooks.getWebhookByOrganizationId",
- query = "SELECT gitHubWebhook FROM GitHubWebhooks gitHubWebhook"
- + " WHERE gitHubWebhook.organizationId = :organizationId")
-@NamedQuery(name = "GitHubWebhooks.getWebhookIds",
- query = "SELECT gitHubWebhook.id FROM GitHubWebhooks gitHubWebhook"
- + " ORDER BY gitHubWebhook.id ASC")
@Data
public class WebhookEntity implements Serializable {
@@ -53,7 +47,7 @@ public class WebhookEntity implements Serializable {
private Long organizationId;
@Column(name = "ORGANIZATION_NAME", nullable = false)
- private String organizationName;
+ private String organizationName;
@Convert(converter = StringListConverter.class)
@Column(name = "TRIGGERS", nullable = false)
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/exception/GithubConnectionException.java b/gamification-github-services/src/main/java/io/meeds/github/gamification/exception/GithubConnectionException.java
similarity index 96%
rename from gamification-github-services/src/main/java/io/meeds/gamification/github/exception/GithubConnectionException.java
rename to gamification-github-services/src/main/java/io/meeds/github/gamification/exception/GithubConnectionException.java
index f7a0f774b..06080daa6 100644
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/exception/GithubConnectionException.java
+++ b/gamification-github-services/src/main/java/io/meeds/github/gamification/exception/GithubConnectionException.java
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package io.meeds.gamification.github.exception;
+package io.meeds.github.gamification.exception;
public class GithubConnectionException extends Exception {
diff --git a/gamification-github-services/src/main/java/io/meeds/gamification/github/listener/GithubEventsListener.java b/gamification-github-services/src/main/java/io/meeds/github/gamification/listener/GithubEventsListener.java
similarity index 77%
rename from gamification-github-services/src/main/java/io/meeds/gamification/github/listener/GithubEventsListener.java
rename to gamification-github-services/src/main/java/io/meeds/github/gamification/listener/GithubEventsListener.java
index bbd177c1a..a85a648ee 100644
--- a/gamification-github-services/src/main/java/io/meeds/gamification/github/listener/GithubEventsListener.java
+++ b/gamification-github-services/src/main/java/io/meeds/github/gamification/listener/GithubEventsListener.java
@@ -16,32 +16,42 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package io.meeds.gamification.github.listener;
+package io.meeds.github.gamification.listener;
import java.util.HashMap;
import java.util.Map;
+import jakarta.annotation.PostConstruct;
import org.exoplatform.services.listener.Event;
import org.exoplatform.services.listener.Listener;
import org.exoplatform.services.listener.ListenerService;
+import org.springframework.stereotype.Component;
+import org.springframework.beans.factory.annotation.Autowired;
-import static io.meeds.gamification.github.utils.Utils.GITHUB_ACTION_EVENT;
-import static io.meeds.gamification.github.utils.Utils.GITHUB_CANCEL_ACTION_EVENT;
+import static io.meeds.github.gamification.utils.Utils.GITHUB_ACTION_EVENT;
+import static io.meeds.github.gamification.utils.Utils.GITHUB_CANCEL_ACTION_EVENT;
+@Component
public class GithubEventsListener extends Listener