List of usage examples for java.util.logging Handler close
public abstract void close() throws SecurityException;
From source file:BSxSB.Controllers.AdminController.java
@RequestMapping(value = "/rejectaccount", method = RequestMethod.POST) public String rejectAccount(Model model, @RequestParam(value = "email") String email) { try {/*from ww w. j a v a2s. c om*/ //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBAdminStudentAccts.log"); logger.addHandler(handler); handler.setFormatter(new SimpleFormatter()); StudentDAO.deleteAccount(email); List<Students> accountrequests = StudentDAO.getAccountRequests(); model.addAttribute("accountrequests", accountrequests); logger.info("Successfully rejected: " + email); logger.info("Accounts successfully updated to model"); handler.close(); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "adminmanagerequests"; }
From source file:BSxSB.Controllers.AdminController.java
@RequestMapping(value = "/acceptallaccount", method = RequestMethod.POST) public String acceptAllAccount(Model model) { try {/*from w ww. j a v a 2 s. c o m*/ //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBAdminStudentAccts.log"); logger.addHandler(handler); handler.setFormatter(new SimpleFormatter()); StudentDAO.acceptAllAccount(); List<Students> accountrequests = StudentDAO.getAccountRequests(); model.addAttribute("accountrequests", accountrequests); logger.info("Successfully accepted all accounts"); logger.info("Accounts successfully updated to model"); handler.close(); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "adminmanagerequests"; }
From source file:BSxSB.Controllers.AdminController.java
@RequestMapping(value = "/acceptaccount", method = RequestMethod.POST) public String acceptAccount(Model model, @RequestParam(value = "email") String email) { try {/*from w w w. ja v a 2s. c om*/ //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBAdminStudentAccts.log"); logger.addHandler(handler); handler.setFormatter(new SimpleFormatter()); StudentDAO.acceptAccount(email); Students student = StudentDAO.getStudent(email); EmailNotification.sendEmail(student.getEmail(), student.getFirstname()); List<Students> accountrequests = StudentDAO.getAccountRequests(); model.addAttribute("accountrequests", accountrequests); logger.info("Successfully accepted: " + email); logger.info("Account successfully updated to model"); handler.close(); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "adminmanagerequests"; }
From source file:BSxSB.Controllers.AdminController.java
@RequestMapping(value = "/admineditscheduleblocks", method = RequestMethod.POST) public String editScheduleBlocks(Model model, @RequestParam(value = "schoolID") String schoolID) { try {/*from w ww. j av a 2s . c o m*/ //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBAdminScheduleBlocks.log", true); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); logger.info("Admin Viewing List of School's Schedule Blocks."); int schoolID2 = Integer.parseInt(schoolID); Schools school = SchoolDAO.getSchool(schoolID2); List<Scheduleblocks> sbs = ScheduleBlockDAO.getSchoolsScheduleBlocks(schoolID2); model.addAttribute("school", school); model.addAttribute("scheduleblocks", sbs); logger.info("School's schedule blocks successfully updated to model."); handler.close(); logger.removeHandler(handler); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "admineditscheduleblocks"; }
From source file:BSxSB.Controllers.AdminController.java
@RequestMapping(value = "/deleteschool", method = RequestMethod.POST) public String deleteSchool(Model model, @RequestParam(value = "schoolID") int schoolID) { SchoolDAO.deleteSchool(schoolID);//from w w w . j a v a2 s . c om try { //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBAdminSchools.log"); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); logger.info("Admin Viewing List of Schools."); SchoolDAO schoolDAO = new SchoolDAO(); ScheduleBlockDAO scheduleBlockDAO = new ScheduleBlockDAO(); List<Schools> schools = schoolDAO.allSchools(); logger.info("Returning list of schools..." + schools.size() + " schools found."); for (Schools school : schools) { List<Scheduleblocks> scheduleBlocks = scheduleBlockDAO .getSchoolsScheduleBlocks(school.getSchoolid()); String SB2Strings = ""; for (Scheduleblocks sb : scheduleBlocks) { SB2Strings += sb.toString(); } school.setScheduleblocks(SB2Strings); } model.addAttribute("school", schools); logger.info("Schools successfully added to model."); handler.close(); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "admin"; }
From source file:BSxSB.Controllers.AdminController.java
@RequestMapping(value = "/admin", method = RequestMethod.GET) public String adminPage(Model model) { try {// www . j a v a2 s.c o m Handler handler = new FileHandler("%tBSxSBAdminSchools.log", true); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); logger.info("Admin Viewing List of Schools."); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); Admins admin = AdminDAO.getAdmin(name); if (!admin.getLoggedin()) { AdminDAO.setLoggedIn(name); } SchoolDAO schoolDAO = new SchoolDAO(); ScheduleBlockDAO scheduleBlockDAO = new ScheduleBlockDAO(); List<Schools> schools = schoolDAO.allSchools(); for (Schools school : schools) { List<Scheduleblocks> scheduleBlocks = scheduleBlockDAO .getSchoolsScheduleBlocks(school.getSchoolid()); String SB2Strings = ""; for (Scheduleblocks sb : scheduleBlocks) { SB2Strings += sb.toString(); } school.setScheduleblocks(SB2Strings); } model.addAttribute("school", schools); logger.info("Schools successfully updated to model."); handler.close(); logger.removeHandler(handler); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "admin"; }
From source file:BSxSB.Controllers.AdminController.java
@RequestMapping(value = "/addscheduleblock", method = RequestMethod.POST) public String addScheduleBlock(Model model, @RequestParam(value = "schoolid") String schoolID, @RequestParam(value = "period") String period, @RequestParam(value = "days") String[] days) { try {//ww w . j a v a 2s. c o m //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBAdminScheduleBlocks.log", true); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); logger.info("Admin Viewing List of School's Schedule Blocks."); int schoolID2 = Integer.parseInt(schoolID); if (period.isEmpty() || days.length == 0) { model.addAttribute("sbempty", "A field is empty"); } int periodInt = Integer.parseInt(period); String daysString = ""; for (String x : days) { daysString += x; daysString += ","; } daysString = daysString.substring(0, daysString.length() - 1); Scheduleblocks sb = ScheduleBlockDAO.getScheduleBlock(schoolID2, periodInt, daysString); if (sb != null) { model.addAttribute("sbexists", "This scheduleblock exists"); logger.info("Error: SB exists"); } else { ScheduleBlockDAO.addScheduleBlock(schoolID2, periodInt, daysString); logger.info( "Scheduleblock with period " + periodInt + " and days " + daysString + " added to school."); } handler.close(); logger.removeHandler(handler); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return editScheduleBlocks(model, schoolID); }
From source file:BSxSB.Controllers.StudentController.java
@RequestMapping(value = "/submitassigned", method = RequestMethod.POST) public String submitAssigned(Model model, @RequestParam(value = "courseidentifier") String courseidentifier, @RequestParam(value = "coursename") String coursename, @RequestParam(value = "instructor") String instructor, @RequestParam(value = "semesters") String[] semesters, @RequestParam(value = "period") String period, @RequestParam(value = "days") String[] days) { try {/*from ww w . ja v a 2s . c o m*/ //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBStudentAssignedCourses.log", true); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); if (coursename.isEmpty() || instructor.isEmpty() || semesters[0].matches("noinput") || period.isEmpty() || days[0].matches("noinput")) { model.addAttribute("fieldempty", "Please fill out all required fields."); logger.info("Error: Fields are empty"); handler.close(); logger.removeHandler(handler); return enterCourses(model); } Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); Students currentStudent = StudentDAO.getStudent(name); int schoolid = currentStudent.getSchoolid(); //Build the semester string String semString = ""; for (int i = 0; i < semesters.length - 1; i++) { semString += semesters[i]; semString += ","; } //Get rid of last ',' semString = semString.substring(0, semString.length() - 1); //Build the scheduleblock days String daysString = ""; for (int i = 0; i < days.length - 1; i++) { daysString += days[i]; daysString += ","; } daysString = daysString.substring(0, daysString.length() - 1); int periodInt = Integer.parseInt(period); Scheduleblocks sb = ScheduleBlockDAO.getScheduleBlock(schoolid, periodInt, daysString); if (sb == null) { model.addAttribute("sbinvalid", "Scheduleblock provided is invalid."); logger.info("Error: The chosen scheduleblock does not exist for this school"); // return error msg } else { Courses c = CourseDAO.getCourse(courseidentifier, coursename, sb.getScheduleblockid(), schoolid, instructor, semString); if (c != null) { if (RegistrationDAO.isRegistered(c, currentStudent)) { model.addAttribute("alreadyreg", "You are already registered for this course"); logger.info("Error: already registered for this course"); } else { RegistrationDAO.addRegistration(c.getCourseid(), currentStudent.getStudentid()); CourseDAO.incrementCourseStudents(c.getCourseid()); model.addAttribute("halfsuccess", "Course already exists, you have been successfully added to the course roster."); logger.info("Course exists and student has been added to roster"); } } else { int sbid = sb.getScheduleblockid(); Courses newCourse = new Courses(schoolid, coursename, courseidentifier, instructor, sbid, semString); newCourse.setNumstudents(1); int studentid = currentStudent.getStudentid(); CourseDAO.addCourse(newCourse, studentid); model.addAttribute("success", "New course successfully added."); logger.info("Course " + courseidentifier + " " + coursename + " successfully added"); } } Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid()); List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname()); model.addAttribute("schoolyears", schoolyears); model.addAttribute("numSemesters", currentSchool.getNumsemesters()); model.addAttribute("numPeriods", currentSchool.getNumperiods()); model.addAttribute("numDays", currentSchool.getNumdays()); handler.close(); logger.removeHandler(handler); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "studententercourses"; }
From source file:BSxSB.Controllers.StudentController.java
@RequestMapping(value = "/unfriend", method = RequestMethod.POST) public String unfriend(Model model, @RequestParam(value = "id") int id) { try {//from w w w . j a v a 2 s.c o m //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBStudentFriends.log", true); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); Students currentStudent = StudentDAO.getStudent(name); FriendshipsDAO.deletefriend(currentStudent.getStudentid(), id); logger.info("Successfully deleted friendship between " + currentStudent.getStudentid() + " and " + id); List<Students> friends = StudentDAO.getFriends(currentStudent.getStudentid()); Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid()); List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname()); model.addAttribute("schoolyears", schoolyears); model.addAttribute("friends", friends); logger.info("Friends updated to model."); handler.close(); logger.removeHandler(handler); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "studentdisplayfriends"; }
From source file:BSxSB.Controllers.StudentController.java
@RequestMapping(value = "/acceptfriend", method = RequestMethod.POST) public String acceptfriend(Model model, @RequestParam(value = "id") int id) { try {//from w ww .j a v a2 s .c o m //Initialize the file that the logger writes to. Handler handler = new FileHandler("%tBSxSBStudentFriends.log", true); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); Students currentStudent = StudentDAO.getStudent(name); FriendshipsDAO.acceptfriend(currentStudent.getStudentid(), id); logger.info("Approved friendship between " + currentStudent.getStudentid() + " and " + id); List<Students> friendrequests = StudentDAO.getFriendRequests(currentStudent.getStudentid()); Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid()); List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname()); model.addAttribute("schoolyears", schoolyears); model.addAttribute("friendrequests", friendrequests); logger.info("Friend requests updated to model."); handler.close(); logger.removeHandler(handler); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { logger.log(Level.SEVERE, null, ex); } return "studentmanagefriends"; }