public void loadSchoolFeed(@RequestParam Long schoolId)
throws ParserConfigurationException, SAXException, IOException, Exception {
LOGGER.info("Updating school with id: " + schoolId);
Provider provider = null;
School school = null;
Dump dump = null;
CronTaskReport report = null;
try {
school = schoolService.getSchool(schoolId, null);
LOGGER.info("School name: " + school.getName());
provider = providerService.getProviderById(school.getProvider(), null);
//school = schoolService.getSchool(schoolId, null);
dump = dumpService.getLastDumpByOwner(school.getProvider());
report = cronTaskReportService.create();
report.setObject_id(school.getProvider());
report.setDate(new Date());
report.setType(CronTaskReport.TYPE.PROVIDER_SCHOOLS);
report.setDescription(new StringBuffer("School: ").append(provider.getName()).toString());
int retries = 1;
boolean errors = false;
StringBuffer errorsSb = new StringBuffer();
while(retries > 0) {
try {
providerImporter.importCourses(provider, school, dump);
retries = -1; // Break the loop
} catch(Exception e) {
LOGGER.severe(StackTraceUtil.getStackTrace(e));
LOGGER.info("" + retries + " Fail importing courses: "+school.getName() );
retries--;
if(!(retries > 0)) {
errors = true;
errorsSb.append(school.getName()).append(" -> ").append(e.getCause()).append("\n");
LOGGER.severe(StackTraceUtil.getStackTrace(e));
}
}
}