The Unified and Autonomous Development Platform
Fix issue #228 - RESTful API
Robin Shen3e7bd3224367
diff --git a/pom.xml b/pom.xmlindex 8024a6f013..77e64ea1d4 100644--- a/pom.xml+++ b/pom.xml@@ -9,7 +9,7 @@<version>1.0.5</version></parent><artifactId>server</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version><packaging>pom</packaging><build><finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>diff --git a/server-core/pom.xml b/server-core/pom.xmlindex 8ea80aebfc..561c5fdb50 100644--- a/server-core/pom.xml+++ b/server-core/pom.xml@@ -7,7 +7,7 @@<parent><groupId>io.onedev</groupId><artifactId>server</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><build><plugins>diff --git a/server-core/src/main/java/io/onedev/server/CoreModule.java b/server-core/src/main/java/io/onedev/server/CoreModule.javaindex 86b1b0b2b5..9829eef619 100644--- a/server-core/src/main/java/io/onedev/server/CoreModule.java+++ b/server-core/src/main/java/io/onedev/server/CoreModule.java@@ -217,7 +217,7 @@ import io.onedev.server.persistence.annotation.Sessional;import io.onedev.server.persistence.annotation.Transactional;import io.onedev.server.persistence.dao.Dao;import io.onedev.server.persistence.dao.DefaultDao;-import io.onedev.server.rest.RestUtils;+import io.onedev.server.rest.RestConstants;import io.onedev.server.rest.jersey.DefaultServletContainer;import io.onedev.server.rest.jersey.JerseyConfigurator;import io.onedev.server.rest.jersey.ResourceConfigProvider;@@ -569,7 +569,7 @@ public class CoreModule extends AbstractPluginModule {@Overridepublic void configure(ResourceConfig resourceConfig) {- resourceConfig.packages(RestUtils.class.getPackage().getName());+ resourceConfig.packages(RestConstants.class.getPackage().getName());}});diff --git a/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultBuildManager.java b/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultBuildManager.javaindex 70f6ce4c62..461d273ab5 100644--- a/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultBuildManager.java+++ b/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultBuildManager.java@@ -319,7 +319,7 @@ public class DefaultBuildManager extends BaseEntityManager<Build> implements Buitry {for (Project each: projects) {Collection<String> availableJobNames = jobNames.get(each.getId());- if (!availableJobNames.isEmpty()) {+ if (availableJobNames != null && !availableJobNames.isEmpty()) {Collection<String> accessibleJobNames = getAccessibleJobNames(each);if (accessibleJobNames.containsAll(availableJobNames)) {projectCriterions.add(Restrictions.eq(Build.PROP_PROJECT, each));diff --git a/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultSshKeyManager.java b/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultSshKeyManager.javaindex 5c0122dc14..2899743545 100644--- a/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultSshKeyManager.java+++ b/server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultSshKeyManager.java@@ -1,8 +1,5 @@package io.onedev.server.entitymanager.impl;-import java.io.IOException;-import java.security.GeneralSecurityException;-import java.security.PublicKey;import java.util.Collection;import java.util.Date;import java.util.HashMap;@@ -11,7 +8,6 @@ import java.util.Map;import javax.inject.Inject;import javax.inject.Singleton;-import org.apache.sshd.common.config.keys.KeyUtils;import org.hibernate.criterion.Restrictions;import org.hibernate.criterion.SimpleExpression;import org.slf4j.Logger;@@ -28,8 +24,6 @@ import io.onedev.server.persistence.annotation.Transactional;import io.onedev.server.persistence.dao.BaseEntityManager;import io.onedev.server.persistence.dao.Dao;import io.onedev.server.persistence.dao.EntityCriteria;-import io.onedev.server.security.CipherUtils;-import io.onedev.server.ssh.SshKeyUtils;@Singletonpublic class DefaultSshKeyManager extends BaseEntityManager<SshKey> implements SshKeyManager {@@ -55,19 +49,12 @@ public class DefaultSshKeyManager extends BaseEntityManager<SshKey> implements Spublic void syncSshKeys(User user, Collection<String> sshKeys) {Map<String, SshKey> syncMap = new HashMap<>();for (String content: sshKeys) {- try {- PublicKey pubEntry = SshKeyUtils.decodeSshPublicKey(content);- String digest = KeyUtils.getFingerPrint(CipherUtils.DIGEST_FORMAT, pubEntry);-- SshKey sshKey = new SshKey();- sshKey.setDigest(digest);- sshKey.setContent(content);- sshKey.setOwner(user);- sshKey.setCreatedAt(new Date());- syncMap.put(content, sshKey);- } catch (IOException | GeneralSecurityException e) {- logger.error("Error parsing SSH key", e);- }+ SshKey sshKey = new SshKey();+ sshKey.setContent(content);+ sshKey.setOwner(user);+ sshKey.setCreatedAt(new Date());+ sshKey.digest();+ syncMap.put(content, sshKey);}Map<String, SshKey> currentMap = new HashMap<>();diff --git a/server-core/src/main/java/io/onedev/server/model/SshKey.java b/server-core/src/main/java/io/onedev/server/model/SshKey.javaindex cb5584ff98..8380cafecf 100644--- a/server-core/src/main/java/io/onedev/server/model/SshKey.java+++ b/server-core/src/main/java/io/onedev/server/model/SshKey.java@@ -1,5 +1,8 @@package io.onedev.server.model;+import java.io.IOException;+import java.security.GeneralSecurityException;+import java.security.PublicKey;import java.util.Date;import javax.annotation.Nullable;@@ -13,9 +16,13 @@ import javax.persistence.Table;import javax.persistence.UniqueConstraint;import javax.validation.ConstraintValidatorContext;+import org.apache.sshd.common.config.keys.KeyUtils;import org.hibernate.validator.constraints.NotEmpty;+import com.fasterxml.jackson.annotation.JsonIgnore;+import io.onedev.commons.utils.StringUtils;+import io.onedev.server.security.CipherUtils;import io.onedev.server.ssh.SshKeyUtils;import io.onedev.server.util.validation.Validatable;import io.onedev.server.util.validation.annotation.ClassValidating;@@ -34,12 +41,14 @@ public class SshKey extends AbstractEntity implements Validatable {private static final long serialVersionUID = 1L;- @Column(nullable=false, length = 5000)+ @Column(nullable=false, length=5000)private String content;+ @JsonIgnore@Column(nullable=false)private String digest;-++ @JsonIgnore@Column(nullable=false)private Date createdAt;@@ -92,6 +101,15 @@ public class SshKey extends AbstractEntity implements Validatable {return null;}+ public void digest() {+ try {+ PublicKey pubEntry = SshKeyUtils.decodeSshPublicKey(content);+ digest = KeyUtils.getFingerPrint(CipherUtils.DIGEST_FORMAT, pubEntry);+ } catch (IOException | GeneralSecurityException e) {+ throw new RuntimeException(e);+ }+ }+@Overridepublic boolean isValid(ConstraintValidatorContext context) {if (content == null) {diff --git a/server-core/src/main/java/io/onedev/server/rest/BuildQuerySettingResource.java b/server-core/src/main/java/io/onedev/server/rest/BuildQuerySettingResource.javaindex dcad916fc6..cf933e6b62 100644--- a/server-core/src/main/java/io/onedev/server/rest/BuildQuerySettingResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/BuildQuerySettingResource.java@@ -44,13 +44,11 @@ public class BuildQuerySettingResource {return querySetting;}- @Api(order=200)+ @Api(order=200, description="Update build query setting of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull BuildQuerySetting querySetting) {- if (!SecurityUtils.canAccess(querySetting.getProject())- || !SecurityUtils.isAdministrator() && !querySetting.getUser().equals(SecurityUtils.getUser())) {+ public Long createOrUpdate(@NotNull BuildQuerySetting querySetting) {+ if (!SecurityUtils.isAdministrator() && !querySetting.getUser().equals(SecurityUtils.getUser()))throw new UnauthorizedException();- }querySettingManager.save(querySetting);return querySetting.getId();}diff --git a/server-core/src/main/java/io/onedev/server/rest/BuildResource.java b/server-core/src/main/java/io/onedev/server/rest/BuildResource.javaindex 4a07639c35..d1b39660f1 100644--- a/server-core/src/main/java/io/onedev/server/rest/BuildResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/BuildResource.java@@ -26,7 +26,9 @@ import io.onedev.server.rest.jersey.InvalidParamException;import io.onedev.server.search.entity.build.BuildQuery;import io.onedev.server.security.SecurityUtils;-@Api(order=4000)+@Api(order=4000, description="In most cases, build resource is operated with build id, which is different from build number. "+ + "To get build id of a particular build number, use the <a href='/help/api/io.onedev.server.rest.BuildResource/queryBasicInfo'>Query Basic Info</a> operation with query for "+ + "instance <code>"Number" is "projectName#100"</code>")@Path("/builds")@Consumes(MediaType.APPLICATION_JSON)@Produces(MediaType.APPLICATION_JSON)@@ -43,7 +45,7 @@ public class BuildResource {@Api(order=100)@Path("/{buildId}")@GET- public Build get(@PathParam("buildId") Long buildId) {+ public Build getBasicInfo(@PathParam("buildId") Long buildId) {Build build = buildManager.load(buildId);if (!SecurityUtils.canAccess(build))throw new UnauthorizedException();@@ -92,11 +94,13 @@ public class BuildResource {@Api(order=600)@GET- public List<Build> query(@QueryParam("query") String query, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ public List<Build> queryBasicInfo(+ @QueryParam("query") @Api(description="Syntax of this query is the same as query box in <a href='/builds'>builds page</a>", example="\"Number\" is \"projectName#100\"") String query,+ @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);BuildQuery parsedQuery;try {diff --git a/server-core/src/main/java/io/onedev/server/rest/CodeCommentQuerySettingResource.java b/server-core/src/main/java/io/onedev/server/rest/CodeCommentQuerySettingResource.javaindex e55c0197ad..088b0d1a68 100644--- a/server-core/src/main/java/io/onedev/server/rest/CodeCommentQuerySettingResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/CodeCommentQuerySettingResource.java@@ -44,9 +44,9 @@ public class CodeCommentQuerySettingResource {return querySetting;}- @Api(order=200)+ @Api(order=200, description="Update code comment query setting of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull CodeCommentQuerySetting querySetting) {+ public Long createOrUpdate(@NotNull CodeCommentQuerySetting querySetting) {if (!SecurityUtils.canAccess(querySetting.getProject())|| !SecurityUtils.isAdministrator() && !querySetting.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/CodeCommentReplyResource.java b/server-core/src/main/java/io/onedev/server/rest/CodeCommentReplyResource.javaindex 8d8921d77b..8406644056 100644--- a/server-core/src/main/java/io/onedev/server/rest/CodeCommentReplyResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/CodeCommentReplyResource.java@@ -44,9 +44,9 @@ public class CodeCommentReplyResource {return reply;}- @Api(order=200)+ @Api(order=200, description="Update code comment reply of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull CodeCommentReply reply) {+ public Long createOrUpdate(@NotNull CodeCommentReply reply) {if (!SecurityUtils.canReadCode(reply.getComment().getProject()) ||!SecurityUtils.isAdministrator() && !reply.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/CodeCommentResource.java b/server-core/src/main/java/io/onedev/server/rest/CodeCommentResource.javaindex 8b1b35bd97..ba0c93a817 100644--- a/server-core/src/main/java/io/onedev/server/rest/CodeCommentResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/CodeCommentResource.java@@ -54,7 +54,7 @@ public class CodeCommentResource {@Api(order=100)@Path("/{commentId}")@GET- public CodeComment get(@PathParam("commentId") Long commentId) {+ public CodeComment getBasicInfo(@PathParam("commentId") Long commentId) {CodeComment comment = commentManager.load(commentId);if (!SecurityUtils.canReadCode(comment.getProject()))throw new UnauthorizedException();@@ -73,12 +73,14 @@ public class CodeCommentResource {@Api(order=300)@GET- public Collection<CodeComment> query(@QueryParam("projectId") Long projectId,- @QueryParam("pullRequestId") Long pullRequestId, @QueryParam("query") String query,- @QueryParam("offset") int offset, @QueryParam("count") int count) {+ public Collection<CodeComment> queryBasicInfo(+ @QueryParam("projectId") Long projectId,+ @QueryParam("pullRequestId") Long pullRequestId,+ @QueryParam("query") @Api(description="Syntax of this query is the same as query box in project code comments page", example="created by me") String query,+ @QueryParam("offset") @Api(example="0") int offset, @QueryParam("count") @Api(example="100") int count) {- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);Project project;if (projectId != null)@@ -114,9 +116,9 @@ public class CodeCommentResource {return commentManager.query(project, pullRequest, parsedQuery, offset, count);}- @Api(order=400)+ @Api(order=400, description="Update code comment of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull CodeComment comment) {+ public Long createOrUpdate(@NotNull CodeComment comment) {if (!SecurityUtils.canReadCode(comment.getProject()) ||!SecurityUtils.isAdministrator() && !comment.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/CommitQuerySettingResource.java b/server-core/src/main/java/io/onedev/server/rest/CommitQuerySettingResource.javaindex 07b99962ec..cb97567e13 100644--- a/server-core/src/main/java/io/onedev/server/rest/CommitQuerySettingResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/CommitQuerySettingResource.java@@ -44,9 +44,9 @@ public class CommitQuerySettingResource {return querySetting;}- @Api(order=200)+ @Api(order=200, description="Update commit query setting of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull CommitQuerySetting querySetting) {+ public Long createOrUpdate(@NotNull CommitQuerySetting querySetting) {if (!SecurityUtils.canAccess(querySetting.getProject())|| !SecurityUtils.isAdministrator() && !querySetting.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/GroupAuthorizationResource.java b/server-core/src/main/java/io/onedev/server/rest/GroupAuthorizationResource.javaindex 00f7d463fc..bbbde82a40 100644--- a/server-core/src/main/java/io/onedev/server/rest/GroupAuthorizationResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/GroupAuthorizationResource.java@@ -43,9 +43,9 @@ public class GroupAuthorizationResource {return authorizationManager.load(authorizationId);}- @Api(order=200)+ @Api(order=200, description="Update group authorization of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull GroupAuthorization authorization) {+ public Long createOrUpdate(@NotNull GroupAuthorization authorization) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();authorizationManager.save(authorization);diff --git a/server-core/src/main/java/io/onedev/server/rest/GroupResource.java b/server-core/src/main/java/io/onedev/server/rest/GroupResource.javaindex bd4ae7e645..7d6e70dbb8 100644--- a/server-core/src/main/java/io/onedev/server/rest/GroupResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/GroupResource.java@@ -47,7 +47,7 @@ public class GroupResource {@Api(order=100)@Path("/{groupId}")@GET- public Group get(@PathParam("groupId") Long groupId) {+ public Group getBasicInfo(@PathParam("groupId") Long groupId) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();return groupManager.load(groupId);@@ -73,14 +73,14 @@ public class GroupResource {@Api(order=400)@GET- public List<Group> query(@QueryParam("name") String name, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ public List<Group> queryBasicInfo(@QueryParam("name") String name, @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);EntityCriteria<Group> criteria = EntityCriteria.of(Group.class);if (name != null)@@ -89,9 +89,9 @@ public class GroupResource {return groupManager.query(criteria, offset, count);}- @Api(order=500)+ @Api(order=500, description="Update group of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull Group group) {+ public Long createOrUpdate(@NotNull Group group) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();groupManager.save(group, (String) group.getCustomData());diff --git a/server-core/src/main/java/io/onedev/server/rest/IssueCommentResource.java b/server-core/src/main/java/io/onedev/server/rest/IssueCommentResource.javaindex 4b22598222..036be1c75c 100644--- a/server-core/src/main/java/io/onedev/server/rest/IssueCommentResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/IssueCommentResource.java@@ -44,9 +44,9 @@ public class IssueCommentResource {return comment;}- @Api(order=200)+ @Api(order=200, description="Update issue comment of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull IssueComment comment) {+ public Long createOrUpdate(@NotNull IssueComment comment) {if (!SecurityUtils.canAccess(comment.getIssue().getProject()) ||!SecurityUtils.isAdministrator() && !comment.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/IssueQuerySettingResource.java b/server-core/src/main/java/io/onedev/server/rest/IssueQuerySettingResource.javaindex ab58ad3877..0722ab6082 100644--- a/server-core/src/main/java/io/onedev/server/rest/IssueQuerySettingResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/IssueQuerySettingResource.java@@ -44,9 +44,9 @@ public class IssueQuerySettingResource {return querySetting;}- @Api(order=200)+ @Api(order=200, description="Update issue query setting of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull IssueQuerySetting querySetting) {+ public Long createOrUpdate(@NotNull IssueQuerySetting querySetting) {if (!SecurityUtils.canAccess(querySetting.getProject())|| !SecurityUtils.isAdministrator() && !querySetting.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/IssueResource.java b/server-core/src/main/java/io/onedev/server/rest/IssueResource.javaindex e34deb2220..f1677d926e 100644--- a/server-core/src/main/java/io/onedev/server/rest/IssueResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/IssueResource.java@@ -45,12 +45,15 @@ import io.onedev.server.model.PullRequest;import io.onedev.server.model.User;import io.onedev.server.model.support.issue.field.spec.FieldSpec;import io.onedev.server.rest.annotation.Api;+import io.onedev.server.rest.annotation.EntityCreate;import io.onedev.server.rest.annotation.EntityId;import io.onedev.server.rest.jersey.InvalidParamException;import io.onedev.server.search.entity.issue.IssueQuery;import io.onedev.server.security.SecurityUtils;-@Api(order=2000)+@Api(order=2000, description="In most cases, issue resource is operated with issue id, which is different from issue number. "+ + "To get issue id of a particular issue number, use the <a href='/help/api/io.onedev.server.rest.IssueResource/queryBasicInfo'>Query Basic Info</a> operation with query for "+ + "instance <code>"Number" is "projectName#100"</code>")@Path("/issues")@Consumes(MediaType.APPLICATION_JSON)@Produces(MediaType.APPLICATION_JSON)@@ -81,7 +84,7 @@ public class IssueResource {@Api(order=100)@Path("/{issueId}")@GET- public Issue get(@PathParam("issueId") Long issueId) {+ public Issue getBasicInfo(@PathParam("issueId") Long issueId) {Issue issue = issueManager.load(issueId);if (!SecurityUtils.canAccess(issue.getProject()))throw new UnauthorizedException();@@ -160,11 +163,13 @@ public class IssueResource {@Api(order=900)@GET- public List<Issue> query(@QueryParam("query") String query, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ public List<Issue> queryBasicInfo(+ @QueryParam("query") @Api(description="Syntax of this query is the same as query box in <a href='/issues'>issues page</a>", example="\"Number\" is \"projectName#100\"") String query,+ @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);IssueQuery parsedQuery;try {@@ -178,7 +183,7 @@ public class IssueResource {@Api(order=1000)@POST- public Long open(@NotNull @Valid IssueOpenData data) {+ public Long create(@NotNull @Valid IssueOpenData data) {User user = SecurityUtils.getUser();Project project = projectManager.load(data.getProjectId());@@ -336,6 +341,7 @@ public class IssueResource {return Response.ok().build();}+ @EntityCreate(Issue.class)public static class IssueOpenData implements Serializable {private static final long serialVersionUID = 1L;diff --git a/server-core/src/main/java/io/onedev/server/rest/IssueVoteResource.java b/server-core/src/main/java/io/onedev/server/rest/IssueVoteResource.javaindex c038af775a..73f7585606 100644--- a/server-core/src/main/java/io/onedev/server/rest/IssueVoteResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/IssueVoteResource.java@@ -44,9 +44,9 @@ public class IssueVoteResource {return vote;}- @Api(order=200)+ @Api(order=200, description="Update issue vote of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull IssueVote vote) {+ public Long createOrUpdate(@NotNull IssueVote vote) {if (!SecurityUtils.canAccess(vote.getIssue().getProject())|| !SecurityUtils.isAdministrator() && !vote.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/IssueWatchResource.java b/server-core/src/main/java/io/onedev/server/rest/IssueWatchResource.javaindex 4bf79504db..fa54690e83 100644--- a/server-core/src/main/java/io/onedev/server/rest/IssueWatchResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/IssueWatchResource.java@@ -44,9 +44,9 @@ public class IssueWatchResource {return watch;}- @Api(order=200)+ @Api(order=200, description="Update issue watch of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull IssueWatch watch) {+ public Long createOrUpdate(@NotNull IssueWatch watch) {if (!SecurityUtils.canAccess(watch.getIssue().getProject())|| !SecurityUtils.isAdministrator() && !watch.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/JobRunResource.java b/server-core/src/main/java/io/onedev/server/rest/JobRunResource.javaindex 6492a6a9a4..2ef3eed81c 100644--- a/server-core/src/main/java/io/onedev/server/rest/JobRunResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/JobRunResource.java@@ -31,6 +31,7 @@ import io.onedev.server.model.Build;import io.onedev.server.model.Project;import io.onedev.server.model.PullRequest;import io.onedev.server.rest.annotation.Api;+import io.onedev.server.rest.annotation.EntityCreate;import io.onedev.server.rest.annotation.EntityId;import io.onedev.server.security.SecurityUtils;import io.onedev.server.util.validation.annotation.CommitHash;@@ -61,7 +62,7 @@ public class JobRunResource {@Api(order=100)@POST- public Long run(@NotNull @Valid JobRun jobRun) {+ public Long runBuild(@NotNull @Valid JobRun jobRun) {Project project = projectManager.load(jobRun.projectId);if (!SecurityUtils.canRunJob(project, jobRun.jobName))throw new UnauthorizedException();@@ -92,9 +93,9 @@ public class JobRunResource {}@Api(order=200)- @Path("/rerun")+ @Path("/rebuild")@POST- public Response rerun(@NotNull @Valid JobRerun jobRerun) {+ public Response rebuild(@NotNull @Valid JobRerun jobRerun) {Build build = buildManager.load(jobRerun.buildId);if (!SecurityUtils.canRunJob(build.getProject(), build.getJobName()))throw new UnauthorizedException();@@ -105,7 +106,7 @@ public class JobRunResource {@Api(order=300)@Path("/{buildId}")@DELETE- public Response delete(@PathParam("buildId") Long buildId) {+ public Response cancelBuild(@PathParam("buildId") Long buildId) {Build build = buildManager.load(buildId);if (!SecurityUtils.canRunJob(build.getProject(), build.getJobName()))throw new UnauthorizedException();@@ -114,6 +115,7 @@ public class JobRunResource {return Response.ok().build();}+ @EntityCreate(Build.class)public static class JobRun implements Serializable {private static final long serialVersionUID = 1L;@@ -125,6 +127,9 @@ public class JobRunResource {private String jobName;+ @Api(description="A map of param name to value list. Normally the value list contains only one "+ + "param value. However in case the job param is defined as multi-valued in build spec, "+ + "you can add multiple param values")private Map<String, List<String>> params = new HashMap<>();private String refName;@@ -203,8 +208,12 @@ public class JobRunResource {private static final long serialVersionUID = 1L;+ @EntityId(Build.class)private Long buildId;+ @Api(description="A map of param name to value list. Normally the value list contains only one "+ + "param value. However in case the job param is defined as multi-valued in build spec, "+ + "you can add multiple param values")private Map<String, List<String>> params = new HashMap<>();private String reason;diff --git a/server-core/src/main/java/io/onedev/server/rest/MembershipResource.java b/server-core/src/main/java/io/onedev/server/rest/MembershipResource.javaindex ae29439535..dcca476878 100644--- a/server-core/src/main/java/io/onedev/server/rest/MembershipResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/MembershipResource.java@@ -43,9 +43,9 @@ public class MembershipResource {return membershipManager.load(membershipId);}- @Api(order=200)+ @Api(order=200, description="Update membership of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull Membership membership) {+ public Long createOrUpdate(@NotNull Membership membership) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();membershipManager.save(membership);diff --git a/server-core/src/main/java/io/onedev/server/rest/MilestoneResource.java b/server-core/src/main/java/io/onedev/server/rest/MilestoneResource.javaindex 4009365ab8..7425121960 100644--- a/server-core/src/main/java/io/onedev/server/rest/MilestoneResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/MilestoneResource.java@@ -44,9 +44,9 @@ public class MilestoneResource {return milestone;}- @Api(order=200)+ @Api(order=200, description="Update milestone of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull Milestone milestone) {+ public Long createOrUpdate(@NotNull Milestone milestone) {if (!SecurityUtils.canManageIssues(milestone.getProject()))throw new UnauthorizedException();milestoneManager.save(milestone);diff --git a/server-core/src/main/java/io/onedev/server/rest/ProjectResource.java b/server-core/src/main/java/io/onedev/server/rest/ProjectResource.javaindex 2f2e715f75..fa4e34790d 100644--- a/server-core/src/main/java/io/onedev/server/rest/ProjectResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/ProjectResource.java@@ -3,6 +3,7 @@ package io.onedev.server.rest;import java.io.Serializable;import java.util.ArrayList;import java.util.Collection;+import java.util.Date;import java.util.List;import javax.inject.Inject;@@ -41,6 +42,7 @@ import io.onedev.server.rest.annotation.Api;import io.onedev.server.rest.jersey.InvalidParamException;import io.onedev.server.search.entity.project.ProjectQuery;import io.onedev.server.security.SecurityUtils;+import io.onedev.server.util.DateUtils;@Api(order=1000)@Path("/projects")@@ -62,7 +64,7 @@ public class ProjectResource {@Api(order=100)@Path("/{projectId}")@GET- public Project get(@Api(description="Internal id of project") @PathParam("projectId") Long projectId) {+ public Project getBasicInfo(@PathParam("projectId") Long projectId) {Project project = projectManager.load(projectId);if (!SecurityUtils.canAccess(project))throw new UnauthorizedException();@@ -119,11 +121,13 @@ public class ProjectResource {@Api(order=700)@GET- public List<Project> query(@QueryParam("query") String query, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ public List<Project> queryBasicInfo(+ @QueryParam("query") @Api(description="Syntax of this query is the same as query box in <a href='/projects'>projects page</a>", example="\"Name\" is \"projectName\"") String query,+ @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);ProjectQuery parsedQuery;try {@@ -139,33 +143,39 @@ public class ProjectResource {@Path("/{projectId}/milestones")@GETpublic List<Milestone> queryMilestones(@PathParam("projectId") Long projectId, @QueryParam("name") String name,- @QueryParam("dueBefore") String dueBefore, @QueryParam("dueAfter") String dueAfter,- @QueryParam("closed") Boolean closed, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ @QueryParam("dueBefore") @Api(exampleProvider="getDateExample", description="ISO 8601 date") String dueBefore,+ @QueryParam("dueAfter") @Api(exampleProvider="getDateExample", description="ISO 8601 date") String dueAfter,+ @QueryParam("closed") Boolean closed, @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {Project project = projectManager.load(projectId);if (!SecurityUtils.canAccess(project))throw new UnauthorizedException();- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);EntityCriteria<Milestone> criteria = EntityCriteria.of(Milestone.class);criteria.add(Restrictions.eq(Milestone.PROP_PROJECT, project));if (name != null)criteria.add(Restrictions.ilike(Milestone.PROP_NAME, name.replace('%', '*')));if (dueBefore != null)- criteria.add(Restrictions.le(Milestone.PROP_DUE_DATE, RestUtils.toDate(dueBefore)));+ criteria.add(Restrictions.le(Milestone.PROP_DUE_DATE, DateUtils.parseISO8601Date(dueBefore)));if (dueAfter != null)- criteria.add(Restrictions.ge(Milestone.PROP_DUE_DATE, RestUtils.toDate(dueAfter)));+ criteria.add(Restrictions.ge(Milestone.PROP_DUE_DATE, DateUtils.parseISO8601Date(dueAfter)));if (closed != null)criteria.add(Restrictions.eq(Milestone.PROP_CLOSED, closed));return milestoneManager.query(criteria, offset, count);}- @Api(order=800)+ @SuppressWarnings("unused")+ private static String getDateExample() {+ return DateUtils.formatISO8601Date(new Date());+ }++ @Api(order=800, description="Update project of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull Project project) {+ public Long createOrUpdate(@NotNull Project project) {if (project.isNew())projectManager.create(project);else if (!SecurityUtils.canManage(project))@@ -176,10 +186,10 @@ public class ProjectResource {return project.getId();}- @Api(order=900)+ @Api(order=900, description="Update project setting")@Path("/{projectId}/setting")@POST- public Response saveSetting(@PathParam("projectId") Long projectId, @NotNull ProjectSetting setting) {+ public Response updateSetting(@PathParam("projectId") Long projectId, @NotNull ProjectSetting setting) {Project project = projectManager.load(projectId);if (!SecurityUtils.canManage(project))throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/PullRequestAssignmentResource.java b/server-core/src/main/java/io/onedev/server/rest/PullRequestAssignmentResource.javaindex 273b1f6271..cf61e8b0a6 100644--- a/server-core/src/main/java/io/onedev/server/rest/PullRequestAssignmentResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/PullRequestAssignmentResource.java@@ -45,9 +45,9 @@ public class PullRequestAssignmentResource {return assignment;}- @Api(order=200)+ @Api(order=200, description="Update pull request assignment of specified id in request body, or create new if id property not provided")@POST- public Long save(PullRequestAssignment assignment) {+ public Long createOrUpdate(PullRequestAssignment assignment) {PullRequest pullRequest = assignment.getRequest();if (!SecurityUtils.canReadCode(pullRequest.getProject()) || !SecurityUtils.canModify(pullRequest))throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/PullRequestCommentResource.java b/server-core/src/main/java/io/onedev/server/rest/PullRequestCommentResource.javaindex 760fa09eae..58f9103b3c 100644--- a/server-core/src/main/java/io/onedev/server/rest/PullRequestCommentResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/PullRequestCommentResource.java@@ -44,9 +44,9 @@ public class PullRequestCommentResource {return comment;}- @Api(order=200)+ @Api(order=200, description="Update pull request comment of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull PullRequestComment comment) {+ public Long createOrUpdate(@NotNull PullRequestComment comment) {if (!SecurityUtils.canReadCode(comment.getProject()) ||!SecurityUtils.isAdministrator() && !comment.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/PullRequestQuerySettingResource.java b/server-core/src/main/java/io/onedev/server/rest/PullRequestQuerySettingResource.javaindex fa73ac1809..bc6df623b8 100644--- a/server-core/src/main/java/io/onedev/server/rest/PullRequestQuerySettingResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/PullRequestQuerySettingResource.java@@ -44,9 +44,9 @@ public class PullRequestQuerySettingResource {return querySetting;}- @Api(order=200)+ @Api(order=200, description="Update pull request query setting of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull PullRequestQuerySetting querySetting) {+ public Long createOrUpdate(@NotNull PullRequestQuerySetting querySetting) {if (!SecurityUtils.canAccess(querySetting.getProject())|| !SecurityUtils.isAdministrator() && !querySetting.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/PullRequestResource.java b/server-core/src/main/java/io/onedev/server/rest/PullRequestResource.javaindex 5da35b6129..79ac63e42f 100644--- a/server-core/src/main/java/io/onedev/server/rest/PullRequestResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/PullRequestResource.java@@ -44,13 +44,16 @@ import io.onedev.server.model.User;import io.onedev.server.model.support.pullrequest.MergePreview;import io.onedev.server.model.support.pullrequest.MergeStrategy;import io.onedev.server.rest.annotation.Api;+import io.onedev.server.rest.annotation.EntityCreate;import io.onedev.server.rest.annotation.EntityId;import io.onedev.server.rest.jersey.InvalidParamException;import io.onedev.server.search.entity.pullrequest.PullRequestQuery;import io.onedev.server.security.SecurityUtils;import io.onedev.server.util.ProjectAndBranch;-@Api(order=3000)+@Api(order=3000, description="In most cases, pull request resource is operated with pull request id, which is different from pull request number. "+ + "To get pull request id of a particular pull request number, use the <a href='/help/api/io.onedev.server.rest.PullRequestResource/queryBasicInfo'>Query Basic Info</a> operation with query for "+ + "instance <code>"Number" is "projectName#100"</code>")@Path("/pull-requests")@Consumes(MediaType.APPLICATION_JSON)@Produces(MediaType.APPLICATION_JSON)@@ -74,7 +77,7 @@ public class PullRequestResource {@Api(order=100)@Path("/{requestId}")@GET- public PullRequest get(@PathParam("requestId") Long requestId) {+ public PullRequest getBasicInfo(@PathParam("requestId") Long requestId) {PullRequest pullRequest = pullRequestManager.load(requestId);if (!SecurityUtils.canReadCode(pullRequest.getProject()))throw new UnauthorizedException();@@ -173,11 +176,13 @@ public class PullRequestResource {@Api(order=1100)@GET- public List<PullRequest> query(@QueryParam("query") String query, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ public List<PullRequest> queryBasicInfo(+ @QueryParam("query") @Api(description="Syntax of this query is the same as query box in <a href='/pull-requests'>pull requests page</a>", example="\"Number\" is \"projectName#100\"") String query,+ @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);PullRequestQuery parsedQuery;try {@@ -191,7 +196,7 @@ public class PullRequestResource {@Api(order=1200)@POST- public Long open(@NotNull PullRequestOpenData data) {+ public Long create(@NotNull PullRequestOpenData data) {User user = SecurityUtils.getUser();ProjectAndBranch target = new ProjectAndBranch(data.getTargetProjectId(), data.getTargetBranch());@@ -391,6 +396,7 @@ public class PullRequestResource {return Response.ok().build();}+ @EntityCreate(PullRequest.class)public static class PullRequestOpenData implements Serializable {private static final long serialVersionUID = 1L;diff --git a/server-core/src/main/java/io/onedev/server/rest/PullRequestReviewResource.java b/server-core/src/main/java/io/onedev/server/rest/PullRequestReviewResource.javaindex 1fb495241d..eddcd4ded3 100644--- a/server-core/src/main/java/io/onedev/server/rest/PullRequestReviewResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/PullRequestReviewResource.java@@ -47,9 +47,9 @@ public class PullRequestReviewResource {return review;}- @Api(order=200)+ @Api(order=200, description="Update pull request review of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull PullRequestReview review) {+ public Long createOrUpdate(@NotNull PullRequestReview review) {if (!SecurityUtils.canReadCode(review.getRequest().getProject())|| !SecurityUtils.isAdministrator() && !review.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/PullRequestWatchResource.java b/server-core/src/main/java/io/onedev/server/rest/PullRequestWatchResource.javaindex 874f0f8683..bb4045ddc7 100644--- a/server-core/src/main/java/io/onedev/server/rest/PullRequestWatchResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/PullRequestWatchResource.java@@ -44,9 +44,9 @@ public class PullRequestWatchResource {return watch;}- @Api(order=200)+ @Api(order=200, description="Update pull request watch of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull PullRequestWatch watch) {+ public Long createOrUpdate(@NotNull PullRequestWatch watch) {if (!SecurityUtils.canReadCode(watch.getRequest().getProject())|| !SecurityUtils.isAdministrator() && !watch.getUser().equals(SecurityUtils.getUser())) {throw new UnauthorizedException();diff --git a/server-core/src/main/java/io/onedev/server/rest/RestConstants.java b/server-core/src/main/java/io/onedev/server/rest/RestConstants.javanew file mode 100644index 0000000000..0ac694d645--- /dev/null+++ b/server-core/src/main/java/io/onedev/server/rest/RestConstants.java@@ -0,0 +1,7 @@+package io.onedev.server.rest;++public class RestConstants {++ public static final int MAX_PAGE_SIZE = 100;++}diff --git a/server-core/src/main/java/io/onedev/server/rest/RestUtils.java b/server-core/src/main/java/io/onedev/server/rest/RestUtils.javadeleted file mode 100644index f4aaa5b8f4..0000000000--- a/server-core/src/main/java/io/onedev/server/rest/RestUtils.java+++ /dev/null@@ -1,15 +0,0 @@-package io.onedev.server.rest;--import java.util.Date;--import org.joda.time.format.ISODateTimeFormat;--public class RestUtils {-- public static final int MAX_PAGE_SIZE = 100;-- public static Date toDate(String dateString) {- return ISODateTimeFormat.dateTimeParser().parseDateTime(dateString).toDate();- }--}diff --git a/server-core/src/main/java/io/onedev/server/rest/RoleResource.java b/server-core/src/main/java/io/onedev/server/rest/RoleResource.javaindex ac6c8602c7..bffe230f0c 100644--- a/server-core/src/main/java/io/onedev/server/rest/RoleResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/RoleResource.java@@ -52,14 +52,14 @@ public class RoleResource {@Api(order=200)@GET- public List<Role> query(@QueryParam("name") String name, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ public List<Role> query(@QueryParam("name") String name, @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);EntityCriteria<Role> criteria = EntityCriteria.of(Role.class);if (name != null)@@ -68,9 +68,9 @@ public class RoleResource {return roleManager.query(criteria, offset, count);}- @Api(order=300)+ @Api(order=300, description="Update role of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull Role role) {+ public Long createOrUpdate(@NotNull Role role) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();roleManager.save(role, (String) role.getCustomData());diff --git a/server-core/src/main/java/io/onedev/server/rest/SshKeyResource.java b/server-core/src/main/java/io/onedev/server/rest/SshKeyResource.javaindex a0bf8725df..a89717d32b 100644--- a/server-core/src/main/java/io/onedev/server/rest/SshKeyResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/SshKeyResource.java@@ -1,10 +1,13 @@package io.onedev.server.rest;+import java.util.Date;+import javax.inject.Inject;import javax.inject.Singleton;import javax.ws.rs.Consumes;import javax.ws.rs.DELETE;import javax.ws.rs.GET;+import javax.ws.rs.POST;import javax.ws.rs.Path;import javax.ws.rs.PathParam;import javax.ws.rs.Produces;@@ -42,6 +45,20 @@ public class SshKeyResource {return sshKey;}+ @Api(order=150, description="Update ssh key of specified id in request body, or create new if id property not provided")+ @POST+ public Long createOrUpdate(SshKey sshKey) {+ if (!SecurityUtils.isAdministrator() && !sshKey.getOwner().equals(SecurityUtils.getUser()))+ throw new UnauthorizedException();+ if (sshKey.isNew())+ sshKey.setCreatedAt(new Date());++ sshKey.digest();++ sshKeyManager.save(sshKey);+ return sshKey.getId();+ }+@Api(order=200)@Path("/{sshKeyId}")@DELETEdiff --git a/server-core/src/main/java/io/onedev/server/rest/UserAuthorizationResource.java b/server-core/src/main/java/io/onedev/server/rest/UserAuthorizationResource.javaindex 059fc5139b..5e15195f10 100644--- a/server-core/src/main/java/io/onedev/server/rest/UserAuthorizationResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/UserAuthorizationResource.java@@ -44,9 +44,9 @@ public class UserAuthorizationResource {return authorization;}- @Api(order=200)+ @Api(order=200, description="Update user authorization of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull UserAuthorization authorization) {+ public Long createOrUpdate(@NotNull UserAuthorization authorization) {if (!SecurityUtils.canManage(authorization.getProject()))throw new UnauthorizedException();authorizationManager.save(authorization);diff --git a/server-core/src/main/java/io/onedev/server/rest/UserResource.java b/server-core/src/main/java/io/onedev/server/rest/UserResource.javaindex 06c29c455d..9b5452d389 100644--- a/server-core/src/main/java/io/onedev/server/rest/UserResource.java+++ b/server-core/src/main/java/io/onedev/server/rest/UserResource.java@@ -1,9 +1,6 @@package io.onedev.server.rest;-import java.io.IOException;import java.io.Serializable;-import java.security.GeneralSecurityException;-import java.security.PublicKey;import java.util.ArrayList;import java.util.Collection;import java.util.Date;@@ -28,7 +25,6 @@ import javax.ws.rs.core.Response;import org.apache.shiro.authc.credential.PasswordService;import org.apache.shiro.authz.UnauthenticatedException;import org.apache.shiro.authz.UnauthorizedException;-import org.apache.sshd.common.config.keys.KeyUtils;import org.hibernate.criterion.MatchMode;import org.hibernate.criterion.Restrictions;import org.hibernate.validator.constraints.NotEmpty;@@ -58,9 +54,7 @@ import io.onedev.server.model.support.pullrequest.NamedPullRequestQuery;import io.onedev.server.persistence.dao.EntityCriteria;import io.onedev.server.rest.annotation.Api;import io.onedev.server.rest.jersey.InvalidParamException;-import io.onedev.server.security.CipherUtils;import io.onedev.server.security.SecurityUtils;-import io.onedev.server.ssh.SshKeyUtils;@Api(order=5000)@Path("/users")@@ -85,7 +79,7 @@ public class UserResource {@Api(order=100)@Path("/{userId}")@GET- public User get(@PathParam("userId") Long userId) {+ public User getBasicInfo(@PathParam("userId") Long userId) {User user = userManager.load(userId);if (!SecurityUtils.isAdministrator() && !user.equals(SecurityUtils.getUser()))throw new UnauthorizedException();@@ -95,7 +89,7 @@ public class UserResource {@Api(order=200)@Path("/me")@GET- public User getMe() {+ public User getMyBasicInfo() {User user = SecurityUtils.getUser();if (user == null)throw new UnauthenticatedException();@@ -263,15 +257,15 @@ public class UserResource {@Api(order=1800)@GET- public List<User> query(@QueryParam("name") String name, @QueryParam("fullName") String fullName,- @QueryParam("email") String email, @QueryParam("offset") int offset,- @QueryParam("count") int count) {+ public List<User> queryBasicInfo(@QueryParam("name") String name, @QueryParam("fullName") String fullName,+ @QueryParam("email") String email, @QueryParam("offset") @Api(example="0") int offset,+ @QueryParam("count") @Api(example="100") int count) {if (!SecurityUtils.isAdministrator())throw new UnauthorizedException();- if (count > RestUtils.MAX_PAGE_SIZE)- throw new InvalidParamException("Count should be less than " + RestUtils.MAX_PAGE_SIZE);+ if (count > RestConstants.MAX_PAGE_SIZE)+ throw new InvalidParamException("Count should be less than " + RestConstants.MAX_PAGE_SIZE);EntityCriteria<User> criteria = EntityCriteria.of(User.class);criteria.add(Restrictions.not(Restrictions.eq("id", User.SYSTEM_ID)));@@ -285,9 +279,9 @@ public class UserResource {return userManager.query(criteria, offset, count);}- @Api(order=1900)+ @Api(order=1900, description="Update user of specified id in request body, or create new if id property not provided")@POST- public Long save(@NotNull User user) {+ public Long createOrUpdate(@NotNull User user) {if (user.isNew()) {if (!SecurityUtils.isAdministrator()) {throw new UnauthorizedException();@@ -369,14 +363,7 @@ public class UserResource {sshKey.setContent(content);sshKey.setCreatedAt(new Date());sshKey.setOwner(user);-- try {- PublicKey pubEntry = SshKeyUtils.decodeSshPublicKey(content);- String fingerPrint = KeyUtils.getFingerPrint(CipherUtils.DIGEST_FORMAT, pubEntry);- sshKey.setDigest(fingerPrint);- } catch (IOException | GeneralSecurityException e) {- throw new RuntimeException(e);- }+ sshKey.digest();sshKeyManager.save(sshKey);return sshKey.getId();diff --git a/server-core/src/main/java/io/onedev/server/rest/annotation/Api.java b/server-core/src/main/java/io/onedev/server/rest/annotation/Api.javaindex 2c0c26c9a6..f90c4829e7 100644--- a/server-core/src/main/java/io/onedev/server/rest/annotation/Api.java+++ b/server-core/src/main/java/io/onedev/server/rest/annotation/Api.java@@ -13,10 +13,10 @@ public @interface Api {String exampleProvider() default "";+ String example() default "";+String description() default "";int order() default 100;- String permission() default "";-}diff --git a/server-core/src/main/java/io/onedev/server/rest/annotation/EntityCreate.java b/server-core/src/main/java/io/onedev/server/rest/annotation/EntityCreate.javanew file mode 100644index 0000000000..cfc78560b7--- /dev/null+++ b/server-core/src/main/java/io/onedev/server/rest/annotation/EntityCreate.java@@ -0,0 +1,14 @@+package io.onedev.server.rest.annotation;++import java.lang.annotation.ElementType;+import java.lang.annotation.Retention;+import java.lang.annotation.RetentionPolicy;+import java.lang.annotation.Target;++@Retention(RetentionPolicy.RUNTIME)+@Target({ElementType.TYPE})+public @interface EntityCreate {++ Class<?> value();++}diff --git a/server-core/src/main/java/io/onedev/server/security/CipherUtils.java b/server-core/src/main/java/io/onedev/server/security/CipherUtils.javaindex 21a5e887b5..e7f5b44aa2 100644--- a/server-core/src/main/java/io/onedev/server/security/CipherUtils.java+++ b/server-core/src/main/java/io/onedev/server/security/CipherUtils.java@@ -11,7 +11,6 @@ import org.apache.commons.codec.binary.Base64;import org.apache.shiro.crypto.AesCipherService;import org.apache.sshd.common.digest.BaseDigest;import org.apache.sshd.common.digest.Digest;-import org.apache.sshd.common.digest.DigestUtils;import io.onedev.server.OneDev;import io.onedev.server.entitymanager.SettingManager;@@ -50,14 +49,6 @@ public class CipherUtils {return cipherService.decrypt(data, getCipherKey()).getBytes();}- public static String digest(String content) {- try {- return DigestUtils.getFingerPrint(DIGEST_FORMAT, content);- } catch (Exception e) {- throw new RuntimeException(e);- }- }-private static class KeyPair {private final byte[] privateKey;diff --git a/server-core/src/main/java/io/onedev/server/util/DateUtils.java b/server-core/src/main/java/io/onedev/server/util/DateUtils.javaindex 70af67892b..768cf4587b 100644--- a/server-core/src/main/java/io/onedev/server/util/DateUtils.java+++ b/server-core/src/main/java/io/onedev/server/util/DateUtils.java@@ -7,6 +7,7 @@ import javax.annotation.Nullable;import org.apache.commons.lang3.time.DurationFormatUtils;import org.joda.time.DateTime;+import org.joda.time.format.ISODateTimeFormat;import org.ocpsoft.prettytime.PrettyTime;import com.google.common.collect.Lists;@@ -49,4 +50,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {durationMillis = 0;return DurationFormatUtils.formatDurationWords(durationMillis, true, true);}++ public static Date parseISO8601Date(String dateString) {+ return ISODateTimeFormat.dateTimeParser().parseDateTime(dateString).toDate();+ }++ public static String formatISO8601Date(Date date) {+ return ISODateTimeFormat.dateTime().print(date.getTime());+ }+}\ No newline at end of filediff --git a/server-core/src/main/java/io/onedev/server/web/component/user/sshkey/InsertSshKeyPanel.java b/server-core/src/main/java/io/onedev/server/web/component/user/sshkey/InsertSshKeyPanel.javaindex 472c17ea33..f15461e997 100644--- a/server-core/src/main/java/io/onedev/server/web/component/user/sshkey/InsertSshKeyPanel.java+++ b/server-core/src/main/java/io/onedev/server/web/component/user/sshkey/InsertSshKeyPanel.java@@ -1,11 +1,7 @@package io.onedev.server.web.component.user.sshkey;-import java.io.IOException;-import java.security.GeneralSecurityException;-import java.security.PublicKey;import java.util.Date;-import org.apache.sshd.common.config.keys.KeyUtils;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.ajax.markup.html.form.AjaxButton;@@ -18,8 +14,6 @@ import io.onedev.server.OneDev;import io.onedev.server.entitymanager.SshKeyManager;import io.onedev.server.model.SshKey;import io.onedev.server.model.User;-import io.onedev.server.security.CipherUtils;-import io.onedev.server.ssh.SshKeyUtils;import io.onedev.server.util.Path;import io.onedev.server.util.PathNode;import io.onedev.server.web.editable.BeanContext;@@ -58,14 +52,7 @@ public abstract class InsertSshKeyPanel extends Panel {SshKeyManager sshKeyManager = OneDev.getInstance(SshKeyManager.class);SshKey sshKey = (SshKey) editor.getModelObject();-- try {- PublicKey pubEntry = SshKeyUtils.decodeSshPublicKey(sshKey.getContent());- String fingerPrint = KeyUtils.getFingerPrint(CipherUtils.DIGEST_FORMAT, pubEntry);- sshKey.setDigest(fingerPrint);- } catch (IOException | GeneralSecurityException e) {- throw new RuntimeException(e);- }+ sshKey.digest();if (sshKeyManager.findByDigest(sshKey.getDigest()) != null) {editor.error(new Path(new PathNode.Named("content")), "This key is already in use");diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpPage.java b/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpPage.javaindex 541e7d7162..a592313a0a 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpPage.java+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpPage.java@@ -2,6 +2,11 @@ package io.onedev.server.web.page.help;import java.lang.reflect.Method;+import javax.annotation.Nullable;+import javax.ws.rs.GET;+import javax.ws.rs.POST;+import javax.ws.rs.PUT;+import org.apache.commons.lang.StringUtils;import org.apache.wicket.Component;import org.apache.wicket.markup.head.CssHeaderItem;@@ -31,30 +36,49 @@ public abstract class ApiHelpPage extends LayoutPage {}protected String getResourceTitle(Class<?> resourceClass) {- return StringUtils.capitalize(+ return WordUtils.capitalize(WordUtils.uncamel(StringUtils.substringBeforeLast(- resourceClass.getSimpleName(), "Resource")).toLowerCase());+ resourceClass.getSimpleName(), "Resource")));}+ @Nullableprotected String getResourceDescription(Class<?> resourceClass) {+ String description = "";Api api = resourceClass.getAnnotation(Api.class);if (api != null && api.description().length() != 0)- return api.description();+ description = api.description();+ if (description.length() != 0)+ return description;else- return getResourceTitle(resourceClass);+ return null;}protected String getMethodTitle(Method resourceMethod) {- return StringUtils.capitalize(WordUtils.uncamel(resourceMethod.getName()).toLowerCase());+ return WordUtils.capitalize(WordUtils.uncamel(resourceMethod.getName()));}-++ @Nullableprotected String getMethodDescription(Method resourceMethod) {+ String description = "";Api api = resourceMethod.getAnnotation(Api.class);if (api != null && api.description().length() != 0)- return api.description();+ description = api.description();+ if (description.length() != 0)+ return description;+ else+ return null;+ }++ protected String getHttpMethod(Method resourceMethod) {+ if (resourceMethod.getAnnotation(GET.class) != null)+ return "GET";+ else if (resourceMethod.getAnnotation(POST.class) != null)+ return "POST";+ else if (resourceMethod.getAnnotation(PUT.class) != null)+ return "PUT";else- return getMethodTitle(resourceMethod);+ return "DELETE";}@Overridediff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpUtils.java b/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpUtils.javaindex 933daaa0f6..b7ce87bd80 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpUtils.java+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ApiHelpUtils.java@@ -1,11 +1,13 @@package io.onedev.server.web.page.help;+import java.io.Serializable;import java.lang.reflect.Field;import java.lang.reflect.Method;import java.lang.reflect.Modifier;import java.lang.reflect.Type;import java.util.ArrayList;import java.util.Collection;+import java.util.Comparator;import java.util.Date;import java.util.EnumSet;import java.util.HashMap;@@ -34,12 +36,12 @@ import io.onedev.server.util.ReflectionUtils;public class ApiHelpUtils {- public static Object getExampleValue(Type valueType) {+ public static Serializable getExampleValue(Type valueType) {return getExampleValue(valueType, Sets.newHashSet());}@SuppressWarnings({ "unchecked", "rawtypes" })- public static Object getExampleValue(Type valueType, Set<Class<?>> parsedTypes) {+ public static Serializable getExampleValue(Type valueType, Set<Class<?>> parsedTypes) {Class<?> valueClass = ReflectionUtils.getClass(valueType);Object value = new ExampleProvider(valueClass, valueClass.getAnnotation(Api.class)).getExample();if (value == null) {@@ -72,7 +74,7 @@ public class ApiHelpUtils {}}collection.add(getExampleValue(collectionElementType, parsedTypes));- return collection;+ return (Serializable) collection;} else if (Map.class.isAssignableFrom(valueClass)) {Type mapKeyType = ReflectionUtils.getMapKeyType(valueType);if (mapKeyType == null)@@ -94,14 +96,23 @@ public class ApiHelpUtils {map.put(getExampleValue(mapKeyType, parsedTypes), getExampleValue(mapValueType, parsedTypes));- return map;+ return (Serializable) map;} else {try {if (parsedTypes.add(valueClass)) {Class<?> instantiationClass;if (Modifier.isAbstract(valueClass.getModifiers())) {- instantiationClass = OneDev.getInstance(ImplementationRegistry.class)- .getImplementations(valueClass).iterator().next();+ List<Class<?>> implementations = new ArrayList<>(+ OneDev.getInstance(ImplementationRegistry.class).getImplementations(valueClass));+ Collections.sort(implementations, new Comparator<Class<?>>() {++ @Override+ public int compare(Class<?> o1, Class<?> o2) {+ return o1.getName().compareTo(o2.getName());+ }++ });+ instantiationClass = implementations.iterator().next();} else {instantiationClass = valueClass;}@@ -130,7 +141,7 @@ public class ApiHelpUtils {}}}- return value;+ return (Serializable) value;}public static List<Field> getJsonFields(Class<?> beanClass) {diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ExampleProvider.java b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleProvider.javaindex ff79221974..50a8efde84 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ExampleProvider.java+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleProvider.java@@ -1,5 +1,7 @@package io.onedev.server.web.page.help;+import java.io.Serializable;+import javax.annotation.Nullable;import com.google.common.base.Preconditions;@@ -19,12 +21,15 @@ class ExampleProvider {}@Nullable- public Object getExample() {- if (api != null && api.exampleProvider().length() != 0) {- return Preconditions.checkNotNull(ReflectionUtils.invokeStaticMethod(- apiDeclaringClass, api.exampleProvider()));- } else {- return null;- }+ public Serializable getExample() {+ if (api != null) {+ if (api.example().length() != 0) {+ return api.example();+ } else if (api.exampleProvider().length() != 0) {+ return (Serializable) Preconditions.checkNotNull(ReflectionUtils.invokeStaticMethod(+ apiDeclaringClass, api.exampleProvider()));+ }+ }+ return null;}}\ No newline at end of filediff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValueChanged.java b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValueChanged.javanew file mode 100644index 0000000000..fa01375357--- /dev/null+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValueChanged.java@@ -0,0 +1,13 @@+package io.onedev.server.web.page.help;++import org.apache.wicket.ajax.AjaxRequestTarget;++import io.onedev.server.web.util.AjaxPayload;++public class ExampleValueChanged extends AjaxPayload {++ public ExampleValueChanged(AjaxRequestTarget target) {+ super(target);+ }++}\ No newline at end of filediff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.html b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.htmlindex aee59b1d99..0bb5c28bac 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.html+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.html@@ -35,17 +35,17 @@<div wicket:id="description"></div></div></wicket:fragment>-- <wicket:fragment wicket:id="idOfCurrentEntityHintFrag">- Internal id of current object++ <wicket:fragment wicket:id="idAsResultOfEntityCreateOrUpdateHintFrag">+ Id of created/updated <a wicket:id="entity"><span wicket:id="label"></span></a></wicket:fragment>- <wicket:fragment wicket:id="idOfCurrentEntityInRequestBodyHintFrag">- Update object with this id. Remove this property or set this property as <i>null</i> if you want to create new object+ <wicket:fragment wicket:id="idAsResultOfEntityCreateHintFrag">+ Id of created <a wicket:id="entity"><span wicket:id="label"></span></a></wicket:fragment><wicket:fragment wicket:id="entityIdHintFrag">- Internal id of <a wicket:id="entity"><span wicket:id="label"></span></a>+ Id of <a wicket:id="entity"><span wicket:id="label"></span></a></wicket:fragment><wicket:fragment wicket:id="enumHintFrag">diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.java b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.javaindex 5cdc93ba79..1a78f8a7dd 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.java+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ExampleValuePanel.java@@ -1,25 +1,29 @@package io.onedev.server.web.page.help;+import java.io.Serializable;import java.lang.reflect.Field;import java.lang.reflect.Method;import java.lang.reflect.Modifier;import java.lang.reflect.Type;import java.util.ArrayList;import java.util.Collection;+import java.util.Comparator;import java.util.Date;import java.util.EnumSet;import java.util.HashMap;import java.util.List;import java.util.Map;+import java.util.regex.Pattern;import javax.annotation.Nullable;-import javax.persistence.Id;import javax.persistence.ManyToOne;+import javax.ws.rs.GET;import javax.ws.rs.Path;import org.apache.wicket.Component;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.markup.html.AjaxLink;+import org.apache.wicket.event.Broadcast;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.link.Link;@@ -30,18 +34,21 @@ import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;+import org.apache.wicket.model.Model;import org.glassfish.jersey.server.ResourceConfig;import com.fasterxml.jackson.annotation.JsonTypeInfo;import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.databind.ObjectMapper;+import edu.emory.mathcs.backport.java.util.Collections;import io.onedev.commons.launcher.loader.ImplementationRegistry;import io.onedev.commons.utils.StringUtils;import io.onedev.commons.utils.WordUtils;import io.onedev.server.OneDev;import io.onedev.server.model.AbstractEntity;import io.onedev.server.rest.annotation.Api;+import io.onedev.server.rest.annotation.EntityCreate;import io.onedev.server.rest.annotation.EntityId;import io.onedev.server.util.ReflectionUtils;import io.onedev.server.web.component.floating.FloatingPanel;@@ -55,6 +62,8 @@ public class ExampleValuePanel extends Panel {private static final Map<Class<?>, Class<?>> resourceMap = new HashMap<>();+ private static final Pattern GET_ENTITY_PATH = Pattern.compile("\\/\\{[a-zA-Z_\\-0-9]+\\}");+static {ResourceConfig config = OneDev.getInstance(ResourceConfig.class);@@ -62,62 +71,71 @@ public class ExampleValuePanel extends Panel {if (clazz.getAnnotation(Path.class) != null) {Api api = clazz.getAnnotation(Api.class);if (api == null || !api.exclude()) {- try {- Method method = clazz.getMethod("get", Long.class);- if (AbstractEntity.class.isAssignableFrom(method.getReturnType()))+ for (Method method: clazz.getMethods()) {+ if (AbstractEntity.class.isAssignableFrom(method.getReturnType())+ && method.getAnnotation(GET.class) != null+ && method.getAnnotation(Path.class) != null+ && GET_ENTITY_PATH.matcher(method.getAnnotation(Path.class).value()).matches()) {resourceMap.put(method.getReturnType(), clazz);- } catch (NoSuchMethodException | SecurityException e) {+ }}}}}}- private final Object value;+ private final IModel<Serializable> valueModel;private final IModel<ValueInfo> valueInfoModel;- private final boolean requestBody;-- public ExampleValuePanel(String id, Object value, boolean requestBody) {- this(id, value, newNullValueModel(), requestBody);- }+ private final Class<?> requestBodyClass;- public ExampleValuePanel(String id, Object value, IModel<ValueInfo> valueInfoModel, boolean requestBody) {+ public ExampleValuePanel(String id, IModel<Serializable> valueModel, IModel<ValueInfo> valueInfoModel,+ @Nullable Class<?> requestBodyClass) {super(id);- this.value = value;+ this.valueModel = valueModel;this.valueInfoModel = valueInfoModel;- this.requestBody = requestBody;+ this.requestBodyClass = requestBodyClass;}@Overrideprotected void onDetach() {+ valueModel.detach();valueInfoModel.detach();super.onDetach();}++ @Nullable+ private Serializable getValue() {+ return valueModel.getObject();+ }@Overrideprotected void onInitialize() {super.onInitialize();-- if (value == null || value.getClass() == String.class- || value.getClass() == boolean.class || value.getClass() == Boolean.class- || value.getClass() == int.class || value.getClass() == Integer.class- || value.getClass() == long.class || value.getClass() == Long.class- || value.getClass() == Date.class || value instanceof Enum) {- add(newScalarFragment(value));+ setOutputMarkupId(true);+ }++ @Override+ protected void onBeforeRender() {+ if (getValue() == null || getValue().getClass() == String.class+ || getValue().getClass() == boolean.class || getValue().getClass() == Boolean.class+ || getValue().getClass() == int.class || getValue().getClass() == Integer.class+ || getValue().getClass() == long.class || getValue().getClass() == Long.class+ || getValue().getClass() == Date.class || getValue() instanceof Enum) {+ addOrReplace(newScalarFragment(getValue()));} else if (getField() != null && getField().getAnnotation(ManyToOne.class) != null) {- add(newScalarFragment(((AbstractEntity)value).getId()));- } else if (value instanceof Collection) {- add(newArrayFragment());- } else if (value instanceof Map) {- add(newMapFragment());+ addOrReplace(newScalarFragment(((AbstractEntity)getValue()).getId()));+ } else if (getValue() instanceof Collection) {+ addOrReplace(newArrayFragment());+ } else if (getValue() instanceof Map) {+ addOrReplace(newMapFragment());} else {- add(newObjectFragment());+ addOrReplace(newObjectFragment());}if (newValueHint("psuedoId") != null) {- add(new DropdownLink("hint") {+ addOrReplace(new DropdownLink("hint") {@Overrideprotected Component newContent(String id, FloatingPanel dropdown) {@@ -126,12 +144,12 @@ public class ExampleValuePanel extends Panel {});} else {- add(new WebMarkupContainer("hint").setVisible(false));+ addOrReplace(new WebMarkupContainer("hint").setVisible(false));}- setOutputMarkupId(true);+ super.onBeforeRender();}-+@SuppressWarnings({ "unchecked", "rawtypes" })@Nullableprivate Component newValueHint(String componentId) {@@ -139,10 +157,10 @@ public class ExampleValuePanel extends Panel {boolean hasHint = false;- if (value instanceof Date) {+ if (getValue() instanceof Date) {fragment.add(new Fragment("typeHint", "dateHintFrag", this));hasHint = true;- } else if (value instanceof Enum && getDeclaredClass() != null) {+ } else if (getValue() instanceof Enum && getDeclaredClass() != null) {Fragment typeHintFrag = new Fragment("typeHint", "enumHintFrag", this);List<String> possibleValues = new ArrayList<>();for (Object each: EnumSet.allOf((Class<Enum>) getDeclaredClass()))@@ -152,11 +170,10 @@ public class ExampleValuePanel extends Panel {fragment.add(typeHintFrag);hasHint = true;} else if (getField() != null) {- if (getField().getAnnotation(ManyToOne.class) != null- || getField().getAnnotation(EntityId.class) != null) {+ if (getField().getAnnotation(ManyToOne.class) != null || getField().getAnnotation(EntityId.class) != null) {Class<?> entityClass;- if (value instanceof AbstractEntity)- entityClass = value.getClass();+ if (getValue() instanceof AbstractEntity)+ entityClass = getValue().getClass();elseentityClass = getField().getAnnotation(EntityId.class).value();Class<?> resourceClass = resourceMap.get(entityClass);@@ -164,20 +181,48 @@ public class ExampleValuePanel extends Panel {Fragment typeHintFrag = new Fragment("typeHint", "entityIdHintFrag", this);Link<Void> link = new ViewStateAwarePageLink<Void>("entity", ResourceDetailPage.class,ResourceDetailPage.paramsOf(resourceClass));- link.add(new Label("label", WordUtils.uncamel(resourceClass.getSimpleName()).toLowerCase()));+ link.add(new Label("label", WordUtils.uncamel(entityClass.getSimpleName()).toLowerCase()));typeHintFrag.add(link);fragment.add(typeHintFrag);hasHint = true;} else {fragment.add(new WebMarkupContainer("typeHint").setVisible(false));}- } else if (getField().getAnnotation(Id.class) != null) {- if (requestBody) {- fragment.add(new Fragment("typeHint", "idOfCurrentEntityInRequestBodyHintFrag", this));+ } else {+ fragment.add(new WebMarkupContainer("typeHint").setVisible(false));+ }+ } else if (getValue() instanceof Long+ && getValueOrigin() == ValueInfo.Origin.RESPONSE_BODY+ && requestBodyClass != null) {+ if (AbstractEntity.class.isAssignableFrom(requestBodyClass)) {+ Class<?> resourceClass = resourceMap.get(requestBodyClass);+ if (resourceClass != null) {+ Fragment typeHintFrag = new Fragment("typeHint", "idAsResultOfEntityCreateOrUpdateHintFrag", this);++ Link<Void> link = new ViewStateAwarePageLink<Void>("entity", ResourceDetailPage.class,+ ResourceDetailPage.paramsOf(resourceClass));+ String entityName = WordUtils.uncamel(requestBodyClass.getSimpleName()).toLowerCase();+ link.add(new Label("label", entityName));+ typeHintFrag.add(link);+ fragment.add(typeHintFrag);hasHint = true;} else {- fragment.add(new Fragment("typeHint", "idOfCurrentEntityHintFrag", this));+ fragment.add(new WebMarkupContainer("typeHint").setVisible(false));+ }+ } else if (requestBodyClass.getAnnotation(EntityCreate.class) != null) {+ Class<?> entityClass = requestBodyClass.getAnnotation(EntityCreate.class).value();+ Class<?> resourceClass = resourceMap.get(entityClass);+ if (resourceClass != null) {+ Fragment typeHintFrag = new Fragment("typeHint", "idAsResultOfEntityCreateHintFrag", this);+ Link<Void> link = new ViewStateAwarePageLink<Void>("entity", ResourceDetailPage.class,+ ResourceDetailPage.paramsOf(resourceClass));+ String entityName = WordUtils.uncamel(entityClass.getSimpleName()).toLowerCase();+ link.add(new Label("label", entityName));+ typeHintFrag.add(link);+ fragment.add(typeHintFrag);hasHint = true;+ } else {+ fragment.add(new WebMarkupContainer("typeHint").setVisible(false));}} else {fragment.add(new WebMarkupContainer("typeHint").setVisible(false));@@ -189,9 +234,9 @@ public class ExampleValuePanel extends Panel {String description = "";if (getField() != null && getField().getAnnotation(Api.class) != null)description = getField().getAnnotation(Api.class).description();- if (description.length() == 0 && value != null- && value.getClass().getAnnotation(Api.class) != null) {- description = value.getClass().getAnnotation(Api.class).description();+ if (description.length() == 0 && getValue() != null+ && getValue().getClass().getAnnotation(Api.class) != null) {+ description = getValue().getClass().getAnnotation(Api.class).description();}if (description.length() != 0) {hasHint = true;@@ -206,45 +251,61 @@ public class ExampleValuePanel extends Panel {return null;}- private Fragment newScalarFragment(Object value) {+ private Fragment newScalarFragment(Serializable value) {Fragment fragment = new Fragment("content", "scalarFrag", this);- fragment.add(new Label("value", toJson(value)));+ if (getValueOrigin() == ValueInfo.Origin.REQUEST_BODY || getValueOrigin() == ValueInfo.Origin.RESPONSE_BODY)+ fragment.add(new Label("value", toJson(value)));+ else+ fragment.add(new Label("value", String.valueOf(value)));+return fragment;}- private static IModel<ValueInfo> newNullValueModel() {- return new AbstractReadOnlyModel<ValueInfo>() {+ private Fragment newArrayFragment() {+ Fragment fragment = new Fragment("content", "arrayFrag", this);+ fragment.add(new ListView<Serializable>("elements", new AbstractReadOnlyModel<List<Serializable>>() {+ @SuppressWarnings("unchecked")@Override- public ValueInfo getObject() {- return null;+ public List<Serializable> getObject() {+ return new ArrayList<Serializable>((Collection<? extends Serializable>) getValue());}- };- }-- private Fragment newArrayFragment() {- Fragment fragment = new Fragment("content", "arrayFrag", this);- fragment.add(new ListView<Object>("elements", new ArrayList<Object>(((Collection<?>)value))) {+ }) {@Override- protected void populateItem(ListItem<Object> item) {- IModel<ValueInfo> valueInfoModel;- if (getValueInfo() != null) {- valueInfoModel = new LoadableDetachableModel<ValueInfo>() {+ protected void populateItem(ListItem<Serializable> item) {+ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {- @Override- protected ValueInfo load() {- Field field = getField();- Type declaredType = ReflectionUtils.getCollectionElementType(getDeclaredType());- return new ValueInfo(field, declaredType);- }-- };- } else {- valueInfoModel = newNullValueModel();- }- item.add(new ExampleValuePanel("element", item.getModelObject(), valueInfoModel, requestBody));+ @Override+ protected ValueInfo load() {+ Type declaredType = ReflectionUtils.getCollectionElementType(getDeclaredType());+ return new ValueInfo(getValueOrigin(), declaredType, null);+ }++ };++ item.add(new ExampleValuePanel("element", new IModel<Serializable>() {++ @Override+ public void detach() {+ }++ @Override+ public Serializable getObject() {+ return item.getModelObject();+ }++ @SuppressWarnings({ "unchecked", "rawtypes" })+ @Override+ public void setObject(Serializable object) {+ Collection collection = (Collection)getValue();+ collection.remove(item.getModelObject());+ collection.add(object);+ }++ }, valueInfoModel, requestBodyClass));+item.add(new WebMarkupContainer("comma").setVisible(item.getIndex() < getModelObject().size()-1));}@@ -258,51 +319,61 @@ public class ExampleValuePanel extends Panel {fragment.add(new WebMarkupContainer("typeInfo").setVisible(false));- IModel<List<Map.Entry<?, ?>>> entriesModel = new LoadableDetachableModel<List<Map.Entry<?, ?>>>() {+ IModel<List<Map.Entry<Serializable, Serializable>>> entriesModel =+ new AbstractReadOnlyModel<List<Map.Entry<Serializable, Serializable>>>() {+ @SuppressWarnings("unchecked")@Override- protected List<Map.Entry<?, ?>> load() {- return new ArrayList<Map.Entry<?, ?>>(((Map<?, ?>)value).entrySet());+ public List<Map.Entry<Serializable, Serializable>> getObject() {+ return new ArrayList<Map.Entry<Serializable, Serializable>>(((Map<Serializable, Serializable>)getValue()).entrySet());}};- fragment.add(new ListView<Map.Entry<?, ?>>("properties", entriesModel) {+ fragment.add(new ListView<Map.Entry<Serializable, Serializable>>("properties", entriesModel) {@Override- protected void populateItem(ListItem<Map.Entry<?, ?>> item) {- IModel<ValueInfo> valueInfoModel;- if (getValueInfo() != null) {- valueInfoModel = new LoadableDetachableModel<ValueInfo>() {+ protected void populateItem(ListItem<Map.Entry<Serializable, Serializable>> item) {+ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {- @Override- protected ValueInfo load() {- Field field = getField();- Type declaredType = ReflectionUtils.getMapKeyType(getDeclaredType());- return new ValueInfo(field, declaredType);- }-- };- } else {- valueInfoModel = newNullValueModel();- }- item.add(new ExampleValuePanel("name", item.getModelObject().getKey(), valueInfoModel, requestBody));+ @Override+ protected ValueInfo load() {+ Type declaredType = ReflectionUtils.getMapKeyType(getDeclaredType());+ return new ValueInfo(getValueOrigin(), declaredType, null);+ }++ };+ item.add(new ExampleValuePanel("name", Model.of(item.getModelObject().getKey()), valueInfoModel, requestBodyClass));- if (getValueInfo() != null) {- valueInfoModel = new LoadableDetachableModel<ValueInfo>() {+ valueInfoModel = new LoadableDetachableModel<ValueInfo>() {- @Override- protected ValueInfo load() {- Field field = getField();- Type declaredType = ReflectionUtils.getMapValueType(getDeclaredType());- return new ValueInfo(field, declaredType);- }+ @Override+ protected ValueInfo load() {+ Type declaredType = ReflectionUtils.getMapValueType(getDeclaredType());+ return new ValueInfo(getValueOrigin(), declaredType, null);+ }- };- } else {- valueInfoModel = newNullValueModel();- }- item.add(new ExampleValuePanel("value", item.getModelObject().getValue(), valueInfoModel, requestBody));+ };+ item.add(new ExampleValuePanel("value", new IModel<Serializable>() {++ @Override+ public void detach() {+ }++ @Override+ public Serializable getObject() {+ return item.getModelObject().getValue();+ }++ @SuppressWarnings("unchecked")+ @Override+ public void setObject(Serializable object) {+ Map<Serializable, Serializable> map = (Map<Serializable, Serializable>)getValue();+ map.put(item.getModelObject().getKey(), object);+ }++ }, valueInfoModel, requestBodyClass));+item.add(new WebMarkupContainer("comma").setVisible(item.getIndex() < getModelObject().size()-1));}@@ -318,7 +389,7 @@ public class ExampleValuePanel extends Panel {@Overrideprotected List<Field> load() {- return ApiHelpUtils.getJsonFields(value.getClass());+ return ApiHelpUtils.getJsonFields(getValue().getClass());}};@@ -328,16 +399,43 @@ public class ExampleValuePanel extends Panel {&& !Collection.class.isAssignableFrom(getDeclaredClass())&& !Map.class.isAssignableFrom(getDeclaredClass())) {Fragment typeInfoFragment = new Fragment("typeInfo", "typeInfoFrag", this);- typeInfoFragment.add(new ExampleValuePanel("name", JsonTypeInfo.Id.CLASS.getDefaultPropertyName(), requestBody));- typeInfoFragment.add(new ExampleValuePanel("value", value.getClass().getName(), requestBody));++ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {++ @Override+ protected ValueInfo load() {+ return new ValueInfo(getValueOrigin(), String.class, null);+ }++ };+ typeInfoFragment.add(new ExampleValuePanel("name", Model.of(JsonTypeInfo.Id.CLASS.getDefaultPropertyName()),+ valueInfoModel, requestBodyClass));+ typeInfoFragment.add(new ExampleValuePanel("value", new AbstractReadOnlyModel<Serializable>() {++ @Override+ public Serializable getObject() {+ return getValue().getClass().getName();+ }++ }, valueInfoModel, requestBodyClass));typeInfoFragment.add(new MenuLink("implementations") {@Overrideprotected List<MenuItem> getMenuItems(FloatingPanel dropdown) {List<MenuItem> items = new ArrayList<>();- ImplementationRegistry registry = OneDev.getInstance(ImplementationRegistry.class);- for (Class<?> clazz: registry.getImplementations(getDeclaredClass())) {+ List<Class<?>> implementations = new ArrayList<>(+ OneDev.getInstance(ImplementationRegistry.class).getImplementations(getDeclaredClass()));+ Collections.sort(implementations, new Comparator<Class<?>>() {++ @Override+ public int compare(Class<?> o1, Class<?> o2) {+ return o1.getName().compareTo(o2.getName());+ }++ });++ for (Class<?> clazz: implementations) {items.add(new MenuItem() {@Override@@ -351,11 +449,10 @@ public class ExampleValuePanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {- Object newValue = ApiHelpUtils.getExampleValue(clazz);- Component newExampleValuePanel = new ExampleValuePanel(- ExampleValuePanel.this.getId(), newValue, valueInfoModel, requestBody);- ExampleValuePanel.this.replaceWith(newExampleValuePanel);- target.add(newExampleValuePanel);+ Serializable newValue = ApiHelpUtils.getExampleValue(clazz);+ valueModel.setObject(newValue);+ target.add(ExampleValuePanel.this);+ send(getPage(), Broadcast.BREADTH, new ExampleValueChanged(target));}};@@ -380,26 +477,60 @@ public class ExampleValuePanel extends Panel {@Overrideprotected void populateItem(ListItem<Field> item) {Field field = item.getModelObject();++ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {++ @Override+ protected ValueInfo load() {+ return new ValueInfo(getValueOrigin(), String.class, null);+ }++ };if (field.getAnnotation(ManyToOne.class) != null)- item.add(new ExampleValuePanel("name", field.getName() + "Id", requestBody));+ item.add(new ExampleValuePanel("name", Model.of(field.getName() + "Id"), valueInfoModel, requestBodyClass));else- item.add(new ExampleValuePanel("name", field.getName(), requestBody));+ item.add(new ExampleValuePanel("name", Model.of(field.getName()), valueInfoModel, requestBodyClass));field.setAccessible(true);- try {- IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {+ valueInfoModel = new LoadableDetachableModel<ValueInfo>() {- @Override- protected ValueInfo load() {+ @Override+ protected ValueInfo load() {+ Field field = item.getModelObject();+ return new ValueInfo(getValueOrigin(), field.getGenericType(), field);+ }++ };+ item.add(new ExampleValuePanel("value", new IModel<Serializable>() {++ @Override+ public void detach() {+ }++ @Override+ public Serializable getObject() {+ try {Field field = item.getModelObject();- return new ValueInfo(field, field.getGenericType());+ field.setAccessible(true);+ return (Serializable) field.get(getValue());+ } catch (IllegalArgumentException | IllegalAccessException e) {+ throw new RuntimeException(e);}-- };- item.add(new ExampleValuePanel("value", field.get(value), valueInfoModel, requestBody));- } catch (IllegalArgumentException | IllegalAccessException e) {- throw new RuntimeException(e);- }+ }++ @Override+ public void setObject(Serializable object) {+ try {+ Field field = item.getModelObject();+ field.setAccessible(true);+ field.set(getValue(), object);+ } catch (IllegalArgumentException | IllegalAccessException e) {+ throw new RuntimeException(e);+ }+ }++ }, valueInfoModel, requestBodyClass));+item.add(new WebMarkupContainer("comma").setVisible(item.getIndex() < getModelObject().size()-1));}@@ -408,27 +539,25 @@ public class ExampleValuePanel extends Panel {return fragment;}- @Nullableprivate ValueInfo getValueInfo() {return valueInfoModel.getObject();}@Nullableprivate Field getField() {- return getValueInfo()!=null? getValueInfo().getField(): null;+ return getValueInfo().getField();}- @Nullableprivate Type getDeclaredType() {- return getValueInfo()!=null? getValueInfo().getDeclaredType(): null;+ return getValueInfo().getDeclaredType();}- @Nullableprivate Class<?> getDeclaredClass() {- if (getDeclaredType() != null)- return ReflectionUtils.getClass(getDeclaredType());- else- return null;+ return ReflectionUtils.getClass(getDeclaredType());+ }++ private ValueInfo.Origin getValueOrigin() {+ return getValueInfo().getOrigin();}private String toJson(Object value) {@@ -438,25 +567,5 @@ public class ExampleValuePanel extends Panel {throw new RuntimeException(e);}}-- private static class ValueInfo {-- private final Field field;-- private final Type declaredType;-- public ValueInfo(Field field, Type declaredType) {- this.field = field;- this.declaredType = declaredType;- }-- public Field getField() {- return field;- }-- public Type getDeclaredType() {- return declaredType;- }-- }+}diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.html b/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.htmlindex 56be4ee979..3db2c7e459 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.html+++ b/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.html@@ -1,43 +1,53 @@<wicket:extend>- <h5 wicket:id="title" class="mb-4"></h5>- <div class="method-detail">+ <div wicket:id="title" class="title"></div>+ <div wicket:id="description" class="alert alert-notice alert-light mb-4"></div>+ <div class="method-detail border-top pt-3"><dl class="content">- <dt>Method</dt>+ <dt>Http Method</dt><dd wicket:id="method"></dd>- <dt>Path</dt>- <dd wicket:id="path"></dd>- <wicket:enclosure child="pathPlaceholders">- <dt>Path Placeholders</dt>+ <dt>End Point</dt><dd>- <dl wicket:id="pathPlaceholders">- <dt wicket:id="name"></dt>- <dd>- <dl>- <dt>Description</dt>- <dd wicket:id="description"></dd>- <dt>Example</dt>- <dd wicket:id="example"></dd>- </dl>- </dd>- </dl>+ <div wicket:id="path"></div>+ <wicket:enclosure child="pathPlaceholders">+ <table class="table mt-4">+ <thead>+ <tr>+ <td>Placeholder</td>+ <td>Description</td>+ <td>Example</td>+ </tr>+ </thead>+ <tbody>+ <tr wicket:id="pathPlaceholders">+ <td wicket:id="name"></td>+ <td wicket:id="description"></td>+ <td wicket:id="example"></td>+ </tr>+ </tbody>+ </table>+ </wicket:enclosure></dd>- </wicket:enclosure><wicket:enclosure child="queryParams"><dt>Query Parameters</dt><dd>- <dl wicket:id="queryParams">- <dt wicket:id="name"></dt>- <dd>- <dl>- <dt>Description</dt>- <dd wicket:id="description"></dd>- <dt>Required</dt>- <dd wicket:id="required"></dd>- <dt>Example</dt>- <dd wicket:id="example"></dd>- </dl>- </dd>- </dl>+ <table class="table">+ <thead>+ <tr>+ <td>Parameter</td>+ <td>Description</td>+ <td>Required</td>+ <td>Example</td>+ </tr>+ </thead>+ <tbody>+ <tr wicket:id="queryParams">+ <td wicket:id="name"></td>+ <td wicket:id="description"></td>+ <td wicket:id="required"></td>+ <td wicket:id="example"></td>+ </tr>+ </tbody>+ </table></dd></wicket:enclosure><wicket:enclosure child="requestBodyExample">@@ -46,13 +56,11 @@<dl><dt>Content Type</dt><dd>application/json</dd>- <dt>Example</dt>+ <dt>Example <a wicket:id="copyRequestBodyExample" class="ml-1" title="Copy to clipboard"><wicket:svg href="copy" class="icon icon-sm"/></a></dt><dd wicket:id="requestBodyExample"></dd></dl></dd></wicket:enclosure>- <dt>Required Permission</dt>- <dd wicket:id="permission"></dd><dt>Response</dt><dd><dl>@@ -76,6 +84,10 @@</dd></dl></dd>+ <dt>cURL Example <a wicket:id="copyCurlExample" class="ml-1" title="Copy to clipboard"><wicket:svg href="copy" class="icon icon-sm"/></a></dt>+ <dd>+ <code wicket:id="curlExample"></code>+ </dd></dl></div><wicket:fragment wicket:id="topbarTitleFrag">@@ -89,7 +101,7 @@<dl><dt>Content Type</dt><dd>application/json</dd>- <dt>Example</dt>+ <dt>Example <a wicket:id="copyExample" class="ml-1" title="Copy to clipboard"><wicket:svg href="copy" class="icon icon-sm"/></a></dt><dd wicket:id="example"></dd></dl></wicket:fragment>diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.java b/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.javaindex 7faca6c3b2..fe9802f2bd 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.java+++ b/server-core/src/main/java/io/onedev/server/web/page/help/MethodDetailPage.java@@ -1,19 +1,21 @@package io.onedev.server.web.page.help;+import java.io.Serializable;import java.lang.reflect.Method;import java.lang.reflect.Parameter;import java.util.ArrayList;+import java.util.LinkedHashMap;import java.util.List;+import java.util.Map;-import javax.ws.rs.GET;-import javax.ws.rs.POST;-import javax.ws.rs.PUT;+import javax.annotation.Nullable;import javax.ws.rs.Path;import javax.ws.rs.PathParam;import javax.ws.rs.QueryParam;import javax.ws.rs.core.Response;import org.apache.wicket.Component;+import org.apache.wicket.event.IEvent;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.link.Link;@@ -22,14 +24,21 @@ import org.apache.wicket.markup.html.list.ListView;import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;+import org.apache.wicket.model.Model;import org.apache.wicket.request.mapper.parameter.PageParameters;+import com.fasterxml.jackson.core.JsonProcessingException;+import com.fasterxml.jackson.databind.ObjectMapper;+import io.onedev.commons.utils.ExplicitException;import io.onedev.commons.utils.StringUtils;import io.onedev.commons.utils.WordUtils;+import io.onedev.server.OneDev;+import io.onedev.server.entitymanager.SettingManager;import io.onedev.server.rest.annotation.Api;import io.onedev.server.rest.jersey.ParamCheckFilter;import io.onedev.server.web.component.link.ViewStateAwarePageLink;+import io.onedev.server.web.component.link.copytoclipboard.CopyToClipboardLink;import io.onedev.server.web.util.TextUtils;@SuppressWarnings("serial")@@ -80,28 +89,82 @@ public class MethodDetailPage extends ApiHelpPage {return methodModel.getObject();}+ @Nullable+ private Parameter getRequestBodyParam() {+ for (Parameter param: getResourceMethod().getParameters()) {+ if (param.getAnnotation(PathParam.class) == null && param.getAnnotation(QueryParam.class) == null)+ return param;+ }+ return null;+ }+@Overrideprotected void onInitialize() {super.onInitialize();Method method = getResourceMethod();- add(new Label("title", getMethodDescription(method)));-- if (method.getAnnotation(GET.class) != null)- add(new Label("method", "GET"));- else if (method.getAnnotation(POST.class) != null)- add(new Label("method", "POST"));- else if (method.getAnnotation(PUT.class) != null)- add(new Label("method", "PUT"));- else- add(new Label("method", "DELETE"));++ add(new Label("title", getMethodTitle(getResourceMethod())));++ String description = getMethodDescription(method);+ add(new Label("description", description).setVisible(description!=null));++ String httpMethod = getHttpMethod(method);+ add(new Label("method", httpMethod));++ Class<?> requestBodyClass;++ Parameter param = getRequestBodyParam();++ if (param != null) {+ Serializable exampleValue = new ExampleProvider(resourceClass, param.getAnnotation(Api.class)).getExample();+ if (exampleValue == null)+ exampleValue = ApiHelpUtils.getExampleValue(param.getParameterizedType());+ requestBodyClass = exampleValue.getClass();+ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {++ @Override+ protected ValueInfo load() {+ return new ValueInfo(ValueInfo.Origin.REQUEST_BODY,+ getRequestBodyParam().getParameterizedType(), null);+ }++ };++ Model<Serializable> valueModel = Model.of(exampleValue);+ add(new ExampleValuePanel("requestBodyExample", valueModel, valueInfoModel, requestBodyClass));+ add(new CopyToClipboardLink("copyRequestBodyExample", new LoadableDetachableModel<String>() {++ @Override+ protected String load() {+ return toJson(valueModel.getObject());+ }++ }) {++ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);+ if (event.getPayload() instanceof ExampleValueChanged)+ ((ExampleValueChanged)event.getPayload()).getHandler().add(this);+ }++ }.setOutputMarkupId(true));+ } else {+ requestBodyClass = null;+ add(new WebMarkupContainer("requestBodyExample").setVisible(false));+ }String resourcePathValue = resourceClass.getAnnotation(Path.class).value();Path methodPath = method.getAnnotation(Path.class);++ String endPoint;if (methodPath != null)- add(new Label("path", "/api" + resourcePathValue + methodPath.value()));+ endPoint = "/api" + resourcePathValue + methodPath.value();else- add(new Label("path", "/api" + resourcePathValue));+ endPoint = "/api" + resourcePathValue;++ add(new Label("path", endPoint));add(new ListView<Parameter>("pathPlaceholders", new LoadableDetachableModel<List<Parameter>>() {@@ -128,10 +191,27 @@ public class MethodDetailPage extends ApiHelpPage {elseitem.add(new Label("description", StringUtils.capitalize(WordUtils.uncamel(pathParam.value()))));- Object exampleValue = new ExampleProvider(getResourceMethod().getDeclaringClass(), api).getExample();+ Serializable exampleValue = new ExampleProvider(getResourceMethod().getDeclaringClass(), api).getExample();if (exampleValue == null)exampleValue = ApiHelpUtils.getExampleValue(param.getParameterizedType());- item.add(new ExampleValuePanel("example", exampleValue, false));++ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {++ @Override+ protected ValueInfo load() {+ return new ValueInfo(ValueInfo.Origin.PATH_PLACEHOLDER,+ item.getModelObject().getParameterizedType(), null);+ }++ };++ item.add(new ExampleValuePanel("example", Model.of(exampleValue), valueInfoModel, requestBodyClass));+ }++ @Override+ protected void onConfigure() {+ super.onConfigure();+ setVisible(!getModelObject().isEmpty());}});@@ -157,15 +237,26 @@ public class MethodDetailPage extends ApiHelpPage {item.add(new Label("name", queryParam.value()));Api api = param.getAnnotation(Api.class);if (api != null && api.description().length() != 0)- item.add(new Label("description", api.description()));+ item.add(new Label("description", api.description()).setEscapeModelStrings(false));else- item.add(new Label("description", StringUtils.capitalize(WordUtils.uncamel(queryParam.value()))));+ item.add(new Label("description", StringUtils.capitalize(WordUtils.uncamel(queryParam.value()).toLowerCase())));item.add(new Label("required", TextUtils.describe(ParamCheckFilter.isRequired(param))));- Object exampleValue = new ExampleProvider(getResourceMethod().getDeclaringClass(), api).getExample();+ Serializable exampleValue = new ExampleProvider(getResourceMethod().getDeclaringClass(), api).getExample();if (exampleValue == null)exampleValue = ApiHelpUtils.getExampleValue(param.getParameterizedType());- item.add(new ExampleValuePanel("example", exampleValue, false));++ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {++ @Override+ protected ValueInfo load() {+ return new ValueInfo(ValueInfo.Origin.QUERY_PARAM,+ item.getModelObject().getParameterizedType(), null);+ }++ };++ item.add(new ExampleValuePanel("example", Model.of(exampleValue), valueInfoModel, requestBodyClass));}@Override@@ -176,43 +267,114 @@ public class MethodDetailPage extends ApiHelpPage {});- Parameter requestBodyParam = null;- for (Parameter param: method.getParameters()) {- if (param.getAnnotation(PathParam.class) == null && param.getAnnotation(QueryParam.class) == null) {- requestBodyParam = param;- break;- }- }-- if (requestBodyParam != null) {- Object exampleValue = new ExampleProvider(resourceClass, requestBodyParam.getAnnotation(Api.class)).getExample();- if (exampleValue == null) {- exampleValue = ApiHelpUtils.getExampleValue(requestBodyParam.getParameterizedType());- }- add(new ExampleValuePanel("requestBodyExample", exampleValue, true));- } else {- add(new WebMarkupContainer("requestBodyExample").setVisible(false));- }-- Api api = method.getAnnotation(Api.class);- if (api != null && api.permission().length() != 0)- add(new Label("permission", api.permission()));- else- add(new Label("permission", "Anyone can perform this operation"));-if (method.getReturnType() == Response.class) {add(new Label("successResponseBody", "No response body if successful; error"));} else {Fragment fragment = new Fragment("successResponseBody", "hasResponseBodyFrag", MethodDetailPage.this);- Object exampleValue = new ExampleProvider(resourceClass, method.getAnnotation(Api.class)).getExample();+ Serializable exampleValue = new ExampleProvider(resourceClass, method.getAnnotation(Api.class)).getExample();if (exampleValue == null)exampleValue = ApiHelpUtils.getExampleValue(method.getGenericReturnType());- fragment.add(new ExampleValuePanel("example", exampleValue, false));++ IModel<ValueInfo> valueInfoModel = new LoadableDetachableModel<ValueInfo>() {++ @Override+ protected ValueInfo load() {+ return new ValueInfo(ValueInfo.Origin.RESPONSE_BODY,+ getResourceMethod().getGenericReturnType(), null);+ }++ };++ IModel<Serializable> valueModel = Model.of(exampleValue);++ fragment.add(new ExampleValuePanel("example", valueModel, valueInfoModel, requestBodyClass));++ fragment.add(new CopyToClipboardLink("copyExample", new LoadableDetachableModel<String>() {++ @Override+ protected String load() {+ return toJson(valueModel.getObject());+ }++ }) {++ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);+ if (event.getPayload() instanceof ExampleValueChanged)+ ((ExampleValueChanged)event.getPayload()).getHandler().add(this);+ }++ }.setOutputMarkupId(true));+add(fragment);}+ for (Parameter pathParam: getResourceMethod().getParameters()) {+ if (pathParam.getAnnotation(PathParam.class) != null) {+ Api api = pathParam.getAnnotation(Api.class);+ Serializable exampleValue = new ExampleProvider(getResourceMethod().getDeclaringClass(), api).getExample();+ if (exampleValue == null)+ exampleValue = ApiHelpUtils.getExampleValue(pathParam.getParameterizedType());+ endPoint = endPoint.replace("{" + pathParam.getAnnotation(PathParam.class).value() + "}", String.valueOf(exampleValue));+ }+ }++ Map<String, String> queryParams = new LinkedHashMap<>();++ for (Parameter queryParam: getResourceMethod().getParameters()) {+ if (queryParam.getAnnotation(QueryParam.class) != null) {+ String paramName = queryParam.getAnnotation(QueryParam.class).value();++ Api api = queryParam.getAnnotation(Api.class);+ Serializable exampleValue = new ExampleProvider(getResourceMethod().getDeclaringClass(), api).getExample();+ if (exampleValue == null)+ exampleValue = ApiHelpUtils.getExampleValue(queryParam.getParameterizedType());++ queryParams.put(paramName, String.valueOf(exampleValue));+ }+ }++ StringBuilder curlExample = new StringBuilder();++ curlExample.append("$ curl -u <login name>:<password or access token> ");+ if (!queryParams.isEmpty())+ curlExample.append("-G ");++ switch (getHttpMethod(method)) {+ case "DELETE":+ curlExample.append("-X DELETE ");+ break;+ case "PUT":+ curlExample.append("-X PUT [email protected] -H \"Content-Type: application/json\" ");+ break;+ case "POST":+ curlExample.append("[email protected] -H \"Content-Type: application/json\" ");+ break;+ }++ curlExample.append(OneDev.getInstance(SettingManager.class).getSystemSetting().getServerUrl()).append(endPoint);++ for (Map.Entry<String, String> entry: queryParams.entrySet()) {+ if (entry.getValue().contains(" "))+ curlExample.append(" --data-urlencode '").append(entry.getKey()).append("=").append(entry.getValue()).append("'");+ else+ curlExample.append(" --data-urlencode ").append(entry.getKey()).append("=").append(entry.getValue());+ }++ add(new Label("curlExample", curlExample));++ add(new CopyToClipboardLink("copyCurlExample", Model.of(curlExample.toString().substring(1))));}+ private String toJson(Object value) {+ try {+ return OneDev.getInstance(ObjectMapper.class).writeValueAsString(value);+ } catch (JsonProcessingException e) {+ throw new RuntimeException(e);+ }+ }+@Overrideprotected Component newTopbarTitle(String componentId) {Fragment fragment = new Fragment(componentId, "topbarTitleFrag", this);@@ -231,5 +393,5 @@ public class MethodDetailPage extends ApiHelpPage {params.add(PARAM_METHOD, resourceMethod);return params;}-+}diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.html b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.htmlindex 3510493b69..077fae621d 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.html+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.html@@ -1,11 +1,23 @@<wicket:extend>- <h5 wicket:id="title" class="mb-4"></h5>- <table class="table resource-detail">- <tr wicket:id="methods" class="method">- <td>- <a wicket:id="link" class="title`"><span wicket:id="label"></span></a>- </td>- </tr>+ <div wicket:id="title" class="title"></div>+ <div wicket:id="description" class="alert alert-notice alert-light mb-5"></div>+ <table class="table">+ <thead>+ <tr>+ <td>Operation</td>+ <td>Http Method</td>+ <td>End Point</td>+ </tr>+ </thead>+ <tbody>+ <tr wicket:id="methods" class="method">+ <td>+ <a wicket:id="link" class="title`"><span wicket:id="label"></span></a>+ </td>+ <td wicket:id="httpMethod"></td>+ <td wicket:id="path"></td>+ </tr>+ </tbody></table><wicket:fragment wicket:id="topbarTitleFrag"><a wicket:id="resources">Resources</a> <span class="dot"></span> <span wicket:id="resource"></span>diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.java b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.javaindex 3b33efaf34..315e01ce4e 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.java+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceDetailPage.java@@ -8,6 +8,7 @@ import javax.ws.rs.DELETE;import javax.ws.rs.GET;import javax.ws.rs.POST;import javax.ws.rs.PUT;+import javax.ws.rs.Path;import org.apache.wicket.Component;import org.apache.wicket.markup.html.basic.Label;@@ -41,7 +42,10 @@ public class ResourceDetailPage extends ApiHelpPage {protected void onInitialize() {super.onInitialize();- add(new Label("title", getResourceDescription(resourceClass)));+ add(new Label("title", getResourceTitle(resourceClass)));++ String description = getResourceDescription(resourceClass);+ add(new Label("description", description).setEscapeModelStrings(false).setVisible(description!=null));add(new ListView<Method>("methods", new LoadableDetachableModel<List<Method>>() {@@ -70,9 +74,18 @@ public class ResourceDetailPage extends ApiHelpPage {Link<Void> link = new ViewStateAwarePageLink<Void>("link", MethodDetailPage.class,MethodDetailPage.paramsOf(resourceClass, method.getName()));- link.add(new Label("label", getMethodDescription(method)));+ link.add(new Label("label", getMethodTitle(method)));item.add(link);++ item.add(new Label("httpMethod", getHttpMethod(method)));++ String resourcePathValue = resourceClass.getAnnotation(Path.class).value();+ Path methodPath = method.getAnnotation(Path.class);+ if (methodPath != null)+ item.add(new Label("path", resourcePathValue + methodPath.value()));+ else+ item.add(new Label("path", resourcePathValue));}});diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.html b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.htmlindex 52ae7fce11..1bf24e1a20 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.html+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.html@@ -1,14 +1,23 @@<wicket:extend>- <h5 class="mb-4">All RESTful Resources</h5>- <div class="alert alert-light-info">+ <div class="title">All RESTful Resources</div>+ <div class="alert alert-notice alert-light mb-5">In case anonymous access is disabled or anonymous user does not have enough permission for a resource operation,you will need to authenticate by providing user name and password (or access token) via http basic auth header</div><table class="table resources">- <tr wicket:id="resources" class="resource">- <td>- <a wicket:id="link" class="title"><span wicket:id="label"></span></a>- </td>- </tr>+ <thead>+ <tr>+ <td>Resource</td>+ <td>End Point</td>+ </tr>+ </thead>+ <tbody>+ <tr wicket:id="resources" class="resource">+ <td>+ <a wicket:id="link" class="title"><span wicket:id="label"></span></a>+ </td>+ <td wicket:id="path"></td>+ </tr>+ </tbody></table></wicket:extend>\ No newline at end of filediff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.java b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.javaindex 98c5374f4b..2a90a779ae 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.java+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ResourceListPage.java@@ -55,9 +55,11 @@ public class ResourceListPage extends ApiHelpPage {Link<Void> link = new ViewStateAwarePageLink<Void>("link", ResourceDetailPage.class,ResourceDetailPage.paramsOf(clazz));- link.add(new Label("label", getResourceDescription(clazz)));+ link.add(new Label("label", getResourceTitle(clazz)));item.add(link);++ item.add(new Label("path", clazz.getAnnotation(Path.class).value()));}});diff --git a/server-core/src/main/java/io/onedev/server/web/page/help/ValueInfo.java b/server-core/src/main/java/io/onedev/server/web/page/help/ValueInfo.javanew file mode 100644index 0000000000..5d9923c2ae--- /dev/null+++ b/server-core/src/main/java/io/onedev/server/web/page/help/ValueInfo.java@@ -0,0 +1,37 @@+package io.onedev.server.web.page.help;++import java.lang.reflect.Field;+import java.lang.reflect.Type;++import javax.annotation.Nullable;++class ValueInfo {++ public enum Origin {REQUEST_BODY, RESPONSE_BODY, PATH_PLACEHOLDER, QUERY_PARAM};++ private final Origin origin;++ private final Type declaredType;++ private final Field field;++ public ValueInfo(Origin origin, Type declaredType, @Nullable Field field) {+ this.origin = origin;+ this.declaredType = declaredType;+ this.field = field;+ }++ public Type getDeclaredType() {+ return declaredType;+ }++ public Origin getOrigin() {+ return origin;+ }++ @Nullable+ public Field getField() {+ return field;+ }++}\ No newline at end of filediff --git a/server-core/src/main/java/io/onedev/server/web/page/help/api-help.css b/server-core/src/main/java/io/onedev/server/web/page/help/api-help.cssindex 53073e3f2f..e8f895e1ca 100644--- a/server-core/src/main/java/io/onedev/server/web/page/help/api-help.css+++ b/server-core/src/main/java/io/onedev/server/web/page/help/api-help.css@@ -2,12 +2,23 @@margin-left: 2rem;}.api-help dt {- font-weight: 600;+ font-weight: 500;+ font-size: 1.1rem;+ margin-bottom: 0.8rem;+}+.api-help dd {+ margin-bottom: 1.6rem;}.api-help dl {margin-bottom: 0;}+.api-help>.card-body>.title {+ font-size: 18px;+ font-weight: 500;+ margin-bottom: 1.5rem;+}+.example-value-scalar, .example-value-brace,.example-value-bracket, .example-value-comma {font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;@@ -24,3 +35,4 @@ a.example-value-implementations>.icon {.floating>.content>.example-value-hint {padding: 1rem;}+diff --git a/server-plugin/pom.xml b/server-plugin/pom.xmlindex 9596d1161f..2c02704353 100644--- a/server-plugin/pom.xml+++ b/server-plugin/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-archetype/pom.xml b/server-plugin/server-plugin-archetype/pom.xmlindex ecbac2d2f5..ee1efdd1da 100644--- a/server-plugin/server-plugin-archetype/pom.xml+++ b/server-plugin/server-plugin-archetype/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><build><resources>diff --git a/server-plugin/server-plugin-authenticator-ldap/pom.xml b/server-plugin/server-plugin-authenticator-ldap/pom.xmlindex d2661c0e95..06258d0309 100644--- a/server-plugin/server-plugin-authenticator-ldap/pom.xml+++ b/server-plugin/server-plugin-authenticator-ldap/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.authenticator.ldap.LdapModule</moduleClass>diff --git a/server-plugin/server-plugin-buildspec-gradle/pom.xml b/server-plugin/server-plugin-buildspec-gradle/pom.xmlindex f7b77054e1..bfd6a52a91 100644--- a/server-plugin/server-plugin-buildspec-gradle/pom.xml+++ b/server-plugin/server-plugin-buildspec-gradle/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.buildspec.gradle.GradleModule</moduleClass>diff --git a/server-plugin/server-plugin-buildspec-maven/pom.xml b/server-plugin/server-plugin-buildspec-maven/pom.xmlindex 61288e8e75..c6b24adc88 100644--- a/server-plugin/server-plugin-buildspec-maven/pom.xml+++ b/server-plugin/server-plugin-buildspec-maven/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.buildspec.maven.MavenModule</moduleClass>diff --git a/server-plugin/server-plugin-buildspec-node/pom.xml b/server-plugin/server-plugin-buildspec-node/pom.xmlindex 6e443d2217..198d36b41c 100644--- a/server-plugin/server-plugin-buildspec-node/pom.xml+++ b/server-plugin/server-plugin-buildspec-node/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.buildspec.node.NodePluginModule</moduleClass>diff --git a/server-plugin/server-plugin-executor-docker/pom.xml b/server-plugin/server-plugin-executor-docker/pom.xmlindex 31799e9533..d260ef28fb 100644--- a/server-plugin/server-plugin-executor-docker/pom.xml+++ b/server-plugin/server-plugin-executor-docker/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.docker.DockerModule</moduleClass>diff --git a/server-plugin/server-plugin-executor-kubernetes/pom.xml b/server-plugin/server-plugin-executor-kubernetes/pom.xmlindex 0a08b0ec40..3613dcf90f 100644--- a/server-plugin/server-plugin-executor-kubernetes/pom.xml+++ b/server-plugin/server-plugin-executor-kubernetes/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.executor.kubernetes.KubernetesModule</moduleClass>diff --git a/server-plugin/server-plugin-report-checkstyle/pom.xml b/server-plugin/server-plugin-report-checkstyle/pom.xmlindex f572481e1d..71b0ffce86 100644--- a/server-plugin/server-plugin-report-checkstyle/pom.xml+++ b/server-plugin/server-plugin-report-checkstyle/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.checkstyle.CheckstylePluginModule</moduleClass>diff --git a/server-plugin/server-plugin-report-clover/pom.xml b/server-plugin/server-plugin-report-clover/pom.xmlindex 2fb9baccda..23c0c28f7e 100644--- a/server-plugin/server-plugin-report-clover/pom.xml+++ b/server-plugin/server-plugin-report-clover/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.clover.CloverPluginModule</moduleClass>diff --git a/server-plugin/server-plugin-report-jest/pom.xml b/server-plugin/server-plugin-report-jest/pom.xmlindex 84a6e78c32..90162f2c74 100644--- a/server-plugin/server-plugin-report-jest/pom.xml+++ b/server-plugin/server-plugin-report-jest/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.jest.JestTestReportModule</moduleClass>diff --git a/server-plugin/server-plugin-report-markdown/pom.xml b/server-plugin/server-plugin-report-markdown/pom.xmlindex 8997f56b83..4c3d9f64b3 100644--- a/server-plugin/server-plugin-report-markdown/pom.xml+++ b/server-plugin/server-plugin-report-markdown/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.markdown.MarkdownReportModule</moduleClass>diff --git a/server-plugin/server-plugin-sso-openid/pom.xml b/server-plugin/server-plugin-sso-openid/pom.xmlindex ada4aa8487..e86e094e51 100644--- a/server-plugin/server-plugin-sso-openid/pom.xml+++ b/server-plugin/server-plugin-sso-openid/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><dependencies><dependency>diff --git a/server-product/pom.xml b/server-product/pom.xmlindex c21f55c473..75469e4c0a 100644--- a/server-product/pom.xml+++ b/server-product/pom.xml@@ -7,7 +7,7 @@<parent><groupId>io.onedev</groupId><artifactId>server</artifactId>- <version>4.3.5</version>+ <version>4.4.0</version></parent><dependencies><dependency>