use of io.pivotal.cla.data.ContributorLicenseAgreement in project pivotal-cla by pivotalsoftware.
the class CclaController method claForm.
@RequestMapping("/sign/{claName}/ccla")
public String claForm(@AuthenticationPrincipal User user, SignCorporateClaForm signCorporateClaForm, Map<String, Object> model) throws Exception {
String claName = signCorporateClaForm.getClaName();
Integer pullRequestId = signCorporateClaForm.getPullRequestId();
String repositoryId = signCorporateClaForm.getRepositoryId();
CorporateSignatureInfo corporateResponse = claService.findCorporateSignatureInfoFor(claName, user);
ContributorLicenseAgreement cla = corporateResponse.getContributorLicenseAgreement();
CorporateSignature signed = corporateResponse.getCorporateSignature();
List<String> currentUserGitHubOrganizations = corporateResponse.getGitHubOrganizations();
if (cla == null) {
throw new ResourceNotFoundException();
}
if (cla.getSupersedingCla() != null) {
cla = cla.getSupersedingCla();
}
signCorporateClaForm.setSigned(signed != null);
signCorporateClaForm.setName(user.getName());
signCorporateClaForm.setClaId(cla.getId());
signCorporateClaForm.setRepositoryId(repositoryId);
signCorporateClaForm.setPullRequestId(pullRequestId);
signCorporateClaForm.setGitHubOrganizations(currentUserGitHubOrganizations);
model.put("cla", cla);
return "cla/ccla/sign";
}
use of io.pivotal.cla.data.ContributorLicenseAgreement in project pivotal-cla by pivotalsoftware.
the class CclaController method view.
@GetMapping("/view/{claName}/ccla")
public String view(@PathVariable String claName, Map<String, Object> model) throws Exception {
ContributorLicenseAgreement cla = clas.findByNameAndPrimaryTrue(claName);
if (cla == null) {
throw new ResourceNotFoundException();
}
if (cla.getSupersedingCla() != null) {
cla = cla.getSupersedingCla();
}
model.put("cla", cla);
return "cla/ccla/view";
}
use of io.pivotal.cla.data.ContributorLicenseAgreement in project pivotal-cla by pivotalsoftware.
the class IclaController method signCla.
@RequestMapping(value = "/sign/{claName}/icla", method = RequestMethod.POST)
public String signCla(@AuthenticationPrincipal User user, @Valid SignClaForm signClaForm, BindingResult result, Map<String, Object> model, RedirectAttributes redirect) throws Exception {
String claName = signClaForm.getClaName();
Integer pullRequestId = signClaForm.getPullRequestId();
String repositoryId = signClaForm.getRepositoryId();
ContributorLicenseAgreement cla = clas.findOne(signClaForm.getClaId());
if (result.hasErrors()) {
model.put("cla", cla);
return "cla/icla/sign";
}
IndividualSignature signature = new IndividualSignature();
signature.setCla(cla);
signature.setName(signClaForm.getName());
signature.setCountry(signClaForm.getCountry());
signature.setEmail(signClaForm.getEmail());
signature.setMailingAddress(signClaForm.getMailingAddress());
signature.setDateOfSignature(new Date());
signature.setTelephone(signClaForm.getTelephone());
signature.setGitHubLogin(user.getGitHubLogin());
individual.save(signature);
// update github
redirect.addAttribute("claName", claName);
if (repositoryId == null || pullRequestId == null) {
return "redirect:/sign/{claName}/icla";
}
ClaPullRequestStatusRequest updatePullRequest = signClaForm.createUpdatePullRequestStatus(user.getGitHubLogin());
if (updatePullRequest != null) {
updatePullRequest.getCommitStatus().setSuccess(true);
claService.savePullRequestStatus(updatePullRequest);
}
redirect.addAttribute("repositoryId", repositoryId);
redirect.addAttribute("pullRequestId", pullRequestId);
return "redirect:/sign/{claName}/icla";
}
use of io.pivotal.cla.data.ContributorLicenseAgreement in project pivotal-cla by pivotalsoftware.
the class AdminCrudClaController method saveCla.
@RequestMapping(value = "/admin/cla", method = RequestMethod.POST)
public String saveCla(@AuthenticationPrincipal User user, @Valid ClaForm claForm, BindingResult result, Map<String, Object> model) throws Exception {
boolean primary = claForm.isPrimary();
if (primary) {
ContributorLicenseAgreement existingPrimaryCla = claRepo.findByNameAndPrimaryTrue(claForm.getName());
Long existingPrimaryClaId = existingPrimaryCla == null ? null : existingPrimaryCla.getId();
if (existingPrimaryClaId != null && !existingPrimaryClaId.equals(claForm.getId())) {
result.rejectValue("primary", "errors.primary.exists", "A primary CLA with this name already exists");
}
}
if (result.hasErrors()) {
Iterable<ContributorLicenseAgreement> clas = claRepo.findAll();
model.put("licenses", clas);
return "admin/cla/form";
}
ContributorLicenseAgreement supersedingCla = null;
if (claForm.getSupersedingCla() != null) {
supersedingCla = claRepo.findOne(claForm.getSupersedingCla());
}
String accessToken = user.getAccessToken();
MarkdownContent individual = claForm.getIndividualContent();
String individualHtml = gitHub.markdownToHtml(accessToken, individual.getMarkdown());
individual.setHtml(individualHtml);
MarkdownContent corporate = claForm.getCorporateContent();
String corperateHtml = gitHub.markdownToHtml(accessToken, corporate.getMarkdown());
corporate.setHtml(corperateHtml);
boolean isCreateNew = claForm.getId() == null;
ContributorLicenseAgreement cla = isCreateNew ? new ContributorLicenseAgreement() : claRepo.findOne(claForm.getId());
cla.setCorporateContent(claForm.getCorporateContent());
cla.setDescription(claForm.getDescription());
cla.setIndividualContent(claForm.getIndividualContent());
cla.setName(claForm.getName());
cla.setPrimary(claForm.isPrimary());
cla.setSupersedingCla(supersedingCla);
claRepo.save(cla);
return "redirect:/admin/cla/?success";
}
use of io.pivotal.cla.data.ContributorLicenseAgreement in project pivotal-cla by pivotalsoftware.
the class CclaControllerTests method signFormSupersedingCla.
@Test
public void signFormSupersedingCla() {
ContributorLicenseAgreement springCla = DataUtils.createSpringCla();
springCla.setSupersedingCla(cla);
when(mockClaRepository.findByNameAndPrimaryTrue(springCla.getName())).thenReturn(springCla);
SignCclaPage signPage = SignCclaPage.go(getDriver(), springCla.getName());
signPage.assertClaLink(springCla.getName());
assertThat(signPage.getCorporate()).isEqualTo(cla.getCorporateContent().getHtml());
assertThat(signPage.isSigned()).isFalse();
}
Aggregations