« Return to Thread: Issue about UrlRewritter

RE: Issue about UrlRewritter

by Slobodan Vujasinovic-2 :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,

 

Thank you for the contribution! We’ll include it in next TAF (EAF) release.

 

NOTE: we’ve already updated public CVS repository.

 

Sorry for any possible inconvenience we’ve caused!

 

Slobodan Vujasinovic

---------------------------------

PROZONE d.o.o.

21000 Novi Sad

Dunavska 13

 

tel:    +381-21-4720-200

fax:    +381-21-451-216

mobile: +381-63-1073-978

email:  slobodan.vujasinovic@...

web:    www.prozone.co.yu

---------------------------------

 

From: Luís Oliveira [mailto:loliveira@...]
Sent: Thursday, 27 December, 2007 14:11
To: enhydra@...
Cc: 'Luis Leite'; José Gonçalves
Subject: [enhydra] Issue about UrlRewritter

 

Hi,

 

In my Enhydra Apps, I used to create a class  MyUrlRewriter  that implements the Interface org.enhydra.xml.io. URLRewriter. In this class, I override the method rewriteURL according to the needs of each application. Then, before calling method comms.response.writeDOM (to write the pages to the socket), I used to call the method options.setURLRewriter in which the parameter is my own URL Rewriter.

 

Resuming:

 

public class MyUrlRewriter implements org.enhydra.xml.io. URLRewriter

{

      …

      public String rewriteURL(String originalUrl) {

            //app specific logic for URLs

 

//call the Enhydra Rewritter to the url already changed above
_enhydraURLRewriter.rewriteURL(urlRewritten);

      }

}

 

 

public class BasePO implements HttpPresentation

{

      …

 

      private void writePage(Page page, HttpPresentationComms comms) {



 XMLObject document = page.getDocument();

      OutputOptions options = this.getComms().response.createOutputOptions(document);           

      MyUrlWriter urlRewriter = new MyUrlWriter(…);

      options.setURLRewriter(urlRewriter);    //choosing my own URL Rewritter instead of Enhydra URL Rewritter

      …

      }

}

 

Besides, in web.xml file, the key SessionManager/EncodeUrlState has value “Auto” (to let Enhydra encode session in URL when needed).

 

The problem is that in the 7.2 version of Enhydra, the method writeDOM of class com.lutris.appserver.server.httpPresentation.servlet. ServletHttpPresentationResponse was changed to:

 

     public void writeDOM(OutputOptions outputOptions, Node document) throws HttpPresentationException

      {

            try

            {

                  // Copy options so as to not modify when changing encoding.

                  OutputOptions options = new OutputOptions(outputOptions);

                 

                  setupEncoding(document, options);

                 

                  if (options.getMIMEType() != null && options.getMIMEType().equals("text/html"))

                        options.addFreeformOption(org.enhydra.util.DOMFormatter.FORMATTER_NAME, new ExtHTMLFormatter(document, options, true));

                  else

                        options.addFreeformOption(org.enhydra.util.DOMFormatter.FORMATTER_NAME, new ExtXMLFormatter(document, options, true));

 

//          Enable encoding of session id in URL, if needed.

                  boolean encodeSessionKey = shouldEncodeSessionKey();

                  if (encodeSessionKey)

                  {

                        options.setURLRewriter(new URLRewriter()

                        {

                             public String rewriteURL(String urlAttrValue)

                             …

 

The problem is that if Enhydra needs to encode session, the class ServletHttpPresentationResponse creates a new instance of UrlRewritter, discarding the URL Rewritter I had set.

I suggest to create a new instance of UrlRewitter only if we need to encode session and there’s no one. So, I suggest to change the line

 

if (encodeSessionKey)

 

to this one:

 

if (encodeSessionKey && options.getURLRewriter() == null)

 

 

Do you agree with this solution? There’s anyone better ?

 

 

Best Regards
Luis Oliveira

 

 

 

 

LUIS OLIVEIRA | SOFTWARE ENGINEER

loliveira@...


PHONE: + 351 253 305 250
FAX : +351 253 305 251
www.mobicomp.com

 

image002

_______________________________________________________________

| THE MAGIC OF MOBILITY

CONFIDENTIALITY NOTICE: This message, as well as existing attached files, is confidential and intended exclusively for the individual(s) named as addressees. If you are not the intended recipient, you are kindly requested not to make any use whatsoever of its contents and to proceed to the destruction of the message, thereby notifying the sender.
DISCLAIMER: The sender of this message can not ensure the security of its electronic transmission and consequently does not accept liability for any fact which may interfere with the integrity of its content.

 

 




--
You receive this message as a subscriber of the enhydra@... mailing list.
To unsubscribe: mailto:enhydra-unsubscribe@...
For general help: mailto:sympa@...?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

 « Return to Thread: Issue about UrlRewritter