At 17:39 05/12/01, Steve Davis wrote:

>Hi,
>
>I was looking through the source code to try and get up to speed on Turbine
>and Jetspeed and I noticed a potential bug in
>
>src/java/org/apache/jetspeed/services/template/JetspeedTemplateService.java
>
>The method is getScreenTemplateName which if I am following the flow of the
>code correctly is not really being used for Jetspeed as it is configured now.
>So it is probably not a big issue.  The method looks like it was copied from
>getLayoutTemplateName which gets passed in a String parameter named "name" 
>while
>getScreenTemplateName gets passed in a String parameter named "key". There is
>null check at the begining that checks for a null "name" not "key".  Also all
>the logging in getScreenTemplateName refers to getLayoutTemplateName so that
>might cause some confusion if the method was ever called. Here is the method
>with my comments added.

Oh,you're right. The logging comments are wrong - and possibly confusing.
The check "name==null" comes out of the TurbineTemplateService - the old 
one. The method has totally changed in the new one....

>     /**
>      * Locate and return the name of a screen template.
>      *
>      *
>      * @param name A String which is the key to the template.
>      * @return A String with the screen template path.
>      * @exception Exception, a generic exception.
>      */
>     public String getScreenTemplateName(String key)
>         throws Exception
>     {
>// This should probably be "key" not "name"
>         if (name==null)
>//      ^^^^^^^^^^^^^^
>             throw new Exception ("TurbineTemplateService: " +
>                 "getLayoutTemplateName() was passed in a null value.");
>//               ^^^^^^^^^^^^^^^^^^^^^^
>
>// All references to "name" below here are ok.
>
>         String name = null;
>
>         if (  useCache && templateCache.containsKey(key) )
>         {
>             name = (String)templateCache.get(key);
>         }
>         else
>         {
>         Log.debug("JetspeedTemplatePage.getLayoutTemplateName(" + key + 
> ")");
>//                                      ^^^^^^^^^^^^^^^^^^^^^
>             String[] names = parseScreenTemplate(key);
>             name = names[2];
>             addToCache( key, names[0], screenCache );
>             addToCache( key, names[1], layoutCache );
>             addToCache( key, names[2], templateCache );
>         }
>         return name;
>     }
>
>What is the procedure for me to submit changes if I find anything else?  It
>would probably be faster for me to just make the change and submit it for
>review rather than tell the active developers about it and have them have to
>make the changes.  It looks like you guys have put a lot of good work into
>this and I would like to help out where I can. Thanks.

Good idea. make the changes and send them to one of the developers.
btw: One hint I forgot to give you in my last mail: if you set the loglevel 
to "debug", you'll get a detailed log of how and where the templates are 
searched.
I don't know if I already said this explicitly, but in my opinion, it would 
be best if the JetspeedTemplate service could be replaced by the original 
TurbineTemplateService. There was once the idea of a 
"ResourceLocatingService" that could be used for the actual locating of the 
respective template. BUt this is just an idea.

Thank you very much for your help!

ingo.

>Steven F. Davis
>Digital Evergreen Interactive - Application Architect
>[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to