99
1010import javax .servlet .http .HttpServletRequest ;
1111
12+ import org .gitlab4j .api .GitLabApi ;
1213import org .gitlab4j .api .GitLabApiException ;
1314import org .gitlab4j .api .HookManager ;
1415import org .gitlab4j .api .utils .HttpRequestUtils ;
1920 */
2021public class WebHookManager extends HookManager {
2122
22- private final static Logger LOG = Logger .getLogger (WebHookManager . class . getName () );
23+ private final static Logger LOGGER = GitLabApi .getLogger ();
2324 private final JacksonJson jacksonJson = new JacksonJson ();
2425
2526 // Collection of objects listening for WebHook events.
@@ -53,12 +54,12 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
5354
5455 if (!isValidSecretToken (request )) {
5556 String message = "X-Gitlab-Token mismatch!" ;
56- LOG .warning (message );
57+ LOGGER .warning (message );
5758 throw new GitLabApiException (message );
5859 }
5960
6061 String eventName = request .getHeader ("X-Gitlab-Event" );
61- LOG .info ("handleEvent: X-Gitlab-Event=" + eventName );
62+ LOGGER .info ("handleEvent: X-Gitlab-Event=" + eventName );
6263 switch (eventName ) {
6364
6465 case BuildEvent .BUILD_HOOK_X_GITLAB_EVENT :
@@ -74,19 +75,19 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
7475
7576 default :
7677 String message = "Unsupported X-Gitlab-Event, event Name=" + eventName ;
77- LOG .warning (message );
78+ LOGGER .warning (message );
7879 throw new GitLabApiException (message );
7980 }
8081
8182 try {
8283
8384 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 ));
8687 String postData = HttpRequestUtils .getPostDataAsString (request );
87- LOG .fine ("Raw POST data:\n " + postData );
88+ LOGGER .fine ("Raw POST data:\n " + postData );
8889 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 " );
9091 } else {
9192 InputStreamReader reader = new InputStreamReader (request .getInputStream ());
9293 event = jacksonJson .unmarshal (Event .class , reader );
@@ -95,7 +96,7 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
9596 fireEvent (event );
9697
9798 } 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 ());
99100 throw new GitLabApiException (e );
100101 }
101102 }
@@ -108,7 +109,7 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
108109 */
109110 public void handleEvent (Event event ) throws GitLabApiException {
110111
111- LOG .info ("handleEvent: object_kind=" + event .getObjectKind ());
112+ LOGGER .info ("handleEvent: object_kind=" + event .getObjectKind ());
112113
113114 switch (event .getObjectKind ()) {
114115 case BuildEvent .OBJECT_KIND :
@@ -123,7 +124,7 @@ public void handleEvent(Event event) throws GitLabApiException {
123124
124125 default :
125126 String message = "Unsupported event object_kind, object_kind=" + event .getObjectKind ();
126- LOG .warning (message );
127+ LOGGER .warning (message );
127128 throw new GitLabApiException (message );
128129 }
129130
@@ -194,7 +195,7 @@ public void fireEvent(Event event) throws GitLabApiException {
194195
195196 default :
196197 String message = "Unsupported event object_kind, object_kind=" + event .getObjectKind ();
197- LOG .warning (message );
198+ LOGGER .warning (message );
198199 throw new GitLabApiException (message );
199200 }
200201 }
0 commit comments