[Building Sakai] Create a site by Sakai API

Steve Swinsburg s.swinsburg at lancaster.ac.uk
Sun Jul 12 03:08:51 PDT 2009


Hi Phuc,

This all looks good. You want:

addedSite.setPublished(true);

to publish the site.

You could take a look at how the webservices do it, they are a pretty  
good example of some clean concise code. Reproduced below:
		
		Site siteEdit = null;
		siteEdit = SiteService.addSite(siteid, type);
		siteEdit.setTitle(title);
		siteEdit.setDescription(description);
		siteEdit.setShortDescription(shortdesc);
		siteEdit.setIconUrl(iconurl);
		siteEdit.setInfoUrl(infourl);
		siteEdit.setJoinable(joinable);
		siteEdit.setJoinerRole(joinerrole);
		siteEdit.setPublished(published);
		siteEdit.setPubView(publicview);
		siteEdit.setSkin(skin);
		siteEdit.setType(type);
		SiteService.save(siteEdit);

cheers,
Steve



On 11 Jul 2009, at 22:05, Phuc Bui wrote:

> Dear all,
> I use class org.sakaiproject.site.api.SiteService to create a site.
> But I do not know how to publish this site, and add some default  
> tool for it (ex: Home, SiteInfo, Announcement …) (of course, all  
> works should be done by Sakai API). I tried this class -  
> org.sakaiproject.tool.api.ToolManager, and see the  
> methodregister(Tool tool), but I don’t know how to use it ?
> I have a part of code:
>
> Site addedSite = siteService.addSite(siteId, siteType);
> addedSite.setDescription("create by NLU Tool as a demo");
> addedSite.setJoinable(true);
> addedSite.setJoinerRole("student");
> addedSite.setTitle("Demo site created by NLU Tool");
>
> siteService.allowAccessSite(addedSite.getId());
> siteService.save(addedSite);
>
> I did it, but the site that was created by this method did not have  
> the title and description like this ?
>
> Looking forward to your replies,
> Thanks,
> Phuc Bui
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org 
>  with a subject of "unsubscribe"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20090712/60225dda/attachment.html 


More information about the sakai-dev mailing list