}
@Override
public ActionForward continueCandidacyCreation(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException {
MobilityIndividualApplicationProcessBean bean =
(MobilityIndividualApplicationProcessBean) getIndividualCandidacyProcessBean();
final PersonBean personBean = bean.getPersonBean();
if (existsIndividualCandidacyProcessForDocumentId(request, personBean.getIdDocumentType(),
personBean.getDocumentIdNumber())) {
addActionMessage("individualCandidacyMessages", request, "mobility.error.candidacy.for.person.already.exists");
return executeCreateCandidacyPersonalInformationInvalid(mapping, form, request, response);
}
final Set<Person> persons = new HashSet<Person>(Person.readByDocumentIdNumber(personBean.getDocumentIdNumber()));
if (persons.size() > 1) {
addActionMessage("individualCandidacyMessages", request, "mobility.error.person.with.same.identifier.exists.multiple");
return executeCreateCandidacyPersonalInformationInvalid(mapping, form, request, response);
} else if (persons.size() == 1) {
Person person = persons.iterator().next();
if (person.getStudent() != null && person.getStudent().hasActiveRegistrations()) {
addActionMessage("individualCandidacyMessages", request,
"mobility.error.person.with.same.identifier.exists.active.registration");
return executeCreateCandidacyPersonalInformationInvalid(mapping, form, request, response);
}
if (person.getStudent() != null && !person.getStudent().getNumber().toString().equals(bean.getPersonNumber())) {
addActionMessage("individualCandidacyMessages", request,
"mobility.error.person.with.same.identifier.exists.different.student", Unit.getInstitutionAcronym());
return executeCreateCandidacyPersonalInformationInvalid(mapping, form, request, response);
}
personBean.setPerson(person);
}
IndividualCandidacyDocumentFile photoDocumentFile =
createIndividualCandidacyDocumentFile(bean.getPhotoDocument(), bean.getPersonBean().getDocumentIdNumber());
bean.getPhotoDocument().setDocumentFile(photoDocumentFile);
request.setAttribute(getIndividualCandidacyProcessBeanName(), getIndividualCandidacyProcessBean());
if (bean.isToAccessFenix() && !(personBean.getEmail().equals(personBean.getEmailConfirmation()))) {
addActionMessage("individualCandidacyMessages", request, "mobility.error.emails.are.not.equals");
return executeCreateCandidacyPersonalInformationInvalid(mapping, form, request, response);
}
if (bean.isToAccessFenix() && bean.getPublicCandidacyHashCode() == null) {
DegreeOfficePublicCandidacyHashCode candidacyHashCode = null;
candidacyHashCode =
DegreeOfficePublicCandidacyHashCode.getPublicCandidacyHashCodeByEmailAndCandidacyProcessType(bean
.getPersonBean().getEmail(), getProcessType(), getCurrentOpenParentProcess());
if (candidacyHashCode != null && candidacyHashCode.getIndividualCandidacyProcess() != null) {
addActionMessage("individualCandidacyMessages", request, "mobility.error.email.is.bounded.to.candidacy");
return executeCreateCandidacyPersonalInformationInvalid(mapping, form, request, response);