Commit 0abb1d21 authored by Greg Messner's avatar Greg Messner
Browse files

Changed processing of whitespace on content properties (#136).

parent f5a54d5a
...@@ -48,8 +48,8 @@ public class GitLabApiForm extends Form { ...@@ -48,8 +48,8 @@ public class GitLabApiForm extends Form {
return (this); return (this);
} }
String stringValue = value.toString().trim(); String stringValue = value.toString();
if (required && stringValue.length() == 0) { if (required && stringValue.trim().length() == 0) {
throw new IllegalArgumentException(name + " cannot be empty or null"); throw new IllegalArgumentException(name + " cannot be empty or null");
} }
......
...@@ -86,7 +86,7 @@ public class RepositoryFileApi extends AbstractApi { ...@@ -86,7 +86,7 @@ public class RepositoryFileApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
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 = createForm(file, branchName, commitMessage);
Response response; Response response;
if (isApiVersion(ApiVersion.V3)) { if (isApiVersion(ApiVersion.V3)) {
response = post(Response.Status.CREATED, formData, "projects", projectId, "repository", "files"); response = post(Response.Status.CREATED, formData, "projects", projectId, "repository", "files");
...@@ -116,7 +116,7 @@ public class RepositoryFileApi extends AbstractApi { ...@@ -116,7 +116,7 @@ public class RepositoryFileApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
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 formData = file2form(file, branchName, commitMessage); Form formData = createForm(file, branchName, commitMessage);
Response response; Response response;
if (isApiVersion(ApiVersion.V3)) { if (isApiVersion(ApiVersion.V3)) {
response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "repository", "files"); response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "repository", "files");
...@@ -215,7 +215,7 @@ public class RepositoryFileApi extends AbstractApi { ...@@ -215,7 +215,7 @@ public class RepositoryFileApi extends AbstractApi {
return (response.readEntity(InputStream.class)); return (response.readEntity(InputStream.class));
} }
private Form file2form(RepositoryFile file, String branchName, String commitMessage) { private Form createForm(RepositoryFile file, String branchName, String commitMessage) {
Form form = new Form(); Form form = new Form();
if (isApiVersion(ApiVersion.V3)) { if (isApiVersion(ApiVersion.V3)) {
...@@ -228,6 +228,6 @@ public class RepositoryFileApi extends AbstractApi { ...@@ -228,6 +228,6 @@ public class RepositoryFileApi extends AbstractApi {
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);
} }
} }
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