Commit 31cd97f1 authored by Greg Messner's avatar Greg Messner
Browse files

Fixed updateProject() (#292).

parent 6ca487bf
...@@ -984,9 +984,9 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -984,9 +984,9 @@ public class ProjectApi extends AbstractApi implements Constants {
* Updates a project. The following properties on the Project instance * Updates a project. The following properties on the Project instance
* are utilized in the edit of the project, null values are not updated: * are utilized in the edit of the project, null values are not updated:
* *
* id (required) - existing project id * id (required) - existing project id, either id or path must be provided
* name (required) - project name * name (optional) - project name
* path (optional) - project path * path (optional) - project path, either id or path must be provided
* defaultBranch (optional) - master by default * defaultBranch (optional) - master by default
* description (optional) - short project description * description (optional) - short project description
* visibility (optional) - Limit by visibility public, internal, or private * visibility (optional) - Limit by visibility public, internal, or private
...@@ -1026,18 +1026,11 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1026,18 +1026,11 @@ public class ProjectApi extends AbstractApi implements Constants {
throw new RuntimeException("Project instance cannot be null."); throw new RuntimeException("Project instance cannot be null.");
} }
Integer id = project.getId(); // This will throw an exception if both id and path are not present
if (id == null) { Object projectIdentifier = getProjectIdOrPath(project);
throw new RuntimeException("Project ID cannot be null.");
}
String name = project.getName();
if (name == null || name.trim().length() == 0) {
throw new RuntimeException("Project name cannot be null or empty.");
}
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true) .withParam("name", project.getName())
.withParam("path", project.getPath()) .withParam("path", project.getPath())
.withParam("default_branch", project.getDefaultBranch()) .withParam("default_branch", project.getDefaultBranch())
.withParam("description", project.getDescription()) .withParam("description", project.getDescription())
...@@ -1078,7 +1071,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1078,7 +1071,7 @@ public class ProjectApi extends AbstractApi implements Constants {
} }
} }
Response response = putWithFormData(Response.Status.OK, formData, "projects", id); Response response = putWithFormData(Response.Status.OK, formData, "projects", projectIdentifier);
return (response.readEntity(Project.class)); return (response.readEntity(Project.class));
} }
......
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