if (user != null) {
if (action.equals("add")) {
String dept = req.getParameter("dept");
String course = req.getParameter("course");
String section = req.getParameter("section");
WorklistItemObject wio = new WorklistItemObject(dept, course,
section);
SectionInformationObject sio = spiderDatastore
.querySectionFromId(dept, course, section);
List<SectionInformationObject> siol = d.getWorklistAsSIO(user);
boolean conflict = isInConflict(siol, sio);
boolean success = false;
if (!conflict)
success = d.addWorklistItem(user, wio);
if (success)
xmlout += "\t<message>Item was successfully added to worklist</message>\n";
else if (conflict)
xmlout += "\t<message>Unable to add to worklist, due to schedule conflict</message>\n";
else
xmlout += "\t<message>Item already exists in worklist</message>\n";
} else if (action.equals("remove")) {
String dept = req.getParameter("dept");
String course = req.getParameter("course");
String section = req.getParameter("section");
String start = req.getParameter("start");
// String end = req.getParameter("end");
WorklistItemObject wio = new WorklistItemObject(dept, course,
section);
boolean success = d.deleteWorklistItem(user, wio);
if (success) {
xmlout += "\t<message>Item was successfully removed from worklist</message>\n";
} else
xmlout += "\t<message>Item failed to remove from worklist</message>\n";
} else if (action.equals("get")) {
List<SectionInformationObject> siol = d.getWorklistAsSIO(user);
for (Iterator<SectionInformationObject> i = siol.iterator(); i
.hasNext();) {
SectionInformationObject sio = i.next();
xmlout += "\t<item>\n";
xmlout += "\t\t<dept>" + sio.getDepartmentId()
+ "</dept>\n";
xmlout += "\t\t<course>" + sio.getCourseId()
+ "</course>\n";
xmlout += "\t\t<section>" + sio.getSectionId()
+ "</section>\n";
xmlout += "\t\t<start>" + sio.getStart() + "</start>\n";
xmlout += "\t\t<end>" + sio.getEnd() + "</end>\n";
xmlout += "\t\t<day>" + sio.getDay() + "</day>\n";
xmlout += "\t\t<term>" + sio.getTerm() + "</term>\n";
xmlout += "\t\t<building>" + sio.getBuilding()
+ "</building>\n";
xmlout += "\t\t<room>" + sio.getRoom() + "</room>\n";
xmlout += "\t</item>\n";
}
} else if (action.equals("view")) {
String email = req.getParameter("email");
if (d.checkSubscriptionExists(email, user)) {
List<SectionInformationObject> siol = d
.getWorklistAsSIO(email);
for (Iterator<SectionInformationObject> i = siol.iterator(); i
.hasNext();) {
SectionInformationObject sio = i.next();
xmlout += "\t<item>\n";
xmlout += "\t\t<dept>" + sio.getDepartmentId()
+ "</dept>\n";
xmlout += "\t\t<course>" + sio.getCourseId()
+ "</course>\n";
xmlout += "\t\t<section>" + sio.getSectionId()
+ "</section>\n";
xmlout += "\t\t<start>" + sio.getStart() + "</start>\n";
xmlout += "\t\t<end>" + sio.getEnd() + "</end>\n";
xmlout += "\t\t<day>" + sio.getDay() + "</day>\n";
xmlout += "\t\t<term>" + sio.getTerm() + "</term>\n";
xmlout += "\t\t<building>" + sio.getBuilding()
+ "</building>\n";
xmlout += "\t\t<room>" + sio.getRoom() + "</room>\n";
xmlout += "\t</item>\n";
}
}
} else if (action.equals("check")) {
String dept = req.getParameter("dept");
String course = req.getParameter("course");
String section = req.getParameter("section");
WorklistItemObject wio = new WorklistItemObject(dept, course,
section);
boolean success = d.checkWorklistItemExists(user, wio);
if (success)
xmlout += "\t<exist>true</exist>\n";
else