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
ae564a49
Commit
ae564a49
authored
May 20, 2015
by
Greg Messner
Browse files
Fixed javadoc warnings.
parent
821e2232
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/RepositoryApi.java
View file @
ae564a49
...
@@ -26,7 +26,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -26,7 +26,7 @@ public class RepositoryApi extends AbstractApi {
* GET /projects/:id/repository/branches
* GET /projects/:id/repository/branches
*
*
* @param projectId
* @param projectId
* @return the list of repository branches for
m
the specified project ID
* @return the list of repository branches for the specified project ID
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
List
<
Branch
>
getBranches
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
Branch
>
getBranches
(
Integer
projectId
)
throws
GitLabApiException
{
...
...
src/main/java/com/messners/gitlab/api/RepositoryFileApi.java
View file @
ae564a49
...
@@ -5,7 +5,6 @@ import javax.ws.rs.core.Response;
...
@@ -5,7 +5,6 @@ import javax.ws.rs.core.Response;
import
com.messners.gitlab.api.models.RepositoryFile
;
import
com.messners.gitlab.api.models.RepositoryFile
;
/**
/**
* This class provides an entry point to all the GitLab API repository files calls.
* This class provides an entry point to all the GitLab API repository files calls.
*
*
...
@@ -13,95 +12,94 @@ import com.messners.gitlab.api.models.RepositoryFile;
...
@@ -13,95 +12,94 @@ import com.messners.gitlab.api.models.RepositoryFile;
*/
*/
public
class
RepositoryFileApi
extends
AbstractApi
{
public
class
RepositoryFileApi
extends
AbstractApi
{
public
RepositoryFileApi
(
GitLabApi
gitLabApi
)
{
public
RepositoryFileApi
(
GitLabApi
gitLabApi
)
{
super
(
gitLabApi
);
super
(
gitLabApi
);
}
}
/**
/**
* Get file from repository
* Get file from repository. Allows you to receive information about file in repository like name, size, content.
* Allows you to receive information about file in repository like name, size, content.
* Note that file content is Base64 encoded.
* Note that file content is Base64 encoded.
*
*
* GET /projects/:id/repository/files
* GET /projects/:id/repository/files
*
*
* @param file
_p
ath (required) - Full path to new file. Ex. lib/class.rb
* @param file
P
ath (required) - Full path to new file. Ex. lib/class.rb
* @param projectId
* @param projectId
* @param ref (required) - The name of branch, tag or commit
* @param ref (required) - The name of branch, tag or commit
* @return
* @return
a RepositoryFile instance with the file info
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
RepositoryFile
getFile
(
String
filePath
,
Integer
projectId
,
String
ref
)
throws
GitLabApiException
{
public
RepositoryFile
getFile
(
String
filePath
,
Integer
projectId
,
String
ref
)
throws
GitLabApiException
{
Form
form
=
new
Form
();
Form
form
=
new
Form
();
addFormParam
(
form
,
"file_path"
,
filePath
,
true
);
addFormParam
(
form
,
"file_path"
,
filePath
,
true
);
addFormParam
(
form
,
"ref"
,
ref
,
true
);
addFormParam
(
form
,
"ref"
,
ref
,
true
);
Response
response
=
get
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"files"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"files"
);
return
(
response
.
readEntity
(
RepositoryFile
.
class
));
return
(
response
.
readEntity
(
RepositoryFile
.
class
));
}
}
/**
/**
* Create new file in repository
* Create new file in repository
*
*
* POST /projects/:id/repository/files
* POST /projects/:id/repository/files
*
*
* file_path (required) - Full path to new file. Ex. lib/class.rb
* file_path (required) - Full path to new file. Ex. lib/class.rb
* branch_name (required) - The name of branch
* branch_name (required) - The name of branch
* encoding (optional) - 'text' or 'base64'. Text is default.
* encoding (optional) - 'text' or 'base64'. Text is default.
* content (required) - File content
* content (required) - File content
* commit_message (required) - Commit message
* commit_message (required) - Commit message
*
*
* @param file
* @param file
* @param projectId
* @param projectId
* @param branchName
* @param branchName
* @param commitMessage
* @param commitMessage
* @return
* @return
a RepositoryFile instance with the created file info
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
RepositoryFile
createFile
(
RepositoryFile
file
,
Integer
projectId
,
String
branchName
,
String
commitMessage
)
throws
GitLabApiException
{
public
RepositoryFile
createFile
(
RepositoryFile
file
,
Integer
projectId
,
String
branchName
,
String
commitMessage
)
throws
GitLabApiException
{
Form
formData
=
file2form
(
file
,
branchName
,
commitMessage
);
Form
formData
=
file2form
(
file
,
branchName
,
commitMessage
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"repository"
,
"files"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"repository"
,
"files"
);
return
(
response
.
readEntity
(
RepositoryFile
.
class
));
return
(
response
.
readEntity
(
RepositoryFile
.
class
));
}
}
/**
/**
* Update existing file in repository
* Update existing file in repository
*
*
* PUT /projects/:id/repository/files
* PUT /projects/:id/repository/files
*
*
* file_path (required) - Full path to new file. Ex. lib/class.rb
* file_path (required) - Full path to new file. Ex. lib/class.rb
* branch_name (required) - The name of branch
* branch_name (required) - The name of branch
* encoding (optional) - 'text' or 'base64'. Text is default.
* encoding (optional) - 'text' or 'base64'. Text is default.
* content (required) - File content
* content (required) - File content
* commit_message (required) - Commit message
* commit_message (required) - Commit message
*
*
* @param file
* @param file
* @param projectId
* @param projectId
* @param branchName
* @param branchName
* @param commitMessage
* @param commitMessage
* @return
* @return
a RepositoryFile instance with the updated file info
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
RepositoryFile
updateFile
(
RepositoryFile
file
,
Integer
projectId
,
String
branchName
,
String
commitMessage
)
throws
GitLabApiException
{
public
RepositoryFile
updateFile
(
RepositoryFile
file
,
Integer
projectId
,
String
branchName
,
String
commitMessage
)
throws
GitLabApiException
{
Form
form
=
file2form
(
file
,
branchName
,
commitMessage
);
Form
form
=
file2form
(
file
,
branchName
,
commitMessage
);
Response
response
=
put
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"files"
);
Response
response
=
put
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"files"
);
return
(
response
.
readEntity
(
RepositoryFile
.
class
));
return
(
response
.
readEntity
(
RepositoryFile
.
class
));
}
}
/**
/**
* Delete existing file in repository
* Delete existing file in repository
*
*
* DELETE /projects/:id/repository/files
* DELETE /projects/:id/repository/files
*
*
* file_path (required) - Full path to file. Ex. lib/class.rb
* file_path (required) - Full path to file. Ex. lib/class.rb
* branch_name (required) - The name of branch
* branch_name (required) - The name of branch
* commit_message (required) - Commit message
* commit_message (required) - Commit message
*
*
* @param filePath
* @param filePath
* @param projectId
* @param projectId
* @param branchName
* @param branchName
* @param commitMessage
* @param commitMessage
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
void
deleteFile
(
String
filePath
,
Integer
projectId
,
String
branchName
,
String
commitMessage
)
throws
GitLabApiException
{
public
void
deleteFile
(
String
filePath
,
Integer
projectId
,
String
branchName
,
String
commitMessage
)
throws
GitLabApiException
{
if
(
filePath
==
null
)
{
if
(
filePath
==
null
)
{
throw
new
RuntimeException
(
"filePath cannot be null"
);
throw
new
RuntimeException
(
"filePath cannot be null"
);
...
@@ -114,13 +112,13 @@ public class RepositoryFileApi extends AbstractApi {
...
@@ -114,13 +112,13 @@ public class RepositoryFileApi extends AbstractApi {
delete
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"files"
);
delete
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"files"
);
}
}
private
Form
file2form
(
RepositoryFile
file
,
String
branchName
,
String
commitMessage
){
private
Form
file2form
(
RepositoryFile
file
,
String
branchName
,
String
commitMessage
)
{
Form
form
=
new
Form
();
Form
form
=
new
Form
();
addFormParam
(
form
,
"file_path"
,
file
.
getFilePath
(),
true
);
addFormParam
(
form
,
"file_path"
,
file
.
getFilePath
(),
true
);
addFormParam
(
form
,
"branch_name"
,
branchName
,
true
);
addFormParam
(
form
,
"branch_name"
,
branchName
,
true
);
addFormParam
(
form
,
"encoding"
,
file
.
getEncoding
(),
false
);
addFormParam
(
form
,
"encoding"
,
file
.
getEncoding
(),
false
);
addFormParam
(
form
,
"content"
,
file
.
getContent
(),
true
);
addFormParam
(
form
,
"content"
,
file
.
getContent
(),
true
);
addFormParam
(
form
,
"commit_message"
,
commitMessage
,
true
);
addFormParam
(
form
,
"commit_message"
,
commitMessage
,
true
);
return
form
;
return
form
;
}
}
}
}
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