public ActionForward enrollCourses(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
public ActionForward enrollCourses( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException {
	public ActionForward enrollCourses(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {		HttpSession session = request.getSession();		IUserView userView = (IUserView) session.getAttribute(SessionConstants.U_VIEW);		// retrieve the student information to fill the info 		// to be passed to the readShifts service		InfoStudent infoStudent = null;		infoStudent = (InfoStudent) ServiceUtils.executeService(userView, "ReadStudentByUsername", new Object[] { userView.getUtilizador()});		//Update the student's attending courses:		String[] wantedCourses = ((String[]) ((DynaActionForm) form).get("wantedCourse"));		boolean firstTime = request.getParameter("firstTime") != null;				if (wantedCourses != null && !firstTime) {			//Build up the arrayList			List newAttendingCourses = new ArrayList(wantedCourses.length);			for (int i = 0; i < wantedCourses.length; i++) {				newAttendingCourses.add(i, wantedCourses[i]);			} // end of for (int  = 0;  < ; ++)			Boolean attendenceChanged = (Boolean) (ServiceUtils.executeService(userView, "WriteStudentAttendingCourses", new Object[] { infoStudent, newAttendingCourses }));			if (!attendenceChanged.booleanValue()) {				System.out.println("Nao foi possivel actualizar as disciplinas do aluno");				throw new FenixActionException("Can't Change Degree Attending.");			}		}		// Retrieve the current executionYear to later get the existing degrees		InfoExecutionYear currentExecutionYear = (InfoExecutionYear) ServiceUtils.executeService(userView, "ReadCurrentExecutionYear", new Object[] {		});		// Retrieve the list of existing degrees		List degreeList = (List) ServiceUtils.executeService(userView, "ReadExecutionDegreesByExecutionYear", new Object[] { currentExecutionYear });		// get the student's own course to show first, if there is not one		// already selected		String selectedDegreeAbbrev = request.getParameter("degree");		InfoExecutionDegree selectedDegree = null, idtemp = null;		// if there is no selected degree		if (selectedDegreeAbbrev == null) {			// retrieve the student's own curricular plan			selectedDegreeAbbrev = ((InfoDegree) ServiceUtils.executeService(userView, "ReadCourseByStudent", new Object[] { infoStudent.getNumber(), infoStudent.getDegreeType()})).getSigla();		}		Iterator i = degreeList.iterator();		// we assume that the Abbrev ( sigla ) is unique amongst the degrees		while (i.hasNext()) {			idtemp = (InfoExecutionDegree) i.next();			if (idtemp.getInfoDegreeCurricularPlan().getInfoDegree().getSigla().equals(selectedDegreeAbbrev)) {				selectedDegree = idtemp;				i.remove();			}		}		if (selectedDegree == null) {			// didn't found the degree, doesn't exist. someone did a boo boo			throw new FenixActionException("Wrong Degree Selected. Please enroll in another college.");		} // end of if ()		// add to the beginning of the list the selected degree		degreeList.add(0, selectedDegree);		request.setAttribute("degreeList", degreeList);		InfoExecutionPeriod currentExecutionPeriod = (InfoExecutionPeriod) ServiceUtils.executeService(userView, "ReadCurrentExecutionPeriod", new Object[] {		});		// retrieve all courses pertaining to the selected degree		ArrayList infoExecutionCourses = new ArrayList();		for (int j = 1; j < 6; j++) {			infoExecutionCourses.addAll((List) ServiceUtils.executeService(userView, "SelectExecutionCourse", new Object[] { selectedDegree, currentExecutionPeriod, new Integer(j)}));		}		request.setAttribute("courseList", infoExecutionCourses);		// and finally retrieve all courses the student is currently enrolled in		List attendingCourses = (List) ServiceUtils.executeService(userView, "ReadDisciplinesByStudent", new Object[] { infoStudent.getNumber(), infoStudent.getDegreeType()});		request.setAttribute("wantedCourse", attendingCourses);		return mapping.findForward("selectCourses");	}