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
23b21c94
Commit
23b21c94
authored
Apr 01, 2018
by
Greg Messner
Browse files
Added handling and logging of invalid access levels (#163).
parent
f252531e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
23b21c94
...
@@ -4,6 +4,7 @@ import java.util.Collections;
...
@@ -4,6 +4,7 @@ import java.util.Collections;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.WeakHashMap
;
import
java.util.WeakHashMap
;
import
java.util.logging.Logger
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
...
@@ -22,6 +23,8 @@ import org.gitlab4j.api.utils.SecretString;
...
@@ -22,6 +23,8 @@ import org.gitlab4j.api.utils.SecretString;
*/
*/
public
class
GitLabApi
{
public
class
GitLabApi
{
private
final
static
Logger
LOG
=
Logger
.
getLogger
(
GitLabApi
.
class
.
getName
());
/** GitLab4J default per page. GitLab will ignore anything over 100. */
/** GitLab4J default per page. GitLab will ignore anything over 100. */
public
static
final
int
DEFAULT_PER_PAGE
=
100
;
public
static
final
int
DEFAULT_PER_PAGE
=
100
;
...
@@ -68,6 +71,15 @@ public class GitLabApi {
...
@@ -68,6 +71,15 @@ public class GitLabApi {
private
NotesApi
notesApi
;
private
NotesApi
notesApi
;
private
EventsApi
eventsApi
;
private
EventsApi
eventsApi
;
/**
* Get the GitLab4J shared Logger instance.
*
* @return the GitLab4J shared Logger instance
*/
public
static
final
Logger
getLogger
()
{
return
(
LOG
);
}
/**
/**
* Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.
* Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.
*
*
...
...
src/main/java/org/gitlab4j/api/models/AccessLevel.java
View file @
23b21c94
...
@@ -3,12 +3,14 @@ package org.gitlab4j.api.models;
...
@@ -3,12 +3,14 @@ package org.gitlab4j.api.models;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
org.gitlab4j.api.GitLabApi
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonValue
;
import
com.fasterxml.jackson.annotation.JsonValue
;
public
enum
AccessLevel
{
public
enum
AccessLevel
{
NONE
(
0
),
GUEST
(
10
),
REPORTER
(
20
),
DEVELOPER
(
30
),
MASTER
(
40
),
OWNER
(
50
);
INVALID
(-
1
),
NONE
(
0
),
GUEST
(
10
),
REPORTER
(
20
),
DEVELOPER
(
30
),
MASTER
(
40
),
OWNER
(
50
);
public
final
Integer
value
;
public
final
Integer
value
;
...
@@ -24,7 +26,14 @@ public enum AccessLevel {
...
@@ -24,7 +26,14 @@ public enum AccessLevel {
@JsonCreator
@JsonCreator
public
static
AccessLevel
forValue
(
Integer
value
)
{
public
static
AccessLevel
forValue
(
Integer
value
)
{
return
valuesMap
.
get
(
value
);
AccessLevel
level
=
valuesMap
.
get
(
value
);
if
(
level
!=
null
)
{
return
(
level
);
}
GitLabApi
.
getLogger
().
warning
(
String
.
format
(
"[%d] is not a valid GitLab access level."
,
value
));
return
(
value
==
null
?
null
:
INVALID
);
}
}
@JsonValue
@JsonValue
...
...
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