|
From: Michael K. <ko...@us...> - 2006-10-05 17:57:59
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29495/de/tum/cobricks/univis Modified Files: UnivIS.java Log Message: Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- UnivIS.java 30 May 2006 14:32:00 -0000 1.55 +++ UnivIS.java 5 Oct 2006 17:57:49 -0000 1.56 @@ -35,29 +35,30 @@ import java.io.IOException; import java.io.InputStreamReader; import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.auth.AuthScope; +import org.apache.commons.httpclient.methods.PostMethod; import org.cobricks.core.util.LogUtil; /** * Class for handling UnivIS response. The response returned from UnivIS is * in XML-format. This class implement also the doSynchronize method which * will be used to synchronize UnivIS with Cobricks.<p> - * ------------------------------------------------------------------------- - * To excute this class one have to set the following properties in + * + * To excute this class one has to set the following properties in * conf/localproperties.txt file :<br> * # Proxyeinstellungen <br> * http.proxy.host=myProxyhost <br> * http.proxy.port=myProxyPort<br> - *-------------------------------------------------------------------------- + * * # Properties for univIS <br> * univis.user=myLoggin <br> * univis.pw=myPassword<br> * univis.host=univis.tu-muenchen.de <br> * univis.url=http://univis.tu-muenchen.de/prg <br> - * -------------------------------------------------------------------------- + * * @author <a href="mailto:ma...@in...">Mazan Abdelkader</a> * @version $Date$ */ @@ -93,9 +94,11 @@ httpClient= new HttpClient(); //set the Authencation - httpClient.getState().setAuthenticationPreemptive(true); - Credentials defaultcreds = new UsernamePasswordCredentials(univISUser, univISPWD); - httpClient.getState().setCredentials(null, hostName, defaultcreds); + httpClient.getParams().setAuthenticationPreemptive(true); + Credentials defaultcreds = + new UsernamePasswordCredentials(univISUser, univISPWD); + httpClient.getState().setCredentials(new AuthScope(hostName, 80), + defaultcreds); //get the Host Configuration and set the proxy String proxyHost= properties.getProperty("http.proxy.host"); String proxyPort= properties.getProperty("http.proxy.port"); |
|
From: Michael K. <ko...@us...> - 2006-12-18 16:39:11
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21447/de/tum/cobricks/univis Modified Files: UnivIS.java Log Message: Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- UnivIS.java 15 Dec 2006 23:06:32 -0000 1.57 +++ UnivIS.java 18 Dec 2006 16:39:03 -0000 1.58 @@ -127,7 +127,7 @@ String term = univISSync.getTerm(); uparser.parseXmlResponse(xmlresponse, univISSync); if(univISSync.modeIs("univISmaster")){ - try{ + try { // handel deleted courses in UnivIS // get all Cobricks courses for the sync Parameters. //String cterm = univISSync.getTerm(); @@ -153,11 +153,13 @@ CourseModule cm = c.getCourseModule(); int cmid = cm.getId(); if(univISSync.shouldLog("change")){ - univISSync.log("Deleting course \""+c.getName()+"" + univISSync.log("Deleting course \"" + +c.getName()+"" + "\" from Cobricks..."); } courseManager.deleteCourse(cid, new User()); - courseManager.deleteLecturersFromCourse(cid, new User()); + courseManager. + deleteLecturersFromCourse(cid, new User()); courseManager.deleteCourseProgramsForModule(cmid); } } @@ -169,8 +171,8 @@ UnivISLecture ul = (UnivISLecture)it.next(); String univISId = ul.getUnivISId(); if (univISSync.shouldLog("compare")) { - univISSync.log("Comparing univIS with cobricks for course " + - "\""+ul.getName()+"\"" ); + univISSync.log("Comparing univIS with cobricks for " + +"course \""+ul.getName()+"\"" ); } // get Cobricks course for univISId = cextid Course course = courseManager.getCourseForExtId(univISId); @@ -183,8 +185,8 @@ "\""+course.getName()+"\" ..."); } updateCourse(ul, cid, univISSync); - // get lecturers for ul and update with them the lecturers - // for course + // get lecturers for ul and update with them the + // lecturers for course List lecturersIds = ul.getDozIds(); updateCourseLecturers(lecturersIds, cid, univISSync); Map terms = ul.getTerms(); @@ -196,8 +198,8 @@ // there is no course with the given cextid= univISId, // so insert it in to cobricks. if (univISSync.shouldLog("change")){ - univISSync.log("Inserting course \""+ul.getName()+"\"" + - " into cobriks..."); + univISSync.log("Inserting course \""+ul.getName() + +"\" into cobriks..."); } int cid = insertLectureIntoCobricks(ul, term, univISSync); List lecturersIds = ul.getDozIds(); @@ -211,8 +213,8 @@ } catch(Exception e) { - logger.error(LogUtil.ex("Failed synchronizing univIS with cobricks, " + - "master is univIS.",e)); + logger.error(LogUtil.ex("Failed synchronizing UnivIS with " + +"Cobricks, master is UnivIS.",e)); if(univISSync.shouldLog("error")) { univISSync.log("Failed synchronizing univIS with cobricks, " + "master is univIS: "+e.toString()); @@ -228,11 +230,13 @@ String lfirstname = univISSync.getLecturerFirstName(); String cplabel = univISSync.getProgram(); // TBD: organisation number is not used - List list = courseManager.getCourses(cterm, llastname, lfirstname, cplabel); + List list = courseManager. + getCourses(cterm, llastname, lfirstname, cplabel); if(list.size() == 0){ - univISSync.log("There is no new courses in Cobricks ..."); + univISSync.log("There are no new courses in Cobricks ..."); } - // check which courses have been inserted or updated in Cobricks + // check which courses have been inserted or updated + // in Cobricks Iterator it = list.listIterator(); while(it.hasNext()){ Course course =(Course)it.next(); @@ -240,59 +244,67 @@ String cextid = course.getExtId(); Date clastupdate = course.getLastUpdate(); - if(cextid == null || clastrep == null){ + if(cextid == null || clastrep == null) { - //course is new in cobricks, so insert it in univIS + // course is new in cobricks, so insert it in univIS logger.info("Inserting lecture into UnivIS"); if(univISSync.shouldLog("change")){ - univISSync.log("Inserting lecture\""+course.getName()+"\"" + + univISSync.log("Inserting lecture\"" + +course.getName()+"\"" + " into univIS..."); } - String univISId = insertLectureIntoUnivIS(course, univISSync); + String univISId = + insertLectureIntoUnivIS(course, univISSync); // update the cextid and cextlastrep in course Map attrs = new HashMap(); attrs.put("cextid", univISId); attrs.put("cextlastrep", new Date()); courseManager.updateCourseAttrs(course.getId(), attrs); - }else if (clastrep != null && clastrep.before(clastupdate)) { + } else if (clastrep != null && + clastrep.before(clastupdate)) { logger.info("Updating UnivIS ..."); - //so update univIS + // so update univIS if(univISSync.shouldLog("change")){ univISSync.log("Updating UnivIS for course\"" + " "+course.getName()+"\"..."); } String univISId = updateUnivIS(course, univISSync); - //update the cextid and cextlastrep in course + // update the cextid and cextlastrep in course Map attrs = new HashMap(); attrs.put("cextid", univISId); attrs.put("cextlastrep", new Date()); courseManager.updateCourseAttrs(course.getId(), attrs); } - } - // check which courses have been deleted in Cobricks (and should be - // deleted in UnivIS + // check which courses have been deleted in Cobricks + // (and should be deleted in UnivIS) List lectures = uparser.getLectures(); Iterator it1 = lectures.listIterator(); - while(it1.hasNext()){ + while (it1.hasNext()){ UnivISLecture ul = (UnivISLecture)it1.next(); String univISId = ul.getUnivISId(); + // ignore lectures from other faculties + if (!univISId.startsWith("Lecture/in")) + continue; Course c = courseManager.getCourseForExtId(univISId); - if(c == null){ + if (c == null){ deleteLectureFromUnivIS(ul, univISSync); if (univISSync.shouldLog("change")){ univISSync.log("Deleting course \"" - + ""+ul.getName()+"\" from UnivIS ..."); + + ""+ul.getName() + +"\" from UnivIS ..."); } } } } catch (Exception e) { - logger.error(LogUtil.ex("Failed synchronizing univIS with cobricks, " - +"master is cobricks.", e)); + logger.error(LogUtil. + ex("Failed synchronizing UnivIS with Cobricks, " + +"master is cobricks.", e)); if (univISSync.shouldLog("error")){ - univISSync.log("Failed synchronizing univIS with cobricks, " - +"master is cobricks : "+e.toString()); + univISSync.log("Failed synchronizing UnivIS with " + +"Cobricks, master is cobricks : " + +e.toString()); } } @@ -316,8 +328,8 @@ Date cextlastrep = c1.getLastReplication(); Date cextastupdate = c1.getLastUpdate(); - // check which courses have been deleted in UnivIS and should - // be deleted in cobricks + // check which courses have been deleted in UnivIS and + // should be deleted in cobricks if(id != null){ UnivISLecture ul = uparser.getLectureForId(id); @@ -331,18 +343,23 @@ CourseModule cm = c1.getCourseModule(); int cmid = cm.getId(); if(univISSync.shouldLog("change")){ - univISSync.log("Deleting course \""+c1.getName()+"" + univISSync.log("Deleting course \"" + +c1.getName()+"" + "\" from Cobricks..."); } courseManager.deleteCourse(cid, new User()); - courseManager.deleteLecturersFromCourse(cid, new User()); + courseManager. + deleteLecturersFromCourse(cid, new User()); courseManager.deleteCourseProgramsForModule(cmid); - }else if (ul != null && cextlastrep != null && (cextlastrep.before(cextastupdate))){ - // course has been changed after the last replication, - // so update UnivIS + } else if (ul != null && cextlastrep != null && + (cextlastrep.before(cextastupdate))){ + // course has been changed after the last + // replication, so update UnivIS if (univISSync.shouldLog("change")){ - univISSync.log("Updating UnivIS for course \"" + ""+c1.getName()+"\" ..."); + univISSync.log("Updating UnivIS for " + +"course \"" + +""+c1.getName()+"\" ..."); } String univISId = updateUnivIS(c1, univISSync); wasUnivISUpdated = true; @@ -352,22 +369,24 @@ attrs.put("cextlastrep", new Date()); courseManager.updateCourseAttrs(c1.getId(), attrs); } - }else if(id == null || cextlastrep == null){ + } else if(id == null || cextlastrep == null){ // course is new in Cobricks, so insert it in UnivIS - if(univISSync.shouldLog("change")){ - univISSync.log("Inserting course \""+c1.getName()+"" + if (univISSync.shouldLog("change")) { + univISSync.log("Inserting course \"" + +c1.getName()+"" + "\" into univIS..."); } - String univISId = insertLectureIntoUnivIS(c1, univISSync); + String univISId = + insertLectureIntoUnivIS(c1, univISSync); // update the cextid and cextlastrep in course Map attrs = new HashMap(); attrs.put("cextid", univISId); attrs.put("cextlastrep", new Date()); courseManager.updateCourseAttrs(c1.getId(), attrs); - }/*else if (cextlastrep != null && (cextlastrep.before(cextastupdate))){ + } /*else if (cextlastrep != null && (cextlastrep.before(cextastupdate))){ // course has been changed after the last replication, // so update UnivIS |
|
From: Michael K. <ko...@us...> - 2007-01-12 09:33:05
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22532/de/tum/cobricks/univis Modified Files: UnivIS.java Log Message: Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- UnivIS.java 10 Jan 2007 06:54:34 -0000 1.60 +++ UnivIS.java 12 Jan 2007 09:32:24 -0000 1.61 @@ -25,6 +25,7 @@ import org.cobricks.course.CourseManager; import org.cobricks.course.CoursePresenter; import org.apache.log4j.Logger; +import java.util.ArrayList; import java.util.Properties; import java.util.List; import java.text.SimpleDateFormat; @@ -351,7 +352,7 @@ if (list.size() == 0) { univISSync.log("There are no matching courses in Cobricks ..."); } - + // check which courses have been inserted or updated // in Cobricks Iterator it = list.listIterator(); @@ -2242,6 +2243,7 @@ { if (course == null) return null; String lgroup = courseManager.getGroupForCourse(course.getId()); + if (lgroup == null) lgroup = ""; String result = ""; if (lgroup.equals("infor1")) { result = "in/infor/infor1"; |
|
From: Michael K. <ko...@us...> - 2007-01-18 13:05:55
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19910/de/tum/cobricks/univis Modified Files: UnivIS.java Log Message: Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- UnivIS.java 12 Jan 2007 09:32:24 -0000 1.61 +++ UnivIS.java 18 Jan 2007 13:05:20 -0000 1.62 @@ -176,7 +176,7 @@ univISSync.log("There are no new courses in Cobricks ..."); } Iterator it1 = list.listIterator(); - while(it1.hasNext()){ + while (it1.hasNext()) { Course c1 = (Course)it1.next(); String id = c1.getExtId(); Date cextlastrep = c1.getLastReplication(); @@ -234,11 +234,13 @@ } String univISId = insertLectureIntoUnivIS(c1, univISSync); - // update the cextid and cextlastrep in course - Map attrs = new HashMap(); - attrs.put("cextid", univISId); - attrs.put("cextlastrep", new Date()); - courseManager.updateCourseAttrs(c1.getId(), attrs); + if (univISId!=null && univISId.length()>0) { + // update the cextid and cextlastrep in course + Map attrs = new HashMap(); + attrs.put("cextid", univISId); + attrs.put("cextlastrep", new Date()); + courseManager.updateCourseAttrs(c1.getId(), attrs); + } } /*else if (cextlastrep != null && (cextlastrep.before(cextastupdate))){ @@ -374,12 +376,13 @@ } String univISId = insertLectureIntoUnivIS(course, univISSync); - - // update the cextid and cextlastrep in course - Map attrs = new HashMap(); - attrs.put("cextid", univISId); - attrs.put("cextlastrep", new Date()); - courseManager.updateCourseAttrs(course.getId(), attrs); + if (univISId!=null && univISId.length()>0) { + // update the cextid and cextlastrep in course + Map attrs = new HashMap(); + attrs.put("cextid", univISId); + attrs.put("cextlastrep", new Date()); + courseManager.updateCourseAttrs(course.getId(), attrs); + } } else if (clastrep != null && clastrep.before(clastupdate)) { @@ -618,6 +621,13 @@ String tmps = s.substring(pos+21, pos2); return tmps; } + pos = s.indexOf("<h3>Fehler:</h3>"); + if (pos > -1) { + int pos2 = s.indexOf("<ul>", pos); + int pos3 = s.indexOf("</ul>", pos); + String tmps = s.substring(pos2+4, pos3); + return tmps; + } return ""; } @@ -835,12 +845,13 @@ //get dtype for course with cid Course c = null; String dtype = "0"; - try{ + try { c = courseManager.getCourse(cid); - }catch(Exception e){ - logger.error(LogUtil.ex("Failed Inserting date, course not found", e)); + } catch (Exception e) { + logger.error(LogUtil.ex("Failed Inserting date, " + +"course not found", e)); } - if(c != null){ + if (c != null) { CourseModule ctp = c.getCourseModule(); if(ctp != null){ String cttyp = ctp.getType(); @@ -1431,6 +1442,12 @@ univISSync.log("UnivIS request failed: "+err); return null; } + if (responsemsg.indexOf("<h3>Fehler:</h3>")>0) { + String err = getErrorFromUnivISResponse(responsemsg); + logger.error("UnivIS request failed: "+err); + univISSync.log("UnivIS request failed: "+err); + return null; + } int index = responsemsg.indexOf("name=\"done-lecture/edit:ignore\""); if(index > -1) { @@ -1518,6 +1535,12 @@ logger.error("UnivIS request failed: "+err); univISSync.log("UnivIS request failed: "+err); } + if (responsemsg.indexOf("<h3>Fehler:</h3>")>0) { + String err = getErrorFromUnivISResponse(responsemsg); + logger.error("UnivIS request failed: "+err); + univISSync.log("UnivIS request failed: "+err); + return null; + } } catch(Exception e) { logger.error(LogUtil.ex("Failed connect to univIS.",e)); if(univISSync.shouldLog("error")){ @@ -1724,9 +1747,16 @@ post.addParameter("ects_literature", ""); post.addParameter("keywords", ""); - if(course.getUrl() != null){ - post.addParameter("url_description", course.getUrl()); - }else{ + if (course.getUrl() != null) { + String tmps2 = course.getUrl(); + // check if this is a valid url ... + post.addParameter("url_description", ""); + if (tmps2.indexOf(":")>-1) { + if (tmps2.indexOf("/")>-1) { + post.addParameter("url_description", tmps); + } + } + } else { post.addParameter("url_description", ""); } @@ -1811,7 +1841,7 @@ // get terms List terms = courseManager.getCourseDates(course.getId()); - if(!terms.isEmpty()){ + if (!terms.isEmpty()) { Iterator it3 = terms.listIterator(); int counter3 = 0; while (it3.hasNext()){ @@ -1824,12 +1854,24 @@ String repeat = ""; String roomId = ""; post.addParameter("term"+counter3+"::exclude", ""); - if (cdate != null){ + + if (cdate != null) { int dcycle = cdate.getCycle(); if (cdate.getRoom() != null){ roomId = (cdate.getRoom()).getExtId(); + if (roomId.length()>0) { + if (roomId.startsWith("Room/")) { + roomId = roomId.substring(5); + } + } else { + logger.warn("No UnivISId for room " + +cdate.getRoom().getName()); + univISSync.log("No UnivISId for room " + +cdate.getRoom().getName()); + } } - if (dtype != null && dtype.equalsIgnoreCase("s")){ + + if (dtype != null && dtype.equalsIgnoreCase("s")) { repeat = "s1"; Date sdate = cdate.getStartDate(); if(sdate != null){ @@ -1865,14 +1907,6 @@ endmin = "0" + endmin; endtime = endhour+":"+endmin; } - roomId = (cdate.getRoom()).getExtId(); - if (roomId.startsWith("Room/")){ - roomId = roomId.substring(5); - } - if (repeat != null){ - post.addParameter("term"+counter3+"::repeat", - repeat); - } post.addParameter("term"+counter3+"::starttime", starttime); post.addParameter("term"+counter3+"::endtime", @@ -1928,10 +1962,6 @@ endmin = "0" + endmin; endtime = endhour+":"+endmin; } - roomId = (cdate.getRoom()).getExtId(); - if (roomId.startsWith("Room/")) { - roomId = roomId.substring(5); - } post.addParameter("term"+counter3+"::repeat", repeat); post.addParameter("term"+counter3+"::starttime", @@ -1995,9 +2025,6 @@ endtime = endhour+":"+endmin; } - if (roomId.length()>0 && roomId.startsWith("Room/")){ - roomId = roomId.substring(5); - } post.addParameter("term"+counter3+"::repeat", repeat); post.addParameter("term"+counter3+"::starttime", @@ -2015,10 +2042,10 @@ // bei univIS dtype w = 1 bei cobricks String dweekday = (new Integer(cdate.getWeekday())).toString(); - if(dweekday.equals("1")){ + if (dweekday.equals("1")) { dweekday = "0"; repeat = "w"+dcycle+" "+dweekday; - } else{ + } else { int value = (new Integer(cdate.getWeekday())).intValue(); dweekday = (new Integer(value-1)).toString(); @@ -2040,7 +2067,7 @@ } Integer ehour = (new Integer(cdate.getEndHour())); Integer emin = (new Integer(cdate.getEndMin())); - if(ehour.intValue() == 0 ){ + if (ehour.intValue() == 0 ){ endtime = ""; } else { String endhour = ehour.toString(); @@ -2051,10 +2078,7 @@ endmin = "0" + endmin; endtime = endhour+":"+endmin; } - //String roomId = (cdate.getRoom()).getExtId(); - if(roomId.length()>0 && roomId.startsWith("Room/")){ - roomId = roomId.substring(5); - } + post.addParameter("term"+counter3+"::repeat", repeat); post.addParameter("term"+counter3+"::starttime", |
|
From: Michael K. <ko...@us...> - 2007-03-04 12:50:40
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv28633/de/tum/cobricks/univis Modified Files: UnivIS.java Log Message: Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- UnivIS.java 18 Jan 2007 13:05:20 -0000 1.62 +++ UnivIS.java 4 Mar 2007 12:49:44 -0000 1.63 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006 Cobricks Group. All rights reserved. + * Copyright (c) 2004-2007 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software @@ -1631,7 +1631,7 @@ } else { post.addParameter("ects_lname", ""); } - if(cm.getShortName() != null){ + if (cm.getShortName() != null){ post.addParameter("short", cm.getShortName()); } else { post.addParameter("short", ""); @@ -1646,11 +1646,25 @@ } else { post.addParameter("teilno", ""); } + + // get language + String lang = course.getLang(); + String speclang = ""; + if (lang!=null && lang.equals("en")) { + speclang = "eng"; + } + if (lang!=null && lang.equals("fr")) { + speclang = "fra"; + } + if (lang!=null && lang.equals("it")) { + speclang = "ita"; + } + post.addParameter("speclang", speclang); // get type String ctype = cm.getType(); String univIStype = ""; - if(ctype == null || ctype.length()< 1 + if (ctype == null || ctype.length()< 1 ||ctype.equalsIgnoreCase("Vorlesung")){ univIStype = "vo"; post.addParameter("type", univIStype); @@ -2231,7 +2245,8 @@ try { httpClient.executeMethod(hc,post1); - // Die UnivIS Frage "Lehrveranstaltung wirklich löschen?" beantworten + // Die UnivIS Frage "Lehrveranstaltung wirklich löschen?" + // beantworten // Prepare HTTP Post PostMethod post2 = new PostMethod(univISUrl+"/form"); |
|
From: Michael K. <ko...@us...> - 2007-03-21 08:25:43
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10220/de/tum/cobricks/univis Modified Files: UnivIS.java Log Message: Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- UnivIS.java 4 Mar 2007 12:49:44 -0000 1.63 +++ UnivIS.java 21 Mar 2007 08:25:38 -0000 1.64 @@ -619,6 +619,11 @@ if (pos > -1) { int pos2 = s.indexOf("</td></tr>", pos); String tmps = s.substring(pos+21, pos2); + tmps = tmps.trim(); + if (tmps.startsWith("<li>")) { + tmps = tmps.substring(4); + } + tmps = tmps.trim(); return tmps; } pos = s.indexOf("<h3>Fehler:</h3>"); @@ -626,6 +631,11 @@ int pos2 = s.indexOf("<ul>", pos); int pos3 = s.indexOf("</ul>", pos); String tmps = s.substring(pos2+4, pos3); + tmps = tmps.trim(); + if (tmps.startsWith("<li>")) { + tmps = tmps.substring(4); + } + tmps = tmps.trim(); return tmps; } return ""; @@ -718,45 +728,45 @@ attrs.put("cname_en", ul.getEctsName()); if(ul.getComment() != null) attrs.put("ccomment", ul.getComment()); - if(ul.getURL() != null) + if (ul.getURL() != null) attrs.put("curl", ul.getURL()); // get the integer value form the teilno String - if(ul.getParticipants() != null){ + if (ul.getParticipants() != null){ int ccapacity = Integer.parseInt(ul.getParticipants()); attrs.put("ccapacity", new Integer(ccapacity)); } // get the big decimal value from the ects string - if(ul.getEctsCred() != null){ + if (ul.getEctsCred() != null){ logger.info("cectscredits = "+ul.getEctsCred()); Float cectscredits = Float.valueOf(ul.getEctsCred()); attrs.put("cectscredits", cectscredits); } - if(ul.getSWS() != null){ + if (ul.getSWS() != null){ if(ul.getTyp().equalsIgnoreCase("Vorlesung")){ int chours_lec = Integer.parseInt( ul.getSWS()); attrs.put("chours_lec", new Integer(chours_lec)); - }else if(ul.getTyp().equalsIgnoreCase("Praktikum")){ + } else if(ul.getTyp().equalsIgnoreCase("Praktikum")){ int chours_lab = Integer.parseInt( ul.getSWS()); attrs.put("chours_lab", new Integer(chours_lab)); - }else if(ul.getTyp().equalsIgnoreCase("Seminar") + } else if(ul.getTyp().equalsIgnoreCase("Seminar") || ul.getTyp().equalsIgnoreCase("Hauptseminar") || ul.getTyp().equalsIgnoreCase("Proseminar")){ int chours_sem = Integer.parseInt( ul.getSWS()); attrs.put("chours_sem", new Integer(chours_sem)); - }else if(ul.getTyp().equalsIgnoreCase("Ãbung")){ + } else if(ul.getTyp().equalsIgnoreCase("Ãbung")){ int chours_ex = Integer.parseInt(ul.getSWS()); attrs.put("chours_ex", new Integer(chours_ex)); } } - if(ul.getSummary()!=null) + if (ul.getSummary()!=null) attrs.put("ccontent", ul.getSummary()); - if(ul.getEctsSummary()!=null) + if (ul.getEctsSummary()!=null) attrs.put("ccontent_en", ul.getEctsSummary()); - if(ul.getUnivISId()!=null) + if (ul.getUnivISId()!=null) attrs.put("cextid", ul.getUnivISId()); - if(ul.getOrganizational()!= null) + if (ul.getOrganizational()!= null) attrs.put("cprerequ", ul.getOrganizational()); - if(ul.getEctsOrganizational() != null) + if (ul.getEctsOrganizational() != null) attrs.put("cprerequ_en", ul.getEctsOrganizational()); attrs.put("cextlastrep", new Date()); @@ -1231,16 +1241,16 @@ logger.info("update course ..."); Map map = new HashMap(); String cterm = univISSync.getTerm(); - if(cterm != null) + if (cterm != null) map.put("cterm", cterm); map.put("cimport", new Integer(1)); - if(ul.getName()!= null) + if (ul.getName()!= null) map.put("cname", ul.getName()); - if(ul.getEctsName()!= null) + if (ul.getEctsName()!= null) map.put("cname_en", ul.getEctsName()); - if(ul.getComment()!= null) + if (ul.getComment()!= null) map.put("ccomment", ul.getComment()); - if(ul.getURL()!= null) + if (ul.getURL()!= null) map.put("curl", ul.getURL()); // get the integer value form the teilno String if(ul.getParticipants()!= null){ @@ -1248,22 +1258,22 @@ map.put("ccapacity", new Integer(ccapacity)); } // get the big decimal value from the ects string - if(ul.getEctsCred()!= null){ + if (ul.getEctsCred()!= null){ logger.info("cectscredits = "+ul.getEctsCred()); Float cectscredits = Float.valueOf(ul.getEctsCred()); map.put("cectscredits", cectscredits); } - if(ul.getSummary()!= null) + if (ul.getSummary()!= null) map.put("ccontent", ul.getSummary()); - if(ul.getEctsSummary()!= null) + if (ul.getEctsSummary()!= null) map.put("ccontent_en", ul.getEctsSummary()); - if(ul.getUnivISId()!= null) + if (ul.getUnivISId()!= null) map.put("cextid", ul.getUnivISId()); - if(ul.getOrganizational()!= null) + if (ul.getOrganizational()!= null) map.put("cprerequ", ul.getOrganizational()); - if(ul.getEctsOrganizational() != null) + if (ul.getEctsOrganizational() != null) map.put("cprerequ_en", ul.getEctsOrganizational()); - if(ul.getSWS() != null){ + if (ul.getSWS() != null){ if(ul.getTyp().equalsIgnoreCase("Vorlesung")){ int chours_lec = Integer.parseInt( ul.getSWS()); map.put("chours_lec", new Integer(chours_lec)); @@ -1767,7 +1777,7 @@ post.addParameter("url_description", ""); if (tmps2.indexOf(":")>-1) { if (tmps2.indexOf("/")>-1) { - post.addParameter("url_description", tmps); + post.addParameter("url_description", tmps2); } } } else { @@ -2135,7 +2145,7 @@ { logger.info("updating UnivIS ..."); String responsemsg = null; - //Prepare HTTP Post + // prepare HTTP Post PostMethod post1 = new PostMethod(univISUrl+"/form"); //insert the params post1.addParameter("__s", "1"); @@ -2144,7 +2154,7 @@ post1.addParameter("classification", getUnivISEinordnung(course)); post1.addParameter("parent-lv", ""); post1.addParameter("origin", ""); - //add the course parameters + // add the course parameters addCourseParameters(course, post1, univISSync); String cextid = course.getExtId(); String lv = cextid.substring(8); @@ -2157,21 +2167,28 @@ int evalue = (int)((time - 1007506796106L)/86400000L)+661-2000; post1.addParameter("__e", Integer.toString(evalue)); post1.addParameter("done-save", " Nur speichern "); - try{ + try { httpClient.executeMethod(hc,post1); - //read the response - BufferedReader bf = new BufferedReader(new InputStreamReader( - post1.getResponseBodyAsStream())); - + // read the response + BufferedReader bf = + new BufferedReader(new InputStreamReader( + post1.getResponseBodyAsStream())); responsemsg = readResponse(bf); bf.close(); post1.releaseConnection(); - //logger.info("response : "+responsemsg); - - //Warnung - int index = responsemsg.indexOf("name=\"done-lecture/edit:ignore\""); - if(index > -1) { - + + // check for error message + if (responsemsg.indexOf("<h3>Fehler:</h3>")>0) { + String err = getErrorFromUnivISResponse(responsemsg); + logger.error("UnivIS request failed: "+err); + univISSync.log("UnivIS request failed: "+err); + return null; + } + + // ignore warning + int index = + responsemsg.indexOf("name=\"done-lecture/edit:ignore\""); + if (index > -1) { PostMethod post2 = new PostMethod(univISUrl+"/form"); //insert the params post2.addParameter("__s", "1"); @@ -2195,18 +2212,26 @@ httpClient.executeMethod(hc,post2); - //read the response - bf = - new BufferedReader(new InputStreamReader(post2.getResponseBodyAsStream())); + // read the response + bf = new BufferedReader(new InputStreamReader(post2. + getResponseBodyAsStream())); responsemsg = readResponse(bf); bf.close(); post2.releaseConnection(); + // check for error message + if (responsemsg.indexOf("<h3>Fehler:</h3>")>0) { + String err = getErrorFromUnivISResponse(responsemsg); + logger.error("UnivIS request failed: "+err); + univISSync.log("UnivIS request failed: "+err); + return null; + } + } - }catch(Exception e){ + } catch(Exception e) { logger.error(LogUtil.ex("Failed connect to UnivIS.",e)); - if(univISSync.shouldLog("error")){ + if (univISSync.shouldLog("error")){ univISSync.log("Failed connect to UnivIS : "+e.getMessage()); } } |
|
From: Michael K. <ko...@us...> - 2007-03-27 11:27:52
|
Update of /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv32324/de/tum/cobricks/univis Modified Files: UnivIS.java Log Message: Index: UnivIS.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/de/tum/cobricks/univis/UnivIS.java,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- UnivIS.java 21 Mar 2007 08:25:38 -0000 1.64 +++ UnivIS.java 27 Mar 2007 11:27:39 -0000 1.65 @@ -1593,35 +1593,37 @@ String label = cp.getLabel(); int cpid = cp.getId(); int startsem = courseManager.getStartSemForModule(cpid, cmid); - if(label == null || label.length()<1){ + if (startsem == 0) startsem = 1; + if (label == null || label.length()<1){ continue; - }else if(!(label.startsWith("INF")) || !(label.endsWith("INF"))){ + } else if(!(label.startsWith("INF")) || + !(label.endsWith("INF"))) { title = "in/_lehrv"; - }else if(label.equalsIgnoreCase("INF")){ - if(startsem < 5){ + } else if(label.equalsIgnoreCase("INF")) { + if( startsem < 5) { title = "in/_lehrv_1"; - }else if(startsem > 4){ + } else if(startsem > 4) { title = "in/_lehrv_2"; } - } } } - if(ctype.equalsIgnoreCase("Praktikum")) { + if (ctype.equalsIgnoreCase("Praktikum")) { title = "in/_prakt/prakti"; - }else if(ctype.equalsIgnoreCase("Kolloquium")){ + } else if (ctype.equalsIgnoreCase("Kolloquium")){ title = "in/_prakt/kolloq"; - }else if(ctype.equalsIgnoreCase("Seminar") && + } else if (ctype.equalsIgnoreCase("Seminar") && cname.equalsIgnoreCase("Oberseminar")){ title = "in/_prakt/oberse"; - }else if(ctype.equalsIgnoreCase("Seminar") && + } else if (ctype.equalsIgnoreCase("Seminar") && cname.equalsIgnoreCase("Doktorandenseminar")){ title = "in/_prakt/doktor"; - }else if(ctype.equalsIgnoreCase("Seminar")){ + } else if (ctype.equalsIgnoreCase("Seminar")){ title = "in/_prakt/semina"; } return title; } + /** * Add the course parameters to the formular, which will be send to univIS * @param Course course |