WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: [Building Sakai] Use of GradebookService as a web service

Re: [Building Sakai] Use of GradebookService as a web service

by Matthew Jones-11 :: Rate this Message:

| View in Thread

Hi Shoji!

This probably just looks like a confusing special case. You have to use component manager to get the beans from the spring components, then cast it to the interfaces (apis) that are in shared.

For gradebook, they're probably just named differently, for whatever reason.

Look at this webservice for some example gradebook code for getting gradebooks and grades. Hopefully you can use this for whatever you need.
https://source.sakaiproject.org/svn/msub/longsight.com/webservices/webservices-1.0.x/axis/src/webapp/WSLongsight.jws 

And I think this one on confluence still works too?
https://confluence.sakaiproject.org/display/~steve.swinsburg/Additional+web+services+for+Sakai#AdditionalwebservicesforSakai-SakaiGradebook

-Matthew

On Sat, May 19, 2012 at 10:13 PM, Shoji Kajita <kajita@...> wrote:
Dear Sakai Developers,

I'm trying to develop a new web service for getting information from
Gradebook, but I have been struggling from using GradebookService.

For example, I can call

 gradebookService.isGradebookDefined

successfully when I use

 gradebookService = (GradebookService) ComponentManager.get("org.sakaiproject.service.gradebook.GradebookService");

as seen in the following simple code. But, it is failed when I use

 gradebookService = (GradebookService) ComponentManager.get("org.sakaiproject.service.gradebook.shared.GradebookService");

in line 31. I'm probably misunderstanding something.

I really appreciate if someone gives me any pointer to address this.

Best regards,
Shoji Kajita
Kyoto University
----
01: import org.apache.axis.AxisFault;
02: import org.apache.commons.logging.Log;
03: import org.apache.commons.logging.LogFactory;
04: import org.sakaiproject.service.gradebook.shared.GradebookService;
05: import org.sakaiproject.tool.api.Session;
06: import org.sakaiproject.tool.api.SessionManager;
07: import org.sakaiproject.component.cover.ComponentManager;
08:
09: public class CourseGradebook {
10:
11:     private GradebookService gradebookService;
12:     private SessionManager sessionManager;
13:
14:     private static Log LOG = LogFactory.getLog(CourseGradebook.class);
15:
16:     private Session establishSession(String sessionId) throws AxisFault
17:     {
18:             Session s = sessionManager.getSession(sessionId);
19:
20:             if (s == null)
21:             {
22:                     throw new AxisFault("Session \""+sessionId+"\" is not active");
23:             }
24:             s.setActive();
25:             sessionManager.setCurrentSession(s);
26:             return s;
27:     }
28:
29:     public CourseGradebook() {
30:     //      gradebookService = (GradebookService) ComponentManager.get(GradebookService.class.getName());
31:             gradebookService = (GradebookService) ComponentManager.get("org.sakaiproject.service.gradebook.shared.GradebookService");
32:     //      gradebookService = (GradebookService) ComponentManager.get("org.sakaiproject.service.gradebook.GradebookService");
33:             sessionManager = (SessionManager) ComponentManager.get(SessionManager.class.getName());
34:     }
35:
36:     public String getCompletedDate(String sessionId, String siteId) throws AxisFault {
37:
38:             Session session = establishSession(sessionId);
39:
40:         String gbID = siteId;
41:         if (!gradebookService.isGradebookDefined(gbID)) {
42:             System.out.println("Debug: Not found.");
43:             return "No gradebook found for this site.";
44:         }
45:         return "Gradebook found for this site.";
46:     }
47:
48: }
-----
_______________________________________________
sakai-dev mailing list
sakai-dev@...
http://collab.sakaiproject.org/mailman/listinfo/sakai-dev

TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe@... with a subject of "unsubscribe"


_______________________________________________
sakai-dev mailing list
sakai-dev@...
http://collab.sakaiproject.org/mailman/listinfo/sakai-dev

TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe@... with a subject of "unsubscribe"

 « Return to Thread: [Building Sakai] Use of GradebookService as a web service