Skip to content

The Unified and Autonomous Development Platform

Merge with head commit

steve7250801a9003
diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.java b/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.java
index 3aee7477cf..107855da59 100644
--- a/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.java
+++ b/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.java
@@ -108,7 +108,7 @@ public class EditableUtils {
* @param element
* annotated element to get order from
* @return
- * defined order, or {@link Integer.MAX_VALUE} if Editable annotation is not found
+ * defined order, or {@link Integer#MAX_VALUE} if Editable annotation is not found
*/
public static int getOrder(AnnotatedElement element) {
Editable editable = element.getAnnotation(Editable.class);
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/AddCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/AddCommand.java
index 1c67c3a035..a5a1f0777b 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/AddCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/AddCommand.java
@@ -37,6 +37,8 @@ public class AddCommand extends GitCommand<Void> {
warn(line.substring("warning: ".length()));
else if (line.startsWith("The file will have its original line endings"))
warn(line);
+ else if (line.startsWith("The file will have its original line endings in your working directory"))
+ warn(line);
else
error(line);
}
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/AddSubModuleCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/AddSubModuleCommand.java
index 605a32d639..265da9dc2a 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/AddSubModuleCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/AddSubModuleCommand.java
@@ -4,6 +4,7 @@ import java.io.File;
import com.google.common.base.Preconditions;
import com.pmease.commons.util.execution.Commandline;
+import com.pmease.commons.util.execution.LineConsumer;
public class AddSubModuleCommand extends GitCommand<Void> {
@@ -31,7 +32,25 @@ public class AddSubModuleCommand extends GitCommand<Void> {
Preconditions.checkNotNull(path, "path should be specified.");
Commandline cmd = cmd().addArgs("submodule", "add", url, path);
- cmd.execute(debugLogger, errorLogger).checkReturnCode();
+ cmd.execute(debugLogger, new LineConsumer() {
+
+ @Override
+ public void consume(String line) {
+ if (line.startsWith("warning: "))
+ warn(line.substring("warning: ".length()));
+ else if (line.startsWith("The file will have its original line endings"))
+ warn(line);
+ else if (line.startsWith("The file will have its original line endings in your working directory"))
+ warn(line);
+ else if (line.startsWith("Cloning into"))
+ info(line);
+ else if (line.equals("done."))
+ info(line);
+ else
+ error(line);
+ }
+
+ }).checkReturnCode();
return null;
}
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/CheckoutCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/CheckoutCommand.java
index 470decd2f4..ec5d0b7d8c 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/CheckoutCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/CheckoutCommand.java
@@ -50,6 +50,8 @@ public class CheckoutCommand extends GitCommand<Void> {
public void consume(String line) {
if (line.startsWith("Switched to a new branch"))
info(line);
+ else if (line.startsWith("Switched to branch"))
+ info(line);
else
error(line);
}
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java
index 4f6388396c..89bcb3b0b3 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/CommitCommand.java
@@ -53,6 +53,8 @@ public class CommitCommand extends GitCommand<Void> {
warn(line.substring("warning: ".length()));
else if (line.startsWith("The file will have its original line endings"))
warn(line);
+ else if (line.startsWith("The file will have its original line endings in your working directory"))
+ warn(line);
else
error(line);
}
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/DiffCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/DiffCommand.java
index b578253606..eb5a80c044 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/DiffCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/DiffCommand.java
@@ -111,7 +111,21 @@ public class DiffCommand extends GitCommand<List<FileChangeWithDiffs>> {
}
- }, errorLogger).checkReturnCode();
+ }, new LineConsumer() {
+
+ @Override
+ public void consume(String line) {
+ if (line.startsWith("warning: "))
+ warn(line.substring("warning: ".length()));
+ else if (line.startsWith("The file will have its original line endings"))
+ warn(line);
+ else if (line.startsWith("The file will have its original line endings in your working directory"))
+ warn(line);
+ else
+ error(line);
+ }
+
+ }).checkReturnCode();
if (changeBuilder.newPath != null)
fileChanges.add(changeBuilder.buildFileChange());
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/FetchCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/FetchCommand.java
index 6dfa082ce0..20b6b63c7f 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/FetchCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/FetchCommand.java
@@ -39,7 +39,9 @@ public class FetchCommand extends GitCommand<Void> {
@Override
public void consume(String line) {
if (line.startsWith("From ") || line.startsWith(" * branch"))
- debug(line);
+ info(line);
+ else if (line.startsWith(" * [new ref]"))
+ info(line);
else
error(line);
}
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/PushCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/PushCommand.java
index 8b8b07b484..e16ef71099 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/PushCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/PushCommand.java
@@ -4,6 +4,7 @@ import java.io.File;
import com.google.common.base.Preconditions;
import com.pmease.commons.util.execution.Commandline;
+import com.pmease.commons.util.execution.LineConsumer;
public class PushCommand extends GitCommand<Void> {
@@ -33,7 +34,19 @@ public class PushCommand extends GitCommand<Void> {
Commandline cmd = cmd().addArgs("push");
cmd.addArgs(to, refspec);
- cmd.execute(debugLogger, errorLogger).checkReturnCode();
+ cmd.execute(debugLogger, new LineConsumer() {
+
+ @Override
+ public void consume(String line) {
+ if (line.startsWith("To "))
+ info(line);
+ else if (line.startsWith(" * [new branch]"))
+ info(line);
+ else
+ error(line);
+ }
+
+ }).checkReturnCode();
return null;
}
diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/UpdateRefCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/UpdateRefCommand.java
index a0099d188f..998744bd56 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/command/UpdateRefCommand.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/command/UpdateRefCommand.java
@@ -58,7 +58,11 @@ public class UpdateRefCommand extends GitCommand<Boolean> {
@Override
public void consume(String line) {
- error(line);
+ if (line.startsWith(" * [new ref]"))
+ info(line);
+ else
+ error(line);
+
if (line.startsWith("fatal: Cannot lock the ref"))
refLockError[0] = true;
}
diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.java
index ab330b6ed6..9b071f163e 100644
--- a/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.java
+++ b/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.java
@@ -62,7 +62,7 @@ public class LogCommandTest extends AbstractGitTest {
List<Commit> commits = bareGit.log(null, "master", null, 0, 0);
assertEquals(commits.size(), 6);
assertEquals(commits.get(0).getSubject(), "add dir/file");
- assertEquals(commits.get(0).getMessage(), "add dir/file\n\nadd dir/file to test files under a directory");
+ assertEquals(commits.get(0).getMessage(), "add dir/file\nadd dir/file to test files under a directory");
assertEquals("hello\nworld", commits.get(0).getNote());
assertEquals(commits.get(0).getFileChanges().size(), 2);
assertEquals(commits.get(0).getFileChanges().get(0).getNewPath(), "dir/file");
diff --git a/commons.jersey/pom.xml b/commons.jersey/pom.xml
index 3baeefe7f3..d245a27adc 100644
--- a/commons.jersey/pom.xml
+++ b/commons.jersey/pom.xml
@@ -89,6 +89,5 @@
</repositories>
<properties>
<moduleClass>com.pmease.commons.jersey.JerseyModule</moduleClass>
- <jerseyVersion>1.17</jerseyVersion>
</properties>
</project>
diff --git a/commons.wicket/pom.xml b/commons.wicket/pom.xml
index 6031be713b..a7cca81594 100644
--- a/commons.wicket/pom.xml
+++ b/commons.wicket/pom.xml
@@ -87,7 +87,7 @@
</dependencies>
<properties>
<moduleClass>com.pmease.commons.wicket.WicketModule</moduleClass>
- <wicketVersion>6.13.0</wicketVersion>
+ <wicketVersion>6.14.0</wicketVersion>
</properties>
<repositories>
<repository>
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByBranchCreator.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByBranchCreator.java
index 2d0b048e32..8b4d0a5bc7 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByBranchCreator.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByBranchCreator.java
@@ -2,11 +2,9 @@ package com.pmease.gitop.core.gatekeeper;
import com.google.common.collect.Sets;
import com.pmease.commons.editable.annotation.Editable;
-import com.pmease.gitop.core.Gitop;
-import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.Branch;
-import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.PullRequest;
+import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.User;
import com.pmease.gitop.model.Vote;
import com.pmease.gitop.model.gatekeeper.ApprovalGateKeeper;
@@ -29,7 +27,7 @@ public class IfApprovedByBranchCreator extends ApprovalGateKeeper {
Vote.Result result = branchCreator.checkVoteSince(request.getBaseUpdate());
if (result == null) {
- Gitop.getInstance(VoteInvitationManager.class).inviteToVote(request, Sets.newHashSet(branchCreator), 1);
+ request.inviteToVote(Sets.newHashSet(branchCreator), 1);
return pending("To be approved by user '" + branchCreator.getName() + "'.",
new CanVoteBySpecifiedUser(branchCreator));
} else if (result == Vote.Result.APPROVE) {
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectOwner.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectOwner.java
index ad1a90a6ac..d4b449a392 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectOwner.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectOwner.java
@@ -2,11 +2,9 @@ package com.pmease.gitop.core.gatekeeper;
import com.google.common.collect.Sets;
import com.pmease.commons.editable.annotation.Editable;
-import com.pmease.gitop.core.Gitop;
-import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.Branch;
-import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.PullRequest;
+import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.User;
import com.pmease.gitop.model.Vote;
import com.pmease.gitop.model.gatekeeper.ApprovalGateKeeper;
@@ -28,7 +26,7 @@ public class IfApprovedByProjectOwner extends ApprovalGateKeeper {
Vote.Result result = projectOwner.checkVoteSince(request.getBaseUpdate());
if (result == null) {
- Gitop.getInstance(VoteInvitationManager.class).inviteToVote(request, Sets.newHashSet(projectOwner), 1);
+ request.inviteToVote(Sets.newHashSet(projectOwner), 1);
return pending("To be approved by user '" + projectOwner.getName() + "'.",
new CanVoteBySpecifiedUser(projectOwner));
} else if (result == Vote.Result.APPROVE) {
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectWriters.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectWriters.java
index d888698934..8455561ae2 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectWriters.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedByProjectWriters.java
@@ -7,10 +7,9 @@ import javax.validation.constraints.Min;
import com.pmease.commons.editable.annotation.Editable;
import com.pmease.gitop.core.Gitop;
import com.pmease.gitop.core.manager.AuthorizationManager;
-import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.Branch;
-import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.PullRequest;
+import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.User;
import com.pmease.gitop.model.Vote;
import com.pmease.gitop.model.gatekeeper.ApprovalGateKeeper;
@@ -64,7 +63,7 @@ public class IfApprovedByProjectWriters extends ApprovalGateKeeper {
} else {
int lackApprovals = getLeastApprovals() - approvals;
- Gitop.getInstance(VoteInvitationManager.class).inviteToVote(request, authorizedUsers, lackApprovals);
+ request.inviteToVote(authorizedUsers, lackApprovals);
return pending("To be approved by " + lackApprovals + " authorized user(s).",
new CanVoteByAuthorizedUser());
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedTeam.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedTeam.java
index 2d921c4989..1b3af666f9 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedTeam.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedTeam.java
@@ -6,12 +6,10 @@ import java.util.HashSet;
import javax.validation.constraints.Min;
import com.pmease.commons.editable.annotation.Editable;
-import com.pmease.gitop.core.Gitop;
-import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.Branch;
import com.pmease.gitop.model.Membership;
-import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.PullRequest;
+import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.User;
import com.pmease.gitop.model.Vote;
import com.pmease.gitop.model.gatekeeper.checkresult.CheckResult;
@@ -64,7 +62,7 @@ public class IfApprovedBySpecifiedTeam extends TeamAwareGateKeeper {
} else {
int lackApprovals = getLeastApprovals() - approvals;
- Gitop.getInstance(VoteInvitationManager.class).inviteToVote(request, members, lackApprovals);
+ request.inviteToVote(members, lackApprovals);
return pending("To be approved by " + lackApprovals + " user(s) from team '"
+ getTeam().getName() + "'.", new CanVoteBySpecifiedTeam(getTeam()));
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedUser.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedUser.java
index 3779032bb3..cab93f67a0 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedUser.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfApprovedBySpecifiedUser.java
@@ -7,10 +7,9 @@ import com.pmease.commons.editable.annotation.Editable;
import com.pmease.gitop.core.Gitop;
import com.pmease.gitop.core.editable.UserChoice;
import com.pmease.gitop.core.manager.UserManager;
-import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.Branch;
-import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.PullRequest;
+import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.User;
import com.pmease.gitop.model.Vote;
import com.pmease.gitop.model.gatekeeper.ApprovalGateKeeper;
@@ -46,7 +45,7 @@ public class IfApprovedBySpecifiedUser extends ApprovalGateKeeper {
Vote.Result result = user.checkVoteSince(request.getBaseUpdate());
if (result == null) {
- Gitop.getInstance(VoteInvitationManager.class).inviteToVote(request, Sets.newHashSet(user), 1);
+ request.inviteToVote(Sets.newHashSet(user), 1);
return pending("To be approved by user '" + user.getName() + "'.",
new CanVoteBySpecifiedUser(user));
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfGetMinScoreFromSpecifiedTeam.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfGetMinScoreFromSpecifiedTeam.java
index 1c34282e69..44dc7ba359 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfGetMinScoreFromSpecifiedTeam.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/IfGetMinScoreFromSpecifiedTeam.java
@@ -6,12 +6,10 @@ import java.util.HashSet;
import javax.validation.constraints.Min;
import com.pmease.commons.editable.annotation.Editable;
-import com.pmease.gitop.core.Gitop;
-import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.Branch;
import com.pmease.gitop.model.Membership;
-import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.PullRequest;
+import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.User;
import com.pmease.gitop.model.Vote;
import com.pmease.gitop.model.gatekeeper.checkresult.CheckResult;
@@ -80,7 +78,7 @@ public class IfGetMinScoreFromSpecifiedTeam extends TeamAwareGateKeeper {
} else if (lackApprovals < 0) {
return disapproved("Can not get min score " + getMinScore() + " from team '" + getTeam().getName() + "'.");
} else {
- Gitop.getInstance(VoteInvitationManager.class).inviteToVote(request, members, lackApprovals);
+ request.inviteToVote(members, lackApprovals);
return pending("To be approved by " + lackApprovals + " users from team '"
+ getTeam().getName() + ".", new CanVoteBySpecifiedTeam(getTeam()));
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/manager/VoteInvitationManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/manager/VoteInvitationManager.java
index f8caf64820..d7665540da 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/manager/VoteInvitationManager.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/manager/VoteInvitationManager.java
@@ -1,7 +1,5 @@
package com.pmease.gitop.core.manager;
-import java.util.Collection;
-
import com.google.inject.ImplementedBy;
import com.pmease.commons.hibernate.dao.GenericDao;
import com.pmease.gitop.core.manager.impl.DefaultVoteInvitationManager;
@@ -14,17 +12,4 @@ public interface VoteInvitationManager extends GenericDao<VoteInvitation> {
VoteInvitation find(User reviewer, PullRequest request);
- /**
- * Invite specified number of users in candidates to vote for this request.
- * <p>
- *
- * @param request
- * pull request to invite users to vote
- * @param candidates
- * a collection of users to invite users from
- * @param count
- * number of users to invite
- */
- void inviteToVote(PullRequest request, Collection<User> candidates, int count);
-
}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultVoteInvitationManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultVoteInvitationManager.java
index a7476f6145..aa22d83c2a 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultVoteInvitationManager.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultVoteInvitationManager.java
@@ -1,11 +1,5 @@
package com.pmease.gitop.core.manager.impl;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Set;
-
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -13,13 +7,11 @@ import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import com.pmease.commons.hibernate.Sessional;
-import com.pmease.commons.hibernate.Transactional;
import com.pmease.commons.hibernate.dao.AbstractGenericDao;
import com.pmease.commons.hibernate.dao.GeneralDao;
import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.PullRequest;
import com.pmease.gitop.model.User;
-import com.pmease.gitop.model.Vote;
import com.pmease.gitop.model.VoteInvitation;
@Singleton
@@ -37,49 +29,4 @@ public class DefaultVoteInvitationManager extends AbstractGenericDao<VoteInvitat
return find(new Criterion[]{Restrictions.eq("voter", voter), Restrictions.eq("request", request)});
}
- @Transactional
- public void inviteToVote(PullRequest request, Collection<User> candidates, int count) {
- Collection<User> copyOfCandidates = new HashSet<User>(candidates);
-
- // submitter is not allowed to vote for this request
- if (request.getSubmittedBy() != null)
- copyOfCandidates.remove(request.getSubmittedBy());
-
- /*
- * users already voted since base update should be excluded from
- * invitation list as their votes are still valid
- */
- for (Vote vote : request.getBaseUpdate().listVotesOnwards()) {
- copyOfCandidates.remove(vote.getVoter());
- }
-
- Set<User> invited = new HashSet<User>();
- for (VoteInvitation each : request.getVoteInvitations())
- invited.add(each.getVoter());
-
- invited.retainAll(copyOfCandidates);
-
- for (int i = 0; i < count - invited.size(); i++) {
- User selected = Collections.min(copyOfCandidates, new Comparator<User>() {
-
- @Override
- public int compare(User user1, User user2) {
- return user1.getVotes().size() - user2.getVotes().size();
- }
-
- });
-
- copyOfCandidates.remove(selected);
-
- VoteInvitation invitation = new VoteInvitation();
- invitation.setRequest(request);
- invitation.setVoter(selected);
- invitation.getRequest().getVoteInvitations().add(invitation);
- invitation.getVoter().getVoteInvitations().add(invitation);
-
- save(invitation);
- }
-
- }
-
}
diff --git a/gitop.core/src/test/java/com/pmease/gitop/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java b/gitop.core/src/test/java/com/pmease/gitop/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java
index 47961e8077..4a684efa89 100644
--- a/gitop.core/src/test/java/com/pmease/gitop/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java
+++ b/gitop.core/src/test/java/com/pmease/gitop/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java
@@ -15,12 +15,11 @@ import com.pmease.commons.loader.AppLoader;
import com.pmease.commons.util.FileUtils;
import com.pmease.gitop.core.manager.BranchManager;
import com.pmease.gitop.core.manager.TeamManager;
-import com.pmease.gitop.core.manager.VoteInvitationManager;
import com.pmease.gitop.model.Branch;
import com.pmease.gitop.model.Membership;
-import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.PullRequest;
import com.pmease.gitop.model.PullRequestUpdate;
+import com.pmease.gitop.model.Repository;
import com.pmease.gitop.model.Team;
import com.pmease.gitop.model.User;
import com.pmease.gitop.model.Vote;
@@ -33,9 +32,6 @@ public class IfApprovedByMajoritiesOfSpecifiedTeamTest extends AbstractGitTest {
@Mock
private TeamManager teamManager;
- @Mock
- private VoteInvitationManager voteInvitationManager;
-
@Override
protected void setup() {
super.setup();
@@ -76,8 +72,6 @@ public class IfApprovedByMajoritiesOfSpecifiedTeamTest extends AbstractGitTest {
team.getMemberships().add(membership);
Mockito.when(teamManager.load(1L)).thenReturn(team);
-
- Mockito.when(AppLoader.getInstance(VoteInvitationManager.class)).thenReturn(voteInvitationManager);
}
@Test
@@ -162,7 +156,7 @@ public class IfApprovedByMajoritiesOfSpecifiedTeamTest extends AbstractGitTest {
user.setId(3L);
user.setName("user3");
candidates.add(user);
- Mockito.verify(voteInvitationManager).inviteToVote(request, candidates, 1);
+ Assert.assertEquals("user1", request.getVoteInvitations().iterator().next().getVoter().getName());
Vote vote = new Vote();
vote.setId(1L);
diff --git a/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.java b/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.java
index 3901d0d7f3..f9fb1caced 100644
--- a/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.java
+++ b/gitop.model/src/main/java/com/pmease/gitop/model/PullRequest.java
@@ -3,8 +3,11 @@ package com.pmease.gitop.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.annotation.Nullable;
import javax.persistence.CascadeType;
@@ -355,6 +358,57 @@ public class PullRequest extends AbstractEntity {
return "pull request: " + getId();
}
+ /**
+ * Invite specified number of users in candidates to vote for this request.
+ * <p>
+ *
+ * @param candidates
+ * a collection of users to invite users from
+ * @param count
+ * number of users to invite
+ */
+ public void inviteToVote(Collection<User> candidates, int count) {
+ Collection<User> copyOfCandidates = new HashSet<User>(candidates);
+
+ // submitter is not allowed to vote for this request
+ if (getSubmittedBy() != null)
+ copyOfCandidates.remove(getSubmittedBy());
+
+ /*
+ * users already voted since base update should be excluded from
+ * invitation list as their votes are still valid
+ */
+ for (Vote vote : getBaseUpdate().listVotesOnwards()) {
+ copyOfCandidates.remove(vote.getVoter());
+ }
+
+ Set<User> invited = new HashSet<User>();
+ for (VoteInvitation each : getVoteInvitations())
+ invited.add(each.getVoter());
+
+ invited.retainAll(copyOfCandidates);
+
+ for (int i = 0; i < count - invited.size(); i++) {
+ User selected = Collections.min(copyOfCandidates, new Comparator<User>() {
+
+ @Override
+ public int compare(User user1, User user2) {
+ return user1.getVotes().size() - user2.getVotes().size();
+ }
+
+ });
+
+ copyOfCandidates.remove(selected);
+
+ VoteInvitation invitation = new VoteInvitation();
+ invitation.setRequest(this);
+ invitation.setVoter(selected);
+ invitation.getRequest().getVoteInvitations().add(invitation);
+ invitation.getVoter().getVoteInvitations().add(invitation);
+ }
+
+ }
+
public static class CriterionHelper {
public static Criterion ofOpen() {
return Restrictions.isNull("closeInfo");
diff --git a/gitop.rest/pom.xml b/gitop.rest/pom.xml
index d7c18c11b7..52f6b9f3aa 100644
--- a/gitop.rest/pom.xml
+++ b/gitop.rest/pom.xml
@@ -59,6 +59,5 @@
</repositories>
<properties>
<moduleClass>com.pmease.gitop.rest.RestModule</moduleClass>
- <jerseyVersion>1.17</jerseyVersion>
</properties>
</project>
diff --git a/gitop.web/pom.xml b/gitop.web/pom.xml
index 9f799e946b..b2f2255bf3 100644
--- a/gitop.web/pom.xml
+++ b/gitop.web/pom.xml
@@ -56,7 +56,6 @@
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
- <version>1.17.1</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
@@ -68,13 +67,14 @@
<artifactId>commons-validator</artifactId>
<version>1.4.0</version>
</dependency>
-
+ <!--
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
-
+ -->
+
<!-- Google Closure Dependencies -->
<dependency>
<groupId>com.google.closure</groupId>
@@ -130,6 +130,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -246,22 +250,6 @@
</snapshots>
<url>file://${project.basedir}/repo</url>
</repository>
-
- <!-- For Atlassian Processutils -->
- <repository>
- <id>opencast-public</id>
- <url>http://repository.opencastproject.org/nexus/content/repositories/public/</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- </repository>
</repositories>
<properties>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css
index e054e9a1c2..80914d8113 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css
@@ -1,8 +1,11 @@
/* MISC */
.img-link:hover { text-decoration: none; }
+
+/*
a.dropdown-toggle {text-decoration: none;}
a.dropdown-toggle:focus, a.dropdown-toggle:hover, a.dropdown-toggle.open {
color: white; background-color: #2A6496;}
+*/
pre, code { font-family: Consolas, 'Liberation Mono', Courier, monospace; }
.alert pre, .alert code { background: white; margin: 5px 0; }
diff --git a/gitop.web/src/test/java/com/pmease/gitop/web/util/TagParserTest.java b/gitop.web/src/test/java/com/pmease/gitop/web/util/TagParserTest.java
index 0d186dbaf9..620a5485c9 100644
--- a/gitop.web/src/test/java/com/pmease/gitop/web/util/TagParserTest.java
+++ b/gitop.web/src/test/java/com/pmease/gitop/web/util/TagParserTest.java
@@ -1,24 +1,18 @@
package com.pmease.gitop.web.util;
import java.io.IOException;
-import java.net.URL;
-import java.util.Map;
import org.junit.Test;
-import com.google.common.base.Charsets;
-import com.google.common.io.LineProcessor;
-import com.google.common.io.Resources;
-import com.pmease.commons.git.Commit;
-import com.pmease.gitop.web.git.command.ListTagCommand;
-
public class TagParserTest {
@Test public void testTagParser() throws IOException {
+ /*
URL url = Resources.getResource(TagParserTest.class, "tag.out");
LineProcessor<Map<String, Commit>> tagConsumer = new ListTagCommand.TagConsumer();
Resources.readLines(url, Charsets.UTF_8, tagConsumer);
System.out.println(tagConsumer.getResult().get("v3.0.3").getMessage());
+ */
}
}
diff --git a/parent.general/pom.xml b/parent.general/pom.xml
index df4b24ab2f..676a7a8e7c 100644
--- a/parent.general/pom.xml
+++ b/parent.general/pom.xml
@@ -383,6 +383,21 @@
<artifactId>javax.servlet-api</artifactId>
<version>${servletVersion}</version>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>${jerseyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ <version>${jerseyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>${jerseyVersion}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
@@ -456,8 +471,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<slf4jVersion>1.7.5</slf4jVersion>
<logbackVersion>1.0.11</logbackVersion>
- <dropwizardVersion>0.7.0-SNAPSHOT</dropwizardVersion>
- <jerseyVersion>1.17.1</jerseyVersion>
+ <dropwizardVersion>0.7.0-rc2</dropwizardVersion>
+ <jerseyVersion>1.18.1</jerseyVersion>
<jettyVersion>8.1.10.v20130312</jettyVersion>
<jacksonVersion>2.2.3</jacksonVersion>
<powermockVersion>1.5.1</powermockVersion>
diff --git a/plugin.maven/pom.xml b/plugin.maven/pom.xml
index 7bd481ac5a..43280afb70 100644
--- a/plugin.maven/pom.xml
+++ b/plugin.maven/pom.xml
@@ -47,6 +47,19 @@
<ignore />
</action>
</pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <versionRange>[1.0.0,)</versionRange>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
@@ -155,7 +168,7 @@
</repository>
</repositories>
<properties>
- <mavenVersion>3.0</mavenVersion>
+ <mavenVersion>3.2.1</mavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
diff --git a/plugin.maven/src/main/java/com/pmease/plugin/maven/CreateProductSandboxMojo.java b/plugin.maven/src/main/java/com/pmease/plugin/maven/CreateProductSandboxMojo.java
index ebecea6ff3..7a29c03b4f 100644
--- a/plugin.maven/src/main/java/com/pmease/plugin/maven/CreateProductSandboxMojo.java
+++ b/plugin.maven/src/main/java/com/pmease/plugin/maven/CreateProductSandboxMojo.java
@@ -19,11 +19,11 @@ import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.repository.RemoteRepository;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
-import com.google.inject.internal.util.Preconditions;
+import com.google.common.base.Preconditions;
/**
* @goal create-product-sandbox
diff --git a/plugin.maven/src/main/java/com/pmease/plugin/maven/GenerateProductResourcesMojo.java b/plugin.maven/src/main/java/com/pmease/plugin/maven/GenerateProductResourcesMojo.java
index c35a7bbf5b..9bbb14cebf 100644
--- a/plugin.maven/src/main/java/com/pmease/plugin/maven/GenerateProductResourcesMojo.java
+++ b/plugin.maven/src/main/java/com/pmease/plugin/maven/GenerateProductResourcesMojo.java
@@ -10,9 +10,9 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.repository.RemoteRepository;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
/**
* @goal generate-product-resources
diff --git a/plugin.maven/src/main/java/com/pmease/plugin/maven/PackageArtifactMojo.java b/plugin.maven/src/main/java/com/pmease/plugin/maven/PackageArtifactMojo.java
index 62ac6fa2c0..9445373fb6 100644
--- a/plugin.maven/src/main/java/com/pmease/plugin/maven/PackageArtifactMojo.java
+++ b/plugin.maven/src/main/java/com/pmease/plugin/maven/PackageArtifactMojo.java
@@ -18,9 +18,9 @@ import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
import org.codehaus.plexus.util.IOUtil;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.repository.RemoteRepository;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
/**
* @goal package-artifact
diff --git a/plugin.maven/src/main/java/com/pmease/plugin/maven/PluginUtils.java b/plugin.maven/src/main/java/com/pmease/plugin/maven/PluginUtils.java
index 6acd4c4703..5a76e1ed69 100644
--- a/plugin.maven/src/main/java/com/pmease/plugin/maven/PluginUtils.java
+++ b/plugin.maven/src/main/java/com/pmease/plugin/maven/PluginUtils.java
@@ -33,12 +33,13 @@ import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactResult;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.DependencyRequest;
public class PluginUtils {
@@ -149,13 +150,14 @@ public class PluginUtils {
for (Artifact each: project.getArtifacts()) {
if (containsFile(each.getFile(), PluginConstants.BOOTSTRAP_PROPERTY_FILE)) {
bootArtifacts.add(each);
- org.sonatype.aether.artifact.Artifact aetherArtifact = new org.sonatype.aether.util.artifact.DefaultArtifact(
+ org.eclipse.aether.artifact.Artifact aetherArtifact = new org.eclipse.aether.artifact.DefaultArtifact(
each.getGroupId(), each.getArtifactId(), each.getClassifier(), each.getType(),
each.getVersion());
CollectRequest collectRequest = new CollectRequest(new Dependency(aetherArtifact, null),
new ArrayList<Dependency>(), remoteRepos);
+ DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
try {
- for (ArtifactResult result: repoSystem.resolveDependencies(repoSession, collectRequest, null)) {
+ for (ArtifactResult result: repoSystem.resolveDependencies(repoSession, dependencyRequest).getArtifactResults()) {
Dependency dependency = result.getRequest().getDependencyNode().getDependency();
if (dependency.getArtifact() != null && dependency.getArtifact().getFile() != null) {
aetherArtifact = dependency.getArtifact();