Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
3926451a
Commit
3926451a
authored
Jan 07, 2018
by
Greg Messner
Browse files
Mods to support the new SystemHooksApi (#117).
parent
a4cb6544
Changes
23
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/systemhooks/GroupMemberSystemHookEvent.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
java.util.Date
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
GroupMemberSystemHookEvent
implements
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
;
private
String
groupAccess
;
private
String
groupName
;
private
String
groupPath
;
private
Integer
groupId
;
private
String
userEmail
;
private
String
userName
;
private
String
userUsername
;
private
Integer
userId
;
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
String
getEventName
()
{
return
this
.
eventName
;
}
public
void
setEventName
(
String
eventName
)
{
this
.
eventName
=
eventName
;
}
public
String
getGroupAccess
()
{
return
groupAccess
;
}
public
void
setGroupAccess
(
String
groupAccess
)
{
this
.
groupAccess
=
groupAccess
;
}
public
String
getGroupName
()
{
return
groupName
;
}
public
void
setGroupName
(
String
groupName
)
{
this
.
groupName
=
groupName
;
}
public
String
getGroupPath
()
{
return
groupPath
;
}
public
void
setGroupPath
(
String
groupPath
)
{
this
.
groupPath
=
groupPath
;
}
public
Integer
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
Integer
groupId
)
{
this
.
groupId
=
groupId
;
}
public
String
getUserEmail
()
{
return
userEmail
;
}
public
void
setUserEmail
(
String
userEmail
)
{
this
.
userEmail
=
userEmail
;
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getUserUsername
()
{
return
userUsername
;
}
public
void
setUserUsername
(
String
userUsername
)
{
this
.
userUsername
=
userUsername
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
}
src/main/java/org/gitlab4j/api/systemhooks/GroupSystemHookEvent.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
java.util.Date
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
GroupSystemHookEvent
implements
SystemHookEvent
{
public
static
final
String
GROUP_CREATE_EVENT
=
"group_create"
;
public
static
final
String
GROUP_DESTROY_EVENT
=
"group_destroy"
;
public
static
final
String
GROUP_RENAME_EVENT
=
"group_rename"
;
private
Date
createdAt
;
private
Date
updatedAt
;
private
String
eventName
;
private
String
name
;
private
String
path
;
private
String
fullPath
;
private
Integer
groupId
;
private
String
ownerEmail
;
private
String
ownerName
;
private
String
oldPath
;
private
String
oldFullPath
;
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
String
getEventName
()
{
return
this
.
eventName
;
}
public
void
setEventName
(
String
eventName
)
{
this
.
eventName
=
eventName
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getPath
()
{
return
path
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
public
String
getFullPath
()
{
return
fullPath
;
}
public
void
setFullPath
(
String
fullPath
)
{
this
.
fullPath
=
fullPath
;
}
public
Integer
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
Integer
groupId
)
{
this
.
groupId
=
groupId
;
}
public
String
getOwnerEmail
()
{
return
ownerEmail
;
}
public
void
setOwnerEmail
(
String
ownerEmail
)
{
this
.
ownerEmail
=
ownerEmail
;
}
public
String
getOwnerName
()
{
return
ownerName
;
}
public
void
setOwnerName
(
String
ownerName
)
{
this
.
ownerName
=
ownerName
;
}
public
String
getOldPath
()
{
return
oldPath
;
}
public
void
setOldPath
(
String
oldPath
)
{
this
.
oldPath
=
oldPath
;
}
public
String
getOldFullPath
()
{
return
oldFullPath
;
}
public
void
setOldFullPath
(
String
oldFullPath
)
{
this
.
oldFullPath
=
oldFullPath
;
}
}
src/main/java/org/gitlab4j/api/systemhooks/KeySystemHookEvent.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
java.util.Date
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
KeySystemHookEvent
implements
SystemHookEvent
{
public
static
final
String
KEY_CREATE_EVENT
=
"key_create"
;
public
static
final
String
KEY_DESTROY_EVENT
=
"key_destroy"
;
private
Date
createdAt
;
private
Date
updatedAt
;
private
String
eventName
;
private
String
username
;
private
String
key
;
private
Integer
id
;
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
String
getEventName
()
{
return
this
.
eventName
;
}
public
void
setEventName
(
String
eventName
)
{
this
.
eventName
=
eventName
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
}
src/main/java/org/gitlab4j/api/systemhooks/PushSystemHookEvent.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
org.gitlab4j.api.webhook.AbstractPushEvent
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
PushSystemHookEvent
extends
AbstractPushEvent
implements
SystemHookEvent
{
public
static
final
String
PUSH_EVENT
=
"push"
;
}
src/main/java/org/gitlab4j/api/systemhooks/RepositoryChange.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
RepositoryChange
{
private
String
after
;
private
String
before
;
private
String
ref
;
public
String
getAfter
()
{
return
this
.
after
;
}
public
void
setAfter
(
String
after
)
{
this
.
after
=
after
;
}
public
String
getBefore
()
{
return
this
.
before
;
}
public
void
setBefore
(
String
before
)
{
this
.
before
=
before
;
}
public
String
getRef
()
{
return
this
.
ref
;
}
public
void
setRef
(
String
ref
)
{
this
.
ref
=
ref
;
}
}
src/main/java/org/gitlab4j/api/systemhooks/RepositorySystemHookEvent.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
org.gitlab4j.api.webhook.EventProject
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
RepositorySystemHookEvent
implements
SystemHookEvent
{
public
static
final
String
REPOSITORY_UPDATE_EVENT
=
"repository_update"
;
private
String
eventName
;
private
Integer
userId
;
private
String
userName
;
private
String
userEmail
;
private
String
userAvatar
;
private
Integer
projectId
;
private
EventProject
project
;
private
List
<
RepositoryChange
>
changes
;
private
List
<
String
>
refs
;
public
String
getEventName
()
{
return
(
eventName
);
}
public
void
setEventName
(
String
eventName
)
{
this
.
eventName
=
eventName
;
}
public
Integer
getUserId
()
{
return
this
.
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
String
getUserName
()
{
return
this
.
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getUserEmail
()
{
return
userEmail
;
}
public
void
setUserEmail
(
String
userEmail
)
{
this
.
userEmail
=
userEmail
;
}
public
String
getUserAvatar
()
{
return
userAvatar
;
}
public
void
setUserAvatar
(
String
userAvatar
)
{
this
.
userAvatar
=
userAvatar
;
}
public
Integer
getProjectId
()
{
return
this
.
projectId
;
}
public
void
setProjectId
(
Integer
projectId
)
{
this
.
projectId
=
projectId
;
}
public
EventProject
getProject
()
{
return
project
;
}
public
void
setProject
(
EventProject
project
)
{
this
.
project
=
project
;
}
public
List
<
RepositoryChange
>
getChanges
()
{
return
changes
;
}
public
void
setChanges
(
List
<
RepositoryChange
>
changes
)
{
this
.
changes
=
changes
;
}
public
List
<
String
>
getRefs
()
{
return
refs
;
}
public
void
setRefs
(
List
<
String
>
refs
)
{
this
.
refs
=
refs
;
}
}
\ No newline at end of file
src/main/java/org/gitlab4j/api/systemhooks/SystemHookEvent.java
View file @
3926451a
...
...
@@ -4,17 +4,54 @@ import com.fasterxml.jackson.annotation.JsonSubTypes;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
@JsonTypeInfo
(
use
=
JsonTypeInfo
.
Id
.
NAME
,
include
=
JsonTypeInfo
.
As
.
PROPERTY
,
property
=
"event_name"
)
@JsonSubTypes
({
@JsonSubTypes
.
Type
(
value
=
ProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_CREATE_EVENT
),
@JsonSubTypes
.
Type
(
value
=
ProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_DESTROY_EVENT
),
@JsonSubTypes
.
Type
(
value
=
ProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_RENAME_EVENT
),
@JsonSubTypes
.
Type
(
value
=
ProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_TRANSFER_EVENT
),
@JsonSubTypes
.
Type
(
value
=
ProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_UPDATE_EVENT
),
@JsonSubTypes
.
Type
(
value
=
TeamMemberSystemHookEvent
.
class
,
name
=
TeamMemberSystemHookEvent
.
NEW_TEAM_MEMBER_EVENT
),
@JsonSubTypes
.
Type
(
value
=
TeamMemberSystemHookEvent
.
class
,
name
=
TeamMemberSystemHookEvent
.
TEAM_MEMBER_REMOVED_EVENT
)
@JsonSubTypes
.
Type
(
value
=
CreateProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_CREATE_EVENT
),
@JsonSubTypes
.
Type
(
value
=
DestroyProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_DESTROY_EVENT
),
@JsonSubTypes
.
Type
(
value
=
RenameProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_RENAME_EVENT
),
@JsonSubTypes
.
Type
(
value
=
TransferProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_TRANSFER_EVENT
),
@JsonSubTypes
.
Type
(
value
=
UpdateProjectSystemHookEvent
.
class
,
name
=
ProjectSystemHookEvent
.
PROJECT_UPDATE_EVENT
),
@JsonSubTypes
.
Type
(
value
=
NewTeamMemberSystemHookEvent
.
class
,
name
=
TeamMemberSystemHookEvent
.
NEW_TEAM_MEMBER_EVENT
),
@JsonSubTypes
.
Type
(
value
=
RemoveTeamMemberSystemHookEvent
.
class
,
name
=
TeamMemberSystemHookEvent
.
TEAM_MEMBER_REMOVED_EVENT
),
@JsonSubTypes
.
Type
(
value
=
CreateUserSystemHookEvent
.
class
,
name
=
UserSystemHookEvent
.
USER_CREATE_EVENT
),
@JsonSubTypes
.
Type
(
value
=
DestroyUserSystemHookEvent
.
class
,
name
=
UserSystemHookEvent
.
USER_DESTROY_EVENT
),
@JsonSubTypes
.
Type
(
value
=
RenameUserSystemHookEvent
.
class
,
name
=
UserSystemHookEvent
.
USER_RENAME_EVENT
),
@JsonSubTypes
.
Type
(
value
=
CreateKeySystemHookEvent
.
class
,
name
=
KeySystemHookEvent
.
KEY_CREATE_EVENT
),
@JsonSubTypes
.
Type
(
value
=
DestroyKeySystemHookEvent
.
class
,
name
=
KeySystemHookEvent
.
KEY_DESTROY_EVENT
),
@JsonSubTypes
.
Type
(
value
=
CreateGroupSystemHookEvent
.
class
,
name
=
GroupSystemHookEvent
.
GROUP_CREATE_EVENT
),
@JsonSubTypes
.
Type
(
value
=
DestroyGroupSystemHookEvent
.
class
,
name
=
GroupSystemHookEvent
.
GROUP_DESTROY_EVENT
),
@JsonSubTypes
.
Type
(
value
=
RenameGroupSystemHookEvent
.
class
,
name
=
GroupSystemHookEvent
.
GROUP_RENAME_EVENT
),
@JsonSubTypes
.
Type
(
value
=
NewGroupMemberSystemHookEvent
.
class
,
name
=
GroupMemberSystemHookEvent
.
NEW_GROUP_MEMBER_EVENT
),
@JsonSubTypes
.
Type
(
value
=
RemoveGroupMemberSystemHookEvent
.
class
,
name
=
GroupMemberSystemHookEvent
.
GROUP_MEMBER_REMOVED_EVENT
),
@JsonSubTypes
.
Type
(
value
=
PushSystemHookEvent
.
class
,
name
=
PushSystemHookEvent
.
PUSH_EVENT
),
@JsonSubTypes
.
Type
(
value
=
TagPushSystemHookEvent
.
class
,
name
=
TagPushSystemHookEvent
.
TAG_PUSH_EVENT
),
@JsonSubTypes
.
Type
(
value
=
RepositorySystemHookEvent
.
class
,
name
=
RepositorySystemHookEvent
.
REPOSITORY_UPDATE_EVENT
)
})
public
interface
SystemHookEvent
{
public
String
getEventName
();
}
// All of the following class definitions are needed to make the above work.
// Jackson has a tough time mapping the same class to multiple IDs
class
CreateProjectSystemHookEvent
extends
ProjectSystemHookEvent
{}
class
DestroyProjectSystemHookEvent
extends
ProjectSystemHookEvent
{}
class
RenameProjectSystemHookEvent
extends
ProjectSystemHookEvent
{}
class
TransferProjectSystemHookEvent
extends
ProjectSystemHookEvent
{}
class
UpdateProjectSystemHookEvent
extends
ProjectSystemHookEvent
{}
class
NewTeamMemberSystemHookEvent
extends
TeamMemberSystemHookEvent
{}
class
RemoveTeamMemberSystemHookEvent
extends
TeamMemberSystemHookEvent
{}
class
CreateUserSystemHookEvent
extends
UserSystemHookEvent
{}
class
DestroyUserSystemHookEvent
extends
UserSystemHookEvent
{}
class
RenameUserSystemHookEvent
extends
UserSystemHookEvent
{}
class
CreateKeySystemHookEvent
extends
KeySystemHookEvent
{}
class
DestroyKeySystemHookEvent
extends
KeySystemHookEvent
{}
class
CreateGroupSystemHookEvent
extends
GroupSystemHookEvent
{}
class
DestroyGroupSystemHookEvent
extends
GroupSystemHookEvent
{}
class
RenameGroupSystemHookEvent
extends
GroupSystemHookEvent
{}
class
NewGroupMemberSystemHookEvent
extends
GroupMemberSystemHookEvent
{}
class
RemoveGroupMemberSystemHookEvent
extends
GroupMemberSystemHookEvent
{}
src/main/java/org/gitlab4j/api/systemhooks/SystemHookListener.java
View file @
3926451a
...
...
@@ -20,4 +20,53 @@ public interface SystemHookListener extends java.util.EventListener {
* @param event the TeamMemberSystemHookEvent instance containing info on the team member event
*/
public
void
onTeamMemberEvent
(
TeamMemberSystemHookEvent
event
);
/**
* This method is called when a System Hook user event has been received.
*
* @param event the UserSystemHookEvent instance containing info on the user event
*/
public
void
onUserEvent
(
UserSystemHookEvent
event
);
/**
* This method is called when a System Hook key event has been received.
*
* @param event the KeySystemHookEvent instance containing info on the key event
*/
public
void
onKeyEvent
(
KeySystemHookEvent
event
);
/**
* This method is called when a System Hook group event has been received.
*
* @param event the GroupSystemHookEvent instance containing info on the key event
*/
public
void
onGroupEvent
(
GroupSystemHookEvent
event
);
/**
* This method is called when a System Hook group member event has been received.
*
* @param event the GroupMemberSystemHookEvent instance containing info on the key event
*/
public
void
onGroupMemberEvent
(
GroupMemberSystemHookEvent
event
);
/**
* This method is called when a System Hook push event has been received.
*
* @param event the PushSystemHookEvent instance containing info on the key event
*/
public
void
onPushEvent
(
PushSystemHookEvent
event
);
/**
* This method is called when a System Hook tag push event has been received.
*
* @param event the TagPushSystemHookEvent instance containing info on the key event
*/
public
void
onTagPushEvent
(
TagPushSystemHookEvent
event
);
/**
* This method is called when a System Hook repository event has been received.
*
* @param event the RepositorySystemHookEvent instance containing info on the key event
*/
public
void
onRepositoryEvent
(
RepositorySystemHookEvent
event
);
}
src/main/java/org/gitlab4j/api/systemhooks/SystemHookManager.java
View file @
3926451a
...
...
@@ -113,9 +113,12 @@ public class SystemHookManager extends HookManager {
* @throws GitLabApiException if the event is not supported
*/
public
void
handleEvent
(
SystemHookEvent
event
)
throws
GitLabApiException
{
LOG
.
info
(
"handleEvent: object_kind="
+
event
.
getEventName
());
fireEvent
(
event
);
if
(
event
!=
null
)
{
LOG
.
info
(
"handleEvent:"
+
event
.
getClass
().
getSimpleName
()
+
", eventName="
+
event
.
getEventName
());
fireEvent
(
event
);
}
else
{
LOG
.
warning
(
"handleEvent: provided event cannot be null!"
);
}
}
/**
...
...
@@ -151,6 +154,20 @@ public class SystemHookManager extends HookManager {
fireProjectEvent
((
ProjectSystemHookEvent
)
event
);
}
else
if
(
event
instanceof
TeamMemberSystemHookEvent
)
{
fireTeamMemberEvent
((
TeamMemberSystemHookEvent
)
event
);
}
else
if
(
event
instanceof
UserSystemHookEvent
)
{
fireUserEvent
((
UserSystemHookEvent
)
event
);
}
else
if
(
event
instanceof
KeySystemHookEvent
)
{
fireKeyEvent
((
KeySystemHookEvent
)
event
);
}
else
if
(
event
instanceof
GroupSystemHookEvent
)
{
fireGroupEvent
((
GroupSystemHookEvent
)
event
);
}
else
if
(
event
instanceof
GroupMemberSystemHookEvent
)
{
fireGroupMemberEvent
((
GroupMemberSystemHookEvent
)
event
);
}
else
if
(
event
instanceof
PushSystemHookEvent
)
{
firePushEvent
((
PushSystemHookEvent
)
event
);
}
else
if
(
event
instanceof
TagPushSystemHookEvent
)
{
fireTagPushEvent
((
TagPushSystemHookEvent
)
event
);
}
else
if
(
event
instanceof
RepositorySystemHookEvent
)
{
fireRepositoryEvent
((
RepositorySystemHookEvent
)
event
);
}
else
{
String
message
=
"Unsupported event, event_named="
+
event
.
getEventName
();
LOG
.
warning
(
message
);
...
...
@@ -159,16 +176,56 @@ public class SystemHookManager extends HookManager {
}
protected
void
fireProjectEvent
(
ProjectSystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onProjectEvent
(
event
);
}
}
protected
void
fireTeamMemberEvent
(
TeamMemberSystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onTeamMemberEvent
(
event
);
}
}
protected
void
fireUserEvent
(
UserSystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onUserEvent
(
event
);
}
}
protected
void
fireKeyEvent
(
KeySystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onKeyEvent
(
event
);
}
}
protected
void
fireGroupEvent
(
GroupSystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onGroupEvent
(
event
);
}
}
protected
void
fireGroupMemberEvent
(
GroupMemberSystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onGroupMemberEvent
(
event
);
}
}
protected
void
firePushEvent
(
PushSystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onPushEvent
(
event
);
}
}
protected
void
fireTagPushEvent
(
TagPushSystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onTagPushEvent
(
event
);
}
}
protected
void
fireRepositoryEvent
(
RepositorySystemHookEvent
event
)
{
for
(
SystemHookListener
listener
:
systemHookListeners
)
{
listener
.
onRepositoryEvent
(
event
);
}
}
}
src/main/java/org/gitlab4j/api/systemhooks/TagPushSystemHookEvent.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
org.gitlab4j.api.webhook.AbstractPushEvent
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
TagPushSystemHookEvent
extends
AbstractPushEvent
implements
SystemHookEvent
{
public
static
final
String
TAG_PUSH_EVENT
=
"tag_push"
;
}
src/main/java/org/gitlab4j/api/systemhooks/TeamMemberSystemHookEvent.java
View file @
3926451a
...
...
@@ -132,12 +132,4 @@ public class TeamMemberSystemHookEvent implements SystemHookEvent {
public
void
setProjectVisibility
(
Visibility
projectVisibility
)
{
this
.
projectVisibility
=
projectVisibility
;
}
public
static
String
getNewTeamMemberEvent
()
{
return
NEW_TEAM_MEMBER_EVENT
;
}
public
static
String
getTeamMemberRemovedEvent
()
{
return
TEAM_MEMBER_REMOVED_EVENT
;
}
}
src/main/java/org/gitlab4j/api/systemhooks/UserSystemHookEvent.java
0 → 100644
View file @
3926451a
package
org.gitlab4j.api.systemhooks
;
import
java.util.Date
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
UserSystemHookEvent
implements
SystemHookEvent
{
public
static
final
String
USER_CREATE_EVENT
=
"user_create"
;
public
static
final
String
USER_DESTROY_EVENT
=
"user_destroy"
;
public
static
final
String
USER_RENAME_EVENT
=
"user_rename"
;
private
String
eventName
;
private
Date
createdAt
;
private
Date
updatedAt
;
private
String
email
;
private
String
name
;
private
String
username
;
private
Integer
userId
;
private
String
oldUsername
;
public
String
getEventName
()
{
return
this
.
eventName
;
}
public
void
setEventName
(
String
eventName
)
{
this
.
eventName
=
eventName
;
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
String
getOldUsername
()
{
return
oldUsername
;
}
public
void
setOldUsername
(
String
oldUsername
)
{
this
.
oldUsername
=
oldUsername
;
}
}
src/main/java/org/gitlab4j/api/webhook/AbstractPushEvent.java
View file @
3926451a
...
...
@@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
abstract
class
AbstractPushEvent
implements
Event
{
public
abstract
class
AbstractPushEvent
{
private
String
eventName
;
...
...
@@ -28,10 +28,6 @@ public abstract class AbstractPushEvent implements Event {
private
List
<
EventCommit
>
commits
;
private
Integer
totalCommitsCount
;
public
abstract
String
getObjectKind
();
public
abstract
void
setObjectKind
(
String
objectKind
);
public
String
getEventName
()
{
return
(
eventName
);
}
...
...
src/main/java/org/gitlab4j/api/webhook/PushEvent.java
View file @
3926451a
...
...
@@ -5,11 +5,12 @@ import javax.xml.bind.annotation.XmlAccessType;
import
javax.xml.bind.annotation.XmlAccessorType
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
PushEvent
extends
AbstractPushEvent
{
public
class
PushEvent
extends
AbstractPushEvent
implements
Event
{
public
static
final
String
X_GITLAB_EVENT
=
"Push Hook"
;
public
static
final
String
OBJECT_KIND
=
"push"
;
@Override
public
String
getObjectKind
()
{
return
(
OBJECT_KIND
);
}
...
...
src/main/java/org/gitlab4j/api/webhook/TagPushEvent.java
View file @
3926451a
...
...
@@ -5,11 +5,12 @@ import javax.xml.bind.annotation.XmlAccessType;
import
javax.xml.bind.annotation.XmlAccessorType
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
TagPushEvent
extends
AbstractPushEvent
{
public
class
TagPushEvent
extends
AbstractPushEvent
implements
Event
{
public
static
final
String
X_GITLAB_EVENT
=
"Tag Push Hook"
;
public
static
final
String
OBJECT_KIND
=
"tag_push"
;
@Override
public
String
getObjectKind
()
{
return
(
OBJECT_KIND
);
}
...
...
src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
View file @
3926451a
...
...
@@ -29,7 +29,6 @@ import java.io.IOException;
import
java.io.InputStreamReader
;
import
java.util.List
;
import
org.gitlab4j.api.GitLabApi
;
import
org.gitlab4j.api.models.ArtifactsFile
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.Comment
;
...
...
@@ -62,6 +61,8 @@ import org.gitlab4j.api.models.Tag;
import
org.gitlab4j.api.models.TreeItem
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.systemhooks.ProjectSystemHookEvent
;
import
org.gitlab4j.api.systemhooks.PushSystemHookEvent
;
import
org.gitlab4j.api.systemhooks.SystemHookEvent
;
import
org.gitlab4j.api.systemhooks.TeamMemberSystemHookEvent
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
org.junit.BeforeClass
;
...
...
@@ -466,6 +467,72 @@ public class TestGitLabApiBeans {
}
}
@Test
public
void
testPushSystemHookEvent
()
{
try
{
PushSystemHookEvent
event
=
makeFakeApiCall
(
PushSystemHookEvent
.
class
,
"push-system-hook-event"
);
assertTrue
(
compareJson
(
event
,
"push-system-hook-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testUserSystemHookEvent
()
{
try
{
SystemHookEvent
event
=
makeFakeApiCall
(
SystemHookEvent
.
class
,
"user-system-hook-event"
);
assertTrue
(
compareJson
(
event
,
"user-system-hook-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testGroupSystemHookEvent
()
{
try
{
SystemHookEvent
event
=
makeFakeApiCall
(
SystemHookEvent
.
class
,
"group-system-hook-event"
);
assertTrue
(
compareJson
(
event
,
"group-system-hook-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testGroupMemberSystemHookEvent
()
{
try
{
SystemHookEvent
event
=
makeFakeApiCall
(
SystemHookEvent
.
class
,
"group-member-system-hook-event"
);
assertTrue
(
compareJson
(
event
,
"group-member-system-hook-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testTagPushSystemHookEvent
()
{
try
{
SystemHookEvent
event
=
makeFakeApiCall
(
SystemHookEvent
.
class
,
"tag-push-system-hook-event"
);
assertTrue
(
compareJson
(
event
,
"tag-push-system-hook-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testRepositorySystemHookEvent
()
{
try
{
SystemHookEvent
event
=
makeFakeApiCall
(
SystemHookEvent
.
class
,
"repository-system-hook-event"
);
assertTrue
(
compareJson
(
event
,
"repository-system-hook-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testLabels
()
{
...
...
src/test/resources/org/gitlab4j/api/group-member-system-hook-event.json
0 → 100644
View file @
3926451a
{
"created_at"
:
"2012-07-21T07:30:56Z"
,
"updated_at"
:
"2012-07-21T07:38:22Z"
,
"event_name"
:
"user_add_to_group"
,
"group_access"
:
"Master"
,
"group_id"
:
78
,
"group_name"
:
"StoreCloud"
,
"group_path"
:
"storecloud"
,
"user_email"
:
"johnsmith@gmail.com"
,
"user_name"
:
"John Smith"
,
"user_username"
:
"johnsmith"
,
"user_id"
:
41
}
\ No newline at end of file
src/test/resources/org/gitlab4j/api/group-system-hook-event.json
0 → 100644
View file @
3926451a
{
"event_name"
:
"group_rename"
,
"created_at"
:
"2017-10-30T15:09:00Z"
,
"updated_at"
:
"2017-11-01T10:23:52Z"
,
"name"
:
"Better Name"
,
"path"
:
"better-name"
,
"full_path"
:
"parent-group/better-name"
,
"group_id"
:
64
,
"old_path"
:
"old-name"
,
"old_full_path"
:
"parent-group/old-name"
}
\ No newline at end of file
src/test/resources/org/gitlab4j/api/key-system-hook-event.json
0 → 100644
View file @
3926451a
{
"event_name"
:
"key_destroy"
,
"created_at"
:
"2014-08-18 18:45:16Z"
,
"updated_at"
:
"2012-07-21T07:38:22Z"
,
"username"
:
"root"
,
"key"
:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC58FwqHUbebw2SdT7SP4FxZ0w+lAO/erhy2ylhlcW/tZ3GY3mBu9VeeiSGoGz8hCx80Zrz+aQv28xfFfKlC8XQFpCWwsnWnQqO2Lv9bS8V1fIHgMxOHIt5Vs+9CAWGCCvUOAurjsUDoE2ALIXLDMKnJxcxD13XjWdK54j6ZXDB4syLF0C2PnAQSVY9X7MfCYwtuFmhQhKaBussAXpaVMRHltie3UYSBUUuZaB3J4cg/7TxlmxcNd+ppPRIpSZAB0NI6aOnqoBCpimscO/VpQRJMVLr3XiSYeT6HBiDXWHnIVPfQc03OGcaFqOit6p8lYKMaP/iUQLm+pgpZqrXZ9vB john@localhost"
,
"id"
:
4
}
\ No newline at end of file
src/test/resources/org/gitlab4j/api/push-system-hook-event.json
0 → 100644
View file @
3926451a
{
"event_name"
:
"push"
,
"before"
:
"95790bf891e76fee5e1747ab589903a6a1f80f22"
,
"after"
:
"da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
,
"ref"
:
"refs/heads/master"
,
"checkout_sha"
:
"da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
,
"user_id"
:
4
,
"user_name"
:
"John Smith"
,
"user_email"
:
"john@example.com"
,
"user_avatar"
:
"https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80"
,
"project_id"
:
15
,
"project"
:{
"name"
:
"Diaspora"
,
"description"
:
""
,
"web_url"
:
"http://example.com/mike/diaspora"
,
"git_ssh_url"
:
"git@example.com:mike/diaspora.git"
,
"git_http_url"
:
"http://example.com/mike/diaspora.git"
,
"namespace"
:
"Mike"
,
"visibility_level"
:
0
,
"path_with_namespace"
:
"mike/diaspora"
,
"default_branch"
:
"master"
,
"homepage"
:
"http://example.com/mike/diaspora"
,
"url"
:
"git@example.com:mike/diaspora.git"
,
"ssh_url"
:
"git@example.com:mike/diaspora.git"
,
"http_url"
:
"http://example.com/mike/diaspora.git"
},
"repository"
:{
"name"
:
"Diaspora"
,
"url"
:
"git@example.com:mike/diaspora.git"
,
"description"
:
""
,
"homepage"
:
"http://example.com/mike/diaspora"
,
"git_http_url"
:
"http://example.com/mike/diaspora.git"
,
"git_ssh_url"
:
"git@example.com:mike/diaspora.git"
,
"visibility_level"
:
0
},
"commits"
:
[
{
"id"
:
"c5feabde2d8cd023215af4d2ceeb7a64839fc428"
,
"message"
:
"Add simple search to projects in public area"
,
"timestamp"
:
"2013-05-13T18:18:08Z"
,
"url"
:
"https://dev.gitlab.org/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428"
,
"author"
:
{
"name"
:
"Dmitriy Zaporozhets"
,
"email"
:
"dmitriy.zaporozhets@gmail.com"
}
}
],
"total_commits_count"
:
1
}
\ No newline at end of file
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