} catch (InterceptingLessonException ex) { actionErrors.add("error.intercepting.lesson", new ActionError("error.intercepting.lesson")); saveErrors(request, actionErrors); return mapping.getInputForward();
    public ActionForward createLesson(ActionMapping mapping, ActionForm form,            HttpServletRequest request, HttpServletResponse response) throws Exception {        DynaActionForm manageLessonForm = (DynaActionForm) form;        request.setAttribute("manageLessonForm", manageLessonForm);        ContextUtils.setExecutionPeriodContext(request);        DiaSemana weekDay = new DiaSemana(new Integer(formDay2EnumerateDay((String) manageLessonForm                .get("diaSemana"))));        Boolean quinzenal = (Boolean) manageLessonForm.get("quinzenal");        if (quinzenal == null) {            quinzenal = new Boolean(false);        }        Calendar inicio = Calendar.getInstance();        inicio.set(Calendar.HOUR_OF_DAY, Integer.parseInt((String) manageLessonForm.get("horaInicio")));        inicio.set(Calendar.MINUTE, Integer.parseInt((String) manageLessonForm.get("minutosInicio")));        inicio.set(Calendar.SECOND, 0);        Calendar fim = Calendar.getInstance();        fim.set(Calendar.HOUR_OF_DAY, Integer.parseInt((String) manageLessonForm.get("horaFim")));        fim.set(Calendar.MINUTE, Integer.parseInt((String) manageLessonForm.get("minutosFim")));        fim.set(Calendar.SECOND, 0);        InfoRoom infoSala = new InfoRoom();        infoSala.setNome((String) manageLessonForm.get("nomeSala"));        ActionErrors actionErrors = checkTimeIntervalAndWeekDay(inicio, fim, weekDay);        if (actionErrors.isEmpty()) {            InfoRoom infoRoom = new InfoRoom();            infoRoom.setCapacidadeNormal(new Integer(0));            infoRoom.setCapacidadeExame(new Integer(0));            InfoLesson infoLesson = new InfoLesson();            infoLesson.setDiaSemana(weekDay);            infoLesson.setInicio(inicio);            infoLesson.setFim(fim);            InfoShift infoShift = (InfoShift) (request.getAttribute(SessionConstants.SHIFT));            infoLesson.setInfoShift(infoShift);            infoLesson.setTipo(infoShift.getTipo());            infoLesson.setInfoSala(infoSala);            InfoRoomOccupation infoRoomOccupation = new InfoRoomOccupation();            infoRoomOccupation.setDayOfWeek(weekDay);            infoRoomOccupation.setEndTime(fim);            infoRoomOccupation.setStartTime(inicio);            infoRoomOccupation.setInfoRoom(infoSala);            if (quinzenal.booleanValue()) {                infoRoomOccupation.setFrequency(RoomOccupation.QUINZENAL);                if (manageLessonForm.get("week") == null || manageLessonForm.get("week").equals("")) {                    ActionError actionError = new ActionError("errors.emptyField.checkBoxTrue");                    ActionErrors newActionErrors = new ActionErrors();                    newActionErrors.add("errors.emptyField.checkBoxTrue", actionError);                    saveErrors(request, newActionErrors);                    return prepareCreate(mapping, form, request, response);                }                infoRoomOccupation.setWeekOfQuinzenalStart(new Integer(Integer                        .parseInt((String) manageLessonForm.get("week"))));            } else {                infoRoomOccupation.setFrequency(RoomOccupation.SEMANAL);            }            InfoExecutionPeriod infoExecutionPeriod = (InfoExecutionPeriod) request                    .getAttribute(SessionConstants.EXECUTION_PERIOD);            InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) request                    .getAttribute(SessionConstants.EXECUTION_DEGREE);            InfoPeriod infoPeriod = null;            if (infoExecutionPeriod.getSemester().equals(new Integer(1))) {                infoPeriod = infoExecutionDegree.getInfoPeriodLessonsFirstSemester();            } else {                infoPeriod = infoExecutionDegree.getInfoPeriodLessonsSecondSemester();            }            infoRoomOccupation.setInfoPeriod(infoPeriod);            infoLesson.setInfoRoomOccupation(infoRoomOccupation);            Object args[] = { infoLesson, infoShift };            try {                ServiceUtils.executeService(SessionUtils.getUserView(request), "CreateLesson", args);            } catch (CreateLesson.InvalidLoadException ex) {                if (ex.getMessage().endsWith("REACHED")) {                    actionErrors.add("errors.shift.hours.limit.reached", new ActionError(                            "errors.shift.hours.limit.reached"));                } else {                    actionErrors.add("errors.shift.hours.limit.exceeded", new ActionError(                            "errors.shift.hours.limit.exceeded"));                }                saveErrors(request, actionErrors);                return mapping.getInputForward();            }            return mapping.findForward("EditShift");        }        saveErrors(request, actionErrors);        return mapping.getInputForward();    }