Esempio n. 1
0
  private SupportRequestBean userInfoContextAppend(
      HttpServletRequest request, final StringBuilder exceptionInfo) {

    exceptionInfo.append("[UserLoggedIn] ");

    SupportRequestBean requestBean;
    String user;
    User userView = Authenticate.getUser();
    if (userView != null) {
      user = userView.getUsername();
      requestBean = SupportRequestBean.generateExceptionBean(userView.getPerson());
      MenuFunctionality selectedFunctionality =
          BennuPortalDispatcher.getSelectedFunctionality(request);
      if (selectedFunctionality != null) {
        requestBean.setSelectedFunctionality(selectedFunctionality);
      }
      setUserName(user);
      Set<RoleType> roles = new HashSet<RoleType>();
      for (Role role : userView.getPerson().getPersonRolesSet()) {
        roles.add(role.getRoleType());
      }
      setUserRoles(roles);
    } else {
      user = "******";
      requestBean = SupportRequestBean.generateExceptionBean(null);
    }
    exceptionInfo.append(user + "\n");
    return requestBean;
  }
 @Override
 public boolean isMember(User user) {
   if (user == null) {
     return false;
   }
   if (user.getPerson().getStudent() != null) {
     final Set<CompetenceCourse> competenceCourses = executionCourse.getCompetenceCourses();
     for (Registration registration : user.getPerson().getStudent().getRegistrationsSet()) {
       // students of any degree sharing the same competence of the given execution course
       for (StudentCurricularPlan studentCurricularPlan :
           registration.getStudentCurricularPlansSet()) {
         for (Enrolment enrolment : studentCurricularPlan.getEnrolmentsSet()) {
           CompetenceCourse competenceCourse =
               enrolment.getCurricularCourse().getCompetenceCourse();
           if (competenceCourses.contains(competenceCourse)) {
             return true;
           }
         }
       }
       // students attending the given execution course (most will be in the previous case but some
       // may not)
       if (registration.getAttendingExecutionCoursesFor().contains(executionCourse)) {
         return true;
       }
     }
   }
   return false;
 }
  public void execute(String executionDegreeID, List<SituationName> situationNames)
      throws NotAuthorizedException {

    User id = Authenticate.getUser();
    if ((id != null
            && id.getPerson().getPersonRolesSet() != null
            && !containsRoleType(id.getPerson().getPersonRolesSet()))
        || (id != null
            && id.getPerson().getPersonRolesSet() != null
            && !hasPrivilege(id, executionDegreeID))
        || (id == null)
        || (id.getPerson().getPersonRolesSet() == null)) {
      throw new NotAuthorizedException();
    }
  }
