Le 15 juin 04, à 22:58, Daniel Farinha a écrit :

Dear All,

I've been trying to shorten the URLs used by Jetspeed, as well as trying to
make them unique (as in, one page will only have 1 URL) but it's harder than
it looked.


The problem is as follows:

Lets say I logged in. The first URL I get is:

http://localhost:8080/jetspeed/portal; jsessionid=F127ADD711D9734E54E462920DF
9AA73


However if I manually edit the URL to:

http://localhost:8080/jetspeed/portal

I get the very same page. I'd really rather have the shorter URL come up
automatically.
(the jsessionid in the first URL is really a nuisance, and unnecessary as
the client accepts cookies. isn't there a way I can get rid of it?)



Yes, It's a setting of Tomcat. in server.xml.

Another example. If I click on the page customiser, the default URL is:

http://localhost:8080/jetspeed/portal/media-type/html/user/testuser/ page/def
ault.psml?action=controls.Customize&reset=on


Yet, after editing manually, this shorter version also works:

http://localhost:8080/jetspeed/portal? action=controls.Customize&reset=on

Finally, once logged in, there are n ways of linking to a particular page
(like the main page):


http://localhost:8080/jetspeed/portal/media-type/html/user/testuser/ page/def
ault.psml
http://localhost:8080/jetspeed/portal/user/testuser/page/default.psml
(missing media-type)
http://localhost:8080/jetspeed/portal/page/default.psml (missing user)
http://localhost:8080/jetspeed/portal


But I'd like to force all links to that page to have a unique URL,
preferably the shortest possible.

My aim is to ease the workload of a J2ME browser, which is currently wasting
memory by caching the same page multiple times, and with really long URLs
which also take up storage capacity.



Shortening the URLs is no trivial task if you want to still support all the possible
use cases. However, if you know your expected portal behaviors and target
browsers and customers, you can have some nice optimisations.


Before going into more details in the setup, let's first explain the principles:
Jetspeed Profiler uses a well-known set of parameters to retrieve a PSML page :
- page name (parameter "page", default is "default.psml")
- user name (parameter "user", default is current authenticated user or anonymous)
- media type (parameter "media-type", default to media defined by client capabilities defintion)
- language (parameter "language", default to user-agent language setting)
Whenever, you acces a PSML page, the profiler will match these 4 parameters and using
the appropriate defaults if necessary come up with the correct content.
In most use cases, the default behavior of user name, media type and language is what you need
but Jetspeed will still use with explicit values for all these parameters so that your link is
predictable in any condition.


Now, if you want to shorten your URLs, you can have your portal only depend on the
fallback mechanism for user, media and language and thus never explicitly set the 3 corresponding
parameters.
You can easily achieve this by modifying the JetspeedLink classes that are ued throughout Jetspeed to generate
URLs so that they never include the media-type, language, and user parameters in their rendering method
even if these parameters are set in the request.
You'll find these classes in src/org/apache/jetspeed/util/template/*Link.java
To make the behavior customizable, you'll probably be better off creating a custom property in your config file
to control which parameters to "filter out".


Once you've done this, you can also do some simple changes:
- rename the "page" parameter to something shorter like "p" (defined in the Profiler service)
- define the jetspeed WAR as the root application in your Tomcat if possible.


Once this is done, instead of:
http://myhost/jetspeed/portal/page/news/user/turbine/media-type/html/ language/en
you should have links like:
http://myhost/portal/p/news


Better ain't it ?

Except that now you have broken some features of Jetspeed, like administration of user pages by the administration,
customization of user pages for other media-type than the one supported by the current user-agent, explicit language
settings and switching between languages...


That's hardly perfect, but you can further mitigate things by using "runtime properties" to customize your behaviour
(documented in the Javadocs API page for the class
org.apache.jetspeed.services.resources.JetspeedResourceService


Basically. define a system.property jetspeed.conf.dir to store your runtime properties, for example using the
CATALINA_OPTS environment variable. Add in this variable "-Djetspeed.conf;dir=/my/whatever/dir" and you're set
Now, edit your portal web.xml:
- copy the jetspeed portlet definition to a new "jetspeed-light" portlet definition and add the following mapping:
<servlet-mapping>
<servlet-name> jetspeed-light </servlet-name>
<url-pattern>/jl/* </url-pattern>
</servlet-mapping>
- add a "jl.properties" in /my/whatever/dir and define in this file the property you have selected to control the parameter
filtering
- make sure the default JR.properties, TR.properties and my.properties don't define this filter out property
- restart your webapp server


Now, you still have

http://myhost/portal/

that behaves as your default Jetspeed distribution.

but you can point your J2ME clients to:

http://myhost/jl/

which will always use "short" URIs.

Since both versions belong to the same webapp, they share all their parameters and sessions and you can
seamlessly switch between them if you like.


Hope this helps.

--
Raphaël Luta - [EMAIL PROTECTED]
Apache Jetspeed - Enterprise Portal in Java
http://portals.apache.org/


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



Reply via email to