@@ -984,9 +984,9 @@ public Project createProject(String name, Integer namespaceId, String descriptio
984
984
* Updates a project. The following properties on the Project instance
985
985
* are utilized in the edit of the project, null values are not updated:
986
986
*
987
- * id (required) - existing project id
988
- * name (required ) - project name
989
- * path (optional) - project path
987
+ * id (required) - existing project id, either id or path must be provided
988
+ * name (optional ) - project name
989
+ * path (optional) - project path, either id or path must be provided
990
990
* defaultBranch (optional) - master by default
991
991
* description (optional) - short project description
992
992
* visibility (optional) - Limit by visibility public, internal, or private
@@ -1026,18 +1026,11 @@ public Project updateProject(Project project) throws GitLabApiException {
1026
1026
throw new RuntimeException ("Project instance cannot be null." );
1027
1027
}
1028
1028
1029
- Integer id = project .getId ();
1030
- if (id == null ) {
1031
- throw new RuntimeException ("Project ID cannot be null." );
1032
- }
1033
-
1034
- String name = project .getName ();
1035
- if (name == null || name .trim ().length () == 0 ) {
1036
- throw new RuntimeException ("Project name cannot be null or empty." );
1037
- }
1029
+ // This will throw an exception if both id and path are not present
1030
+ Object projectIdentifier = getProjectIdOrPath (project );
1038
1031
1039
1032
GitLabApiForm formData = new GitLabApiForm ()
1040
- .withParam ("name" , name , true )
1033
+ .withParam ("name" , project . getName () )
1041
1034
.withParam ("path" , project .getPath ())
1042
1035
.withParam ("default_branch" , project .getDefaultBranch ())
1043
1036
.withParam ("description" , project .getDescription ())
@@ -1078,7 +1071,7 @@ public Project updateProject(Project project) throws GitLabApiException {
1078
1071
}
1079
1072
}
1080
1073
1081
- Response response = putWithFormData (Response .Status .OK , formData , "projects" , id );
1074
+ Response response = putWithFormData (Response .Status .OK , formData , "projects" , projectIdentifier );
1082
1075
return (response .readEntity (Project .class ));
1083
1076
}
1084
1077
0 commit comments