9
9
10
10
import javax .servlet .http .HttpServletRequest ;
11
11
12
+ import org .gitlab4j .api .GitLabApi ;
12
13
import org .gitlab4j .api .GitLabApiException ;
13
14
import org .gitlab4j .api .HookManager ;
14
15
import org .gitlab4j .api .utils .HttpRequestUtils ;
19
20
*/
20
21
public class WebHookManager extends HookManager {
21
22
22
- private final static Logger LOG = Logger .getLogger (WebHookManager . class . getName () );
23
+ private final static Logger LOGGER = GitLabApi .getLogger ();
23
24
private final JacksonJson jacksonJson = new JacksonJson ();
24
25
25
26
// Collection of objects listening for WebHook events.
@@ -53,12 +54,12 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
53
54
54
55
if (!isValidSecretToken (request )) {
55
56
String message = "X-Gitlab-Token mismatch!" ;
56
- LOG .warning (message );
57
+ LOGGER .warning (message );
57
58
throw new GitLabApiException (message );
58
59
}
59
60
60
61
String eventName = request .getHeader ("X-Gitlab-Event" );
61
- LOG .info ("handleEvent: X-Gitlab-Event=" + eventName );
62
+ LOGGER .info ("handleEvent: X-Gitlab-Event=" + eventName );
62
63
switch (eventName ) {
63
64
64
65
case BuildEvent .BUILD_HOOK_X_GITLAB_EVENT :
@@ -74,19 +75,19 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
74
75
75
76
default :
76
77
String message = "Unsupported X-Gitlab-Event, event Name=" + eventName ;
77
- LOG .warning (message );
78
+ LOGGER .warning (message );
78
79
throw new GitLabApiException (message );
79
80
}
80
81
81
82
try {
82
83
83
84
Event event ;
84
- if (LOG .isLoggable (Level .FINE )) {
85
- LOG .fine (HttpRequestUtils .getShortRequestDump (eventName + " webhook" , true , request ));
85
+ if (LOGGER .isLoggable (Level .FINE )) {
86
+ LOGGER .fine (HttpRequestUtils .getShortRequestDump (eventName + " webhook" , true , request ));
86
87
String postData = HttpRequestUtils .getPostDataAsString (request );
87
- LOG .fine ("Raw POST data:\n " + postData );
88
+ LOGGER .fine ("Raw POST data:\n " + postData );
88
89
event = jacksonJson .unmarshal (Event .class , postData );
89
- LOG .fine (event .getObjectKind () + " event:\n " + jacksonJson .marshal (event ) + "\n " );
90
+ LOGGER .fine (event .getObjectKind () + " event:\n " + jacksonJson .marshal (event ) + "\n " );
90
91
} else {
91
92
InputStreamReader reader = new InputStreamReader (request .getInputStream ());
92
93
event = jacksonJson .unmarshal (Event .class , reader );
@@ -95,7 +96,7 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
95
96
fireEvent (event );
96
97
97
98
} catch (Exception e ) {
98
- LOG .warning ("Error parsing JSON data, exception=" + e .getClass ().getSimpleName () + ", error=" + e .getMessage ());
99
+ LOGGER .warning ("Error parsing JSON data, exception=" + e .getClass ().getSimpleName () + ", error=" + e .getMessage ());
99
100
throw new GitLabApiException (e );
100
101
}
101
102
}
@@ -108,7 +109,7 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
108
109
*/
109
110
public void handleEvent (Event event ) throws GitLabApiException {
110
111
111
- LOG .info ("handleEvent: object_kind=" + event .getObjectKind ());
112
+ LOGGER .info ("handleEvent: object_kind=" + event .getObjectKind ());
112
113
113
114
switch (event .getObjectKind ()) {
114
115
case BuildEvent .OBJECT_KIND :
@@ -123,7 +124,7 @@ public void handleEvent(Event event) throws GitLabApiException {
123
124
124
125
default :
125
126
String message = "Unsupported event object_kind, object_kind=" + event .getObjectKind ();
126
- LOG .warning (message );
127
+ LOGGER .warning (message );
127
128
throw new GitLabApiException (message );
128
129
}
129
130
@@ -194,7 +195,7 @@ public void fireEvent(Event event) throws GitLabApiException {
194
195
195
196
default :
196
197
String message = "Unsupported event object_kind, object_kind=" + event .getObjectKind ();
197
- LOG .warning (message );
198
+ LOGGER .warning (message );
198
199
throw new GitLabApiException (message );
199
200
}
200
201
}
0 commit comments