Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
97b50e81
Commit
97b50e81
authored
6 years ago
by
Greg Messner
Browse files
Options
Download
Email Patches
Plain Diff
Mods to support requestUrl and requestQuesyString properties (#238).
parent
3bbacbd8
main
5.0.x
5.0.x.jdk17
6.x
No related merge requests found
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
src/main/java/org/gitlab4j/api/systemhooks/AbstractSystemHookEvent.java
+31
-0
...org/gitlab4j/api/systemhooks/AbstractSystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/GroupMemberSystemHookEvent.java
+3
-3
.../gitlab4j/api/systemhooks/GroupMemberSystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/GroupSystemHookEvent.java
+1
-2
...va/org/gitlab4j/api/systemhooks/GroupSystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/KeySystemHookEvent.java
+1
-1
...java/org/gitlab4j/api/systemhooks/KeySystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/ProjectSystemHookEvent.java
+1
-1
.../org/gitlab4j/api/systemhooks/ProjectSystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/RepositorySystemHookEvent.java
+1
-2
...g/gitlab4j/api/systemhooks/RepositorySystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/SystemHookEvent.java
+9
-1
...in/java/org/gitlab4j/api/systemhooks/SystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/SystemHookManager.java
+2
-0
.../java/org/gitlab4j/api/systemhooks/SystemHookManager.java
src/main/java/org/gitlab4j/api/systemhooks/TeamMemberSystemHookEvent.java
+1
-1
...g/gitlab4j/api/systemhooks/TeamMemberSystemHookEvent.java
src/main/java/org/gitlab4j/api/systemhooks/UserSystemHookEvent.java
+1
-1
...ava/org/gitlab4j/api/systemhooks/UserSystemHookEvent.java
src/main/java/org/gitlab4j/api/webhook/AbstractEvent.java
+31
-0
src/main/java/org/gitlab4j/api/webhook/AbstractEvent.java
src/main/java/org/gitlab4j/api/webhook/AbstractPushEvent.java
+21
-0
...main/java/org/gitlab4j/api/webhook/AbstractPushEvent.java
src/main/java/org/gitlab4j/api/webhook/BuildEvent.java
+1
-1
src/main/java/org/gitlab4j/api/webhook/BuildEvent.java
src/main/java/org/gitlab4j/api/webhook/Event.java
+12
-1
src/main/java/org/gitlab4j/api/webhook/Event.java
src/main/java/org/gitlab4j/api/webhook/IssueEvent.java
+1
-1
src/main/java/org/gitlab4j/api/webhook/IssueEvent.java
src/main/java/org/gitlab4j/api/webhook/MergeRequestEvent.java
+1
-1
...main/java/org/gitlab4j/api/webhook/MergeRequestEvent.java
src/main/java/org/gitlab4j/api/webhook/NoteEvent.java
+1
-1
src/main/java/org/gitlab4j/api/webhook/NoteEvent.java
src/main/java/org/gitlab4j/api/webhook/PipelineEvent.java
+1
-1
src/main/java/org/gitlab4j/api/webhook/PipelineEvent.java
src/main/java/org/gitlab4j/api/webhook/PushEvent.java
+2
-1
src/main/java/org/gitlab4j/api/webhook/PushEvent.java
src/main/java/org/gitlab4j/api/webhook/WebHookManager.java
+3
-0
src/main/java/org/gitlab4j/api/webhook/WebHookManager.java
with
125 additions
and
19 deletions
+125
-19
src/main/java/org/gitlab4j/api/systemhooks/AbstractSystemHookEvent.java
0 → 100644
+
31
-
0
View file @
97b50e81
package
org.gitlab4j.api.systemhooks
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
public
abstract
class
AbstractSystemHookEvent
implements
SystemHookEvent
{
private
String
requestUrl
;
private
String
requestQuesryString
;
@Override
public
void
setRequestUrl
(
String
requestUrl
)
{
this
.
requestUrl
=
requestUrl
;
}
@Override
@JsonIgnore
public
String
getRequestUrl
()
{
return
(
requestUrl
);
}
@Override
public
void
setRequestQueryString
(
String
requestQuesryString
)
{
this
.
requestQuesryString
=
requestQuesryString
;
}
@Override
@JsonIgnore
public
String
getRequestQueryString
()
{
return
(
requestQuesryString
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/GroupMemberSystemHookEvent.java
+
3
-
3
View file @
97b50e81
...
...
@@ -8,11 +8,11 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
GroupMemberSystemHookEvent
implem
en
t
s
SystemHookEvent
{
public
class
GroupMemberSystemHookEvent
ext
en
d
s
Abstract
SystemHookEvent
{
public
static
final
String
NEW_GROUP_MEMBER_EVENT
=
"user_add_to_group"
;
public
static
final
String
GROUP_MEMBER_REMOVED_EVENT
=
"user_remove_from_group"
;
private
Date
createdAt
;
private
Date
updatedAt
;
private
String
eventName
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/GroupSystemHookEvent.java
+
1
-
2
View file @
97b50e81
...
...
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
GroupSystemHookEvent
implem
en
t
s
SystemHookEvent
{
public
class
GroupSystemHookEvent
ext
en
d
s
Abstract
SystemHookEvent
{
public
static
final
String
GROUP_CREATE_EVENT
=
"group_create"
;
public
static
final
String
GROUP_DESTROY_EVENT
=
"group_destroy"
;
...
...
@@ -26,7 +26,6 @@ public class GroupSystemHookEvent implements SystemHookEvent {
private
String
oldPath
;
private
String
oldFullPath
;
public
Date
getCreatedAt
()
{
return
createdAt
;
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/KeySystemHookEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
KeySystemHookEvent
implem
en
t
s
SystemHookEvent
{
public
class
KeySystemHookEvent
ext
en
d
s
Abstract
SystemHookEvent
{
public
static
final
String
KEY_CREATE_EVENT
=
"key_create"
;
public
static
final
String
KEY_DESTROY_EVENT
=
"key_destroy"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/ProjectSystemHookEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -10,7 +10,7 @@ import org.gitlab4j.api.models.Visibility;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
ProjectSystemHookEvent
implem
en
t
s
SystemHookEvent
{
public
class
ProjectSystemHookEvent
ext
en
d
s
Abstract
SystemHookEvent
{
public
static
final
String
PROJECT_CREATE_EVENT
=
"project_create"
;
public
static
final
String
PROJECT_DESTROY_EVENT
=
"project_destroy"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/RepositorySystemHookEvent.java
+
1
-
2
View file @
97b50e81
...
...
@@ -10,7 +10,7 @@ import org.gitlab4j.api.webhook.EventProject;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
RepositorySystemHookEvent
implem
en
t
s
SystemHookEvent
{
public
class
RepositorySystemHookEvent
ext
en
d
s
Abstract
SystemHookEvent
{
public
static
final
String
REPOSITORY_UPDATE_EVENT
=
"repository_update"
;
...
...
@@ -26,7 +26,6 @@ public class RepositorySystemHookEvent implements SystemHookEvent {
private
List
<
RepositoryChange
>
changes
;
private
List
<
String
>
refs
;
public
String
getEventName
()
{
return
(
eventName
);
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/SystemHookEvent.java
+
9
-
1
View file @
97b50e81
package
org.gitlab4j.api.systemhooks
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonSubTypes
;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
...
...
@@ -28,7 +29,14 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
@JsonSubTypes
.
Type
(
value
=
RepositorySystemHookEvent
.
class
,
name
=
RepositorySystemHookEvent
.
REPOSITORY_UPDATE_EVENT
)
})
public
interface
SystemHookEvent
{
public
String
getEventName
();
String
getEventName
();
void
setRequestUrl
(
String
requestUrl
);
@JsonIgnore
String
getRequestUrl
();
void
setRequestQueryString
(
String
requestQuesryString
);
@JsonIgnore
String
getRequestQueryString
();
}
// All of the following class definitions are needed to make the above work.
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/SystemHookManager.java
+
2
-
0
View file @
97b50e81
...
...
@@ -82,6 +82,8 @@ public class SystemHookManager extends HookManager {
event
=
jacksonJson
.
unmarshal
(
SystemHookEvent
.
class
,
reader
);
}
event
.
setRequestUrl
(
request
.
getRequestURL
().
toString
());
event
.
setRequestQueryString
(
request
.
getQueryString
());
fireEvent
(
event
);
}
catch
(
Exception
e
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/TeamMemberSystemHookEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -10,7 +10,7 @@ import org.gitlab4j.api.models.Visibility;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
TeamMemberSystemHookEvent
implem
en
t
s
SystemHookEvent
{
public
class
TeamMemberSystemHookEvent
ext
en
d
s
Abstract
SystemHookEvent
{
public
static
final
String
NEW_TEAM_MEMBER_EVENT
=
"user_add_to_team"
;
public
static
final
String
TEAM_MEMBER_REMOVED_EVENT
=
"user_remove_from_team"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/systemhooks/UserSystemHookEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
UserSystemHookEvent
implem
en
t
s
SystemHookEvent
{
public
class
UserSystemHookEvent
ext
en
d
s
Abstract
SystemHookEvent
{
public
static
final
String
USER_CREATE_EVENT
=
"user_create"
;
public
static
final
String
USER_DESTROY_EVENT
=
"user_destroy"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/AbstractEvent.java
0 → 100644
+
31
-
0
View file @
97b50e81
package
org.gitlab4j.api.webhook
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
public
abstract
class
AbstractEvent
implements
Event
{
private
String
requestUrl
;
private
String
requestQuesryString
;
@Override
public
void
setRequestUrl
(
String
requestUrl
)
{
this
.
requestUrl
=
requestUrl
;
}
@Override
@JsonIgnore
public
String
getRequestUrl
()
{
return
(
requestUrl
);
}
@Override
public
void
setRequestQueryString
(
String
requestQuesryString
)
{
this
.
requestQuesryString
=
requestQuesryString
;
}
@Override
@JsonIgnore
public
String
getRequestQueryString
()
{
return
(
requestQuesryString
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/AbstractPushEvent.java
+
21
-
0
View file @
97b50e81
...
...
@@ -28,6 +28,9 @@ public abstract class AbstractPushEvent {
private
List
<
EventCommit
>
commits
;
private
Integer
totalCommitsCount
;
private
String
requestUrl
;
private
String
requestQuesryString
;
public
String
getEventName
()
{
return
(
eventName
);
}
...
...
@@ -140,6 +143,24 @@ public abstract class AbstractPushEvent {
this
.
totalCommitsCount
=
totalCommitsCount
;
}
public
void
setRequestUrl
(
String
requestUrl
)
{
this
.
requestUrl
=
requestUrl
;
}
@JsonIgnore
public
String
getRequestUrl
()
{
return
(
requestUrl
);
}
public
void
setRequestQueryString
(
String
requestQuesryString
)
{
this
.
requestQuesryString
=
requestQuesryString
;
}
@JsonIgnore
public
String
getRequestQueryString
()
{
return
(
requestQuesryString
);
}
/**
* Gets the branch name from the ref. Will return null if the ref does not start with "refs/heads/".
*
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/BuildEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import
org.gitlab4j.api.models.User
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
BuildEvent
implem
en
t
s
Event
{
public
class
BuildEvent
ext
en
d
s
Abstract
Event
{
/** X-Gitlab-Event header value pre GitLab v9.3.0 */
public
static
final
String
BUILD_HOOK_X_GITLAB_EVENT
=
"Build Hook"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/Event.java
+
12
-
1
View file @
97b50e81
package
org.gitlab4j.api.webhook
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonSubTypes
;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
...
...
@@ -17,5 +18,15 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
@JsonSubTypes
.
Type
(
value
=
WikiPageEvent
.
class
,
name
=
WikiPageEvent
.
OBJECT_KIND
)
})
public
interface
Event
{
public
String
getObjectKind
();
String
getObjectKind
();
void
setRequestUrl
(
String
url
);
@JsonIgnore
String
getRequestUrl
();
void
setRequestQueryString
(
String
queryString
);
@JsonIgnore
String
getRequestQueryString
();
}
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/IssueEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -7,7 +7,7 @@ import org.gitlab4j.api.models.Assignee;
import
org.gitlab4j.api.models.User
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
IssueEvent
implem
en
t
s
Event
{
public
class
IssueEvent
ext
en
d
s
Abstract
Event
{
public
static
final
String
X_GITLAB_EVENT
=
"Issue Hook"
;
public
static
final
String
OBJECT_KIND
=
"issue"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/MergeRequestEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import
org.gitlab4j.api.models.User
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
MergeRequestEvent
implem
en
t
s
Event
{
public
class
MergeRequestEvent
ext
en
d
s
Abstract
Event
{
public
static
final
String
X_GITLAB_EVENT
=
"Merge Request Hook"
;
public
static
final
String
OBJECT_KIND
=
"merge_request"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/NoteEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -13,7 +13,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import
com.fasterxml.jackson.annotation.JsonValue
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
NoteEvent
implem
en
t
s
Event
{
public
class
NoteEvent
ext
en
d
s
Abstract
Event
{
public
static
final
String
X_GITLAB_EVENT
=
"Note Hook"
;
public
static
final
String
OBJECT_KIND
=
"note"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/PipelineEvent.java
+
1
-
1
View file @
97b50e81
...
...
@@ -10,7 +10,7 @@ import org.gitlab4j.api.models.ArtifactsFile;
import
org.gitlab4j.api.models.User
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
PipelineEvent
implem
en
t
s
Event
{
public
class
PipelineEvent
ext
en
d
s
Abstract
Event
{
public
static
final
String
X_GITLAB_EVENT
=
"Pipeline Hook"
;
public
static
final
String
OBJECT_KIND
=
"pipeline"
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/PushEvent.java
+
2
-
1
View file @
97b50e81
...
...
@@ -16,7 +16,8 @@ public class PushEvent extends AbstractPushEvent implements Event {
}
public
void
setObjectKind
(
String
objectKind
)
{
if
(!
OBJECT_KIND
.
equals
(
objectKind
))
if
(!
OBJECT_KIND
.
equals
(
objectKind
))
{
throw
new
RuntimeException
(
"Invalid object_kind ("
+
objectKind
+
"), must be '"
+
OBJECT_KIND
+
"'"
);
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/webhook/WebHookManager.java
+
3
-
0
View file @
97b50e81
...
...
@@ -8,6 +8,7 @@ import java.util.logging.Level;
import
java.util.logging.Logger
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpUtils
;
import
org.gitlab4j.api.GitLabApi
;
import
org.gitlab4j.api.GitLabApiException
;
...
...
@@ -93,6 +94,8 @@ public class WebHookManager extends HookManager {
event
=
jacksonJson
.
unmarshal
(
Event
.
class
,
reader
);
}
event
.
setRequestUrl
(
request
.
getRequestURL
().
toString
());
event
.
setRequestQueryString
(
request
.
getQueryString
());
fireEvent
(
event
);
}
catch
(
Exception
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets