The Unified and Autonomous Development Platform
Map branch as ManyToOne in CommitVerification.
robin shine1bcfd20625eb
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfVerifiedByBuilds.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfVerifiedByBuilds.javaindex 319c6b1648..ac94a81c85 100644--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfVerifiedByBuilds.java+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfVerifiedByBuilds.java@@ -80,8 +80,8 @@ public class IfVerifiedByBuilds extends AbstractGateKeeper {int passedCount = 0;Collection<CommitVerification> commitVerifications = commitVerificationManager.findBy(request.getTarget(), commit);for (CommitVerification each: commitVerifications) {- if (each.getStatus() == CommitVerification.Status.FAILED)- return disapproved("At least one build is failed for the commit.");+ if (each.getStatus() == CommitVerification.Status.NOT_PASSED)+ return disapproved("At least one build is not passed for the commit.");else if (each.getStatus() == CommitVerification.Status.PASSED)passedCount++;}@@ -119,8 +119,8 @@ public class IfVerifiedByBuilds extends AbstractGateKeeper {int passedCount = 0;Collection<CommitVerification> commitVerifications = commitVerificationManager.findBy(branch, commit);for (CommitVerification each: commitVerifications) {- if (each.getStatus() == CommitVerification.Status.FAILED)- return disapproved("At least one build is failed for the commit.");+ if (each.getStatus() == CommitVerification.Status.NOT_PASSED)+ return disapproved("At least one build is not passed for the commit.");else if (each.getStatus() == CommitVerification.Status.PASSED)passedCount++;}diff --git a/gitop.model/src/main/java/com/pmease/gitop/model/CommitVerification.java b/gitop.model/src/main/java/com/pmease/gitop/model/CommitVerification.javaindex 2767e760b0..6f4f569171 100644--- a/gitop.model/src/main/java/com/pmease/gitop/model/CommitVerification.java+++ b/gitop.model/src/main/java/com/pmease/gitop/model/CommitVerification.java@@ -2,6 +2,8 @@ package com.pmease.gitop.model;import javax.persistence.Column;import javax.persistence.Entity;+import javax.persistence.JoinColumn;+import javax.persistence.ManyToOne;import javax.persistence.Table;import javax.persistence.UniqueConstraint;@@ -14,9 +16,10 @@ import com.pmease.commons.hibernate.AbstractEntity;})public class CommitVerification extends AbstractEntity {- public enum Status {ONGOING, PASSED, FAILED}+ public enum Status {ONGOING, PASSED, NOT_PASSED}- @Column(nullable=false)+ @ManyToOne+ @JoinColumn(nullable=false)private Branch branch;@Column(nullable=false)diff --git a/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.java b/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.javaindex c89df01fde..04da307139 100644--- a/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.java+++ b/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.java@@ -38,7 +38,7 @@ public class PullRequest extends AbstractEntity {public enum Status {PENDING_APPROVAL("Pending Approval"), PENDING_UPDATE("Pending Update"),- PENDING_INTEGRATE("Pending Integrate"), INTEGRATED("Integrated"),+ PENDING_INTEGRATE("Pending Integration"), INTEGRATED("Integrated"),DISCARDED("Discarded");private final String displayName;diff --git a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/BranchResource.java b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/BranchResource.javaindex ba55aff166..e471ea255b 100644--- a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/BranchResource.java+++ b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/BranchResource.java@@ -43,9 +43,9 @@ public class BranchResource {}@GET- @Path("/{branchId}")- public Branch get(@PathParam("branchId") Long branchId) {- Branch branch = dao.load(Branch.class, branchId);+ @Path("/{id}")+ public Branch get(@PathParam("id") Long id) {+ Branch branch = dao.load(Branch.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryRead(branch.getRepository())))throw new UnauthorizedException();return branch;@@ -53,11 +53,11 @@ public class BranchResource {@GETpublic Collection<Branch> query(- @QueryParam("repositoryId") Long repositoryId,+ @QueryParam("repository") Long repositoryId,@QueryParam("name") String name,@Context UriInfo uriInfo) {- JerseyUtils.checkQueryParams(uriInfo, "repositoryId", "name");+ JerseyUtils.checkQueryParams(uriInfo, "repository", "name");EntityCriteria<Branch> criteria = EntityCriteria.of(Branch.class);if (repositoryId != null)@@ -76,18 +76,21 @@ public class BranchResource {}@DELETE- @Path("/{branchId}")- public void delete(@PathParam("branchId") Long branchId) {- Branch branch = dao.load(Branch.class, branchId);+ @Path("/{id}")+ public void delete(@PathParam("id") Long id) {+ Branch branch = dao.load(Branch.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryAdmin(branch.getRepository())))- dao.remove(branch);+ throw new UnauthorizedException();+ dao.remove(branch);}@POSTpublic Long save(@NotNull @Valid Branch branch) {if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryAdmin(branch.getRepository())))- dao.persist(branch);+ throw new UnauthorizedException();++ dao.persist(branch);return branch.getId();}diff --git a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/CommitVerificationResource.java b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/CommitVerificationResource.javaindex 8682e23dd7..21096e3599 100644--- a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/CommitVerificationResource.java+++ b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/CommitVerificationResource.java@@ -43,9 +43,9 @@ public class CommitVerificationResource {}@GET- @Path("/{commitVerificationId}")- public CommitVerification get(@PathParam("commitVerificationId") Long commitVerificationId) {- CommitVerification commitVerification = dao.load(CommitVerification.class, commitVerificationId);+ @Path("/{id}")+ public CommitVerification get(@PathParam("id") Long id) {+ CommitVerification commitVerification = dao.load(CommitVerification.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryRead(commitVerification.getBranch().getRepository())))throw new UnauthorizedException();return commitVerification;@@ -53,12 +53,12 @@ public class CommitVerificationResource {@GETpublic Collection<CommitVerification> query(- @QueryParam("branchId") Long branchId,+ @QueryParam("branch") Long branchId,@QueryParam("configuration") String configuration,@QueryParam("commit") String commit,@Context UriInfo uriInfo) {- JerseyUtils.checkQueryParams(uriInfo, "branchId", "configuration", "commit");+ JerseyUtils.checkQueryParams(uriInfo, "branch", "configuration", "commit");EntityCriteria<CommitVerification> criteria = EntityCriteria.of(CommitVerification.class);if (branchId != null)@@ -82,17 +82,21 @@ public class CommitVerificationResource {}@DELETE- @Path("/{commitVerificationId}")- public void delete(@PathParam("commitVerificationId") Long commitVerificationId) {- CommitVerification commitVerification = dao.load(CommitVerification.class, commitVerificationId);+ @Path("/{id}")+ public void delete(@PathParam("id") Long id) {+ CommitVerification commitVerification = dao.load(CommitVerification.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryWrite(commitVerification.getBranch().getRepository())))- dao.remove(commitVerification);+ throw new UnauthorizedException();++ dao.remove(commitVerification);}@POSTpublic Long save(@NotNull @Valid CommitVerification commitVerification) {if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryWrite(commitVerification.getBranch().getRepository())))- dao.persist(commitVerification);+ throw new UnauthorizedException();++ dao.persist(commitVerification);return commitVerification.getId();}diff --git a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/PullRequestResource.java b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/PullRequestResource.javaindex e64f654bac..5d6600ecbb 100644--- a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/PullRequestResource.java+++ b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/PullRequestResource.java@@ -43,9 +43,9 @@ public class PullRequestResource {}@GET- @Path("/{pullRequestId}")- public PullRequest get(@PathParam("pullRequestId") Long pullRequestId) {- PullRequest request = dao.load(PullRequest.class, pullRequestId);+ @Path("/{id}")+ public PullRequest get(@PathParam("id") Long id) {+ PullRequest request = dao.load(PullRequest.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryRead(request.getTarget().getRepository())))throw new UnauthorizedException();@@ -55,13 +55,11 @@ public class PullRequestResource {@GETpublic Collection<PullRequest> query(- @QueryParam("targetId") Long targetId,- @QueryParam("sourceId") Long sourceId,- @QueryParam("submitterId") Long submitterId,- @QueryParam("status") String status,+ @QueryParam("target") Long targetId, @QueryParam("source") Long sourceId,+ @QueryParam("submitter") Long submitterId, @QueryParam("status") String status,@Context UriInfo uriInfo) {- JerseyUtils.checkQueryParams(uriInfo, "targetId", "sourceId", "submitter_id", "status");+ JerseyUtils.checkQueryParams(uriInfo, "target", "source", "submitter", "status");EntityCriteria<PullRequest> criteria = EntityCriteria.of(PullRequest.class);if (targetId != null)@@ -99,9 +97,9 @@ public class PullRequestResource {}@DELETE- @Path("/{pullRequestId}")- public void delete(@PathParam("pullRequestId") Long pullRequestId) {- PullRequest pullRequest = dao.load(PullRequest.class, pullRequestId);+ @Path("/{id}")+ public void delete(@PathParam("id") Long id) {+ PullRequest pullRequest = dao.load(PullRequest.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryAdmin(pullRequest.getTarget().getRepository())))throw new UnauthorizedException();diff --git a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/RepositoryResource.java b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/RepositoryResource.javaindex b832f780b8..aa57c7d5bd 100644--- a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/RepositoryResource.java+++ b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/RepositoryResource.java@@ -43,10 +43,10 @@ public class RepositoryResource {this.dao = dao;}- @Path("/{repositoryId}")+ @Path("/{id}")@GET- public Repository get(@PathParam("repositoryId") Long repositoryId) {- Repository repository = dao.load(Repository.class, repositoryId);+ public Repository get(@PathParam("id") Long id) {+ Repository repository = dao.load(Repository.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryRead(repository)))throw new UnauthenticatedException();@@ -56,11 +56,11 @@ public class RepositoryResource {@GETpublic Collection<Repository> query(- @QueryParam("userId") Long userId,+ @QueryParam("user") Long userId,@QueryParam("name") String name,@Context UriInfo uriInfo) {- JerseyUtils.checkQueryParams(uriInfo, "userId", "name");+ JerseyUtils.checkQueryParams(uriInfo, "user", "name");EntityCriteria<Repository> criteria = EntityCriteria.of(Repository.class);if (userId != null)@@ -80,16 +80,16 @@ public class RepositoryResource {@POSTpublic Long save(@NotNull @Valid Repository repository) {if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryAdmin(repository)))- throw new UnauthenticatedException();+ throw new UnauthorizedException();dao.persist(repository);return repository.getId();}@DELETE- @Path("/{repositoryId}")- public void delete(@PathParam("repositoryId") Long repositoryId) {- Repository repository = dao.load(Repository.class, repositoryId);+ @Path("/{id}")+ public void delete(@PathParam("id") Long id) {+ Repository repository = dao.load(Repository.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofRepositoryAdmin(repository)))throw new UnauthorizedException();diff --git a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/UserResource.java b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/UserResource.javaindex 4b705af33d..ff66f72d1c 100644--- a/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/UserResource.java+++ b/gitop.rest/src/main/java/com/pmease/gitop/rest/resource/UserResource.java@@ -70,9 +70,9 @@ public class UserResource {}@GET- @Path("/{userId}")- public User get(@PathParam("userId") Long userId) {- User user = dao.load(User.class, userId);+ @Path("/{id}")+ public User get(@PathParam("id") Long id) {+ User user = dao.load(User.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofUserRead(user)))throw new UnauthorizedException();else@@ -89,9 +89,9 @@ public class UserResource {}@DELETE- @Path("/{userId}")- public void delete(@PathParam("userId") Long userId) {- User user = dao.load(User.class, userId);+ @Path("/{id}")+ public void delete(@PathParam("id") Long id) {+ User user = dao.load(User.class, id);if (!SecurityUtils.getSubject().isPermitted(ObjectPermission.ofUserAdmin(user)))throw new UnauthorizedException();diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.cssindex c05e8f7900..fbcd089fa2 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css+++ b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css@@ -1314,7 +1314,7 @@ ul.status-help li:last-child .description {border-bottom: none;}background-color: #F2DEDE;}.request-detail>.status td.primary.success .fa-check-circle {display: block;}.request-detail>.status td.primary.danger .fa-times-circle {display: block;}-.request-detail>.status td.primary.warning .fa-exclamation-circle {display: block;}+.request-detail>.status td.primary.warning .fa-info-circle {display: block;}.request-detail>.status td.primary {border: 1px solid; padding: 8px; border-radius: 4px;color: #8A6D3B; border-color: #F7DEAB; background-color: #FCF8E3; width: 50%;}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/repository/pullrequest/RequestDetailPage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/repository/pullrequest/RequestDetailPage.htmlindex 3b8a050cdb..dce11f7c83 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/repository/pullrequest/RequestDetailPage.html+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/repository/pullrequest/RequestDetailPage.html@@ -33,7 +33,7 @@<td wicket:id="primary" class="primary"><div class="fa fa-check-circle pull-left"></div><div class="fa fa-times-circle pull-left"></div>- <div class="fa fa-exclamation-circle pull-left"></div>+ <div class="fa fa-info-circle pull-left"></div><div class="pull-left"><div wicket:id="message" class="message"></div><wicket:enclosure child="reasons">