[Building Sakai] sites, pages, tools

will trillich will at serensoft.com
Wed Apr 1 16:49:06 PDT 2009


a HA! Finally unravelled this beast -- here's some sample output:

"""
location: !admin-610 : Administration Workspace | On-Line | On-Line (!admin-610)
location: !admin-presence : Administration Workspace
location: 33a5934c-78b0-457a-a6cf-f329cb6f6567 : location:
33a5934c-78b0-457a-a6cf-f329cb6f6567
location: mercury-810 : mercury site | Chat | Chat (mercury-810)
"""

(That's only the headers from !admin>Online>Locations -- there are
still a few IDs that don't translate to tools or worksites...)

Here's the code, it wound up being reasonably simple in the end --
comments welcome:

	public String getLocationDescription(String location)
	{
	    if ( location.endsWith( "-presence" ) ) {
		location = location.substring( 0, location.length() - 9 );
	    }
	    org.sakaiproject.site.api.SiteService siteService =
org.sakaiproject.site.cover.SiteService.getInstance();
	    org.sakaiproject.site.api.ToolConfiguration toolConfig =
siteService.findTool( location );
	    if ( toolConfig != null ) {
		String toolName = toolConfig.getTitle();
		String pageName = toolConfig.getContainingPage().getTitle();
		String siteName =
toolConfig.getContainingPage().getContainingSite().getTitle();
		return siteName + " | " + pageName + " | " + toolName + " (" + location + ")";
	    }
	    try {
		String siteName = siteService.getSite( location ).getTitle();
		return siteName;
	    } catch (Exception e) {
	    }
	    return "location: " + location; /* <= the original code en toto */
	}


On Wed, Apr 1, 2009 at 12:42 PM, Stephen Marquard
<stephen.marquard at uct.ac.za> wrote:
> There is actually no definitive mapping from locations (as used in presence, i.e. online / locations) back to site, tool context, or anything else.
>
> The best you can do is make some assumptions about the format of the location string, and infer what it might mean.
>
> e.g. "abc-presence" is typically site presence, so the "abc" is a site id.
>
> Chat uses a different format to represent chat rooms. Any tool X could make up its own presence location format.
>
> Regards
> Stephen
>
> Stephen Marquard, Learning Technologies Co-ordinator
> Centre for Educational Technology, University of Cape Town
> http://www.cet.uct.ac.za
> Email/IM/XMPP: stephen.marquard at uct.ac.za
> Phone: +27-21-650-5037 Cell: +27-83-500-5290
>
>
>>>> will trillich <will at serensoft.com> 2009/04/01 07:36 PM >>>
> Thanks, Steve -- but we don't want "current tool" -- that code is
> available all over the place! :)
>
> We want the page and/or worksite of any specific, given, tool-id. As
> in !admin > online > locations -- which worksite are these people in?
>
>
> On Wed, Apr 1, 2009 at 4:36 AM, Steve Swinsburg
> <s.swinsburg at lancaster.ac.uk> wrote:
>> Hi Will,
>> You can get the current site that a user is using a tool in by:
>> String siteId = toolManager.getCurrentPlacement().getContext();
>> Once you have that site you can find a tool based on something like:
>> ToolConfiguration toolConfig
>> = siteService.getSite(siteId).getToolForCommonId(toolId);
>> Where toolId is something like sakai.resources".
>> From there you should be able to get the info you need?
>>
>> cheers,
>> Steve
>> ---
>> Steve Swinsburg
>> Portal Systems Developer
>> Centre for e-Science
>> Lancaster University
>> Lancaster
>> LA1 4YT
>> email: s.swinsburg at lancaster.ac.uk
>> phone: +44 (0) 1524 594870
>>
>>
>>
>>
>>
>>
>> On 1 Apr 2009, at 02:54, will trillich wrote:
>>
>> Okay -- this is probably elementary:
>>
>> Worksites have pages, and pages have tools, right?
>>
>> Given a tool ID (such as ea052aee-f422-41d5-ad70-97993a2251b6), how do
>> we figure out which classes and methods to use, in order to find the
>> worksite that that tool is attached to?
>>
>> Seems like the ToolManager or Tool class should have a field/method
>> indicating the page it's on, which should in turn have a field/method
>> indicating the worksite the page is on. There's not enough meat in the
>> javadocs to tell what's going on (except on rare occasion, we stumble
>> into a bit of information but it's seldom).
>>
>> For example, nightly2 javadocs show how lots of methods in the Tool
>> class accept a string or return a string, but there's no description
>> of what the string is expected to be, how it should be used, or what
>> the output is expected to be. E.g. Tool.getHome() returns a mysterious
>> string -- would that be a worksite name or id? page id? some other
>> context?
>>
>> We were hoping for something like
>> getSpecificTool(tool_id_string).getToolPage().getPageSite()...
>>
>> Pointers would be greatly appreciated.
>>
>> --
>> will trillich
>> "If you do not change direction, you may end up where you are
>> heading." -- Lao Tzu
>> _______________________________________________
>> 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"
>>
>>
>
>
>
> --
> will trillich
> "If you do not change direction, you may end up where you are
> heading." -- Lao Tzu
> _______________________________________________
> 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"
>
>



-- 
will trillich
"If you do not change direction, you may end up where you are
heading." -- Lao Tzu


More information about the sakai-dev mailing list