Esempio n. 4
0
  public ActionForward showTeacherCredits(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws NumberFormatException, FenixServiceException, ParseException {

    DynaActionForm teacherCreditsForm = (DynaActionForm) form;
    ExecutionSemester executionSemester =
        FenixFramework.getDomainObject((String) teacherCreditsForm.get("executionPeriodId"));

    Teacher requestedTeacher =
        FenixFramework.getDomainObject((String) teacherCreditsForm.get("teacherId"));

    User userView = Authenticate.getUser();
    Teacher loggedTeacher = userView.getPerson().getTeacher();

    if (requestedTeacher == null || loggedTeacher != requestedTeacher) {
      ActionMessages actionMessages = new ActionMessages();
      actionMessages.add("", new ActionMessage("message.invalid.teacher"));
      saveMessages(request, actionMessages);
      return mapping.findForward("teacher-not-found");
    }

    showLinks(request, executionSemester, RoleType.DEPARTMENT_MEMBER);
    getAllTeacherCredits(request, executionSemester, requestedTeacher);
    return mapping.findForward("show-teacher-credits");
  }
 @Override
 protected void process(final ActivityInformation<MissionProcess> activityInformation) {
   final User user = Authenticate.getUser();
   final Person person = user.getPerson();
   final MissionProcess missionProcess = activityInformation.getProcess();
   missionProcess.unAllocateFunds(person);
 }
Esempio n. 6
0
  @Override
  protected PhdThesisProcess executeActivity(
      PhdThesisProcess process, User userView, Object object) {

    final PhdThesisProcessBean bean = (PhdThesisProcessBean) object;

    if (bean.isToNotify()) {
      notifyJuryElements(process);
      sendAlertToJuryElement(
          process.getIndividualProgramProcess(),
          process.getPresidentJuryElement(),
          "message.phd.request.jury.reviews.external.access.jury.president.body");
    }

    if (process.getActiveState() != PhdThesisProcessStateType.WAITING_FOR_JURY_REPORTER_FEEDBACK) {
      process.createState(
          PhdThesisProcessStateType.WAITING_FOR_JURY_REPORTER_FEEDBACK, userView.getPerson(), "");
    }

    bean.setThesisProcess(process);
    if (process.getMeetingProcess() == null) {
      Process.createNewProcess(userView, PhdMeetingSchedulingProcess.class, bean);
    }

    return process;
  }
  public void execute(Summary summary, Professorship professorshipLogged)
      throws NotAuthorizedException {

    try {
      User userViewLogged = Authenticate.getUser();

      boolean executionCourseResponsibleLogged = professorshipLogged.isResponsibleFor();

      if (userViewLogged == null
          || userViewLogged.getPerson().getPersonRolesSet() == null
          || professorshipLogged == null) {
        throw new NotAuthorizedException("error.summary.not.authorized");
      }
      if (executionCourseResponsibleLogged
          && (summary.getProfessorship() != null
              && (!summary.getProfessorship().equals(professorshipLogged)))) {
        throw new NotAuthorizedException("error.summary.not.authorized");

      } else if (!executionCourseResponsibleLogged
          && (summary.getProfessorship() == null
              || (!summary.getProfessorship().equals(professorshipLogged)))) {
        throw new NotAuthorizedException("error.summary.not.authorized");
      }

    } catch (RuntimeException ex) {
      throw new NotAuthorizedException("error.summary.not.authorized");
    }
  }
  /**
   * @param id
   * @param argumentos
   * @return
   */
  private boolean hasPrivilege(User id, String executionDegreeID) {

    ExecutionDegree executionDegree = null;

    // Read The DegreeCurricularPlan
    try {

      executionDegree = FenixFramework.getDomainObject(executionDegreeID);

    } catch (Exception e) {
      return false;
    }

    if (executionDegree == null) {
      return false;
    }

    if (id.getPerson().hasRole(RoleType.MASTER_DEGREE_ADMINISTRATIVE_OFFICE)) {
      if (executionDegree
          .getDegreeCurricularPlan()
          .getDegree()
          .getDegreeType()
          .equals(DegreeType.MASTER_DEGREE)) {

        return true;
      }
      return false;
    }

    if (id.getPerson().hasRole(RoleType.COORDINATOR)) {
      // modified by Tânia Pousão
      Collection<Coordinator> coodinatorsList = executionDegree.getCoordinatorsListSet();
      if (coodinatorsList == null) {
        return false;
      }
      Iterator<Coordinator> listIterator = coodinatorsList.iterator();
      while (listIterator.hasNext()) {
        Coordinator coordinator = listIterator.next();

        if (coordinator.getPerson() == id.getPerson()) {
          return true;
        }
      }
    }
    return false;
  }
 @Atomic
 public void createNewPeriod() {
   final User userView = Authenticate.getUser();
   if (userView != null && RoleType.MANAGER.isMember(userView.getPerson().getUser())) {
     if (title != null && title.hasContent() && start != null && end != null) {
       new GenericApplicationPeriod(title, description, start, end);
     }
   }
 }
 @Override
 public boolean isMember(User user) {
   if (user == null || user.getPerson().getCoordinatorsSet().isEmpty()) {
     return false;
   }
   for (Coordinator coordinator : user.getPerson().getCoordinatorsSet()) {
     ExecutionDegree executionDegree = coordinator.getExecutionDegree();
     if (executionDegree.getExecutionYear().isCurrent()) {
       if (degreeType != null && degreeType != executionDegree.getDegree().getDegreeType()) {
         continue;
       }
       if (degree != null && !executionDegree.getDegree().equals(degree)) {
         continue;
       }
       return true;
     }
   }
   return false;
 }
 public SortedSet<OutboundMobilityCandidacyContestGroup> getCandidacyContestGroupSet(
     final OutboundMobilityCandidacyPeriod period) {
   final User user = Authenticate.getUser();
   if (AcademicAuthorizationGroup.get(AcademicOperationType.MANAGE_MOBILITY_OUTBOUND)
       .isMember(user)) {
     return period.getOutboundMobilityCandidacyContestGroupSet();
   }
   final SortedSet<OutboundMobilityCandidacyContestGroup> result =
       new TreeSet<OutboundMobilityCandidacyContestGroup>();
   if (user != null && user.getPerson() != null) {
     for (final OutboundMobilityCandidacyContestGroup group :
         user.getPerson().getOutboundMobilityCandidacyContestGroupSet()) {
       if (hasContestForPeriod(period, group)) {
         result.add(group);
       }
     }
   }
   return result;
 }
Esempio n. 12
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 static boolean isAllowedToManageProcess(
      DegreeChangeIndividualCandidacyProcess process, User userView) {
    Set<AcademicProgram> programs =
        AcademicAuthorizationGroup.getProgramsForOperation(
            userView.getPerson(), AcademicOperationType.MANAGE_INDIVIDUAL_CANDIDACIES);

    if (process == null || process.getCandidacy() == null) {
      return false;
    }

    return programs.contains(process.getCandidacy().getSelectedDegree());
  }
Esempio n. 14
0
  public static Set<Sender> getAvailableSenders() {
    final User userView = Authenticate.getUser();

    final Set<Sender> senders = new TreeSet<Sender>(Sender.COMPARATOR_BY_FROM_NAME);
    for (final Sender sender : Bennu.getInstance().getUtilEmailSendersSet()) {
      if (sender.getMembers().isMember(userView)
          || (userView != null && userView.getPerson().hasRole(RoleType.MANAGER))) {
        senders.add(sender);
      }
    }

    return senders;
  }
Esempio n. 15
0
  @Override
  protected PhdProgramCandidacyProcess executeActivity(
      PhdProgramCandidacyProcess process, User userView, Object object) {
    final PhdProgramCandidacyProcessStateBean bean = (PhdProgramCandidacyProcessStateBean) object;
    process.createState(
        PhdProgramCandidacyProcessState.REJECTED, userView.getPerson(), bean.getRemarks());

    AlertService.alertAcademicOffice(
        process.getIndividualProgramProcess(),
        AcademicOperationType.VIEW_PHD_CANDIDACY_ALERTS,
        "message.phd.alert.candidacy.reject.subject",
        "message.phd.alert.candidacy.reject.body");

    return process;
  }
  public ActionForward showPaymentsForEvent(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    final Event event = getEvent(request);
    request.setAttribute("event", event);

    if (!StringUtils.isEmpty(event.getCreatedBy())) {
      User responsible = User.findByUsername(event.getCreatedBy());
      request.setAttribute("responsible", responsible.getPerson());
    }

    if (event.isOpen()) {
      request.setAttribute("entryDTOs", event.calculateEntries());
      request.setAttribute("accountingEventPaymentCodes", event.getNonProcessedPaymentCodes());
    }

    return mapping.findForward("showPaymentsForEvent");
  }
Esempio n. 17
0
  @Override
  protected PhdProgramCandidacyProcess executeActivity(
      PhdProgramCandidacyProcess process, User userView, Object object) {

    final PhdIndividualProgramProcess mainProcess = process.getIndividualProgramProcess();
    if (mainProcess.getPhdProgram() == null) {
      throw new DomainException(
          "error.phd.candidacy.PhdProgramCandidacyProcess.RequestCandidacyReview.invalid.phd.program");
    }

    final PhdProgramCandidacyProcessStateBean bean = (PhdProgramCandidacyProcessStateBean) object;
    process.createState(
        PhdProgramCandidacyProcessState.PENDING_FOR_COORDINATOR_OPINION,
        userView.getPerson(),
        bean.getRemarks());

    if (bean.getGenerateAlert()) {
      AlertService.alertCoordinators(mainProcess, subject(), body(mainProcess));
    }

    return process;
  }
 private boolean isVisible(PartyContact contact) {
   boolean publicSpace =
       true; // because this is a homepage. When this logic is exported to a more proper place
             // remember to pass this as an argument.
   if (!Authenticate.isLogged() && publicSpace && contact.getVisibleToPublic().booleanValue()) {
     return true;
   }
   if (Authenticate.isLogged()) {
     User user = Authenticate.getUser();
     Person reader = user.getPerson();
     if (reader.hasRole(RoleType.CONTACT_ADMIN).booleanValue()
         || reader.hasRole(RoleType.MANAGER).booleanValue()
         || reader.hasRole(RoleType.DIRECTIVE_COUNCIL).booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.EMPLOYEE).booleanValue()
         && contact.getVisibleToEmployees().booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.TEACHER).booleanValue()
         && contact.getVisibleToTeachers().booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.STUDENT).booleanValue()
         && contact.getVisibleToStudents().booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.ALUMNI).booleanValue()
         && contact.getVisibleToAlumni().booleanValue()) {
       return true;
     }
     if (contact.getVisibleToPublic()) {
       return true;
     }
   }
   return false;
 }
Esempio n. 19
0
 @Override
 public boolean allows(User userView) {
   return isMember(userView == null ? null : userView.getPerson());
 }
 private Department getPersonDepartment() {
   final User userView = getUserView();
   final Person person = userView == null ? null : userView.getPerson();
   final Employee employee = person == null ? null : person.getEmployee();
   return employee == null ? null : employee.getCurrentDepartmentWorkingPlace();
 }
 @Override
 public boolean isMember(User user) {
   return user != null
       && user.getPerson() != null
       && !user.getPerson().getProfessorshipsSet().isEmpty();
 }
Esempio n. 22
0
 private static boolean isSelfPerson(Party person) {
   final User userView = Authenticate.getUser();
   return userView.getPerson() != null && userView.getPerson().equals(person);
 }
 @Override
 protected DegreeChangeIndividualCandidacyProcess executeActivity(
     DegreeChangeIndividualCandidacyProcess process, User userView, Object object) {
   process.rejectCandidacy(userView.getPerson());
   return process;
 }