Skip to content

Commit 70ab67b

Browse files
committed
Mods to move property setting into service class.
1 parent c84bea9 commit 70ab67b

File tree

6 files changed

+148
-3
lines changed

6 files changed

+148
-3
lines changed

src/main/java/org/gitlab4j/api/services/ExternalWikiService.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
package org.gitlab4j.api.services;
22

3+
import org.gitlab4j.api.GitLabApiForm;
4+
35
public class ExternalWikiService extends NotificationService {
46

57
public static final String WIKIURL_KEY_PROP = "external_wiki_url";
68

9+
/**
10+
* Get the form data for this service based on it's properties.
11+
*
12+
* @return the form data for this service based on it's properties
13+
*/
14+
@Override
15+
public GitLabApiForm servicePropertiesForm() {
16+
GitLabApiForm formData = new GitLabApiForm()
17+
.withParam("external_wiki_url", getExternalWikiUrl(), true);
18+
return formData;
19+
}
20+
721
public String getExternalWikiUrl() {
822
return this.getProperty(WIKIURL_KEY_PROP);
923
}

src/main/java/org/gitlab4j/api/services/HipChatService.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.gitlab4j.api.services;
22

3+
import org.gitlab4j.api.GitLabApiForm;
4+
35
import com.fasterxml.jackson.annotation.JsonIgnore;
46

57
public class HipChatService extends NotificationService {
@@ -11,7 +13,32 @@ public class HipChatService extends NotificationService {
1113
public static final String API_VERSION_PROP = "api_version";
1214
public static final String SERVER_PROP = "server";
1315
public static final String NOTIFY_ONLY_BROKEN_PIPELINES_PROP = "notify_only_broken_pipelines";
14-
16+
17+
/**
18+
* Get the form data for this service based on it's properties.
19+
*
20+
* @return the form data for this service based on it's properties
21+
*/
22+
@Override
23+
public GitLabApiForm servicePropertiesForm() {
24+
GitLabApiForm formData = new GitLabApiForm()
25+
.withParam("push_events", getPushEvents())
26+
.withParam("issues_events", getIssuesEvents())
27+
.withParam("confidential_issues_events", getConfidentialIssuesEvents())
28+
.withParam("merge_requests_events", getMergeRequestsEvents())
29+
.withParam("tag_push_events", getTagPushEvents())
30+
.withParam("note_events", getNoteEvents())
31+
.withParam("confidential_note_events", getConfidentialNoteEvents())
32+
.withParam("pipeline_events", getPipelineEvents())
33+
.withParam("token", getToken(), true)
34+
.withParam("color", getColor())
35+
.withParam("notify", getNotify())
36+
.withParam("room", getRoom())
37+
.withParam("api_version", getApiVersion())
38+
.withParam("server", getServer())
39+
.withParam("notify_only_broken_pipelines", getNotifyOnlyBrokenPipelines());
40+
return formData;
41+
}
1542

1643
public HipChatService withPushEvents(Boolean pushEvents) {
1744
return withPushEvents(pushEvents, this);

src/main/java/org/gitlab4j/api/services/JiraService.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.Map;
44

5+
import org.gitlab4j.api.GitLabApiForm;
6+
57
import com.fasterxml.jackson.annotation.JsonIgnore;
68

79
public class JiraService extends NotificationService {
@@ -14,6 +16,25 @@ public class JiraService extends NotificationService {
1416

1517
private CharSequence password;
1618

19+
/**
20+
* Get the form data for this service based on it's properties.
21+
*
22+
* @return the form data for this service based on it's properties
23+
*/
24+
@Override
25+
public GitLabApiForm servicePropertiesForm() {
26+
GitLabApiForm formData = new GitLabApiForm()
27+
.withParam("merge_requests_events", getMergeRequestsEvents())
28+
.withParam("commit_events", getCommitEvents())
29+
.withParam("url", getUrl(), true)
30+
.withParam("api_url", getApiUrl())
31+
.withParam("project_key", getProjectKey())
32+
.withParam("username", getUsername(), true)
33+
.withParam("password", getPassword(), true)
34+
.withParam("jira_issue_transition_id", getJiraIssueTransitionId());
35+
return formData;
36+
}
37+
1738
public JiraService withCommitEvents(Boolean commitEvents) {
1839
return withCommitEvents(commitEvents, this);
1940
}

src/main/java/org/gitlab4j/api/services/MattermostService.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
11
package org.gitlab4j.api.services;
22

3+
import org.gitlab4j.api.GitLabApiForm;
4+
35
import com.fasterxml.jackson.annotation.JsonIgnore;
46

57
public class MattermostService extends NotificationService {
68

79
private String defaultChannel;
810

11+
/**
12+
* Get the form data for this service based on it's properties.
13+
*
14+
* @return the form data for this service based on it's properties
15+
*/
16+
@Override
17+
public GitLabApiForm servicePropertiesForm() {
18+
GitLabApiForm formData = new GitLabApiForm()
19+
.withParam("webhook", getWebhook(), true)
20+
.withParam("username", getUsername())
21+
.withParam("channel", getDefaultChannel())
22+
.withParam("notify_only_broken_pipelines", getNotifyOnlyBrokenPipelines())
23+
.withParam("notify_only_default_branch", getNotifyOnlyDefaultBranch())
24+
.withParam("push_events", getPushEvents())
25+
.withParam("issues_events", getIssuesEvents())
26+
.withParam("confidential_issues_events", getConfidentialIssuesEvents())
27+
.withParam("merge_requests_events", getMergeRequestsEvents())
28+
.withParam("tag_push_events", getTagPushEvents())
29+
.withParam("note_events", getNoteEvents())
30+
.withParam("confidential_note_events", getConfidentialNoteEvents())
31+
.withParam("pipeline_events", getPipelineEvents())
32+
.withParam("wiki_page_events", getWikiPageEvents())
33+
.withParam("push_channel", getPushChannel())
34+
.withParam("issue_channel", getIssueChannel())
35+
.withParam("confidential_issue_channel", getConfidentialIssueChannel())
36+
.withParam("merge_request_channel", getMergeRequestChannel())
37+
.withParam("note_channel", getNoteChannel())
38+
.withParam("confidential_note_channel", getConfidentialNoteChannel())
39+
.withParam("tag_push_channel", getTagPushChannel())
40+
.withParam("pipeline_channel", getPipelineChannel())
41+
.withParam("wiki_page_channel", getWikiPageChannel());
42+
return formData;
43+
}
44+
945
public MattermostService withPushEvents(Boolean pushEvents) {
1046
return withPushEvents(pushEvents, this);
1147
}

src/main/java/org/gitlab4j/api/services/NotificationService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import java.util.HashMap;
55
import java.util.Map;
66

7+
import org.gitlab4j.api.GitLabApiForm;
8+
79
import com.fasterxml.jackson.annotation.JsonIgnore;
810

911
public abstract class NotificationService {
1012

11-
public static final String WEBHOOK_PROP = "webhook";
12-
public static final String USERNAME_PROP = "username";
1313
public static final String NOTIFY_ONLY_BROKEN_PIPELINES_PROP = "notify_only_broken_pipelines";
1414
public static final String NOTIFY_ONLY_DEFAULT_BRANCH_PROP = "notify_only_default_branch";
1515
public static final String PUSH_CHANNEL_PROP = "push_channel";
@@ -22,6 +22,15 @@ public abstract class NotificationService {
2222
public static final String PIPELINE_CHANNEL_PROP = "pipeline_channel";
2323
public static final String WIKI_PAGE_CHANNEL_PROP = "wiki_page_channel";
2424

25+
public static final String WEBHOOK_PROP = "webhook";
26+
public static final String USERNAME_PROP = "username";
27+
public static final String DESCRIPTION_PROP = "description";
28+
public static final String TITLE_PROP = "title";
29+
public static final String NEW_ISSUE_URL_PROP = "new_issue_url";
30+
public static final String ISSUES_URL_PROP = "issues_url";
31+
public static final String PROJECT_URL_PROP = "project_url";
32+
public static final String PUSH_EVENTS_PROP = "push_events";
33+
2534
private Integer id;
2635
private String title;
2736
private Date createdAt;
@@ -42,6 +51,8 @@ public abstract class NotificationService {
4251

4352
private Map<String, Object> properties;
4453

54+
public abstract GitLabApiForm servicePropertiesForm();
55+
4556
public Integer getId() {
4657
return id;
4758
}

src/main/java/org/gitlab4j/api/services/SlackService.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
11
package org.gitlab4j.api.services;
22

3+
import org.gitlab4j.api.GitLabApiForm;
4+
35
import com.fasterxml.jackson.annotation.JsonIgnore;
46

57
public class SlackService extends NotificationService {
68

79
private String defaultChannel;
810

11+
/**
12+
* Get the form data for this service based on it's properties.
13+
*
14+
* @return the form data for this service based on it's properties
15+
*/
16+
@Override
17+
public GitLabApiForm servicePropertiesForm() {
18+
GitLabApiForm formData = new GitLabApiForm()
19+
.withParam("webhook", getWebhook(), true)
20+
.withParam("username", getUsername())
21+
.withParam("channel", getDefaultChannel())
22+
.withParam("notify_only_broken_pipelines", getNotifyOnlyBrokenPipelines())
23+
.withParam("notify_only_default_branch", getNotifyOnlyDefaultBranch())
24+
.withParam("push_events", getPushEvents())
25+
.withParam("issues_events", getIssuesEvents())
26+
.withParam("confidential_issues_events", getConfidentialIssuesEvents())
27+
.withParam("merge_requests_events", getMergeRequestsEvents())
28+
.withParam("tag_push_events", getTagPushEvents())
29+
.withParam("note_events", getNoteEvents())
30+
.withParam("confidential_note_events", getConfidentialNoteEvents())
31+
.withParam("pipeline_events", getPipelineEvents())
32+
.withParam("wiki_page_events", getWikiPageEvents())
33+
.withParam("push_channel", getPushChannel())
34+
.withParam("issue_channel", getIssueChannel())
35+
.withParam("confidential_issue_channel", getConfidentialIssueChannel())
36+
.withParam("merge_request_channel", getMergeRequestChannel())
37+
.withParam("note_channel", getNoteChannel())
38+
.withParam("confidential_note_channel", getConfidentialNoteChannel())
39+
.withParam("tag_push_channel", getTagPushChannel())
40+
.withParam("pipeline_channel", getPipelineChannel())
41+
.withParam("wiki_page_channel", getWikiPageChannel());
42+
return formData;
43+
}
44+
945
public SlackService withPushEvents(Boolean pushEvents) {
1046
return withPushEvents(pushEvents, this);
1147
}

0 commit comments

Comments
 (0)