if (from == null || from.length() == 0) { ActionErrors actionErrors = new ActionErrors(); actionErrors.add("error.from.address.cannot.be.null", new ActionError("error.from.address.cannot.be.null")); saveErrors(request, actionErrors); return prepare(mapping, form, request, response); }
    public ActionForward send(ActionMapping mapping, ActionForm form, HttpServletRequest request,            HttpServletResponse response) throws FenixActionException, FenixServiceException,            FenixFilterException {        HttpSession session = this.getSession(request);        IUserView userView = (IUserView) session.getAttribute(SessionConstants.U_VIEW);        Integer objectCode = null;        Integer shiftID = null;        Integer groupCode = null;        String from = request.getParameter("from");        String fromName = request.getParameter("fromName");        String text = request.getParameter("text");        String subject = request.getParameter("subject");        if (request.getParameter("candidaciesSend") != null                && request.getParameter("candidaciesSend").equals("true")) {            return this.sendMailCandidacies(mapping, form, request, response);        }        try {            groupCode = new Integer(request.getParameter("studentGroupCode"));        } catch (NumberFormatException ex) {            // ok, we don't want to view a group's student list        }        try {            shiftID = new Integer(request.getParameter("shiftCode"));        } catch (NumberFormatException ex) {            // ok, we don't want to view a shift's student list        }        String objectCodeString = request.getParameter("objectCode");        if (objectCodeString == null) {            objectCodeString = (String) request.getAttribute("objectCode");        }        objectCode = new Integer(objectCodeString);        Object args[] = { objectCode, null };        TeacherAdministrationSiteView siteView = null;        InfoSiteStudents infoSiteStudents = null;        List groupStudents = null;        List shiftStudents = null;        List failedEmails = null;        siteView = (TeacherAdministrationSiteView) ServiceManagerServiceFactory.executeService(userView,                "ReadStudentsByCurricularCourse", args);        infoSiteStudents = (InfoSiteStudents) siteView.getComponent();        if (shiftID != null) {            // the objectCode is needed by the filter...doing this is            // awfull !!!            // please read            // http://www.dcc.unicamp.br/~oliva/fun/prog/resign-patterns            Object[] argsReadShiftStudents = { objectCode, shiftID };            shiftStudents = (List) ServiceManagerServiceFactory.executeService(userView,                    "teacher.ReadStudentsByShiftID", argsReadShiftStudents);            infoSiteStudents.setStudents(shiftStudents);        }        if (groupCode != null) {            Object[] argsReadGroupStudents = { objectCode, groupCode };            groupStudents = (List) ServiceManagerServiceFactory.executeService(userView,                    "teacher.ReadStudentsByStudentGroupID", argsReadGroupStudents);            infoSiteStudents.setStudents(groupStudents);        }        Collections.sort(infoSiteStudents.getStudents(), new BeanComparator("number"));        //        // and finnaly, let us send the emaaaaaaaails !        //        List bccList = new LinkedList();        List toList = new LinkedList();        toList.add(from);        List ccList = new LinkedList();        for (Iterator iter = infoSiteStudents.getStudents().iterator(); iter.hasNext();) {            InfoStudent infoStudent = (InfoStudent) iter.next();            bccList.add(infoStudent.getInfoPerson().getEmail());        }        Object[] argsSendMails = { toList, ccList, bccList, fromName, from, subject, text };        failedEmails = (List) ServiceManagerServiceFactory.executeService(userView, "commons.SendMail",                argsSendMails);        getFailedMails(request, infoSiteStudents.getStudents(), failedEmails);        return mapping.findForward("mailSent");    }