Commit 4c62a279 authored by Greg Messner's avatar Greg Messner
Browse files

Added Javadoc and log warning when fetching all groups, projects, or users...

Added Javadoc and log warning when fetching all groups, projects, or users from https://gitlab.com (#396).
parent b19472d9
...@@ -33,7 +33,11 @@ public class GroupApi extends AbstractApi { ...@@ -33,7 +33,11 @@ public class GroupApi extends AbstractApi {
} }
/** /**
* Get a list of groups. (As user: my groups, as admin: all groups) * <p>Get a list of groups. (As user: my groups, as admin: all groups)</p>
*
* <strong>WARNING:</strong> Do not use this method to fetch groups from https://gitlab.com,
* gitlab.com has many 1,000's of public groups and it will a long time to fetch all of them.
* Instead use {@link #getGroups(int itemsPerPage)} which will return a Pager of Group instances.
* *
* <pre><code>GitLab Endpoint: GET /groups</code></pre> * <pre><code>GitLab Endpoint: GET /groups</code></pre>
* *
...@@ -41,6 +45,13 @@ public class GroupApi extends AbstractApi { ...@@ -41,6 +45,13 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<Group> getGroups() throws GitLabApiException { public List<Group> getGroups() throws GitLabApiException {
String url = this.gitLabApi.getGitLabServerUrl();
if (url.startsWith("https://gitlab.com")) {
GitLabApi.getLogger().warning("Fetching all groups from " + url +
" may take many minutes to complete, use Pager<Group> getGroups(int) instead.");
}
return (getGroups(getDefaultPerPage()).all()); return (getGroups(getDefaultPerPage()).all());
} }
......
...@@ -67,7 +67,11 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -67,7 +67,11 @@ public class ProjectApi extends AbstractApi implements Constants {
} }
/** /**
* Get a list of projects accessible by the authenticated user. * <p>Get a list of projects accessible by the authenticated user.</p>
*
* <strong>WARNING:</strong> Do not use this method to fetch projects from https://gitlab.com,
* gitlab.com has many 100,000's of public projects and it will take hours to fetch all of them.
* Instead use {@link #getProjects(int itemsPerPage)} which will return a Pager of Project instances.
* *
* <pre><code>GET /projects</code></pre> * <pre><code>GET /projects</code></pre>
* *
...@@ -75,6 +79,13 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -75,6 +79,13 @@ public class ProjectApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<Project> getProjects() throws GitLabApiException { public List<Project> getProjects() throws GitLabApiException {
String url = this.gitLabApi.getGitLabServerUrl();
if (url.startsWith("https://gitlab.com")) {
GitLabApi.getLogger().warning("Fetching all projects from " + url +
" may take many hours to complete, use Pager<Project> getProjects(int) instead.");
}
return (getProjects(getDefaultPerPage()).all()); return (getProjects(getDefaultPerPage()).all());
} }
......
...@@ -47,7 +47,11 @@ public class UserApi extends AbstractApi { ...@@ -47,7 +47,11 @@ public class UserApi extends AbstractApi {
} }
/** /**
* Get a list of users. * <p>Get a list of users.</p>
*
* <strong>WARNING:</strong> Do not use this method to fetch users from https://gitlab.com,
* gitlab.com has many 1,000,000's of users and it will a long time to fetch all of them.
* Instead use {@link #getUsers(int itemsPerPage)} which will return a Pager of Group instances.
* *
* <pre><code>GitLab Endpoint: GET /users</code></pre> * <pre><code>GitLab Endpoint: GET /users</code></pre>
* *
...@@ -55,6 +59,13 @@ public class UserApi extends AbstractApi { ...@@ -55,6 +59,13 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<User> getUsers() throws GitLabApiException { public List<User> getUsers() throws GitLabApiException {
String url = this.gitLabApi.getGitLabServerUrl();
if (url.startsWith("https://gitlab.com")) {
GitLabApi.getLogger().warning("Fetching all users from " + url +
" may take many minutes to complete, use Pager<User> getUsers(int) instead.");
}
return (getUsers(getDefaultPerPage()).all()); return (getUsers(getDefaultPerPage()).all());
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment