Skip to content

Commit 67b1e3b

Browse files
committed
Minor format changes from previous merge.
1 parent 6b73b77 commit 67b1e3b

File tree

6 files changed

+119
-130
lines changed

6 files changed

+119
-130
lines changed

src/main/java/com/messners/gitlab/api/GitLabApi.java

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,19 @@ public ProjectApi getProjectApi () {
117117
public RepositoryApi getRepositoryApi () {
118118
return (repositoryApi);
119119
}
120-
121-
120+
121+
122+
/**
123+
* Gets the RepositoryFileApi instance owned by this GitLabApi instance. The RepositoryFileApi is used
124+
* to perform all repository files related API calls.
125+
*
126+
* @return the RepositoryFileApi instance owned by this GitLabApi instance
127+
*/
128+
public RepositoryFileApi getRepositoryFileApi() {
129+
return repositoryFileApi;
130+
}
131+
132+
122133
/**
123134
* Gets the SessionApi instance owned by this GitLabApi instance. The SessionApi is used
124135
* to perform a login to the GitLab API.
@@ -139,26 +150,4 @@ public SessionApi getSessionApi () {
139150
public UserApi getUserApi () {
140151
return (userApi);
141152
}
142-
143-
144-
/**
145-
* Gets the RepositoryFileApi instance owned by this GitLabApi instance. The RepositoryFileApi is used
146-
* to perform all repository files related API calls.
147-
*
148-
* @return the RepositoryFileApi instance owned by this GitLabApi instance
149-
*/
150-
public RepositoryFileApi getRepositoryFileApi() {
151-
return repositoryFileApi;
152-
}
153-
154-
/**
155-
* Gets the RepositoryFileApi instance owned by this GitLabApi instance. The RepositoryFileApi is used
156-
* to perform all repository files related API calls.
157-
*
158-
* @return the RepositoryFileApi instance owned by this GitLabApi instance
159-
*/
160-
public void setRepositoryFileApi(RepositoryFileApi repositoryFileApi) {
161-
this.repositoryFileApi = repositoryFileApi;
162-
}
163-
164153
}

src/main/java/com/messners/gitlab/api/ProjectApi.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public Project createProject (Project project) throws GitLabApiException {
131131
return (createProject(project, null));
132132
}
133133

