[DG: Spanish Sakai] [Building Sakai] How to get site id

DAVID ROLDAN MARTINEZ darolmar at upvnet.upv.es
Sun Jun 28 23:02:25 PDT 2009


Diego,

I'm sorry for the delay in the answer but, as you know, we are very busy with our migration process.

Try with this  but it will only work if your tool is JSF-like:

FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
String placementId = (String) req.getAttribute(Tool.PLACEMENT_ID);
ToolConfiguration toolConfig = SiteService.findTool(placementId);
String siteId = toolConfig.getSiteId();

David

De: sakai-dev-bounces at collab.sakaiproject.org [mailto:sakai-dev-bounces at collab.sakaiproject.org] En nombre de Diego del Blanco Orobitg
Enviado el: viernes, 26 de junio de 2009 13:23
Para: sakai-dev at collab.sakaiproject.org; David.Horwitz at uct.ac.za
Asunto: Re: [Building Sakai] How to get site id

Dear David,

I know that toolManager.getCurrentPlacement() will return null if I invoke it from a Samigo Services because the request is not made directly from a tool. Considering this pointing, I've tried to get  toolManager.getCurrentPlacement().getContext() from one of the beans of my tool, instead to leave Samigo Services to do it for my tool and...I'm getting the same NPE!!!.

My bean looks like this:

public class ReivenListBean {

....

      public ReivenListBean(){

            if (ToolManager.getCurrentPlacement()!=null){
                System.out.println(" > toolManager.currentPlacement---> NOT NULL");
            }else{
                 System.out.println(" > toolManager.currentPlacement ---> NULL");
            }

....
}

And I declare it in faces-config.xml as a managed session bean. When I select my tool from a site, I can read the following message at catalina.out:

> toolManager.currentPlacement ---> NULL

I really don't know why!!!!. I have analyzed the link to my tool in Sakai main page, to see which pattern it follows and be able to check if it is valid for a tool or not. And here you have what I've found:
Site-info
<!-- start Tool Body -->
<div class="portletMainWrap">
<iframe name="Main9bd95d6ax328fx4a14xb2c0xfbbaf22a6145"
 id="Main9bd95d6ax328fx4a14xb2c0xfbbaf22a6145"
 title="Informaci&#243;n del sitio "
 class ="portletMainIframe"
 height="50"
 width="100%"
 frameborder="0"
 marginwidth="0"
 marginheight="0"
 scrolling="auto"
 src="http://localhost:8080/portal/tool/9bd95d6a-328f-4a14-b2c0-fbbaf22a6145?panel=Main">
</iframe>
</div>
<!-- end Tool Body -->
My Tool

<!-- start Tool Body -->
<div class="portletMainWrap">
 <iframe name="Maine4759e5axcc51x44dcxb9b2x9be7f28ee6ca"
 id="Maine4759e5axcc51x44dcxb9b2x9be7f28ee6ca"
 title="Reiven Content "
 class ="portletMainIframe"
 height="50"
 width="100%"
 frameborder="0"
 marginwidth="0"
 marginheight="0"
 scrolling="auto"
 src="http://localhost:8080/portal/tool/e4759e5a-cc51-44dc-b9b2-9be7f28ee6ca?panel=Main">
 </iframe>
</div>
<!-- end Tool Body -->

That is, the request is very similar to the one generated for other sakai tools (site-info, in this case). So, why ToolManager.getCurrentPlacement() is not usable here? Is any other way of getting Site id?

Following your suggestion from yestarday, I've tried to get ServletContext using FacesContext.getExternalContext() but I haven't found sakai.tool.placement at HttpRequestParameters, though I've found sakai.tool.placement.id<http://sakai.tool.placement.id/> but I don't know if this other parameter is usefull or not.

Does anybody of ouy know what can be happening? I would appreciate any help.

Thank you very much in advance.





[cid:image002.png at 01C9F7CD.9BA30BC0]<http://www.setival.com/>
Tlf: 902 05 06 02
Fax: 96 199 42 43



Diego del Blanco Orobitg
Director del Área de e-Learning y Nuevas Tecnologías
diego.delblanco at setival.com<mailto:diego.delblanco at setival.com>
Móvil: 653 683 489



  Oficinas de Valencia
  Parque Tecnológico - Edificio CEEI
  C/Benjamin Franklin, 12
  46980 Valencia

Este mensaje y sus archivos son confidenciales. No está permitida su reproducción o distribución sin la autorización expresa de SETIVAL SCV. Si usted no es el destinatario previsto, cualquier uso, acceso o copia de este mensaje queda desautorizado. Si ha recibido este mensaje por error, por favor bórrelo e infórmenos por esta misma vía.
De acuerdo con la LSSICE y la LOPD, le comunicamos que sus datos personales y dirección de correo electrónico forman parte de un fichero automatizado, cuyo responsable es SETIVAL SCV, siendo la finalidad del fichero el envío de información de carácter comercial sobre nuestros servicios. Si lo desea puede ejercer los derechos de oposición, acceso,rectificación y cancelación de sus datos enviando un mensaje de correo electrónico a setival at setival.com<mailto:setival at setival.com> indicando en el asunto el derecho que desea ejercitar. Gracias por su colaboración.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/spanish-sakai/attachments/20090629/e7b451d4/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 619 bytes
Desc: image001.png
Url : http://collab.sakaiproject.org/pipermail/spanish-sakai/attachments/20090629/e7b451d4/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 10922 bytes
Desc: image002.png
Url : http://collab.sakaiproject.org/pipermail/spanish-sakai/attachments/20090629/e7b451d4/attachment-0003.png 


More information about the spanish-sakai mailing list