@WebMethod @Path("/undeleteAssignments") @Produces("text/plain") @GET public String undeleteAssignments( @WebParam(name = "sessionId", partName = "sessionId") @QueryParam("sessionId") String sessionId, @WebParam(name = "context", partName = "context") @QueryParam("context") String context) { try { // establish the session Session s = establishSession(sessionId); Iterator assingments = assignmentService.getAssignmentsForContext(context); while (assingments.hasNext()) { Assignment ass = (Assignment) assingments.next(); ResourceProperties rp = ass.getProperties(); try { String deleted = rp.getProperty(ResourceProperties.PROP_ASSIGNMENT_DELETED); LOG.info("Assignment " + ass.getTitle() + " deleted status: " + deleted); if (deleted != null) { AssignmentEdit ae = assignmentService.editAssignment(ass.getId()); ResourcePropertiesEdit rpe = ae.getPropertiesEdit(); LOG.info("undeleting" + ass.getTitle() + " for site " + context); rpe.removeProperty(ResourceProperties.PROP_ASSIGNMENT_DELETED); assignmentService.commitEdit(ae); } } catch (IdUnusedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (PermissionException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (Exception e) { LOG.error("WS undeleteAssignments(): " + e.getClass().getName() + " : " + e.getMessage()); return e.getClass().getName() + " : " + e.getMessage(); } return "success"; }
@WebMethod @Path("/getAssignmentsForContext") @Produces("text/plain") @GET public String getAssignmentsForContext( @WebParam(name = "sessionid", partName = "sessionid") @QueryParam("sessionid") String sessionid, @WebParam(name = "context", partName = "context") @QueryParam("context") String context) { try { // establish the session Session s = establishSession(sessionid); // ok will this give me a list of assignments for the course LOG.info("assignment list requested for " + context); Iterator assignments = assignmentService.getAssignmentsForContext(context); Document dom = Xml.createDocument(); Node all = dom.createElement("assignments"); dom.appendChild(all); while (assignments.hasNext()) { Assignment thisA = (Assignment) assignments.next(); LOG.debug("got " + thisA.getTitle()); if (!thisA.getDraft()) { AssignmentContent asCont = thisA.getContent(); LOG.debug("about to start building xml doc"); Element uElement = dom.createElement("assignment"); uElement.setAttribute("id", thisA.getId()); uElement.setAttribute("title", thisA.getTitle()); LOG.debug("added title and id"); if (asCont != null) { Integer temp = new Integer(asCont.getTypeOfGrade()); String gType = temp.toString(); uElement.setAttribute("gradeType", gType); } /* these need to be converted to strings */ LOG.debug("About to get dates"); Time dueTime = thisA.getDueTime(); Time openTime = thisA.getOpenTime(); Time closeTime = thisA.getCloseTime(); LOG.debug("got dates"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); if (openTime != null) { LOG.debug("open time is " + openTime.toString()); uElement.setAttribute("openTime", format.format(new Date(openTime.getTime()))); } if (closeTime != null) { LOG.debug("close time is " + closeTime.toString()); uElement.setAttribute("closeTime", format.format(new Date(closeTime.getTime()))); } if (dueTime != null) { LOG.debug("due time is " + dueTime.toString()); uElement.setAttribute("dueTime", format.format(new Date(dueTime.getTime()))); } LOG.debug("apending element to parent"); all.appendChild(uElement); } else { LOG.debug("this is a draft assignment"); } } String retVal = Xml.writeDocumentToString(dom); return retVal; } catch (Exception e) { LOG.error( "WS getAssignmentsForContext(): " + e.getClass().getName() + " : " + e.getMessage()); } return "<assignments/ >"; }