private Capable verifyActiveContributorAgreement() {
if (! (user instanceof IdentifiedUser)) {
return new Capable("Must be logged in to verify Contributor Agreement");
}
final IdentifiedUser iUser = (IdentifiedUser) user;
boolean hasContactInfo = !missing(iUser.getAccount().getFullName())
&& !missing(iUser.getAccount().getPreferredEmail())
&& iUser.getAccount().isContactFiled();
List<AccountGroup.UUID> okGroupIds = Lists.newArrayList();
List<AccountGroup.UUID> missingInfoGroupIds = Lists.newArrayList();
for (ContributorAgreement ca : contributorAgreements) {
List<AccountGroup.UUID> groupIds;
if (hasContactInfo || !ca.isRequireContactInformation()) {
groupIds = okGroupIds;
} else {
groupIds = missingInfoGroupIds;
}
for (PermissionRule rule : ca.getAccepted()) {
if ((rule.getAction() == Action.ALLOW) && (rule.getGroup() != null)
&& (rule.getGroup().getUUID() != null)) {
groupIds.add(new AccountGroup.UUID(rule.getGroup().getUUID().get()));
}
}
}
if (iUser.getEffectiveGroups().containsAnyOf(okGroupIds)) {
return Capable.OK;
}
if (iUser.getEffectiveGroups().containsAnyOf(missingInfoGroupIds)) {
final StringBuilder msg = new StringBuilder();
for (ContributorAgreement ca : contributorAgreements) {
if (ca.isRequireContactInformation()) {
msg.append(ca.getName());
break;