134+
134135
/**
135136
* Creates new project owned by the current user. The following properties on the Project instance
136137
* are utilized in the creation of the project:
@@ -181,6 +182,7 @@ public Project createProject (Project project, String importUrl) throws GitLabAp
181182
return (response.readEntity(Project.class));
182183
}
183184

185+
184186
/**
185187
* Creates a Project
186188
*
@@ -199,28 +201,29 @@ public Project createProject (Project project, String importUrl) throws GitLabAp
199201
* @throws GitLabApiException
200202
*/
201203
public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled, Boolean wikiEnabled, Boolean snippetsEnabled, Boolean publik, Integer visibilityLevel, String importUrl) throws GitLabApiException{
202-
204+
203205
if (name == null || name.trim().length() == 0) {
204206
return (null);
205207
}
206-
208+
207209
Form formData = new Form();
208210
addFormParam(formData, "name", name, true);
209211
addFormParam(formData, "namespace_id", namespaceId);
210212
addFormParam(formData, "description", description);
211-
addFormParam(formData, "issues_enabled", issuesEnabled);
213+
addFormParam(formData, "issues_enabled", issuesEnabled);
212214
addFormParam(formData, "wall_enabled", wallEnabled);
213215
addFormParam(formData, "merge_requests_enabled", mergeRequestsEnabled);
214216
addFormParam(formData, "wiki_enabled", wikiEnabled);
215217
addFormParam(formData, "snippets_enabled", snippetsEnabled);
216218
addFormParam(formData, "public", publik);
217219
addFormParam(formData, "visibility_level", visibilityLevel);
218220
addFormParam(formData, "import_url", importUrl);
219-
221+
220222
Response response = post(Response.Status.CREATED, formData, "projects");
221223
return (response.readEntity(Project.class));
222224
}
223-
225+
226+
224227
/**
225228
* Removes project with all resources(issues, merge requests etc).
226229
*

src/main/java/com/messners/gitlab/api/RepositoryApi.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,26 @@ public List<TreeItem> getTree (Integer projectId) throws GitLabApiException {
135135
Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "tree");
136136
return (response.readEntity(new GenericType<List<TreeItem>>() {}));
137137
}
138-
139-
138+
139+
140140
/**
141141
* Get the raw file contents for a file by commit sha and path.
142-
*
142+
*
143143
* GET /projects/:id/repository/blobs/:sha
144-
*
144+
*
145145
* @param projectId
146146
* @param commitOrBranchName
147147
* @return a string with the file content for the specified file
148148
* @throws GitLabApiException
149149
*/
150-
public String getRawFileContent (Integer projectId, String commitOrBranchName, String filepath) throws GitLabApiException {
151-
150+
public String getRawFileContent (Integer projectId, String commitOrBranchName, String filepath) throws GitLabApiException {
152151
Form formData = new Form();
153152
addFormParam(formData, "filepath", filepath, true);
154153
Response response = get(Response.Status.OK, formData.asMap(), "projects", projectId, "repository", "blobs", commitOrBranchName);
155154
return (response.readEntity(String.class));
156155
}
157-
156+
157+
158158
/**
159159
* Get the raw file contents for a blob by blob SHA.
160160
*
@@ -169,5 +169,4 @@ public String getRawBlobCotent(Integer projectId, String sha) throws GitLabApiEx
169169
Response response = get(Response.Status.OK, null, "projects", projectId, "repository", "raw_blobs", sha);
170170
return (response.readEntity(String.class));
171171
}
172-
173172
}

src/main/java/com/messners/gitlab/api/RepositoryFileApi.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88

99
/**
1010
* This class provides an entry point to all the GitLab API repository files calls.
11-
*
11+
*
1212
* @author lonfee88 <[email protected]>
1313
*/
1414
public class RepositoryFileApi extends AbstractApi {
1515

1616
public RepositoryFileApi (GitLabApi gitLabApi) {
1717
super(gitLabApi);
1818
}
19-
19+
2020
/**
2121
* Get file from repository
2222
* Allows you to receive information about file in repository like name, size, content.
23-
* Note that file content is Base64 encoded.
24-
*
23+
* Note that file content is Base64 encoded.
24+
*
2525
* GET /projects/:id/repository/files
26-
*
26+
*
2727
* @param file_path (required) - Full path to new file. Ex. lib/class.rb
2828
* @param projectId
2929
* @param ref (required) - The name of branch, tag or commit
@@ -37,18 +37,18 @@ public RepositoryFile getFile(String filePath, Integer projectId, String ref) th
3737
Response response = get(Response.Status.OK, form.asMap(),"projects", projectId, "repository", "files");
3838
return (response.readEntity(RepositoryFile.class));
3939
}
40-
40+
4141
/**
4242
* Create new file in repository
43-
*
43+
*
4444
* POST /projects/:id/repository/files
45-
*
45+
*
4646
* file_path (required) - Full path to new file. Ex. lib/class.rb
4747
* branch_name (required) - The name of branch
4848
* encoding (optional) - 'text' or 'base64'. Text is default.
4949
* content (required) - File content
5050
* commit_message (required) - Commit message
51-
*
51+
*
5252
* @param file
5353
* @param projectId
5454
* @param branchName
@@ -61,18 +61,18 @@ public RepositoryFile createFile (RepositoryFile file, Integer projectId, String
6161
Response response = post(Response.Status.CREATED, formData, "projects", projectId, "repository", "files");
6262
return (response.readEntity(RepositoryFile.class));
6363
}
64-
64+
6565
/**
6666
* Update existing file in repository
67-
*
67+
*
6868
* PUT /projects/:id/repository/files
69-
*
69+
*
7070
* file_path (required) - Full path to new file. Ex. lib/class.rb
7171
* branch_name (required) - The name of branch
7272
* encoding (optional) - 'text' or 'base64'. Text is default.
7373
* content (required) - File content
7474
* commit_message (required) - Commit message
75-
*
75+
*
7676
* @param file
7777
* @param projectId
7878
* @param branchName
@@ -85,35 +85,35 @@ public RepositoryFile updateFile (RepositoryFile file, Integer projectId, String
8585
Response response = put(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files");
8686
return (response.readEntity(RepositoryFile.class));
8787
}
88-
88+
8989
/**
9090
* Delete existing file in repository
91-
*
91+
*
9292
* DELETE /projects/:id/repository/files
9393
*
9494
* file_path (required) - Full path to file. Ex. lib/class.rb
9595
* branch_name (required) - The name of branch
9696
* commit_message (required) - Commit message
97-
*
97+
*
9898
* @param filePath
9999
* @param projectId
100100
* @param branchName
101101
* @param commitMessage
102102
* @throws GitLabApiException
103103
*/
104104
public void deleteFile (String filePath, Integer projectId, String branchName, String commitMessage) throws GitLabApiException {
105-
105+
106106
if (filePath == null) {
107107
throw new RuntimeException("filePath cannot be null");
108108
}
109-
109+
110110
Form form = new Form();
111111
addFormParam(form, "file_path", filePath, true);
112112
addFormParam(form, "branch_name", branchName, true);
113113
addFormParam(form, "commit_message", commitMessage, true);
114114
delete(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files");
115115
}
116-
116+
117117
private Form file2form(RepositoryFile file, String branchName, String commitMessage){
118118
Form form = new Form();
119119
addFormParam(form, "file_path", file.getFilePath(), true);
@@ -123,5 +123,4 @@ private Form file2form(RepositoryFile file, String branchName, String commitMess
123123
addFormParam(form, "commit_message", commitMessage, true);
124124
return form;
125125
}
126-
127126
}

src/main/java/com/messners/gitlab/api/UserApi.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ public User getUser (int userId) throws GitLabApiException {
6262
Response response = get(Response.Status.OK, null, "users", userId);
6363
return (response.readEntity(User.class));
6464
}
65-
66-
// Search users by Email or username
67-
// GET /users?search=:email_or_username
68-
65+
66+
6967
/**
7068
* Search users by Email or username
71-
*
69+
*
7270
* GET /users?search=:email_or_username
7371
*
7472
* @param emailOrUsername
@@ -81,12 +79,13 @@ public List<User> findUsers(String emailOrUsername) throws GitLabApiException {
8179
Response response = get(Response.Status.OK, formData.asMap(), "users");
8280
return (response.readEntity(new GenericType<List<User>>() {}));
8381
}
84-
82+
83+
8584
/**
8685
* Creates a new user. Note only administrators can create new users.
87-
*
86+
*
8887
* POST /users
89-
*
88+
*
9089
* email (required) - Email
9190
* password (required) - Password
9291
* username (required) - Username

0 commit comments

Comments
 (0)