The Unified and Autonomous Development Platform
Refactored gate keeper to make it more clear
robin shine1fc707ffd61c
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.javaindex d6d104fdfa..0d8fec7f53 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java@@ -82,7 +82,7 @@ public class Account extends AbstractUser implements ProtectedObject {/** Optimistic lock is necessary to ensure database integrity when update- * gate keepers and integration policies upon account renaming/deletion+ * gatekeepers and integration policies upon account renaming/deletion*/@Versionprivate long version;@@ -218,7 +218,7 @@ public class Account extends AbstractUser implements ProtectedObject {+ "<li>None: No any permissions granted on repositories"+ "<li>Read: Able to pull and browse repositories"+ "<li>Write: Has full read privilege, and can also push to "- + "repositories unless gate keeper prevents")+ + "repositories unless gatekeeper prevents")@ExcludeValues("ADMIN")@NotNullpublic DepotPrivilege getDefaultPrivilege() {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.javaindex d9b9ff9a48..c49ed2adad 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java@@ -87,7 +87,7 @@ import com.pmease.commons.wicket.editable.annotation.Markdown;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.entity.support.IntegrationPolicy;import com.pmease.gitplex.core.event.RefUpdated;-import com.pmease.gitplex.core.gatekeeper.AndGateKeeper;+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;import com.pmease.gitplex.core.gatekeeper.GateKeeper;import com.pmease.gitplex.core.manager.ConfigManager;import com.pmease.gitplex.core.manager.DepotManager;@@ -139,14 +139,14 @@ public class Depot extends AbstractEntity implements AccountBelonging {/** Optimistic lock is necessary to ensure database integrity when update- * gate keepers and integration policies upon depot renaming/deletion+ * gatekeepers and integration policies upon depot renaming/deletion*/@Versionprivate long version;@Lob@Column(nullable=false, length=65535)- private ArrayList<GateKeeper> gateKeepers = new ArrayList<>();+ private GateKeeper gateKeeper = new DefaultGateKeeper();@Lob@Column(nullable=false, length=65535)@@ -232,12 +232,12 @@ public class Depot extends AbstractEntity implements AccountBelonging {@NotNull@Valid- public List<GateKeeper> getGateKeepers() {- return gateKeepers;+ public GateKeeper getGateKeeper() {+ return gateKeeper;}- public void setGateKeepers(ArrayList<GateKeeper> gateKeepers) {- this.gateKeepers = gateKeepers;+ public void setGateKeeper(GateKeeper gateKeeper) {+ this.gateKeeper = gateKeeper;}@Valid@@ -377,13 +377,6 @@ public class Depot extends AbstractEntity implements AccountBelonging {return true;}- public GateKeeper getGateKeeper() {- AndGateKeeper andGateKeeper = new AndGateKeeper();- for (GateKeeper each: getGateKeepers())- andGateKeeper.getGateKeepers().add(each);- return andGateKeeper;- }-/*** Find fork root of this repository.*diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.javaindex b9732ac1ec..88e7b4b435 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.java@@ -57,7 +57,7 @@ public abstract class AbstractGateKeeper implements GateKeeper {}/**- * Check gate keeper against specified pull request without considering enable flag. This is+ * Check gatekeeper against specified pull request without considering enable flag. This is* typically used to determine whether or not to accept a pull request.** @param requestdiff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.javaindex b8857ee0cd..dc6b111634 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.java@@ -13,7 +13,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;@Editable(name="And Composition", icon="fa-object-group", order=100,category=GateKeeper.CATEGORY_COMPOSITION,- description="This gate keeper will be passed if all contained gate keepers are passed")+ description="This gatekeeper will be passed if all contained child gatekeepers are passed")@Horizontalpublic class AndGateKeeper extends AndOrGateKeeper {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedTeam.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedTeam.javasimilarity index 94%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedTeam.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedTeam.javaindex fe8924fe0f..72af1bbb99 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedTeam.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedTeam.java@@ -15,9 +15,9 @@ import com.pmease.gitplex.core.entity.PullRequestReview;import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;@Editable(order=100, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=- "This gate keeper will be passed if the commit is approved by specified number of users "+ "This gatekeeper will be passed if the commit is approved by specified number of users "+ "from specified team")-public class IfApprovedBySpecifiedTeam extends TeamAwareGateKeeper {+public class ApprovedBySpecifiedTeam extends TeamAwareGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedUser.javasimilarity index 91%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedUser.javaindex c379e165e1..a675342306 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedUser.java@@ -1,75 +1,75 @@-package com.pmease.gitplex.core.gatekeeper;--import org.eclipse.jgit.lib.ObjectId;-import org.hibernate.validator.constraints.NotEmpty;--import com.google.common.base.Preconditions;-import com.google.common.collect.Lists;-import com.google.common.collect.Sets;-import com.pmease.commons.wicket.editable.annotation.Editable;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.annotation.AccountChoice;-import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.PullRequestReview;-import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;-import com.pmease.gitplex.core.manager.AccountManager;--@Editable(order=200, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=- "This gate keeper will be passed if the commit is approved by specified user")-public class IfApprovedBySpecifiedUser extends AbstractGateKeeper {-- private static final long serialVersionUID = 1L;-- private String userName;-- @Editable(name="Select User")- @AccountChoice- @NotEmpty- public String getUserName() {- return userName;- }-- public void setUserName(String userName) {- this.userName = userName;- }-- @Override- public GateCheckResult doCheckRequest(PullRequest request) {- Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));-- PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());- if (result == null) {- request.pickReviewers(Sets.newHashSet(user), 1);-- return pending(Lists.newArrayList("To be approved by " + user.getDisplayName()));- } else if (result == PullRequestReview.Result.APPROVE) {- return passed(Lists.newArrayList("Approved by " + user.getDisplayName()));- } else {- return failed(Lists.newArrayList("Disapproved by " + user.getDisplayName()));- }- }-- @Override- protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {- return pending(Lists.newArrayList("Need approval from " + user.getName()));- }-- @Override- protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {- return pending(Lists.newArrayList("Need approval from " + user.getName()));- }-- @Override- public void onAccountRename(String oldName, String newName) {- if (userName.equals(oldName))- userName = newName;- }-- @Override- public boolean onAccountDelete(String accountName) {- return userName.equals(accountName);- }--}+package com.pmease.gitplex.core.gatekeeper;++import org.eclipse.jgit.lib.ObjectId;+import org.hibernate.validator.constraints.NotEmpty;++import com.google.common.base.Preconditions;+import com.google.common.collect.Lists;+import com.google.common.collect.Sets;+import com.pmease.commons.wicket.editable.annotation.Editable;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.annotation.AccountChoice;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.PullRequestReview;+import com.pmease.gitplex.core.entity.Account;+import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;+import com.pmease.gitplex.core.manager.AccountManager;++@Editable(order=200, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=+ "This gatekeeper will be passed if the commit is approved by specified user")+public class ApprovedBySpecifiedUser extends AbstractGateKeeper {++ private static final long serialVersionUID = 1L;++ private String userName;++ @Editable(name="Select User")+ @AccountChoice+ @NotEmpty+ public String getUserName() {+ return userName;+ }++ public void setUserName(String userName) {+ this.userName = userName;+ }++ @Override+ public GateCheckResult doCheckRequest(PullRequest request) {+ Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));++ PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());+ if (result == null) {+ request.pickReviewers(Sets.newHashSet(user), 1);++ return pending(Lists.newArrayList("To be approved by " + user.getDisplayName()));+ } else if (result == PullRequestReview.Result.APPROVE) {+ return passed(Lists.newArrayList("Approved by " + user.getDisplayName()));+ } else {+ return failed(Lists.newArrayList("Disapproved by " + user.getDisplayName()));+ }+ }++ @Override+ protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {+ return pending(Lists.newArrayList("Need approval from " + user.getName()));+ }++ @Override+ protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {+ return pending(Lists.newArrayList("Need approval from " + user.getName()));+ }++ @Override+ public void onAccountRename(String oldName, String newName) {+ if (userName.equals(oldName))+ userName = newName;+ }++ @Override+ public boolean onAccountDelete(String accountName) {+ return userName.equals(accountName);+ }++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfThenGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ConditionalGateKeeper.javasimilarity index 91%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfThenGateKeeper.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ConditionalGateKeeper.javaindex e2ddca770e..f676350755 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfThenGateKeeper.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ConditionalGateKeeper.java@@ -13,11 +13,12 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;import com.pmease.gitplex.core.gatekeeper.checkresult.Passed;import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;-@Editable(name="If...Then... Composition", order=300, icon="fa-object-group",+@Editable(name="Conditional Composition", order=300, icon="fa-object-group",category=GateKeeper.CATEGORY_COMPOSITION,- description="If first gate keeper is passed, then go ahead to check second gate keeper")+ description="If first gatekeeper is passed, then continue to check second gatekeeper; "+ + "otherwise consider the conditional composition as passed")@Horizontal-public class IfThenGateKeeper extends CompositeGateKeeper {+public class ConditionalGateKeeper extends CompositeGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedTeam.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedTeam.javasimilarity index 94%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedTeam.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedTeam.javaindex 4d7a0f9fd8..e1224545b2 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedTeam.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedTeam.java@@ -15,11 +15,11 @@ import com.pmease.gitplex.core.entity.PullRequestReview;import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=- "This gate keeper will be passed if the commit gets specified number "+ "This gatekeeper will be passed if the commit gets specified number "+ "of disapprovals from specified team. It normally works together "+ "with a NOT container to reject the pull request in case there are "+ "disapprovals")-public class IfDisapprovedBySpecifiedTeam extends TeamAwareGateKeeper {+public class DisapprovedBySpecifiedTeam extends TeamAwareGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedUser.javasimilarity index 91%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedUser.javaindex 9363703efa..c51d7c36ad 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedUser.java@@ -1,72 +1,72 @@-package com.pmease.gitplex.core.gatekeeper;--import org.eclipse.jgit.lib.ObjectId;-import org.hibernate.validator.constraints.NotEmpty;--import com.google.common.base.Preconditions;-import com.google.common.collect.Lists;-import com.pmease.commons.wicket.editable.annotation.Editable;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.annotation.AccountChoice;-import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.PullRequestReview;-import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;-import com.pmease.gitplex.core.manager.AccountManager;--@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=- "This gate keeper will be passed if the commit is disapproved by specified user. "- + "It normally works together with a NOT container to reject the pull request "- + "in case the user disapproved it")-public class IfDisapprovedBySpecifiedUser extends AbstractGateKeeper {-- private static final long serialVersionUID = 1L;-- private String userName;-- @Editable(name="Select User")- @AccountChoice- @NotEmpty- public String getUserName() {- return userName;- }-- public void setUserName(String userName) {- this.userName = userName;- }-- @Override- protected GateCheckResult doCheckRequest(PullRequest request) {- Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));- PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());- if (result == PullRequestReview.Result.DISAPPROVE) {- return passed(Lists.newArrayList("Disapproved by " + userName));- } else {- return failed(Lists.newArrayList("Not disapproved by " + userName));- }- }-- @Override- protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {- return failed(Lists.newArrayList("Not disapproved by " + userName));- }-- @Override- protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit,- ObjectId newCommit) {- return failed(Lists.newArrayList("Not disapproved by " + userName));- }-- @Override- public void onAccountRename(String oldName, String newName) {- if (userName.equals(oldName))- userName = newName;- }-- @Override- public boolean onAccountDelete(String accountName) {- return userName.equals(accountName);- }--}+package com.pmease.gitplex.core.gatekeeper;++import org.eclipse.jgit.lib.ObjectId;+import org.hibernate.validator.constraints.NotEmpty;++import com.google.common.base.Preconditions;+import com.google.common.collect.Lists;+import com.pmease.commons.wicket.editable.annotation.Editable;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.annotation.AccountChoice;+import com.pmease.gitplex.core.entity.Account;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.PullRequestReview;+import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;+import com.pmease.gitplex.core.manager.AccountManager;++@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=+ "This gatekeeper will be passed if the commit is disapproved by specified user. "+ + "It normally works together with a NOT container to reject the pull request "+ + "in case the user disapproved it")+public class DisapprovedBySpecifiedUser extends AbstractGateKeeper {++ private static final long serialVersionUID = 1L;++ private String userName;++ @Editable(name="Select User")+ @AccountChoice+ @NotEmpty+ public String getUserName() {+ return userName;+ }++ public void setUserName(String userName) {+ this.userName = userName;+ }++ @Override+ protected GateCheckResult doCheckRequest(PullRequest request) {+ Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));+ PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());+ if (result == PullRequestReview.Result.DISAPPROVE) {+ return passed(Lists.newArrayList("Disapproved by " + userName));+ } else {+ return failed(Lists.newArrayList("Not disapproved by " + userName));+ }+ }++ @Override+ protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {+ return failed(Lists.newArrayList("Not disapproved by " + userName));+ }++ @Override+ protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit,+ ObjectId newCommit) {+ return failed(Lists.newArrayList("Not disapproved by " + userName));+ }++ @Override+ public void onAccountRename(String oldName, String newName) {+ if (userName.equals(oldName))+ userName = newName;+ }++ @Override+ public boolean onAccountDelete(String accountName) {+ return userName.equals(accountName);+ }++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.javaindex d5d2f77a28..ea03d033a8 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java@@ -15,14 +15,14 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;@Editable(name="Misc")public interface GateKeeper extends Serializable {- String CATEGORY_BASIC = "Basic Gate Keepers";+ String CATEGORY_BASIC = "Basic Gatekeepers";String CATEGORY_USER = "Check Approver/Submitter";- String CATEGORY_COMPOSITION = "Gate Keeper Compositions";+ String CATEGORY_COMPOSITION = "Gatekeeper Compositions";/**- * Check the gate keeper against specified request. This is typically used to determine+ * Check the gatekeeper against specified request. This is typically used to determine* whether or not to accept a pull request.** @param requestdiff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.javaindex d03ac4185b..838918f908 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.java@@ -12,7 +12,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;import com.pmease.gitplex.core.gatekeeper.checkresult.Passed;@Editable(name="Not Composition", order=400, icon="fa-object-group", category=GateKeeper.CATEGORY_COMPOSITION,- description="This gate keeper will be passed if contained gate keeper is not passed")+ description="This gatekeeper will be passed if contained gatekeeper is not passed")@Horizontalpublic class NotGateKeeper extends CompositeGateKeeper {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.javaindex f0cfe51433..a3fc2c6817 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.java@@ -12,7 +12,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Passed;import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;@Editable(name="Or Composition", order=200, icon="fa-object-group", category=GateKeeper.CATEGORY_COMPOSITION,- description="This gate keeper will be passed if any of the contained gate keepers is passed")+ description="This gatekeeper will be passed if any of the contained gatekeepers is passed")@Horizontalpublic class OrGateKeeper extends AndOrGateKeeper {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPerformSpecifiedOperations.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PerformSpecifiedOperations.javasimilarity index 94%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPerformSpecifiedOperations.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PerformSpecifiedOperations.javaindex ed23afc435..a83f60e8b8 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPerformSpecifiedOperations.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PerformSpecifiedOperations.java@@ -17,9 +17,9 @@ import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;@Editable(order=200, icon="fa-wrench", description=- "This gate keeper will be passed if one of specified operations is performed")+ "This gatekeeper will be passed if one of specified operations is performed")@ClassValidating-public class IfPerformSpecifiedOperations extends AbstractGateKeeper implements Validatable {+public class PerformSpecifiedOperations extends AbstractGateKeeper implements Validatable {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPushWithoutRewritingHistory.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PushWithoutRewritingHistory.javasimilarity index 92%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPushWithoutRewritingHistory.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PushWithoutRewritingHistory.javaindex 7013a275fe..2d62d78ad6 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPushWithoutRewritingHistory.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PushWithoutRewritingHistory.java@@ -10,11 +10,11 @@ import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;-@Editable(order=2000, icon="fa-ext fa-repo-lock", description="This gate keeper will be passed if the push "+@Editable(order=2000, icon="fa-ext fa-repo-lock", description="This gatekeeper will be passed if the push "+ "operation does not rewrite history of target branch. Rewriting history of public branches "+ "is dangerous, and it happens when user forces a push without merging/rebasing with the "+ "branch head")-public class IfPushWithoutRewritingHistory extends AbstractGateKeeper {+public class PushWithoutRewritingHistory extends AbstractGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmitWithGerritStylePatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmitWithGerritStylePatch.javasimilarity index 93%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmitWithGerritStylePatch.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmitWithGerritStylePatch.javaindex d98d9d3dae..c51f64a9df 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmitWithGerritStylePatch.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmitWithGerritStylePatch.java@@ -14,10 +14,10 @@ import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;-@Editable(order=3000, icon="fa-ext fa-file-diff", description="This gate keeper will be passed if the pull request "+@Editable(order=3000, icon="fa-ext fa-file-diff", description="This gatekeeper will be passed if the pull request "+ "is submitted with gerrit style patch, that is, only one commit is submitted for review at "+ "a time, and subsequent updates to the review should be done by amending previous commit")-public class IfSubmitWithGerritStylePatch extends AbstractGateKeeper {+public class SubmitWithGerritStylePatch extends AbstractGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedTeam.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedTeam.javasimilarity index 89%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedTeam.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedTeam.javaindex b6faa0d677..8c223ce51e 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedTeam.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedTeam.java@@ -12,8 +12,8 @@ import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;@Editable(order=500, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=- "This gate keeper will be passed if the commit is submitted by a member of specified team")-public class IfSubmittedBySpecifiedTeam extends TeamAwareGateKeeper {+ "This gatekeeper will be passed if the commit is submitted by a member of specified team")+public class SubmittedBySpecifiedTeam extends TeamAwareGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedUser.javasimilarity index 90%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedUser.javaindex ba252844bc..b5633c3aae 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedUser.java@@ -1,70 +1,70 @@-package com.pmease.gitplex.core.gatekeeper;--import org.eclipse.jgit.lib.ObjectId;-import org.hibernate.validator.constraints.NotEmpty;--import com.google.common.base.Preconditions;-import com.google.common.collect.Lists;-import com.pmease.commons.wicket.editable.annotation.Editable;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.annotation.AccountChoice;-import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;-import com.pmease.gitplex.core.manager.AccountManager;--@Editable(order=600, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=- "This gate keeper will be passed if the commit is submitted by specified user")-public class IfSubmittedBySpecifiedUser extends AbstractGateKeeper {-- private static final long serialVersionUID = 1L;-- private String userName;-- @Editable(name="Select User")- @AccountChoice- @NotEmpty- public String getUserName() {- return userName;- }-- public void setUserName(String userName) {- this.userName = userName;- }-- @Override- public GateCheckResult doCheckRequest(PullRequest request) {- return checkSubmitter(request.getSubmitter());- }-- private GateCheckResult checkSubmitter(Account user) {- Account expectedUser = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));- if (expectedUser.equals(user))- return passed(Lists.newArrayList("Submitted by " + expectedUser.getDisplayName()));- else- return failed(Lists.newArrayList("Not submitted by " + expectedUser.getDisplayName()));- }-- @Override- protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {- return checkSubmitter(user);- }-- @Override- protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {- return checkSubmitter(user);- }-- @Override- public void onAccountRename(String oldName, String newName) {- if (userName.equals(oldName))- userName = newName;- }-- @Override- public boolean onAccountDelete(String accountName) {- return userName.equals(accountName);- }--}+package com.pmease.gitplex.core.gatekeeper;++import org.eclipse.jgit.lib.ObjectId;+import org.hibernate.validator.constraints.NotEmpty;++import com.google.common.base.Preconditions;+import com.google.common.collect.Lists;+import com.pmease.commons.wicket.editable.annotation.Editable;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.annotation.AccountChoice;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.Account;+import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;+import com.pmease.gitplex.core.manager.AccountManager;++@Editable(order=600, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=+ "This gatekeeper will be passed if the commit is submitted by specified user")+public class SubmittedBySpecifiedUser extends AbstractGateKeeper {++ private static final long serialVersionUID = 1L;++ private String userName;++ @Editable(name="Select User")+ @AccountChoice+ @NotEmpty+ public String getUserName() {+ return userName;+ }++ public void setUserName(String userName) {+ this.userName = userName;+ }++ @Override+ public GateCheckResult doCheckRequest(PullRequest request) {+ return checkSubmitter(request.getSubmitter());+ }++ private GateCheckResult checkSubmitter(Account user) {+ Account expectedUser = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));+ if (expectedUser.equals(user))+ return passed(Lists.newArrayList("Submitted by " + expectedUser.getDisplayName()));+ else+ return failed(Lists.newArrayList("Not submitted by " + expectedUser.getDisplayName()));+ }++ @Override+ protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {+ return checkSubmitter(user);+ }++ @Override+ protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {+ return checkSubmitter(user);+ }++ @Override+ public void onAccountRename(String oldName, String newName) {+ if (userName.equals(oldName))+ userName = newName;+ }++ @Override+ public boolean onAccountDelete(String accountName) {+ return userName.equals(accountName);+ }++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFiles.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedFiles.javasimilarity index 95%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFiles.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedFiles.javaindex 0f5fa8ab6d..46ed789355 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFiles.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedFiles.java@@ -20,8 +20,8 @@ import com.pmease.gitplex.core.util.ParentAwareMatcher;import com.pmease.gitplex.core.util.includeexclude.IncludeExcludeUtils;@Editable(order=300, icon="fa-file-text", description=- "This gate keeper will be passed if specified files are modified")-public class IfTouchSpecifiedFiles extends AbstractGateKeeper {+ "This gatekeeper will be passed if specified files are modified")+public class TouchSpecifiedFiles extends AbstractGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedRefs.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedRefs.javasimilarity index 95%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedRefs.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedRefs.javaindex 9a79c5f6d2..4ff0a8eb1e 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedRefs.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedRefs.java@@ -18,8 +18,8 @@ import com.pmease.gitplex.core.util.includeexclude.IncludeExcludeParser;import com.pmease.gitplex.core.util.includeexclude.IncludeExcludeUtils;@Editable(order=100, icon="fa-code-fork", description=- "This gate keeper will be passed if specified refs is being touched")-public class IfTouchSpecifiedRefs extends AbstractGateKeeper {+ "This gatekeeper will be passed if specified refs is being touched")+public class TouchSpecifiedRefs extends AbstractGateKeeper {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/VerifiedByBuilds.javasimilarity index 94%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/VerifiedByBuilds.javaindex 5978359134..fc23e4659a 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/VerifiedByBuilds.java@@ -18,10 +18,10 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;import com.pmease.gitplex.core.manager.PullRequestVerificationManager;@Editable(icon="fa-check-circle", order=1000,- description="This gate keeper will be satisfied if commit is verified successfully "+ description="This gatekeeper will be satisfied if commit is verified successfully "+ "by specified number of builds. To make this working, your CI system has to "+ "be configured to build against GitPlex pull requests")-public class IfVerifiedByBuilds extends AbstractGateKeeper {+public class VerifiedByBuilds extends AbstractGateKeeper {private static final long serialVersionUID = 1L;@@ -32,7 +32,7 @@ public class IfVerifiedByBuilds extends AbstractGateKeeper {private boolean blockMode = true;@Editable(order=100, description="This specified number of builds has to be reported successful "- + "for this gate keeper to be passed. Normally this number represents number of build "+ + "for this gatekeeper to be passed. Normally this number represents number of build "+ "configurations setting up to verify the branch.")@Min(1)public int getLeastPassCount() {@@ -52,7 +52,7 @@ public class IfVerifiedByBuilds extends AbstractGateKeeper {this.checkIntegrated = checkIntegrated;}- @Editable(order=300, description="If this is checked, subsequent gate keepers will not be checked "+ @Editable(order=300, description="If this is checked, subsequent gatekeepers will not be checked "+ "while waiting for the build results. This can be used to only notify relevant voters "+ "when the commit passes build.")public boolean isBlockMode() {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.javaindex a4f87bc59d..49f7cd7878 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.java@@ -3,8 +3,8 @@ package com.pmease.gitplex.core.gatekeeper.checkresult;import java.util.List;/*- * Same as Pending, but followed gate keeper should not be checked unless result- * of this gate keeper has been determined.+ * Same as Pending, but followed gatekeeper should not be checked unless result+ * of this gatekeeper has been determined.*/@SuppressWarnings("serial")public class Blocking extends GateCheckResult {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.javaindex b9b8d24bda..e22743cb3d 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java@@ -28,7 +28,6 @@ import com.pmease.gitplex.core.entity.PullRequestStatusChange;import com.pmease.gitplex.core.entity.support.IntegrationPolicy;import com.pmease.gitplex.core.event.lifecycle.SystemStarting;import com.pmease.gitplex.core.event.pullrequest.PullRequestStatusChangeEvent;-import com.pmease.gitplex.core.gatekeeper.GateKeeper;import com.pmease.gitplex.core.manager.AccountManager;import com.pmease.gitplex.core.manager.DepotManager;import com.pmease.gitplex.core.manager.PullRequestManager;@@ -68,9 +67,7 @@ public class DefaultAccountManager extends AbstractEntityManager<Account> implemfor (IntegrationPolicy integrationPolicy: depot.getIntegrationPolicies()) {integrationPolicy.onAccountRename(oldName, account.getName());}- for (GateKeeper gateKeeper: depot.getGateKeepers()) {- gateKeeper.onAccountRename(oldName, account.getName());- }+ depot.getGateKeeper().onAccountRename(oldName, account.getName());}}@@ -139,10 +136,7 @@ public class DefaultAccountManager extends AbstractEntityManager<Account> implemif (it.next().onAccountDelete(account.getName()))it.remove();}- for (Iterator<GateKeeper> it = depot.getGateKeepers().iterator(); it.hasNext();) {- if (it.next().onAccountDelete(account.getName()))- it.remove();- }+ depot.getGateKeeper().onAccountDelete(account.getName());}doAfterCommit(new Runnable() {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.javaindex ea2df2bc26..b4f33206de 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.java@@ -51,7 +51,7 @@ import com.pmease.gitplex.core.event.depot.DepotTransferred;import com.pmease.gitplex.core.event.lifecycle.SystemStarted;import com.pmease.gitplex.core.event.lifecycle.SystemStarting;import com.pmease.gitplex.core.event.lifecycle.SystemStopping;-import com.pmease.gitplex.core.gatekeeper.GateKeeper;+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;import com.pmease.gitplex.core.manager.AccountManager;import com.pmease.gitplex.core.manager.CodeCommentInfoManager;import com.pmease.gitplex.core.manager.CommitInfoManager;@@ -144,10 +144,8 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implementsfor (IntegrationPolicy policy: each.getIntegrationPolicies()) {policy.onDepotTransfer(depot, oldAccount);}- for (Iterator<GateKeeper> it = each.getGateKeepers().iterator(); it.hasNext();) {- if (it.next().onDepotTransfer(each, depot, oldAccount))- it.remove();- }+ if (each.getGateKeeper().onDepotTransfer(each, depot, oldAccount))+ each.setGateKeeper(new DefaultGateKeeper());}}if (oldName != null && !depot.getName().equals(oldName)) {@@ -157,9 +155,7 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implementsfor (IntegrationPolicy integrationPolicy: each.getIntegrationPolicies()) {integrationPolicy.onDepotRename(depot.getAccount(), oldName, depot.getName());}- for (GateKeeper gateKeeper: each.getGateKeepers()) {- gateKeeper.onDepotRename(depot, oldName);- }+ each.getGateKeeper().onDepotRename(depot, oldName);}}@@ -199,10 +195,8 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implementsif (it.next().onDepotDelete(depot))it.remove();}- for (Iterator<GateKeeper> it = each.getGateKeepers().iterator(); it.hasNext();) {- if (it.next().onDepotDelete(depot))- it.remove();- }+ if (each.getGateKeeper().onDepotDelete(depot))+ each.setGateKeeper(new DefaultGateKeeper());}doAfterCommit(new Runnable() {@@ -340,10 +334,8 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implementsit.remove();}}- for (Iterator<GateKeeper> it = each.getGateKeepers().iterator(); it.hasNext();) {- if (it.next().onRefDelete(event.getRefName()))- it.remove();- }+ if (each.getGateKeeper().onRefDelete(event.getRefName()))+ each.setGateKeeper(new DefaultGateKeeper());}}}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.javaindex eecff67544..0f31192699 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.java@@ -1,7 +1,5 @@package com.pmease.gitplex.core.manager.impl;-import java.util.Iterator;-import javax.inject.Inject;import javax.inject.Singleton;@@ -15,7 +13,7 @@ import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.Team;-import com.pmease.gitplex.core.gatekeeper.GateKeeper;+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;import com.pmease.gitplex.core.manager.TeamManager;@Singleton@@ -31,9 +29,7 @@ public class DefaultTeamManager extends AbstractEntityManager<Team> implements Tpublic void save(Team team, String oldName) {if (oldName != null && !oldName.equals(team.getName())) {for (Depot depot: team.getOrganization().getDepots()) {- for (GateKeeper gateKeeper: depot.getGateKeepers()) {- gateKeeper.onTeamRename(oldName, team.getName());- }+ depot.getGateKeeper().onTeamRename(oldName, team.getName());}}dao.persist(team);@@ -43,10 +39,8 @@ public class DefaultTeamManager extends AbstractEntityManager<Team> implements T@Overridepublic void delete(Team team) {for (Depot depot: team.getOrganization().getDepots()) {- for (Iterator<GateKeeper> it = depot.getGateKeepers().iterator(); it.hasNext();) {- if (it.next().onTeamDelete(team.getName()))- it.remove();- }+ if (depot.getGateKeeper().onTeamDelete(team.getName()))+ depot.setGateKeeper(new DefaultGateKeeper());}dao.remove(team);}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.javaindex 04ef9ae94e..8e59032801 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.java@@ -1,30 +1,30 @@-package com.pmease.gitplex.core.util;--/**- * Besides the normal child aware match, this matcher also matches- * parent path ending with slash. For instance, if pattern is defined- * as "parent/child", it will match value "parent/".- * A scenario using this matcher:- * <ol>- * <li> A gate keeper is defined to require that all created tags should match- * the format "refs/tags/v*"- * <li> The tag creation link checks the gate keeper using ref value "refs/tags/"- * to see if tag creation is allowed, and it matches meaning one can create tag- * <li> User then input tag name, and this name will be matched again with the gate keeper- * and if it does not starts with letter "v", the tag creation will not be allowed- *- * @author robin- *- */-public class ParentAwareMatcher extends ChildAwareMatcher {-- @Override- public boolean matches(String rule, String value) {- if (rule.startsWith(value) && value.endsWith("/")) {- return true;- } else {- return super.matches(rule, value);- }- }--}+package com.pmease.gitplex.core.util;++/**+ * Besides the normal child aware match, this matcher also matches+ * parent path ending with slash. For instance, if pattern is defined+ * as "parent/child", it will match value "parent/".+ * A scenario using this matcher:+ * <ol>+ * <li> A gatekeeper is defined to require that all created tags should match+ * the format "refs/tags/v*"+ * <li> The tag creation link checks the gatekeeper using ref value "refs/tags/"+ * to see if tag creation is allowed, and it matches meaning one can create tag+ * <li> User then input tag name, and this name will be matched again with the gatekeeper+ * and if it does not starts with letter "v", the tag creation will not be allowed+ *+ * @author robin+ *+ */+public class ParentAwareMatcher extends ChildAwareMatcher {++ @Override+ public boolean matches(String rule, String value) {+ if (rule.startsWith(value) && value.endsWith("/")) {+ return true;+ } else {+ return super.matches(rule, value);+ }+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.htmlindex 99a2009c27..18e651ca90 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.html@@ -1,18 +1,18 @@-<wicket:panel>- <div class="privilege selection">- <a wicket:id="read">- <div class="title">Read</div>- <div class="description">Able to pull and browse the repository</div>- </a>- <a wicket:id="write">- <div class="title">Write</div>- <div class="description">Has full read privilege, and can also push to- the repository unless gate keeper prevents</div>- </a>- <a wicket:id="admin">- <div class="title">Admin</div>- <div class="description">Has full write privilege, and can also manage- settings of the repository</div>- </a>- </div>+<wicket:panel>+ <div class="privilege selection">+ <a wicket:id="read">+ <div class="title">Read</div>+ <div class="description">Able to pull and browse the repository</div>+ </a>+ <a wicket:id="write">+ <div class="title">Write</div>+ <div class="description">Has full read privilege, and can also push to+ the repository unless gatekeeper prevents</div>+ </a>+ <a wicket:id="admin">+ <div class="title">Admin</div>+ <div class="description">Has full write privilege, and can also manage+ settings of the repository</div>+ </a>+ </div></wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.javaindex ba8cc1cb23..7851a6aa4e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.java@@ -62,13 +62,13 @@ public class ReviewerAvatar extends RemoveableAvatar {if (nowInvited.contains(invitation.getUser())) {getSession().warn("Reviewer '" + invitation.getUser().getDisplayName()- + "' is required by gate keeper and can not be removed");+ + "' is required by gatekeeper and can not be removed");} else {nowInvited.removeAll(prevInvited);if (!nowInvited.isEmpty()) {getSession().warn("Reviewer '" + invitation.getUser().getDisplayName()+ "' is removed and user '" + nowInvited.iterator().next().getDisplayName()- + "' is added as reviewer automatically to satisfy gate keeper requirement.");+ + "' is added as reviewer automatically to satisfy gatekeeper requirement.");}}if (!request.isNew()) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.htmlindex 6fbf3a2ba9..56762abcb8 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html@@ -1,106 +1,106 @@-<wicket:extend>- <div id="new-request">- <div class="head">Open Pull Request</div>- <div class="body">- <div class="branches clearfix">- <div class="branch pull-left">- <label>Target</label>- <div wicket:id="target"></div>- </div>- <div class="action pull-left">- <a wicket:id="swap" title="Swap" class="swap btn btn-default"><i class="fa fa-exchange"></i></a>- </div>- <div class="branch pull-left">- <label>Source</label>- <div wicket:id="source"></div>- </div>- </div>- <div wicket:id="status" class="status"></div>- <ul wicket:id="tabs" class="nav nav-tabs"></ul>- <div wicket:id="tabPanel" class="tab-panel"></div>- </div>- </div>- <wicket:fragment wicket:id="openedFrag">- <div class="alert alert-info">- <div>Pull request #<span wicket:id="no"></span> is already open for this comparison:</div>- <b><a wicket:id="link"><span wicket:id="label"></span></a></b>- </div>- </wicket:fragment>- <wicket:fragment wicket:id="sameBranchFrag">- <div class="alert alert-warning">- <div class="summary">- <span class="fa fa-lg fa-warning"></span>- <span>Please select different branches to integrate.</span>- </div>- </div>- </wicket:fragment>- <wicket:fragment wicket:id="integratedFrag">- <div class="alert alert-success">- <div class="summary">- <span class="fa fa-lg fa-check-circle"></span>- <a wicket:id="targetBranch"></a> is up to date with all commits from <a wicket:id="sourceBranch"></a>.- Try <a wicket:id="swapBranches">swap source and target</a> for the comparison.- </div>- </div>- </wicket:fragment>- <wicket:fragment wicket:id="rejectedFrag">- <div class="alert alert-danger">- <div class="summary">- <span class="fa fa-lg fa-ban"></span>- <span class="message">Gate keeper of target repository rejects the integration request for below reasons:</span>- </div>- <ul class="detail">- <li wicket:id="reasons"><span wicket:id="reason"></span></li>- </ul>- </div>- </wicket:fragment>- <wicket:fragment wicket:id="canSendFrag">- <div class="can-send">- <form wicket:id="form">- <table>- <tr class="title">- <td class="name">Title <span class="required"></span></td>- <td wicket:id="title" class="value">- <input wicket:id="title" type="text" class="form-control focusable" placeholder="Input title here">- <div wicket:id="feedback"></div>- </td>- </tr>- <tr class="description">- <td class="name">Description</td>- <td class="value"><textarea wicket:id="comment" rows="5" class="form-control focusable"></textarea></td>- </tr>- <tr class="assignee">- <td class="name">Assignee <span class="required"></span></td>- <td wicket:id="assignee" class="value">- <input wicket:id="assignee" type="hidden"></input>- <div wicket:id="feedback"></div>- <div class="help-block">- <i class="fa fa-info-circle"></i> Assignee is responsible for integration of the- pull request after it passes gate keeper check.- </div>- </td>- </tr>- <tr class="reviewers">- <td class="name">Reviewers</td>- <td wicket:id="reviewers" class="value">- <ul class="clearfix list-unstyled">- <li wicket:id="reviewers" class="pull-left">- <a wicket:id="avatar"></a>- </li>- <wicket:enclosure child="addReviewer">- <li class="pull-left"><input wicket:id="addReviewer" type="hidden"></input></li>- </wicket:enclosure>- </ul>- <div wicket:id="prePopulateHint" class="help-block">- <i class="fa fa-info-circle"></i> GitPlex pre-populated some reviewers above as suggested- by gate keeper of the repository. You may adjust the list by removing existing (hovering mouse- over reviewer avatar) or adding more.- </div>- </td>- </tr>- </table>- <input wicket:id="send" type="submit" class="btn btn-primary" value="Send Pull Request"></input>- </form>- </div>- </wicket:fragment>+<wicket:extend>+ <div id="new-request">+ <div class="head">Open Pull Request</div>+ <div class="body">+ <div class="branches clearfix">+ <div class="branch pull-left">+ <label>Target</label>+ <div wicket:id="target"></div>+ </div>+ <div class="action pull-left">+ <a wicket:id="swap" title="Swap" class="swap btn btn-default"><i class="fa fa-exchange"></i></a>+ </div>+ <div class="branch pull-left">+ <label>Source</label>+ <div wicket:id="source"></div>+ </div>+ </div>+ <div wicket:id="status" class="status"></div>+ <ul wicket:id="tabs" class="nav nav-tabs"></ul>+ <div wicket:id="tabPanel" class="tab-panel"></div>+ </div>+ </div>+ <wicket:fragment wicket:id="openedFrag">+ <div class="alert alert-info">+ <div>Pull request #<span wicket:id="no"></span> is already open for this comparison:</div>+ <b><a wicket:id="link"><span wicket:id="label"></span></a></b>+ </div>+ </wicket:fragment>+ <wicket:fragment wicket:id="sameBranchFrag">+ <div class="alert alert-warning">+ <div class="summary">+ <span class="fa fa-lg fa-warning"></span>+ <span>Please select different branches to integrate.</span>+ </div>+ </div>+ </wicket:fragment>+ <wicket:fragment wicket:id="integratedFrag">+ <div class="alert alert-success">+ <div class="summary">+ <span class="fa fa-lg fa-check-circle"></span>+ <a wicket:id="targetBranch"></a> is up to date with all commits from <a wicket:id="sourceBranch"></a>.+ Try <a wicket:id="swapBranches">swap source and target</a> for the comparison.+ </div>+ </div>+ </wicket:fragment>+ <wicket:fragment wicket:id="rejectedFrag">+ <div class="alert alert-danger">+ <div class="summary">+ <span class="fa fa-lg fa-ban"></span>+ <span class="message">Gatekeeper of target repository rejects the integration request for below reasons:</span>+ </div>+ <ul class="detail">+ <li wicket:id="reasons"><span wicket:id="reason"></span></li>+ </ul>+ </div>+ </wicket:fragment>+ <wicket:fragment wicket:id="canSendFrag">+ <div class="can-send">+ <form wicket:id="form">+ <table>+ <tr class="title">+ <td class="name">Title <span class="required"></span></td>+ <td wicket:id="title" class="value">+ <input wicket:id="title" type="text" class="form-control focusable" placeholder="Input title here">+ <div wicket:id="feedback"></div>+ </td>+ </tr>+ <tr class="description">+ <td class="name">Description</td>+ <td class="value"><textarea wicket:id="comment" rows="5" class="form-control focusable"></textarea></td>+ </tr>+ <tr class="assignee">+ <td class="name">Assignee <span class="required"></span></td>+ <td wicket:id="assignee" class="value">+ <input wicket:id="assignee" type="hidden"></input>+ <div wicket:id="feedback"></div>+ <div class="help-block">+ <i class="fa fa-info-circle"></i> Assignee is responsible for integration of the+ pull request after it passes gatekeeper check.+ </div>+ </td>+ </tr>+ <tr class="reviewers">+ <td class="name">Reviewers</td>+ <td wicket:id="reviewers" class="value">+ <ul class="clearfix list-unstyled">+ <li wicket:id="reviewers" class="pull-left">+ <a wicket:id="avatar"></a>+ </li>+ <wicket:enclosure child="addReviewer">+ <li class="pull-left"><input wicket:id="addReviewer" type="hidden"></input></li>+ </wicket:enclosure>+ </ul>+ <div wicket:id="prePopulateHint" class="help-block">+ <i class="fa fa-info-circle"></i> GitPlex pre-populated some reviewers above as suggested+ by gatekeeper of the repository. You may adjust the list by removing existing (hovering mouse+ over reviewer avatar) or adding more.+ </div>+ </td>+ </tr>+ </table>+ <input wicket:id="send" type="submit" class="btn btn-primary" value="Send Pull Request"></input>+ </form>+ </div>+ </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.htmlindex f93c09d8ce..4aaeac3a1f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html@@ -1,116 +1,116 @@-<wicket:extend>- <div id="request-detail">- <div wicket:id="requestHead" class="head clearfix">- <div wicket:id="title" class="title pull-left"></div>- <div wicket:id="number" class="number pull-left"></div>- <a wicket:id="editLink" title="Edit title" class="edit"><i class="fa fa-pencil"></i></a>- <form wicket:id="editForm" class="pull-left form-inline">- <input wicket:id="title" type="text" placeholder="Input title" class="form-control focusable"></input>- <input wicket:id="save" type="submit" value="Save" class="btn btn-primary"/>- <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"/>- </form>- </div>- <div wicket:id="statusAndBranches" class="status-and-branches clearfix">- <div wicket:id="status" class="label pull-left status"></div>- <div class="pull-left branches">- <a wicket:id="user"></a> <span wicket:id="action"></span> into <a wicket:id="target" class="branch"></a>- from <a wicket:id="source" class="branch"></a> <span wicket:id="date"></span>- </div>- </div>- <div wicket:id="requestSummary" class="summary well">- <div wicket:id="discardedNote">- <i class="fa fa-info-circle"></i> This pull request has been discarded.- </div>- <div wicket:id="pendingUpdateNote" class="note">- <i class="fa fa-exclamation-triangle"></i> This pull request does not pass gate keeper- checks below, and needs to be updated with new commits.- </div>- <div wicket:id="pendingApprovalNote" class="note">- <i class="fa fa-exclamation-triangle"></i> This pull request needs to be approved before it can- be integrated.- </div>- <div wicket:id="integratedNote" class="integrated-note">- <div wicket:id="fastForwarded">- <i class="fa fa-info-circle"></i> Target branch was fast-forwarded to source branch.- </div>- <div wicket:id="merged">- <i class="fa fa-info-circle"></i> Target branch was merged with source branch.- </div>- <div wicket:id="mergedOutside">- <i class="fa fa-info-circle"></i> Target branch was merged with source branch by someone outside of this pull request.- </div>- <div wicket:id="squashed">- <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was squashed- before merging into target branch. Run this command if you want to sync local- branch with the source branch:- <kbd>git fetch origin && git rebase</kbd>- </p>- </div>- <div wicket:id="sourceRebased">- <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was rebased- before merging into target branch. Run this command if you want to sync local- branch with the source branch:- <kbd>git fetch origin && git rebase</kbd>- </p>- </div>- <div wicket:id="targetRebased">- <p><i class="fa fa-info-circle"></i> Per integration strategy, target branch was rebased on top of source branch.- Run this command if you want to sync local branch with the target branch:- <kbd>git fetch origin && git rebase</kbd>- </p>- </div>- </div>- <div wicket:id="statusReasons" class="status-reasons">- <ul><li wicket:id="reasons" class="reason"><span wicket:id="reason"></span></li></ul>- </div>- <div wicket:id="integrationPreview" class="integration-preview">- <div wicket:id="calculating">- <wicket:link>- <img src="ajax-indicator.gif"></img> Calculating integration preview...- </wicket:link>- </div>- <div wicket:id="noConflict" class="no-conflict">- <label><i class="fa fa-check-circle"></i> Able to integrate without conflicts.</label>- <wicket:enclosure child="preview">- <a wicket:id="preview">Preview</a> the integration result.- </wicket:enclosure>- <wicket:enclosure child="verification">- <span class="fa fa-arrow-right"></span> Build of the integration is <span wicket:id="verification"></span>- </wicket:enclosure>- </div>- <div wicket:id="conflict" class="conflict">- <span><i class="fa fa-warning"></i> There are integration conflicts.</span>- <wicket:enclosure child="resolveInstructionsTrigger">- Please follow <a wicket:id="resolveInstructionsTrigger" href="javascript:void(0);">this instruction</a> to resolve the conflicts.- </wicket:enclosure>- </div>- </div>- <div wicket:id="operations" class="operations">- <div class="buttons">- <a wicket:id="approve" class="btn btn-primary">Approve</a>- <a wicket:id="disapprove" class="btn btn-primary">Disapprove</a>- <a wicket:id="integrate" class="btn btn-success">Integrate</a>- <a wicket:id="discard" class="btn btn-danger">Discard</a>- <a wicket:id="reopen" class="btn btn-primary">Reopen</a>- <a wicket:id="deleteSourceBranch" class="btn btn-primary">Delete source branch</a>- <a wicket:id="restoreSourceBranch" class="btn btn-primary">Restore source branch</a>- </div>- <div wicket:id="confirm" class="confirm"></div>- </div>- </div>- <ul wicket:id="requestTabs" class="tabs nav nav-tabs"></ul>- <wicket:child></wicket:child>- </div>- <wicket:fragment wicket:id="operationConfirmFrag">- <form wicket:id="form" class="leave-confirm">- <div wicket:id="hint" class="hint"></div>- <div wicket:id="feedback"></div>- <textarea wicket:id="note" class="form-control focusable" rows="5" placeholder="Leave a note"></textarea>- <input wicket:id="submit" type="submit" value="Confirm" class="btn"></input>- <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"></input>- </form>- </wicket:fragment>- <wicket:fragment wicket:id="codeCommentsTabLinkFrag">- <a wicket:id="link"><i class="fa fa-circle"></i> Code Comments</a>- </wicket:fragment>+<wicket:extend>+ <div id="request-detail">+ <div wicket:id="requestHead" class="head clearfix">+ <div wicket:id="title" class="title pull-left"></div>+ <div wicket:id="number" class="number pull-left"></div>+ <a wicket:id="editLink" title="Edit title" class="edit"><i class="fa fa-pencil"></i></a>+ <form wicket:id="editForm" class="pull-left form-inline">+ <input wicket:id="title" type="text" placeholder="Input title" class="form-control focusable"></input>+ <input wicket:id="save" type="submit" value="Save" class="btn btn-primary"/>+ <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"/>+ </form>+ </div>+ <div wicket:id="statusAndBranches" class="status-and-branches clearfix">+ <div wicket:id="status" class="label pull-left status"></div>+ <div class="pull-left branches">+ <a wicket:id="user"></a> <span wicket:id="action"></span> into <a wicket:id="target" class="branch"></a>+ from <a wicket:id="source" class="branch"></a> <span wicket:id="date"></span>+ </div>+ </div>+ <div wicket:id="requestSummary" class="summary well">+ <div wicket:id="discardedNote">+ <i class="fa fa-info-circle"></i> This pull request has been discarded.+ </div>+ <div wicket:id="pendingUpdateNote" class="note">+ <i class="fa fa-exclamation-triangle"></i> This pull request does not pass gatekeeper+ checks below, and needs to be updated with new commits.+ </div>+ <div wicket:id="pendingApprovalNote" class="note">+ <i class="fa fa-exclamation-triangle"></i> This pull request needs to be approved before it can+ be integrated.+ </div>+ <div wicket:id="integratedNote" class="integrated-note">+ <div wicket:id="fastForwarded">+ <i class="fa fa-info-circle"></i> Target branch was fast-forwarded to source branch.+ </div>+ <div wicket:id="merged">+ <i class="fa fa-info-circle"></i> Target branch was merged with source branch.+ </div>+ <div wicket:id="mergedOutside">+ <i class="fa fa-info-circle"></i> Target branch was merged with source branch by someone outside of this pull request.+ </div>+ <div wicket:id="squashed">+ <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was squashed+ before merging into target branch. Run this command if you want to sync local+ branch with the source branch:+ <kbd>git fetch origin && git rebase</kbd>+ </p>+ </div>+ <div wicket:id="sourceRebased">+ <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was rebased+ before merging into target branch. Run this command if you want to sync local+ branch with the source branch:+ <kbd>git fetch origin && git rebase</kbd>+ </p>+ </div>+ <div wicket:id="targetRebased">+ <p><i class="fa fa-info-circle"></i> Per integration strategy, target branch was rebased on top of source branch.+ Run this command if you want to sync local branch with the target branch:+ <kbd>git fetch origin && git rebase</kbd>+ </p>+ </div>+ </div>+ <div wicket:id="statusReasons" class="status-reasons">+ <ul><li wicket:id="reasons" class="reason"><span wicket:id="reason"></span></li></ul>+ </div>+ <div wicket:id="integrationPreview" class="integration-preview">+ <div wicket:id="calculating">+ <wicket:link>+ <img src="ajax-indicator.gif"></img> Calculating integration preview...+ </wicket:link>+ </div>+ <div wicket:id="noConflict" class="no-conflict">+ <label><i class="fa fa-check-circle"></i> Able to integrate without conflicts.</label>+ <wicket:enclosure child="preview">+ <a wicket:id="preview">Preview</a> the integration result.+ </wicket:enclosure>+ <wicket:enclosure child="verification">+ <span class="fa fa-arrow-right"></span> Build of the integration is <span wicket:id="verification"></span>+ </wicket:enclosure>+ </div>+ <div wicket:id="conflict" class="conflict">+ <span><i class="fa fa-warning"></i> There are integration conflicts.</span>+ <wicket:enclosure child="resolveInstructionsTrigger">+ Please follow <a wicket:id="resolveInstructionsTrigger" href="javascript:void(0);">this instruction</a> to resolve the conflicts.+ </wicket:enclosure>+ </div>+ </div>+ <div wicket:id="operations" class="operations">+ <div class="buttons">+ <a wicket:id="approve" class="btn btn-primary">Approve</a>+ <a wicket:id="disapprove" class="btn btn-primary">Disapprove</a>+ <a wicket:id="integrate" class="btn btn-success">Integrate</a>+ <a wicket:id="discard" class="btn btn-danger">Discard</a>+ <a wicket:id="reopen" class="btn btn-primary">Reopen</a>+ <a wicket:id="deleteSourceBranch" class="btn btn-primary">Delete source branch</a>+ <a wicket:id="restoreSourceBranch" class="btn btn-primary">Restore source branch</a>+ </div>+ <div wicket:id="confirm" class="confirm"></div>+ </div>+ </div>+ <ul wicket:id="requestTabs" class="tabs nav nav-tabs"></ul>+ <wicket:child></wicket:child>+ </div>+ <wicket:fragment wicket:id="operationConfirmFrag">+ <form wicket:id="form" class="leave-confirm">+ <div wicket:id="hint" class="hint"></div>+ <div wicket:id="feedback"></div>+ <textarea wicket:id="note" class="form-control focusable" rows="5" placeholder="Leave a note"></textarea>+ <input wicket:id="submit" type="submit" value="Confirm" class="btn"></input>+ <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"></input>+ </form>+ </wicket:fragment>+ <wicket:fragment wicket:id="codeCommentsTabLinkFrag">+ <a wicket:id="link"><i class="fa fa-circle"></i> Code Comments</a>+ </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.htmlindex ed21905b4c..94f02aec44 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.html@@ -1,84 +1,84 @@-<wicket:extend>- <table class="overview">- <tr>- <td class="activities">- <table>- <tr wicket:id="requestActivities" class="activity">- <td wicket:id="avatar" class="avatar"><a wicket:id="avatar"></a></td>- <td class="spacer"></td>- <td wicket:id="content" class="content"></td>- </tr>- </table>- <div wicket:id="addComment" class="add-comment">- <form wicket:id="form" class="leave-confirm">- <div wicket:id="feedback"></div>- <textarea wicket:id="input" class="form-control" rows="5" placeholder="Leave a comment"></textarea>- <div class="actions">- <button wicket:id="comment" class="dirty-aware btn btn-primary">Comment</button>- </div>- </form>- </div>- </td>- <td class="info">- <div class="well">- <div wicket:id="assignee" class="assignee"></div>- <div wicket:id="reviewers" class="reviewers">- <label>Reviewers:</label>- <ul class="clearfix list-unstyled">- <li wicket:id="reviewers" class="pull-left">- <a wicket:id="avatar"></a>- <span wicket:id="result"></span>- </li>- </ul>- <wicket:enclosure child="addReviewer">- <div>- <input wicket:id="addReviewer" type="hidden"></input>- </div>- </wicket:enclosure>- </div>- <div wicket:id="integrationStrategy" class="integration-strategy">- <label>- Integration Strategy:- <span wicket:id="help" class="fa fa-question-circle pointer small"></span>- </label>- <div>- <select wicket:id="editor"></select>- <span wicket:id="viewer"></span>- </div>- </div>- <div wicket:id="watch" class="watch">- <div>- <label>Watch Status:</label>- <select wicket:id="option"></select>- </div>- <div class="help-block"><i class="fa fa-info-circle small"></i> <span wicket:id="help"></span></div>- </div>- <div wicket:id="manage" class="manage">- <a wicket:id="synchronize" class="check btn btn-default">Synchronize</a>- <p class="help-block"><i class="fa fa-info-circle"></i> In case the pull request status is out of sync with underlying- repository, you may synchronize them manually here</p>- <a wicket:id="delete" class="delete btn btn-danger">Delete</a>- </div>- </div>- </td>- </tr>- </table>- <wicket:fragment wicket:id="assigneeEditFrag">- <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>- <div>- <input wicket:id="assignee" type="hidden"></input>- </div>- </wicket:fragment>- <wicket:fragment wicket:id="assigneeViewFrag">- <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>- <span wicket:id="assignee" class="avatar"></span>- </wicket:fragment>- <wicket:fragment wicket:id="noAssigneeFrag">- This pull request will be integrated automatically as long as it passes gate keeper check.- </wicket:fragment>- <wicket:fragment wicket:id="sinceChangesRowContentFrag">- <div>- <span class="icon fa fa-ext fa-file-diff"></span> <a wicket:id="sinceChanges">Changes since last visit</a>- </div>- </wicket:fragment>+<wicket:extend>+ <table class="overview">+ <tr>+ <td class="activities">+ <table>+ <tr wicket:id="requestActivities" class="activity">+ <td wicket:id="avatar" class="avatar"><a wicket:id="avatar"></a></td>+ <td class="spacer"></td>+ <td wicket:id="content" class="content"></td>+ </tr>+ </table>+ <div wicket:id="addComment" class="add-comment">+ <form wicket:id="form" class="leave-confirm">+ <div wicket:id="feedback"></div>+ <textarea wicket:id="input" class="form-control" rows="5" placeholder="Leave a comment"></textarea>+ <div class="actions">+ <button wicket:id="comment" class="dirty-aware btn btn-primary">Comment</button>+ </div>+ </form>+ </div>+ </td>+ <td class="info">+ <div class="well">+ <div wicket:id="assignee" class="assignee"></div>+ <div wicket:id="reviewers" class="reviewers">+ <label>Reviewers:</label>+ <ul class="clearfix list-unstyled">+ <li wicket:id="reviewers" class="pull-left">+ <a wicket:id="avatar"></a>+ <span wicket:id="result"></span>+ </li>+ </ul>+ <wicket:enclosure child="addReviewer">+ <div>+ <input wicket:id="addReviewer" type="hidden"></input>+ </div>+ </wicket:enclosure>+ </div>+ <div wicket:id="integrationStrategy" class="integration-strategy">+ <label>+ Integration Strategy:+ <span wicket:id="help" class="fa fa-question-circle pointer small"></span>+ </label>+ <div>+ <select wicket:id="editor"></select>+ <span wicket:id="viewer"></span>+ </div>+ </div>+ <div wicket:id="watch" class="watch">+ <div>+ <label>Watch Status:</label>+ <select wicket:id="option"></select>+ </div>+ <div class="help-block"><i class="fa fa-info-circle small"></i> <span wicket:id="help"></span></div>+ </div>+ <div wicket:id="manage" class="manage">+ <a wicket:id="synchronize" class="check btn btn-default">Synchronize</a>+ <p class="help-block"><i class="fa fa-info-circle"></i> In case the pull request status is out of sync with underlying+ repository, you may synchronize them manually here</p>+ <a wicket:id="delete" class="delete btn btn-danger">Delete</a>+ </div>+ </div>+ </td>+ </tr>+ </table>+ <wicket:fragment wicket:id="assigneeEditFrag">+ <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>+ <div>+ <input wicket:id="assignee" type="hidden"></input>+ </div>+ </wicket:fragment>+ <wicket:fragment wicket:id="assigneeViewFrag">+ <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>+ <span wicket:id="assignee" class="avatar"></span>+ </wicket:fragment>+ <wicket:fragment wicket:id="noAssigneeFrag">+ This pull request will be integrated automatically as long as it passes gatekeeper check.+ </wicket:fragment>+ <wicket:fragment wicket:id="sinceChangesRowContentFrag">+ <div>+ <span class="icon fa fa-ext fa-file-diff"></span> <a wicket:id="sinceChanges">Changes since last visit</a>+ </div>+ </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.javaindex 01246c220f..63dffbca57 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java@@ -83,7 +83,7 @@ public class RequestOverviewPage extends RequestDetailPage {private static final String ASSIGNEE_HELP = "Assignee has write permission to the "+ "repository and is resonsible for integrating the pull request into "- + "target branch after it passes gate keeper check.";+ + "target branch after it passes gatekeeper check.";private enum WatchStatus {WATCHING("Watching"),diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.javaindex 4124a660f2..f782c0f7a0 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.java@@ -52,7 +52,7 @@ public abstract class DepotSettingPage extends DepotPage {*/tabs.add(new DepotSettingTab("Collaborators", "fa fa-fw fa-user", DepotCollaboratorListPage.class));}- tabs.add(new DepotSettingTab("Gate Keepers", "fa fa-fw fa-eye", GateKeeperPage.class));+ tabs.add(new DepotSettingTab("Gatekeepers", "fa fa-fw fa-eye", GateKeeperPage.class));tabs.add(new DepotSettingTab("Integration Policies", "fa fa-fw fa-puzzle-piece", IntegrationPolicyPage.class));add(new Tabbable("depotSettingTabs", tabs));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.cssindex 0bd14f8f87..989c4dbc6a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.css@@ -1,208 +1,207 @@-#depot-setting>table>tbody>tr>td.nav {- width: 200px;- border-right: 1px solid #DDD;- white-space: nowrap;- padding: 20px 0;-}-#depot-setting>table>tbody>tr>td.nav a {- display: block;- color: #666;- text-decoration: none;- padding: 6px 12px;- font-family: monospace;-}-#depot-setting>table>tbody>tr>td.nav li:hover a {- background: #F5F5F5;- color: #010203;-}-#depot-setting>table>tbody>tr>td.nav li.active a {- background: #E8E8E8;- color: #010203;- font-weight: bold;-}-#depot-setting>table>tbody>tr>td.content {- padding: 20px;-}-#depot-setting .general-setting form .delete {- margin-right: 0;-}--.integration-policy-setting .handle {- cursor: move;- margin-right: 8px;-}-.integration-policy-setting .panel-heading a {- color: #444;- margin-right: 8px;-}-.integration-policy-setting .add-new {- display: block;- padding: 16px;- background: #F2F2F2;- border: 1px solid #DDD;- border-radius: 4px;- font-size: 16px;- color: #444;- margin-bottom: 16px;-}-.integration-policy-setting a.add-new:hover {- text-decoration: none;- background-color: #EBEBEB;- border-color: #ADADAD;-}-.integration-policy-setting a.add-new .fa {- margin-left: 8px;-}--.gate-keeper-add.well {- font-size:16px;-}-.gate-keeper-add .fa {- margin-left: 8px;-}-.gate-keeper-add:hover, .gate-keeper-add:focus {- background-color: #EBEBEB;- border-color: #ADADAD;- cursor: pointer;-}-.gate-keeper-selector.floating {- border-radius: 0;-}-.gate-keeper-selector.floating>.content {- width: 600px;-}-.gate-keeper-selector .panel {- border: none;- border-radius: 0;-}-.gate-keeper-selector .panel-heading {- border-top: 1px solid #CCCCCC;- border-radius: 0;-}-.gate-keeper-selector .panel-group>.panel:first-child>.panel-heading {- border-top: none;-}-.gate-keeper-selector .panel-heading.collapsed:hover, .gate-keeper-selector .panel-heading.collapsed:focus {- border-color: #999999;- background-color: #E0E0E0;- cursor: pointer;-}-.gate-keeper-selector .panel-group .panel + .panel {- margin-top: 0px;-}-.gate-keeper-selector .fa {- width: 20px;-}-.gate-keeper-description {- font-size: 13px;- color: #888888;-}-.gate-keeper-item {- margin-bottom: 6px;- padding: 4px;- border: 1px solid white;-}-.gate-keeper-item:hover, .gate-keeper-item:focus {- background-color: #EBEBEB;- cursor: pointer;- border: 1px solid #ADADAD;- border-radius: 4px;-}-.gate-keeper-name {- font-size: 15px;- margin-top: -4px;-}-.gate-keeper-editor {- max-height: 600px;- overflow: auto;-}-.gate-keeper-editor .gate-keeper-name {- font-weight: bold;- font-size: 16px;- margin-top: 0;- margin-bottom: 4px;-}-.gate-keeper-editor .modal-header .fa {- width: 20px;- margin-right: 8px;- margin-top: 4px;-}-.gate-keeper-editor form>.feedback {- margin: 20px 16px -16px 16px;-}-.gate-keeper-editor form>.feedback .alert {- margin-bottom: 0;-}-.gate-keeper .panel-title {- font-size: 14px;-}-.gate-keeper .panel-heading {- padding: 8px;-}-.gate-keeper .fa {- margin-left: 8px;- cursor: pointer;-}-.gate-keeper .gate-keeper-add {- margin: 0px;- padding: 8px;- font-size: 14px;-}-.gate-keeper .reflection {- margin-bottom: 0;-}--.gate-keeper.panel {- border: 1px solid #BBBBBB;-}-.gate-keeper.panel>.panel-heading {- border-color: #BBBBBB;-}-.gate-keeper.panel.disabled, .gate-keeper.panel.disabled .panel {- color: #AAA;-}-.gate-keeper.panel.disabled>.panel-heading, .gate-keeper.panel.disabled .panel-heading {- color: #AAA;-}-.gate-keeper.panel.disabled .fa {- color: inherit;-}-.gate-keeper table.viewer {- font-size: 13px !important;- color: #444444;-}-.gate-keeper td.child {- padding-right: 12px;-}-.gate-keeper table.children>tbody>tr>td.child:last-child {- padding-right: 0;-}-.gate-keeper.panel .panel-body {- overflow:auto;-}-.gate-keeper td.ifthen.connector {- width:1px;-}-.gate-keeper td.ifthen.connector .fa {- margin: 0 6px 0 8px;- color: #666666;- font-size: 36px;-}--#depot-setting .authorization .list table td.actions {- width: 20%;- white-space: nowrap;-}-#depot-setting .authorization .list td.name .note {- font-size: 12px;- color: #888;- margin-top: 4px;-}-#depot-setting .authorization .list td.privilege {- width: 20%;-}--.modal .transfer-depot .message {- font-size: 13px;- margin-bottom: 20px;-}+#depot-setting>table>tbody>tr>td.nav {+ width: 200px;+ border-right: 1px solid #DDD;+ white-space: nowrap;+ padding: 20px 0;+}+#depot-setting>table>tbody>tr>td.nav a {+ display: block;+ color: #666;+ text-decoration: none;+ padding: 6px 12px;+ font-family: monospace;+}+#depot-setting>table>tbody>tr>td.nav li:hover a {+ background: #F5F5F5;+ color: #010203;+}+#depot-setting>table>tbody>tr>td.nav li.active a {+ background: #E8E8E8;+ color: #010203;+ font-weight: bold;+}+#depot-setting>table>tbody>tr>td.content {+ padding: 20px;+}+#depot-setting .general-setting form .delete {+ margin-right: 0;+}++.integration-policy-setting .handle {+ cursor: move;+ margin-right: 8px;+}+.integration-policy-setting .panel-heading a {+ color: #444;+ margin-right: 8px;+}+.integration-policy-setting .add-new {+ display: block;+ padding: 16px;+ background: #F2F2F2;+ border: 1px solid #DDD;+ border-radius: 4px;+ font-size: 16px;+ color: #444;+ margin-bottom: 16px;+}+.integration-policy-setting a.add-new:hover {+ text-decoration: none;+ background-color: #EBEBEB;+ border-color: #ADADAD;+}+.integration-policy-setting a.add-new .fa {+ margin-left: 8px;+}++.gate-keeper-add.well {+ font-size:16px;+}+.gate-keeper-add .fa {+ margin-left: 8px;+}+.gate-keeper-add:hover, .gate-keeper-add:focus {+ background-color: #EBEBEB;+ border-color: #ADADAD;+ cursor: pointer;+}+.gate-keeper-selector.floating {+ border-radius: 0;+}+.gate-keeper-selector.floating>.content {+ width: 600px;+}+.gate-keeper-selector .panel {+ border: none;+ border-radius: 0;+}+.gate-keeper-selector .panel-heading {+ border-top: 1px solid #CCCCCC;+ border-radius: 0;+}+.gate-keeper-selector .panel-group>.panel:first-child>.panel-heading {+ border-top: none;+}+.gate-keeper-selector .panel-heading.collapsed:hover, .gate-keeper-selector .panel-heading.collapsed:focus {+ border-color: #999999;+ background-color: #E0E0E0;+ cursor: pointer;+}+.gate-keeper-selector .panel-group .panel + .panel {+ margin-top: 0px;+}+.gate-keeper-selector .fa {+ width: 20px;+}+.gate-keeper-description {+ font-size: 13px;+ color: #888888;+}+.gate-keeper-item {+ margin-bottom: 6px;+ padding: 4px;+ border: 1px solid white;+}+.gate-keeper-item:hover, .gate-keeper-item:focus {+ background-color: #EBEBEB;+ cursor: pointer;+ border: 1px solid #ADADAD;+ border-radius: 4px;+}+.gate-keeper-name {+ font-size: 15px;+ margin-top: -4px;+}+.gate-keeper-editor {+ max-height: 600px;+ overflow: auto;+}+.gate-keeper-editor .gate-keeper-name {+ font-weight: bold;+ font-size: 16px;+ margin-top: 0;+ margin-bottom: 4px;+}+.gate-keeper-editor .modal-header .fa {+ width: 20px;+ margin-right: 8px;+ margin-top: 4px;+}+.gate-keeper-editor form>.feedback {+ margin: 20px 16px -16px 16px;+}+.gate-keeper-editor form>.feedback .alert {+ margin-bottom: 0;+}+.gate-keeper .panel-title {+ font-size: 14px;+}+.gate-keeper .panel-heading {+ padding: 8px;+}+.gate-keeper .fa {+ margin-left: 8px;+ cursor: pointer;+}+.gate-keeper .gate-keeper-add {+ margin: 0px;+ padding: 8px;+ font-size: 14px;+}+.gate-keeper .reflection {+ margin-bottom: 0;+}++.gate-keeper.panel {+ border: 1px solid #BBBBBB;+}++.gate-keeper.panel>.panel-heading {+ border-color: #BBBBBB;+}+.gate-keeper.panel.disabled, .gate-keeper.panel.disabled .panel {+ color: #AAA;+}+.gate-keeper.panel.disabled>.panel-heading, .gate-keeper.panel.disabled .panel-heading {+ color: #AAA;+}+.gate-keeper.panel.disabled .fa {+ color: inherit;+}+.gate-keeper table.viewer {+ font-size: 13px !important;+ color: #444444;+}+.gate-keeper td.child {+ padding-right: 12px;+}+.gate-keeper table.children>tbody>tr>td.child:last-child {+ padding-right: 0;+}+.gate-keeper.panel .panel-body {+ overflow:auto;+}+.gate-keeper.panel table.ifthen>tbody>tr.if>td {+ padding-bottom: 16px;+}+.gate-keeper.panel table.ifthen>tbody>tr>td>div>div.panel {+ margin-bottom: 0;+}++#depot-setting .authorization .list table td.actions {+ width: 20%;+ white-space: nowrap;+}+#depot-setting .authorization .list td.name .note {+ font-size: 12px;+ color: #888;+ margin-top: 4px;+}+#depot-setting .authorization .list td.privilege {+ width: 20%;+}++.modal .transfer-depot .message {+ font-size: 13px;+ margin-bottom: 20px;+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.htmlindex 06fca2755f..305fa8b8a9 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.html@@ -1,21 +1,9 @@-<wicket:extend>- <div class="gate-keeper-setting">- <div wicket:id="gateKeeperSetting">- <div wicket:id="gateKeepers">- <div wicket:id="gateKeeper"></div>- </div>- <div wicket:id="gateKeeperDropdownTrigger" class="well gate-keeper-add">Add Gate Keeper <i class="fa fa-lg fa-plus-circle"></i></div>- </div>- <div class="help-block">- <h5>Define gate keepers to determine whether or not to accept a pull request or push operation.- Gate keepers plays an important role in GitPlex, for instance, you may use it to:- </h5>- <ul>- <li>Control write access to certain branches or directories.</li>- <li>Require different user to approve different tree of the repository.</li>- <li>Have continuous integration system verifying the code before accepting- the pull request.</li>- </ul>- </div>- </div>+<wicket:extend>+ <div class="gate-keeper-setting">+ <div wicket:id="gateKeeper"></div>+ <div class="help-block">+ <i class="fa fa-info-circle"></i> Repository can only be modified if checking of defined gatekeeper is passed. Multiple gatekeepers can be+ combined together with various composite gatekeepers+ </div>+ </div></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.javaindex e320ef4402..cf8ba45e7b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.java@@ -1,112 +1,107 @@-package com.pmease.gitplex.web.page.depot.setting.gatekeeper;--import org.apache.wicket.Component;-import org.apache.wicket.ajax.AjaxRequestTarget;-import org.apache.wicket.markup.html.WebMarkupContainer;-import org.apache.wicket.markup.html.list.ListItem;-import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.request.mapper.parameter.PageParameters;--import com.pmease.commons.util.ReflectionUtils;-import com.pmease.commons.wicket.component.modal.ModalPanel;-import com.pmease.commons.wicket.editable.EditableUtils;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.core.gatekeeper.GateKeeper;-import com.pmease.gitplex.core.manager.DepotManager;-import com.pmease.gitplex.web.page.depot.setting.DepotSettingPage;--@SuppressWarnings("serial")-public class GateKeeperPage extends DepotSettingPage {-- private static final String CONTAINER_ID = "gateKeeperSetting";-- public GateKeeperPage(PageParameters params) {- super(params);- }-- private WebMarkupContainer newContent() {- WebMarkupContainer content = new WebMarkupContainer(CONTAINER_ID);- content.setOutputMarkupId(true);-- content.add(new ListView<GateKeeper>("gateKeepers", getDepot().getGateKeepers()) {-- @Override- protected void populateItem(final ListItem<GateKeeper> item) {- item.add(new GateKeeperPanel("gateKeeper", item.getModelObject()) {-- @Override- protected void onDelete(AjaxRequestTarget target) {- getDepot().getGateKeepers().remove(item.getIndex());- onGateKeeperChanged(target);- }-- @Override- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {- getDepot().getGateKeepers().set(item.getIndex(), gateKeeper);- onGateKeeperChanged(target);- }-- });- }-- });- content.add(new GateKeeperLink("gateKeeperDropdownTrigger") {-- @Override- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {- getDepot().getGateKeepers().add(gateKeeper);- onGateKeeperChanged(target);- } else {- new ModalPanel(target) {-- @Override- protected Component newContent(String id) {- return new GateKeeperEditor(id, gateKeeper) {-- @Override- protected void onCancel(AjaxRequestTarget target) {- close(target);- }-- @Override- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {- close(target);- getDepot().getGateKeepers().add(gateKeeper);- onGateKeeperChanged(target);- }-- };- }-- };- }- }-- });- content.add(new WebMarkupContainer("gateKeeperPanel").setVisible(false));- content.add(new WebMarkupContainer("gateKeeperModal").setOutputMarkupPlaceholderTag(true).setVisible(false));- return content;- }-- @Override- protected void onInitialize() {- super.onInitialize();-- add(newContent());- }-- private void onGateKeeperChanged(AjaxRequestTarget target) {- GitPlex.getInstance(DepotManager.class).save(getDepot(), null, null);- replace(newContent());- target.add(get(CONTAINER_ID));- }-- @Override- protected void onSelect(AjaxRequestTarget target, Depot depot) {- setResponsePage(GateKeeperPage.class, GateKeeperPage.paramsOf(depot));- }--}+package com.pmease.gitplex.web.page.depot.setting.gatekeeper;++import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.model.IModel;+import org.apache.wicket.model.Model;+import org.apache.wicket.request.mapper.parameter.PageParameters;++import com.pmease.commons.util.ReflectionUtils;+import com.pmease.commons.wicket.component.modal.ModalPanel;+import com.pmease.commons.wicket.editable.EditableUtils;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;+import com.pmease.gitplex.core.gatekeeper.GateKeeper;+import com.pmease.gitplex.core.manager.DepotManager;+import com.pmease.gitplex.web.page.depot.setting.DepotSettingPage;++@SuppressWarnings("serial")+public class GateKeeperPage extends DepotSettingPage {++ public GateKeeperPage(PageParameters params) {+ super(params);+ }++ private Component newContent() {+ if (getDepot().getGateKeeper() instanceof DefaultGateKeeper) {+ return new GateKeeperLink("gateKeeper") {++ @Override+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {+ getDepot().setGateKeeper(gateKeeper);+ onGateKeeperChanged(target);+ } else {+ new ModalPanel(target) {++ @Override+ protected Component newContent(String id) {+ return new GateKeeperEditor(id, gateKeeper) {++ @Override+ protected void onCancel(AjaxRequestTarget target) {+ close(target);+ }++ @Override+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {+ close(target);+ getDepot().setGateKeeper(gateKeeper);+ onGateKeeperChanged(target);+ }++ };+ }++ };+ }+ }++ @Override+ public IModel<?> getBody() {+ return Model.of("Define gatekeeper <i class='fa fa-plus-circle'></i>");+ }++ }.setOutputMarkupId(true).setEscapeModelStrings(false).add(AttributeAppender.append("class", "well gate-keeper-add"));+ } else {+ return new GateKeeperPanel("gateKeeper", getDepot().getGateKeeper()) {++ @Override+ protected void onDelete(AjaxRequestTarget target) {+ getDepot().setGateKeeper(new DefaultGateKeeper());+ onGateKeeperChanged(target);+ }++ @Override+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {+ getDepot().setGateKeeper(gateKeeper);+ onGateKeeperChanged(target);+ }++ }.setOutputMarkupId(true);+ }+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ add(newContent());+ }++ private void onGateKeeperChanged(AjaxRequestTarget target) {+ GitPlex.getInstance(DepotManager.class).save(getDepot(), null, null);+ Component content = newContent();+ replace(content);+ target.add(content);+ }++ @Override+ protected void onSelect(AjaxRequestTarget target, Depot depot) {+ setResponsePage(GateKeeperPage.class, GateKeeperPage.paramsOf(depot));+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.htmlindex 4aa7737550..645766881a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.html@@ -2,9 +2,10 @@<div wicket:id="container" class="gate-keeper panel panel-default "><div class="panel-heading"><span wicket:id="title" class="panel-title"></span>- <span wicket:id="edit" class="fa fa-pencil" title="Edit this gate keeper"></span>- <span wicket:id="delete" class="fa fa-trash" title="Delete this gate keeper"></span>+ <span wicket:id="edit" class="fa fa-pencil" title="Edit this gatekeeper"></span>+ <span wicket:id="delete" class="fa fa-trash" title="Delete this gatekeeper"></span><span wicket:id="enable" class="fa "></span>+ <span wicket:id="help" class="fa fa-question-circle"></span><div wicket:id="editor"></div></div><div class="panel-body">@@ -15,7 +16,7 @@<div wicket:id="children"><div wicket:id="child"></div></div>- <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add Child Gate Keeper<i class="fa fa-plus-circle"></i></div>+ <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add gatekeeper <i class="fa fa-plus-circle"></i></div></wicket:fragment><wicket:fragment wicket:id="orFrag"><table class="children">@@ -25,26 +26,27 @@</td></tr></table>- <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add Child Gate Keeper<i class="fa fa-plus-circle"></i></div>+ <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add gatekeeper <i class="fa fa-plus-circle"></i></div></wicket:fragment><wicket:fragment wicket:id="ifThenFrag"><table class="ifthen">- <tr>- <td class="ifthen if">- <div wicket:id="if"></div>- <div wicket:id="ifTypeSelectorTrigger" class="well gate-keeper-add">Define If Gate Keeper<i class="fa fa-plus-circle"></i></div>+ <tr class="if">+ <td>+ <label>If</label>+ <div wicket:id="ifGate"></div></td>- <td class="ifthen connector"><div class="fa fa-arrow-right"></div></td>- <td class="ifthen then">- <div wicket:id="then"></div>- <div wicket:id="thenTypeSelectorTrigger" class="well gate-keeper-add">Define Then Gate Keeper<i class="fa fa-plus-circle"></i></div>+ </tr>+ <tr class="then">+ <td>+ <label>Then check</label>+ <div wicket:id="thenGate"></div></td></tr></table></wicket:fragment><wicket:fragment wicket:id="notFrag"><div wicket:id="gateKeeper"></div>- <div wicket:id="gateKeeperTypeSelectorTrigger" class="well gate-keeper-add">Define Contained Condition<i class="fa fa-plus-circle"></i></div>+ <div wicket:id="gateKeeperTypeSelectorTrigger" class="well gate-keeper-add">Define gatekeeper <i class="fa fa-plus-circle"></i></div></wicket:fragment><wicket:fragment wicket:id="otherFrag"><div wicket:id="viewer"></div>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.javaindex a09422a368..40264ec746 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.java@@ -1,390 +1,396 @@-package com.pmease.gitplex.web.page.depot.setting.gatekeeper;--import org.apache.wicket.Component;-import org.apache.wicket.ajax.AjaxRequestTarget;-import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;-import org.apache.wicket.ajax.markup.html.AjaxLink;-import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.markup.ComponentTag;-import org.apache.wicket.markup.html.WebMarkupContainer;-import org.apache.wicket.markup.html.basic.Label;-import org.apache.wicket.markup.html.list.ListItem;-import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.html.panel.Panel;-import org.apache.wicket.model.Model;--import com.pmease.commons.util.ReflectionUtils;-import com.pmease.commons.wicket.ajaxlistener.ConfirmListener;-import com.pmease.commons.wicket.component.modal.ModalLink;-import com.pmease.commons.wicket.component.modal.ModalPanel;-import com.pmease.commons.wicket.editable.BeanContext;-import com.pmease.commons.wicket.editable.EditableUtils;-import com.pmease.gitplex.core.gatekeeper.AbstractGateKeeper;-import com.pmease.gitplex.core.gatekeeper.AndGateKeeper;-import com.pmease.gitplex.core.gatekeeper.AndOrGateKeeper;-import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;-import com.pmease.gitplex.core.gatekeeper.GateKeeper;-import com.pmease.gitplex.core.gatekeeper.IfThenGateKeeper;-import com.pmease.gitplex.core.gatekeeper.NotGateKeeper;--@SuppressWarnings("serial")-abstract class GateKeeperPanel extends Panel {-- private final GateKeeper gateKeeper;-- public GateKeeperPanel(String id, GateKeeper gateKeeper) {- super(id);- this.gateKeeper = gateKeeper;- }-- @Override- protected void onInitialize() {- super.onInitialize();-- final WebMarkupContainer container = new WebMarkupContainer("container");- add(container);-- if(!gateKeeper.isEnabled())- container.add(AttributeAppender.append("class", "disabled"));-- final Class<? extends GateKeeper> clazz = gateKeeper.getClass();- container.add(new Label("title", EditableUtils.getName(clazz)));- container.add(new ModalLink("edit") {-- @Override- protected void onConfigure() {- super.onConfigure();-- setVisible(EditableUtils.hasEditableProperties(clazz));- }-- @Override- protected Component newContent(String id) {- return new GateKeeperEditor(id, gateKeeper) {-- @Override- protected void onCancel(AjaxRequestTarget target) {- close(target);- }-- @Override- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {- close(target);- GateKeeperPanel.this.onChange(target, gateKeeper);- }-- };- }-- });-- container.add(new AjaxLink<Void>("delete") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmListener("Do you really want to delete this gate keeper?"));- }-- @Override- public void onClick(AjaxRequestTarget target) {- onDelete(target);- }-- });-- container.add(new AjaxLink<Void>("enable") {-- @Override- public void onClick(AjaxRequestTarget target) {- ((AbstractGateKeeper) gateKeeper).setEnabled(!gateKeeper.isEnabled());- onChange(target, gateKeeper);- }-- @Override- protected void onComponentTag(ComponentTag tag) {- super.onComponentTag(tag);- if (gateKeeper.isEnabled()) {- tag.append("class", "fa-check-square-o", " ");- } else {- tag.append("class", "fa-square-o", " ");- }- }-- }.add(AttributeAppender.append("title", Model.of(gateKeeper.isEnabled()?"Disable this gate keeper":"Enable this gate keeper"))));-- container.add(new WebMarkupContainer("editor").setOutputMarkupPlaceholderTag(true).setVisible(false));-- if (AndOrGateKeeper.class.isAssignableFrom(clazz)) {- final AndOrGateKeeper andOrGateKeeper = (AndOrGateKeeper) gateKeeper;- final Fragment fragment;- if (andOrGateKeeper instanceof AndGateKeeper)- fragment = new Fragment("content", "andFrag", GateKeeperPanel.this);- else- fragment = new Fragment("content", "orFrag", GateKeeperPanel.this);-- fragment.add(new ListView<GateKeeper>("children", andOrGateKeeper.getGateKeepers()) {-- @Override- protected void populateItem(final ListItem<GateKeeper> item) {- item.add(new GateKeeperPanel("child", item.getModelObject()) {-- @Override- protected void onDelete(AjaxRequestTarget target) {- andOrGateKeeper.getGateKeepers().remove(item.getIndex());- GateKeeperPanel.this.onChange(target, andOrGateKeeper);- }-- @Override- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {- andOrGateKeeper.getGateKeepers().set(item.getIndex(), gateKeeper);- GateKeeperPanel.this.onChange(target, andOrGateKeeper);- }-- });- }-- });- fragment.add(new GateKeeperLink("childTypeSelectorTrigger") {-- @Override- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {- andOrGateKeeper.getGateKeepers().add(gateKeeper);- GateKeeperPanel.this.onChange(target, andOrGateKeeper);- } else {- new ModalPanel(target) {-- @Override- protected Component newContent(String id) {- return new GateKeeperEditor(id, gateKeeper) {-- @Override- protected void onCancel(AjaxRequestTarget target) {- close(target);- }-- @Override- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {- close(target);- fragment.replace(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));- andOrGateKeeper.getGateKeepers().add(gateKeeper);- GateKeeperPanel.this.onChange(target, andOrGateKeeper);- }-- };- }-- };- }- }-- });-- fragment.add(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));- container.add(fragment);- } else if (clazz == NotGateKeeper.class) {- final NotGateKeeper notGateKeeper = (NotGateKeeper) gateKeeper;- final Fragment fragment = new Fragment("content", "notFrag", GateKeeperPanel.this);-- if (notGateKeeper.getGateKeeper() instanceof DefaultGateKeeper) {- fragment.add(new GateKeeperLink("gateKeeperTypeSelectorTrigger") {-- @Override- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {- notGateKeeper.setGateKeeper(gateKeeper);- GateKeeperPanel.this.onChange(target, notGateKeeper);- } else {- new ModalPanel(target) {-- @Override- protected Component newContent(String id) {- return new GateKeeperEditor(id, gateKeeper) {-- @Override- protected void onCancel(AjaxRequestTarget target) {- close(target);- }-- @Override- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {- close(target);- fragment.replace(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));- notGateKeeper.setGateKeeper(gateKeeper);- GateKeeperPanel.this.onChange(target, notGateKeeper);- }-- };- }-- };- }- }-- });-- fragment.add(new WebMarkupContainer("gateKeeper").setVisible(false));- fragment.add(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));- } else {- fragment.add(new GateKeeperPanel("gateKeeper", notGateKeeper.getGateKeeper()) {-- @Override- protected void onDelete(AjaxRequestTarget target) {- notGateKeeper.setGateKeeper(new DefaultGateKeeper());- GateKeeperPanel.this.onChange(target, notGateKeeper);- }-- @Override- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {- notGateKeeper.setGateKeeper(gateKeeper);- GateKeeperPanel.this.onChange(target, notGateKeeper);- }-- });- fragment.add(new WebMarkupContainer("gateKeeperTypeSelectorTrigger").setVisible(false));- fragment.add(new WebMarkupContainer("gateKeeperTypeSelector").setVisible(false));- fragment.add(new WebMarkupContainer("gateKeeperEditor").setVisible(false));- }- container.add(fragment);- } else if (clazz == IfThenGateKeeper.class) {- final IfThenGateKeeper ifThenGateKeeper = (IfThenGateKeeper) gateKeeper;- final Fragment fragment = new Fragment("content", "ifThenFrag", GateKeeperPanel.this);-- if (ifThenGateKeeper.getIfGate() instanceof DefaultGateKeeper) {- fragment.add(new GateKeeperLink("ifTypeSelectorTrigger") {-- @Override- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {- ifThenGateKeeper.setIfGate(gateKeeper);- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- } else {- new ModalPanel(target) {-- @Override- protected Component newContent(String id) {- return new GateKeeperEditor(id, gateKeeper) {-- @Override- protected void onCancel(AjaxRequestTarget target) {- close(target);- }-- @Override- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {- close(target);- fragment.replace(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));- ifThenGateKeeper.setIfGate(gateKeeper);- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- }-- };- }-- };- }- }-- });- fragment.add(new WebMarkupContainer("if").setVisible(false));- fragment.add(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));- } else {- fragment.add(new GateKeeperPanel("if", ifThenGateKeeper.getIfGate()) {-- @Override- protected void onDelete(AjaxRequestTarget target) {- ifThenGateKeeper.setIfGate(new DefaultGateKeeper());- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- }-- @Override- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {- ifThenGateKeeper.setIfGate(gateKeeper);- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- }-- });- fragment.add(new WebMarkupContainer("ifTypeSelectorTrigger").setVisible(false));- fragment.add(new WebMarkupContainer("ifTypeSelector").setVisible(false));- fragment.add(new WebMarkupContainer("ifEditor").setVisible(false));- }-- if (ifThenGateKeeper.getThenGate() instanceof DefaultGateKeeper) {- fragment.add(new GateKeeperLink("thenTypeSelectorTrigger") {-- @Override- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {- ifThenGateKeeper.setThenGate(gateKeeper);- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- } else {- new ModalPanel(target) {-- @Override- protected Component newContent(String id) {- return new GateKeeperEditor(id, gateKeeper) {-- @Override- protected void onCancel(AjaxRequestTarget target) {- close(target);- }-- @Override- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {- close(target);- fragment.replace(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));- ifThenGateKeeper.setThenGate(gateKeeper);- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- }-- };- }-- };- }- }-- });-- fragment.add(new WebMarkupContainer("then").setVisible(false));- fragment.add(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));- } else {- fragment.add(new GateKeeperPanel("then", ifThenGateKeeper.getThenGate()) {-- @Override- protected void onDelete(AjaxRequestTarget target) {- ifThenGateKeeper.setThenGate(new DefaultGateKeeper());- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- }-- @Override- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {- ifThenGateKeeper.setThenGate(gateKeeper);- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);- }-- });- fragment.add(new WebMarkupContainer("thenTypeSelectorTrigger").setVisible(false));- fragment.add(new WebMarkupContainer("thenTypeSelector").setVisible(false));- fragment.add(new WebMarkupContainer("thenEditor").setVisible(false));- }-- container.add(fragment);- } else {- Fragment fragment = new Fragment("content", "otherFrag", GateKeeperPanel.this);- fragment.add(BeanContext.viewBean("viewer", gateKeeper));- container.add(fragment);- }- }-- protected abstract void onDelete(AjaxRequestTarget target);-- protected abstract void onChange(AjaxRequestTarget target, GateKeeper gateKeeper);--}+package com.pmease.gitplex.web.page.depot.setting.gatekeeper;++import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;+import org.apache.wicket.ajax.markup.html.AjaxLink;+import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.markup.ComponentTag;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.ListView;+import org.apache.wicket.markup.html.panel.Fragment;+import org.apache.wicket.markup.html.panel.Panel;+import org.apache.wicket.model.IModel;+import org.apache.wicket.model.Model;++import com.pmease.commons.util.ReflectionUtils;+import com.pmease.commons.wicket.ajaxlistener.ConfirmListener;+import com.pmease.commons.wicket.component.modal.ModalLink;+import com.pmease.commons.wicket.component.modal.ModalPanel;+import com.pmease.commons.wicket.editable.BeanContext;+import com.pmease.commons.wicket.editable.EditableUtils;+import com.pmease.gitplex.core.gatekeeper.AbstractGateKeeper;+import com.pmease.gitplex.core.gatekeeper.AndGateKeeper;+import com.pmease.gitplex.core.gatekeeper.AndOrGateKeeper;+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;+import com.pmease.gitplex.core.gatekeeper.GateKeeper;+import com.pmease.gitplex.core.gatekeeper.ConditionalGateKeeper;+import com.pmease.gitplex.core.gatekeeper.NotGateKeeper;++import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior;++@SuppressWarnings("serial")+abstract class GateKeeperPanel extends Panel {++ private final GateKeeper gateKeeper;++ public GateKeeperPanel(String id, GateKeeper gateKeeper) {+ super(id);+ this.gateKeeper = gateKeeper;+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ final WebMarkupContainer container = new WebMarkupContainer("container");+ add(container);++ if(!gateKeeper.isEnabled())+ container.add(AttributeAppender.append("class", "disabled"));++ final Class<? extends GateKeeper> clazz = gateKeeper.getClass();+ container.add(new Label("title", EditableUtils.getName(clazz)));+ container.add(new ModalLink("edit") {++ @Override+ protected void onConfigure() {+ super.onConfigure();++ setVisible(EditableUtils.hasEditableProperties(clazz));+ }++ @Override+ protected Component newContent(String id) {+ return new GateKeeperEditor(id, gateKeeper) {++ @Override+ protected void onCancel(AjaxRequestTarget target) {+ close(target);+ }++ @Override+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {+ close(target);+ GateKeeperPanel.this.onChange(target, gateKeeper);+ }++ };+ }++ });++ container.add(new AjaxLink<Void>("delete") {++ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new ConfirmListener("Do you really want to delete this gatekeeper?"));+ }++ @Override+ public void onClick(AjaxRequestTarget target) {+ onDelete(target);+ }++ });++ container.add(new AjaxLink<Void>("enable") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ ((AbstractGateKeeper) gateKeeper).setEnabled(!gateKeeper.isEnabled());+ onChange(target, gateKeeper);+ }++ @Override+ protected void onComponentTag(ComponentTag tag) {+ super.onComponentTag(tag);+ if (gateKeeper.isEnabled()) {+ tag.append("class", "fa-check-square-o", " ");+ } else {+ tag.append("class", "fa-square-o", " ");+ }+ }++ }.add(AttributeAppender.append("title", Model.of(gateKeeper.isEnabled()?"Disable this gatekeeper":"Enable this gatekeeper"))));++ container.add(new WebMarkupContainer("help").add(new TooltipBehavior(Model.of(EditableUtils.getDescription(gateKeeper.getClass())))));++ container.add(new WebMarkupContainer("editor").setOutputMarkupPlaceholderTag(true).setVisible(false));++ if (AndOrGateKeeper.class.isAssignableFrom(clazz)) {+ final AndOrGateKeeper andOrGateKeeper = (AndOrGateKeeper) gateKeeper;+ final Fragment fragment;+ if (andOrGateKeeper instanceof AndGateKeeper)+ fragment = new Fragment("content", "andFrag", GateKeeperPanel.this);+ else+ fragment = new Fragment("content", "orFrag", GateKeeperPanel.this);++ fragment.add(new ListView<GateKeeper>("children", andOrGateKeeper.getGateKeepers()) {++ @Override+ protected void populateItem(final ListItem<GateKeeper> item) {+ item.add(new GateKeeperPanel("child", item.getModelObject()) {++ @Override+ protected void onDelete(AjaxRequestTarget target) {+ andOrGateKeeper.getGateKeepers().remove(item.getIndex());+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);+ }++ @Override+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {+ andOrGateKeeper.getGateKeepers().set(item.getIndex(), gateKeeper);+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);+ }++ });+ }++ });+ fragment.add(new GateKeeperLink("childTypeSelectorTrigger") {++ @Override+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {+ andOrGateKeeper.getGateKeepers().add(gateKeeper);+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);+ } else {+ new ModalPanel(target) {++ @Override+ protected Component newContent(String id) {+ return new GateKeeperEditor(id, gateKeeper) {++ @Override+ protected void onCancel(AjaxRequestTarget target) {+ close(target);+ }++ @Override+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {+ close(target);+ fragment.replace(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));+ andOrGateKeeper.getGateKeepers().add(gateKeeper);+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);+ }++ };+ }++ };+ }+ }++ });++ fragment.add(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));+ container.add(fragment);+ } else if (clazz == NotGateKeeper.class) {+ final NotGateKeeper notGateKeeper = (NotGateKeeper) gateKeeper;+ final Fragment fragment = new Fragment("content", "notFrag", GateKeeperPanel.this);++ if (notGateKeeper.getGateKeeper() instanceof DefaultGateKeeper) {+ fragment.add(new GateKeeperLink("gateKeeperTypeSelectorTrigger") {++ @Override+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {+ notGateKeeper.setGateKeeper(gateKeeper);+ GateKeeperPanel.this.onChange(target, notGateKeeper);+ } else {+ new ModalPanel(target) {++ @Override+ protected Component newContent(String id) {+ return new GateKeeperEditor(id, gateKeeper) {++ @Override+ protected void onCancel(AjaxRequestTarget target) {+ close(target);+ }++ @Override+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {+ close(target);+ fragment.replace(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));+ notGateKeeper.setGateKeeper(gateKeeper);+ GateKeeperPanel.this.onChange(target, notGateKeeper);+ }++ };+ }++ };+ }+ }++ });++ fragment.add(new WebMarkupContainer("gateKeeper").setVisible(false));+ fragment.add(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));+ } else {+ fragment.add(new GateKeeperPanel("gateKeeper", notGateKeeper.getGateKeeper()) {++ @Override+ protected void onDelete(AjaxRequestTarget target) {+ notGateKeeper.setGateKeeper(new DefaultGateKeeper());+ GateKeeperPanel.this.onChange(target, notGateKeeper);+ }++ @Override+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {+ notGateKeeper.setGateKeeper(gateKeeper);+ GateKeeperPanel.this.onChange(target, notGateKeeper);+ }++ });+ fragment.add(new WebMarkupContainer("gateKeeperTypeSelectorTrigger").setVisible(false));+ fragment.add(new WebMarkupContainer("gateKeeperTypeSelector").setVisible(false));+ fragment.add(new WebMarkupContainer("gateKeeperEditor").setVisible(false));+ }+ container.add(fragment);+ } else if (clazz == ConditionalGateKeeper.class) {+ final ConditionalGateKeeper ifThenGateKeeper = (ConditionalGateKeeper) gateKeeper;+ final Fragment fragment = new Fragment("content", "ifThenFrag", GateKeeperPanel.this);++ if (ifThenGateKeeper.getIfGate() instanceof DefaultGateKeeper) {+ fragment.add(new GateKeeperLink("ifGate") {++ @Override+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {+ ifThenGateKeeper.setIfGate(gateKeeper);+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ } else {+ new ModalPanel(target) {++ @Override+ protected Component newContent(String id) {+ return new GateKeeperEditor(id, gateKeeper) {++ @Override+ protected void onCancel(AjaxRequestTarget target) {+ close(target);+ }++ @Override+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {+ close(target);+ fragment.replace(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));+ ifThenGateKeeper.setIfGate(gateKeeper);+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ }++ };+ }++ };+ }+ }++ @Override+ public IModel<?> getBody() {+ return Model.of("Define gatekeeper <i class='fa fa-plus-circle'></i>");+ }++ }.setEscapeModelStrings(false).add(AttributeAppender.append("class", "well gate-keeper-add")));+ } else {+ fragment.add(new GateKeeperPanel("ifGate", ifThenGateKeeper.getIfGate()) {++ @Override+ protected void onDelete(AjaxRequestTarget target) {+ ifThenGateKeeper.setIfGate(new DefaultGateKeeper());+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ }++ @Override+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {+ ifThenGateKeeper.setIfGate(gateKeeper);+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ }++ });+ }+ fragment.add(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));++ if (ifThenGateKeeper.getThenGate() instanceof DefaultGateKeeper) {+ fragment.add(new GateKeeperLink("thenGate") {++ @Override+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {+ ifThenGateKeeper.setThenGate(gateKeeper);+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ } else {+ new ModalPanel(target) {++ @Override+ protected Component newContent(String id) {+ return new GateKeeperEditor(id, gateKeeper) {++ @Override+ protected void onCancel(AjaxRequestTarget target) {+ close(target);+ }++ @Override+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {+ close(target);+ fragment.replace(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));+ ifThenGateKeeper.setThenGate(gateKeeper);+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ }++ };+ }++ };+ }+ }++ @Override+ public IModel<?> getBody() {+ return Model.of("Define gatekeeper <i class='fa fa-plus-circle'></i>");+ }++ }.setEscapeModelStrings(false).add(AttributeAppender.append("class", "well gate-keeper-add")));+ } else {+ fragment.add(new GateKeeperPanel("thenGate", ifThenGateKeeper.getThenGate()) {++ @Override+ protected void onDelete(AjaxRequestTarget target) {+ ifThenGateKeeper.setThenGate(new DefaultGateKeeper());+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ }++ @Override+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {+ ifThenGateKeeper.setThenGate(gateKeeper);+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);+ }++ });+ }+ fragment.add(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));++ container.add(fragment);+ } else {+ Fragment fragment = new Fragment("content", "otherFrag", GateKeeperPanel.this);+ fragment.add(BeanContext.viewBean("viewer", gateKeeper));+ container.add(fragment);+ }+ }++ protected abstract void onDelete(AjaxRequestTarget target);++ protected abstract void onChange(AjaxRequestTarget target, GateKeeper gateKeeper);++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.htmlindex 21b55a4476..a54cd8e2a1 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.html@@ -1,37 +1,37 @@-<wicket:extend>- <div class="general-setting">- <form wicket:id="form" class="leave-confirm">- <div wicket:id="editor"></div>- <div class="actions">- <input class="btn btn-primary dirty-aware" value="Update" type="submit"></input>- <a wicket:id="delete" class="delete btn btn-danger pull-right">Delete</a>- <a wicket:id="transfer" class="transfer btn btn-danger pull-right">Transfer</a>- </div>- </form>- </div>- <wicket:fragment wicket:id="transferFrag">- <div class="transfer-depot">- <!-- Add form tag so that the default delete button can be triggered when user hits return -->- <form wicket:id="form">- <div class="modal-header">- <h4 id="modal-title" class="modal-title">- Transfer repository to another account- </h4>- </div>- <div class="modal-body">- <div class="message">You can only transfer repository to accounts you have administrative- rights on. Also note that original team references in repository- authorization and gate keeper definition will be removed after transferring as teams are local to account.</div>- <div class="form-group">- <input wicket:id="account" type="hidden" class="form-control" placeholder="Select destination account..."></input>- <div wicket:id="feedback"></div>- </div>- </div>- <div class="modal-footer">- <input wicket:id="transfer" type="submit" class="btn btn-danger dirty-aware" value="Transfer"></input>- <a wicket:id="cancel" class="btn btn-default">Cancel</a>- </div>- </form>- </div>- </wicket:fragment>+<wicket:extend>+ <div class="general-setting">+ <form wicket:id="form" class="leave-confirm">+ <div wicket:id="editor"></div>+ <div class="actions">+ <input class="btn btn-primary dirty-aware" value="Update" type="submit"></input>+ <a wicket:id="delete" class="delete btn btn-danger pull-right">Delete</a>+ <a wicket:id="transfer" class="transfer btn btn-danger pull-right">Transfer</a>+ </div>+ </form>+ </div>+ <wicket:fragment wicket:id="transferFrag">+ <div class="transfer-depot">+ <!-- Add form tag so that the default delete button can be triggered when user hits return -->+ <form wicket:id="form">+ <div class="modal-header">+ <h4 id="modal-title" class="modal-title">+ Transfer repository to another account+ </h4>+ </div>+ <div class="modal-body">+ <div class="message">You can only transfer repository to accounts you have administrative+ rights on. Also note that original team references in repository+ authorization and gatekeeper definition will be removed after transferring as teams are local to account.</div>+ <div class="form-group">+ <input wicket:id="account" type="hidden" class="form-control" placeholder="Select destination account..."></input>+ <div wicket:id="feedback"></div>+ </div>+ </div>+ <div class="modal-footer">+ <input wicket:id="transfer" type="submit" class="btn btn-danger dirty-aware" value="Transfer"></input>+ <a wicket:id="cancel" class="btn btn-default">Cancel</a>+ </div>+ </form>+ </div>+ </wicket:fragment></wicket:extend>\ No newline at end of file