@Override
  public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
      throws IOException, ServletException {
    arg2.doFilter(arg0, arg1);

    HttpServletRequest request = (HttpServletRequest) arg0;
    ResponseWrapper response = (ResponseWrapper) arg1;

    if ("doOperation".equals(request.getParameter("method"))
        && "PRINT_ALL_DOCUMENTS".equals(request.getParameter("operationType"))) {

      try {
        // clean the response html and make a DOM document out of it
        String responseHtml = clean(response.getContent());
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = builder.parse(new ByteArrayInputStream(responseHtml.getBytes()));

        // alter paths of link/img tags so itext can use them properly
        patchLinks(doc, request);

        // structure pdf document
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(doc, "");
        renderer.layout();

        // create the pdf
        ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
        renderer.createPDF(pdfStream);

        // concatenate with other docs
        final Person person = (Person) request.getAttribute("person");
        final StudentCandidacy candidacy = getCandidacy(request);
        ByteArrayOutputStream finalPdfStream =
            concatenateDocs(pdfStream.toByteArray(), person, candidacy);
        byte[] pdfByteArray = finalPdfStream.toByteArray();

        // associate the summary file to the candidacy
        associateSummaryFile(pdfByteArray, person.getStudent().getNumber().toString(), candidacy);

        // redirect user to the candidacy summary page
        response.reset();
        response.sendRedirect(buildRedirectURL(request, candidacy));

        response.flushBuffer();
      } catch (ParserConfigurationException e) {
        logger.error(e.getMessage(), e);
      } catch (SAXException e) {
        logger.error(e.getMessage(), e);
      } catch (DocumentException e) {
        logger.error(e.getMessage(), e);
      }
    }
  }
  @Override
  public void handle(Page page, TemplateContext local, TemplateContext global) {
    Homepage homepage = homepage(page.getSite());
    if (homepage == null || !homepage.isHomepageActivated()) {
      return; // TODO we might want 404 here
    }

    global.put("homepage", homepage);
    Person owner = homepage.getPerson();
    global.put("owner", owner);

    if (homepage.getShowCurrentAttendingExecutionCourses()) {
      SortedSet<Attends> attendedCoursesByName =
          new TreeSet<Attends>(Attends.ATTENDS_COMPARATOR_BY_EXECUTION_COURSE_NAME);
      attendedCoursesByName.addAll(homepage.getPerson().getCurrentAttends());
      global.put("attendingCourses", attendedCoursesByName);
    }

    List<? extends PartyContact> emails = owner.getEmailAddresses();
    global.put("visibleEmails", getSortedFilteredContacts(emails));

    List<? extends PartyContact> phones = owner.getPhones();
    global.put(
        "visiblePersonalPhones", getSortedFilteredContacts(phones, PartyContactType.PERSONAL));
    global.put("visibleWorkPhones", getSortedFilteredContacts(phones, PartyContactType.WORK));

    List<? extends PartyContact> mobilePhones = owner.getMobilePhones();
    global.put("visibleMobilePhones", getSortedFilteredContacts(mobilePhones));

    List<? extends PartyContact> websites = owner.getWebAddresses();
    global.put("visibleWebsites", getSortedFilteredContacts(websites));
  }
  @Atomic
  public static void run(Department department, String[] add, String[] remove) {
    check(RolePredicates.DEPARTMENT_ADMINISTRATIVE_OFFICE_PREDICATE);
    List<Person> toAdd = materializePersons(add);
    List<Person> toRemove = materializePersons(remove);
    List<Person> finalList = new ArrayList<Person>();

    Role bolonhaRole = Role.getRoleByRoleType(RoleType.BOLONHA_MANAGER);

    Group group = department.getCompetenceCourseMembersGroup();
    if (group == null) {
      group = new FixedSetGroup();
    }

    for (Person person : group.getElements()) {

      if (!toRemove.contains(person)) {
        finalList.add(person);
        addBolonhaRole(person, bolonhaRole);
      } else if (person.hasRole(RoleType.BOLONHA_MANAGER)
          && !belongsToOtherGroupsWithSameRole(department, person)) {
        person.removeRoleByType(RoleType.BOLONHA_MANAGER);
      }
    }

    for (Person person : toAdd) {
      if (!finalList.contains(person)) {
        finalList.add(person);
        addBolonhaRole(person, bolonhaRole);
      }
    }

    department.setCompetenceCourseMembersGroup(new FixedSetGroup(finalList));
  }
  public ActionForward showExecutionDegrees(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    DynaValidatorForm personExecutionCourseForm = (DynaValidatorForm) form;

    String personId = (String) personExecutionCourseForm.get("teacherId");
    Person person = Person.readPersonByUsername(personId);
    setChoosedExecutionPeriod(
        request, ReadNotClosedExecutionPeriods.run(), personExecutionCourseForm);
    InfoExecutionPeriod infoExecutionPeriod =
        (InfoExecutionPeriod) request.getAttribute("infoExecutionPeriod");
    final ExecutionSemester executionPeriod = infoExecutionPeriod.getExecutionPeriod();
    if (executionPeriod.getSemester().intValue() == 2
        && executionPeriod.getExecutionYear().getYear().equals("2010/2011")) {
    } else {
      if (person.getTeacher() == null
          || (person.getTeacher().getTeacherAuthorization(executionPeriod) == null
              && !person.hasRole(RoleType.TEACHER))) {
        request.setAttribute("notAuth", true);
        return showExecutionYearExecutionPeriods(
            mapping, personExecutionCourseForm, request, response);
      }
    }

    prepareSecondStep(personExecutionCourseForm, request);
    personExecutionCourseForm.set("page", new Integer(2));
    return mapping.findForward("second-step");
  }
  public ActionForward prepareEditObject(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixServiceException, ClassNotFoundException {

    Person person = checkUser();

    String documentIdNumber = person.getDocumentIdNumber();
    DynaActionForm actionForm = (DynaActionForm) form;
    Integer idPos1Index = (Integer) actionForm.get("idPos1Index");
    Integer idPos2Index = (Integer) actionForm.get("idPos2Index");
    Integer idPos3Index = (Integer) actionForm.get("idPos3Index");
    Character idPos1Value = (Character) actionForm.get("idPos1Value");
    Character idPos2Value = (Character) actionForm.get("idPos2Value");
    Character idPos3Value = (Character) actionForm.get("idPos3Value");

    if (documentIdNumber.charAt(idPos1Index - 1) == idPos1Value.charValue()
        && documentIdNumber.charAt(idPos2Index - 1) == idPos2Value.charValue()
        && documentIdNumber.charAt(idPos3Index - 1) == idPos3Value.charValue()) {

      DomainObject object = getDomainObject(actionForm, "classToManageId");

      if (object != null) {
        request.setAttribute("objectToEdit", object);
      }
    } else {
      request.setAttribute("message", "Who the hell are you!?!?!");
    }
    return mapping.findForward("prepareEditObject");
  }
Ejemplo n.º 6
0
  public List run(String identificationDocumentNumber, IDDocumentType identificationDocumentType)
      throws Exception {

    // Check if person exists
    Person person =
        Person.readByDocumentIdNumberAndIdDocumentType(
            identificationDocumentNumber, identificationDocumentType);

    if (person == null) {
      throw new NonExistingServiceException();
    }

    List<Guide> guides = new ArrayList<Guide>(person.getGuides());
    if (guides.size() == 0) {
      return null;
    }

    BeanComparator numberComparator = new BeanComparator("number");
    BeanComparator versionComparator = new BeanComparator("version");
    ComparatorChain chainComparator = new ComparatorChain();
    chainComparator.addComparator(numberComparator);
    chainComparator.addComparator(versionComparator);
    Collections.sort(guides, chainComparator);

    return getLatestVersions(guides);
  }
Ejemplo n.º 7
0
  private void fillSpreadSheet(
      final Collection<CerimonyInquiryPerson> requests, final StyledExcelSpreadsheet sheet) {

    setHeaders(sheet);

    for (CerimonyInquiryPerson inquiryPerson : requests) {
      final Person person = inquiryPerson.getPerson();
      final CerimonyInquiryAnswer inquiryAnswer = inquiryPerson.getCerimonyInquiryAnswer();

      sheet.newRow();
      sheet.addCell(person.getUsername());
      sheet.addCell(person.getName());
      sheet.addCell(person.getEmail());
      final StringBuilder contacts = new StringBuilder();
      for (final PartyContact partyContact : person.getPartyContactsSet()) {
        if (partyContact instanceof Phone || partyContact instanceof MobilePhone) {
          if (contacts.length() > 0) {
            contacts.append(", ");
          }
          contacts.append(partyContact.getPresentationValue());
        }
      }
      sheet.addCell(contacts.toString());
      sheet.addCell((inquiryAnswer != null ? inquiryAnswer.getText() : new String("-")));
      sheet.addCell(getDegrees(person));
      sheet.addCell(inquiryPerson.getComment());
    }
  }
Ejemplo n.º 8
0
  public ActionForward deletePersonFunction(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final Integer personFunctionId = new Integer(request.getParameter("personFunctionID"));

    final PersonFunction personFunction =
        (PersonFunction) rootDomainObject.readAccountabilityByOID(personFunctionId);
    final Person person = personFunction.getPerson();

    personFunction.delete();

    final ActionForward actionForward =
        new ActionForward(
            "/functionsManagement/listPersonFunctions.faces?personID="
                + person.getIdInternal()
                + "&"
                + net.sourceforge
                    .fenixedu
                    .presentationTier
                    .servlets
                    .filters
                    .ContentInjectionRewriter
                    .CONTEXT_ATTRIBUTE_NAME
                + "=/conselho-cientifico/conselho-cientifico");
    actionForward.setRedirect(false);
    return actionForward;
  }
 private String getMail(Person person) {
   if (person.hasInstitutionalEmailAddress()) {
     return person.getInstitutionalEmailAddressValue();
   } else {
     String emailForSendingEmails = person.getEmailForSendingEmails();
     return emailForSendingEmails != null ? emailForSendingEmails : StringUtils.EMPTY;
   }
 }
Ejemplo n.º 10
0
  public List run(InfoPerson infoPerson) {
    final List<InfoStudent> result = new ArrayList<InfoStudent>();

    Person person = (Person) rootDomainObject.readPartyByOID(infoPerson.getIdInternal());
    for (final Registration registration : person.getStudents()) {
      result.add(InfoStudent.newInfoFromDomain(registration));
    }

    return result;
  }
 protected boolean showSimilarPersons(
     final ChoosePersonBean choosePersonBean, final Collection<Person> persons) {
   if (!persons.isEmpty()) {
     return true;
   }
   return !Person.findByDateOfBirth(
           choosePersonBean.getDateOfBirth(),
           Person.findInternalPersonMatchingFirstAndLastName(choosePersonBean.getName()))
       .isEmpty();
 }
Ejemplo n.º 12
0
 @Override
 public boolean isMember(Person person) {
   return (person != null
       && person.hasEmployee()
       && checkParentUnits(
           getObject(), Collections.singletonList(person.getEmployee().getCurrentWorkingPlace())));
   // return (person != null && person.hasEmployee() && getObject() ==
   // person.getEmployee().getCurrentDepartmentWorkingPlace()
   // .getDepartmentUnit());
 }
Ejemplo n.º 13
0
 @Atomic
 public static Invitation run(InvitedPersonBean bean) {
   check(RolePredicates.MANAGER_OR_OPERATOR_PREDICATE);
   Person person = new Person(bean);
   Invitation invitation =
       new Invitation(
           person, bean.getUnit(), bean.getResponsible(), bean.getBegin(), bean.getEnd());
   person.setIstUsername();
   return invitation;
 }
Ejemplo n.º 14
0
 private static boolean hasActiveProfessorship() {
   final ExecutionSemester executionSemester = ExecutionSemester.readActualExecutionSemester();
   final Person person = AccessControl.getPerson();
   for (final Professorship professorship : person.getProfessorshipsSet()) {
     if (professorship.getExecutionCourse().getExecutionPeriod() == executionSemester) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 15
0
  @Atomic
  public static InfoDepartment run(String username) throws FenixServiceException {
    InfoDepartment infoDepartment = null;

    final Person person = Person.readPersonByUsername(username);
    final Collection<Department> departmentList = person.getManageableDepartmentCredits();
    if (!departmentList.isEmpty()) {
      infoDepartment = InfoDepartment.newInfoFromDomain(departmentList.iterator().next());
    }
    return infoDepartment;
  }
 private Person checkUser() {
   Person person = AccessControl.getPerson();
   Unit ciistUnit =
       Unit.readByCostCenterCode(
           FenixConfigurationManager.getConfiguration().getCIISTCostCenterCode());
   Unit currentWorkingPlace = person.getEmployee().getCurrentWorkingPlace();
   if ((currentWorkingPlace != null && ciistUnit != null && !currentWorkingPlace.equals(ciistUnit))
       || person.getPersonRole(RoleType.MANAGER) == null) {
     throw new DomainException("What you want do do hein?!?!");
   }
   return person;
 }
Ejemplo n.º 17
0
  @Checked("ResultPredicates.writePredicate")
  public void removeParticipation(ResultParticipation participation) {

    Person person = participation.getPerson();
    if (person.equals(this.getCreator())) {
      throw new DomainException("error.researcher.Result.cannotRemoveCreatorParticipation");
    } else {
      participation.deleteIfNotLast();
      this.reOrderParticipations(this.getOrderedResultParticipations());
      updateModifiedByAndDate();
    }
  }
  public ActionForward deleteObject(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixServiceException, ClassNotFoundException {

    Person person = checkUser();

    String documentIdNumber = person.getDocumentIdNumber();

    DynaActionForm actionForm = (DynaActionForm) form;
    Integer idPos1Index = (Integer) actionForm.get("idPos1Index");
    Integer idPos2Index = (Integer) actionForm.get("idPos2Index");
    Integer idPos3Index = (Integer) actionForm.get("idPos3Index");
    Character idPos1Value = (Character) actionForm.get("idPos1Value");
    Character idPos2Value = (Character) actionForm.get("idPos2Value");
    Character idPos3Value = (Character) actionForm.get("idPos3Value");

    if (documentIdNumber.charAt(idPos1Index - 1) == idPos1Value.charValue()
        && documentIdNumber.charAt(idPos2Index - 1) == idPos2Value.charValue()
        && documentIdNumber.charAt(idPos3Index - 1) == idPos3Value.charValue()) {

      String classToDelete = (String) actionForm.get("classToManage");
      String classToDeleteId = (String) actionForm.get("classToManageId");

      try {
        DeleteObjectByOID.run(classToDeleteId);
        request.setAttribute(
            "message",
            "Object "
                + classToDelete
                + " with ID:"
                + classToDeleteId
                + " Deleted. God have mercy of your soul...");

      } catch (Exception e) {
        logger.error(e.getMessage(), e);
        request.setAttribute(
            "message", "Error deleting Object " + classToDelete + " with ID:" + classToDeleteId);
      }

    } else {
      request.setAttribute("message", "Who the hell are you!?!?!");
    }

    request.setAttribute("domainClasses", getClasses());
    ((DynaActionForm) form).set("method", "prepareEditObject");
    return mapping.findForward("chooseClassToManage");
  }
Ejemplo n.º 19
0
  protected void run(
      Site site,
      Container container,
      File file,
      String originalFilename,
      String displayName,
      Group permittedGroup,
      Person person,
      EducationalResourceType type)
      throws FenixServiceException, DomainException, IOException {

    final VirtualPath filePath = getVirtualPath(site, container);

    Collection<FileSetMetaData> metaData =
        createMetaData(person.getName(), displayName, site.getAuthorName(), type);

    final byte[] bs = FileUtils.readFileToByteArray(file);

    checkSiteQuota(site, bs.length);

    FileContent fileContent =
        new FileContent(filePath, originalFilename, displayName, metaData, bs, permittedGroup);

    container.addFile(fileContent);
  }
  @Atomic
  public static Boolean run(Person person, ExecutionCourse executionCourse)
      throws NotAuthorizedException {
    AbstractModifyProfessorshipWithPerson.run(person);

    Professorship professorshipToDelete = person.getProfessorshipByExecutionCourse(executionCourse);

    Collection shiftProfessorshipList = professorshipToDelete.getAssociatedShiftProfessorshipSet();

    boolean hasCredits = false;

    if (!shiftProfessorshipList.isEmpty()) {
      hasCredits =
          CollectionUtils.exists(
              shiftProfessorshipList,
              new Predicate() {

                @Override
                public boolean evaluate(Object arg0) {
                  ShiftProfessorship shiftProfessorship = (ShiftProfessorship) arg0;
                  return shiftProfessorship.getPercentage() != null
                      && shiftProfessorship.getPercentage() != 0;
                }
              });
    }

    if (!hasCredits) {
      professorshipToDelete.delete();
    } else {
      if (hasCredits) {
        throw new DomainException("error.remove.professorship");
      }
    }
    return Boolean.TRUE;
  }
Ejemplo n.º 21
0
  @Atomic
  public static ExternalContract run(ServiceArguments arguments) throws FenixServiceException {

    ExternalContract storedExternalContract = null;
    String personName = arguments.getPersonName();
    Unit organization = arguments.getUnit();
    storedExternalContract =
        ExternalContract.readByPersonNameAddressAndInstitutionID(
            personName, null, organization.getExternalId());
    if (storedExternalContract != null) {
      throw new ExistingServiceException(
          "error.exception.commons.ExternalContract.existingExternalContract");
    }

    Person externalPerson =
        Person.createExternalPerson(
            personName,
            Gender.MALE,
            null,
            null,
            null,
            null,
            null,
            String.valueOf(System.currentTimeMillis()),
            IDDocumentType.EXTERNAL);
    return new ExternalContract(externalPerson, organization, new YearMonthDay(), null);
  }
  public ActionForward fillCandidacyInformation(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response) {

    final IndividualCandidacyProcessBean bean = getIndividualCandidacyProcessBean();
    request.setAttribute(getIndividualCandidacyProcessBeanName(), bean);

    if (!StringUtils.isEmpty(bean.getPersonBean().getSocialSecurityNumber())) {
      Party existingSocialSecurityNumberParty =
          Person.readByContributorNumber(bean.getPersonBean().getSocialSecurityNumber());

      if (existingSocialSecurityNumberParty != null
          && existingSocialSecurityNumberParty != bean.getPersonBean().getPerson()) {
        // found person with same contributor number
        addActionMessage(request, "error.party.existing.contributor.number");
        return mapping.findForward("fill-personal-information");
      }
    }

    try {
      DegreeOfficePublicCandidacyHashCode candidacyHashCode =
          DegreeOfficePublicCandidacyHashCodeOperations.getUnusedOrCreateNewHashCode(
              getProcessType(), getParentProcess(request), bean.getPersonBean().getEmail());
      bean.setPublicCandidacyHashCode(candidacyHashCode);
    } catch (HashCodeForEmailAndProcessAlreadyBounded e) {
      addActionMessage(request, "error.candidacy.hash.code.already.bounded");
      return mapping.findForward("fill-personal-information");
    }

    return mapping.findForward("fill-candidacy-information");
  }
Ejemplo n.º 23
0
    public static boolean eval(Person contactPerson) {
      if (hasRole(RoleType.OPERATOR)
          || hasRole(RoleType.MANAGER)
          || isSelfPerson(contactPerson)
          || hasRole(RoleType.PERSONNEL_SECTION)) {
        return true;
      }

      if (contactPerson.getStudent() != null
          && !contactPerson.hasRole(RoleType.GRANT_OWNER)
          && !contactPerson.hasRole(RoleType.EMPLOYEE)) {
        return AcademicAuthorizationGroup.get(AcademicOperationType.EDIT_STUDENT_PERSONAL_DATA)
            .isMember(Authenticate.getUser());
      }

      return false;
    }
  private String generateTicket() {
    final StringBuilder builder = new StringBuilder();

    builder.append(getExternalId());
    builder.append(hashCode());

    final InstitutionAffiliationEvent event = getInstitutionAffiliationEvent();
    final Person person = event.getPerson();
    final User user = person.getUser();
    builder.append(user.getUserUId());
    builder.append(user.getExternalId());

    final DateTime instant = getGenerated();
    builder.append(instant.toString("yyyy-MM-dd HH:mm:ss"));

    return DigestUtils.shaHex(builder.toString());
  }
  public ActionForward welcome(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    /*//Pick up user so that you can find out which
    //agreement greeting is supposed to be shown.
    //(for single agreement supervisors only)
    final IUserView userView = UserView.getUser();
    Person supervisor = userView.getPerson();

    //If action is being called after Protocol Selection, it means
    //this supervisor is responsible for several agreements.
    //In that case the agreement greeting supposed to be shown
    //is attainable through the request.
    final String registrationProtocolId = request.getParameter("registrationProtocolId");
    RegistrationProtocol registrationProtocol = FenixFramework.getDomainObject(registrationProtocolId);
    RegistrationAgreement registrationAgreement;

    //If coming from selectProtocol, read agreement from request. Else read from user. Plain simple.
    if(registrationProtocol != null){
        registrationAgreement = registrationProtocol.getRegistrationAgreement();
    } else {
        registrationAgreement = supervisor.getRegistrationProtocols().iterator().next().getRegistrationAgreement();
    }*/

    final IUserView userView = UserView.getUser();
    Person supervisor = userView.getPerson();
    RegistrationProtocol registrationProtocol = supervisor.getOnlyRegistrationProtocol();

    if (registrationProtocol == null) {
      return mapping.findForward("welcome");
    }

    switch (registrationProtocol.getRegistrationAgreement()) {
      case AFA:
        return mapping.findForward("welcome_AFA");

      case MA:
        return mapping.findForward("welcome_MA");

      default:
        return mapping.findForward("welcome");
    }
  }
 @Service
 public static Boolean run(
     Person person, ExecutionYear executionYear, final List executionCourseResponsabilities)
     throws MaxResponsibleForExceed, InvalidCategory, NotAuthorizedException {
   AbstractModifyProfessorshipWithPerson.run(person);
   person.updateResponsabilitiesFor(
       executionYear.getIdInternal(), executionCourseResponsabilities);
   return true;
 }
Ejemplo n.º 27
0
  public ActionForward chooseStudent(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final StudentContextSelectionBean studentContextSelectionBean = getRenderedObject();

    final String number = studentContextSelectionBean.getNumber();
    if (number != null && !number.isEmpty()) {
      final AcademicInterval academicInterval = studentContextSelectionBean.getAcademicInterval();
      final ExecutionInterval executionInterval =
          ExecutionInterval.getExecutionInterval(academicInterval);

      final SearchParameters searchParameters = new SearchParameters();
      if (StringUtils.isNumeric(number)) {
        searchParameters.setStudentNumber(Integer.valueOf(number));
      } else {
        searchParameters.setUsername(number);
      }
      final CollectionPager<Person> people =
          new SearchPerson()
              .run(searchParameters, new SearchPerson.SearchPersonPredicate(searchParameters));
      final Collection<Registration> registrations = new ArrayList<Registration>();
      for (final Person person : people.getCollection()) {
        if (person.getStudent() != null) {
          for (final Registration registration : person.getStudent().getRegistrationsSet()) {
            if (registration.hasAnyActiveState((ExecutionSemester) executionInterval)) {
              registrations.add(registration);
            }
          }
        }
      }

      if (studentContextSelectionBean.getToEdit()) {
        request.setAttribute("toEditScheduleRegistrations", registrations);
      } else {
        request.setAttribute("registrations", registrations);
        request.setAttribute("timeTableExecutionSemester", executionInterval);
      }
    }

    return prepare(mapping, form, request, response);
  }
Ejemplo n.º 28
0
  public static boolean hasAvailableSender() {
    final User userView = Authenticate.getUser();
    if (userView != null) {
      if (userView.getPerson().hasRole(RoleType.MANAGER)) {
        return true;
      }

      final Person person = userView.getPerson();
      if (person != null && !person.getMessagesSet().isEmpty()) {
        return true;
      }

      for (final Sender sender : Bennu.getInstance().getUtilEmailSendersSet()) {
        if (sender.allows(userView)) {
          return true;
        }
      }
    }
    return false;
  }
 private boolean hasMatchingLine(
     final Person person, final String line, final CardGenerationEntry currentEntry) {
   for (final CardGenerationEntry cardGenerationEntry : person.getCardGenerationEntriesSet()) {
     if (currentEntry != cardGenerationEntry
         && cardGenerationEntry.matches(line)
         && isInValidTimeFrame(cardGenerationEntry)) {
       return true;
     }
   }
   return false;
 }
  @Override
  protected HtmlComponent createTextField(Object object, Class type) {

    Person person = (Person) object;
    String username = (person != null) ? person.getUsername() : null;

    final HtmlComponent container = super.createTextField(username, type);
    final HtmlFormComponent formComponent =
        (HtmlFormComponent)
            container.getChild(
                new Predicate<HtmlComponent>() {
                  @Override
                  public boolean apply(HtmlComponent input) {
                    return input instanceof HtmlFormComponent;
                  }
                });
    formComponent.setConverter(new PersonUsernameConverter());

    return formComponent;
  }