Commit 080232de authored by Tim Olshansky's avatar Tim Olshansky

Merge pull request #69 from Halcom/master

added methods:
parents 71927310 50adeacf
...@@ -690,6 +690,63 @@ public class GitlabAPI { ...@@ -690,6 +690,63 @@ public class GitlabAPI {
GitlabCommitDiff[] diffs = retrieve().to(tailUrl, GitlabCommitDiff[].class); GitlabCommitDiff[] diffs = retrieve().to(tailUrl, GitlabCommitDiff[].class);
return Arrays.asList(diffs); return Arrays.asList(diffs);
} }
/**
* Get raw file content
*
* @param project Project
* @param sha The commit or branch name
* @param filepath The path the file
* @throws IOException
*/
public byte[] getRawFileContent(GitlabProject project, String sha, String filepath) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/blobs/" + sha + "?filepath=" + filepath;
return retrieve().to(tailUrl, byte[].class);
}
/**
* Get the raw file contents for a blob by blob SHA.
*
* @param project Project
* @param sha The commit or branch name
* @throws IOException
*/
public byte[] getRawBlobContent(GitlabProject project, String sha) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/raw_blobs/" + sha;
return retrieve().to(tailUrl, byte[].class);
}
/**
* Get an archive of the repository
*
* @param project Project
* @throws IOException
*/
public byte[] getFileArchive(GitlabProject project) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/archive";
return retrieve().to(tailUrl, byte[].class);
}
/**
* Get an archive of the repository
*
* @param project Project
* @param path The path inside repository. Used to get contend of subdirectories (optional)
* @param ref_name The name of a repository branch or tag or if not given the default branch (optional)
* @throws IOException
*/
public List<GitlabRepositoryTree> getRepositoryTree(GitlabProject project, String path, String ref_name) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository" + GitlabRepositoryTree.URL;
if (path != null) {
tailUrl = tailUrl + (tailUrl.indexOf('?') > 0 ? '&' : '?') + "path=" + path;
}
if (ref_name != null) {
tailUrl = tailUrl + (tailUrl.indexOf('?') > 0 ? '&' : '?') + "ref_name=" + ref_name;
}
GitlabRepositoryTree[] tree = retrieve().to(tailUrl, GitlabRepositoryTree[].class);
return Arrays.asList(tree);
}
public GitlabNote createNote(GitlabMergeRequest mergeRequest, String body) throws IOException { public GitlabNote createNote(GitlabMergeRequest mergeRequest, String body) throws IOException {
String tailUrl = GitlabProject.URL + "/" + mergeRequest.getProjectId() + String tailUrl = GitlabProject.URL + "/" + mergeRequest.getProjectId() +
......
...@@ -285,8 +285,10 @@ public class GitlabHTTPRequestor { ...@@ -285,8 +285,10 @@ public class GitlabHTTPRequestor {
InputStreamReader reader = null; InputStreamReader reader = null;
try { try {
reader = new InputStreamReader(wrapStream(connection, connection.getInputStream()), "UTF-8"); reader = new InputStreamReader(wrapStream(connection, connection.getInputStream()), "UTF-8");
if (byte[].class == type) {
return type.cast(IOUtils.toByteArray(reader));
}
String data = IOUtils.toString(reader); String data = IOUtils.toString(reader);
if (type != null) { if (type != null) {
return GitlabAPI.MAPPER.readValue(data, type); return GitlabAPI.MAPPER.readValue(data, type);
} else if (instance != null) { } else if (instance != null) {
......
package org.gitlab.api.models;
public class GitlabRepositoryTree {
public static String URL = "/tree";
private String name;
private String type;
private String mode;
private String id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMode() {
return mode;
}
public void setMode(String mode) {
this.mode = mode;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
...@@ -89,7 +89,7 @@ public class GitlabAPIT { ...@@ -89,7 +89,7 @@ public class GitlabAPIT {
api.updateUser(gitUser.getId(), gitUser.getEmail(), password, gitUser.getUsername(), api.updateUser(gitUser.getId(), gitUser.getEmail(), password, gitUser.getUsername(),
gitUser.getName(), "newSkypeId", gitUser.getLinkedin(), gitUser.getTwitter(), gitUser.getWebsiteUrl(), gitUser.getName(), "newSkypeId", gitUser.getLinkedin(), gitUser.getTwitter(), gitUser.getWebsiteUrl(),
10 /* project limit does not come back on GET */, gitUser.getExternUid(), gitUser.getExternProviderName(), 10 /* project limit does not come back on GET */, gitUser.getExternUid(), gitUser.getExternProviderName(),
gitUser.getBio(), gitUser.isAdmin(), gitUser.isCanCreateGroup(), false); gitUser.getBio(), gitUser.isAdmin(), gitUser.isCanCreateGroup());
GitlabUser postUpdate = api.getUserViaSudo(gitUser.getUsername()); GitlabUser postUpdate = api.getUserViaSudo(gitUser.getUsername());
......
Markdown is supported
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