Re: T5: Custom asset locator?

2008-03-31 Thread Andreas Pardeike

Robert,

It's not about security and only partial about pretty url's. The
thing is that I am building a meta site which will host a bunch of
sites that other companies can design. Since this will be a portal,
I provide basic functions like login, basket, search etc as components
which then will be used in predefined templates that I create.

As a result, a single T5 app will be used to host several sites - all
distinguished by host name. And inside each site, I have a mixture of
static (better: non-db based content like a shopping cart page) and
dynamic pages.

Those dynamic pages are not completely free. They are based on html
snippets and a template name and I use the template matching that name
and fill in the snippets from the db - and those snippets again can
contain references to images, css and so.

It's probably easiest show by example:

Customer A has a site SITE-A. I have defined template X, Y and Z. The
customer uploads a page '/test.html' onto an ftp account and a script
fetches:

- the name of the template to use. Let's say X.
- the html of three div's with ids set to i.e. 'left', 'middle', 'right'
- the html in the left column has an img src=/foo.gif

What happens here is that after that, my app makes it possible to
call

http://www.SITE-A.com/dynamic/test.html

which will trigger a tapestry page Dynamic with context '/test.html'.
That page (could also be a service but I found a page sufficient) then
uses a Layout component pattern in a dynamic way to use template X.

In template X, there are three components with ref-ids 'left', 'middle'
and 'right'. They will fetch and output the html from the database. The
browser will call '/foo.gif' as a result which will also be fetched
from the database via a tapestry service.

Also, the template X contains some 'internal' graphics. And here, the
problem exists. Unlike the content that comes from the database and
which is fetched with the hostname as a key, the assets inside the
template (i.e. a page header gif) are not separated by hostname. So
I would need to use /site-a/header.gif and /site-b/header.gif in two
templates for site-a and site-b.

I don't want that. Especially since I want to reuse the template by
copying it when a new site is to be added. All I want is to have the
gif in

/myassets/site-a/header.gif
/myassets/site-b/header.gif

in my tapestry project and call it in the code without a notion of the
site it is used at. Same goes for the browser URL. There I don't want
the site notion:

http://www.site-a.com/header.gif

Repeating the site inside the path would be not so nice:

http://www.longsitenamehere.com/longsitenamehere/header.gif

First, it's quite ugly and second, it will create confusion if users
start to abuse other sites content.


Sorry for the long post but I felt that I had to go into detail to
show why I want what I want.
/Andreas Pardeike

PS: Please note that basically everything is already implemented except
for the host separation of my own assets...

PS2: I am thinking of switching the url scheme for 'static' and
'dynamic' pages so the customer pages have the same paths as the
files they upload (all static pages will then have defined subfolder
prefixed). That requires some changes but will still leave me with the
same problem regarding my tapestry assets.


On 28 mar 2008, at 19.32, Robert Zeigler wrote:
Question: is the crux of the matter pretty urls, or is the cruz of  
the matter security?
If the crux is pretty urls, then we should think about this some  
more... trying to map a single url onto multiple resources, and  
cache all of those resources seems pretty tricky.
If, on the other hand, you just need to make sure that site_a  
users don't have access to site_b's assets, then maybe this isn't  
the best approach?
For instance, you could use a dispatcher to verify that the user in  
question has access to the asset in question.
For example, you could use the AssetProtectionDispatcher* that I  
wrote awhile back, and contribute your own AssetPathAuthorizer which  
looks at the asset path, and the current user, and determines if the  
user has access to the asset.


Then you're not beating your head over trying to map a single url to  
multiple assets, and you're using the built-in caching, and site b's  
users aren't peaking at site a's assets.


If you also want pretty urls to boot... I'll have to mull over it a  
bit when I have a bit more time.



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



RE: T5: Custom asset locator?

2008-03-28 Thread Cordenier Christophe
Hello

I'm not sure this can help, this is just an idea,
but maybe it would be easier to create a new type of binding Factory upon the 
AssetBinding factory to add dynamic datas.

Best regards,
Christophe.

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 14:58
À : Tapestry users
Objet : T5: Custom asset locator?

Hi everyone,

First: many many thanks to the list for all the valuable info I
get from it (either as passive reading or answers to my questions!)

My problem: I want to expand the virtual /assets mapping because
in the app I am writing, I use the current host name to run different
sites/layouts.

So I want to implement that

Host: www.SITE_A.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_A/i/test.gif

and

Host: www.SITE_B.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_B/i/test.gif

instead of the default way to do it by using

img src=${asset:classpath:/CURRENTSITE/i/test.gif} /
or @Path(classpath:${host}/i/test.gif)

and have it dynamically expand to the same paths. The motivation behind
this is that

a) users at SITE_A could replace the url with 'SITE_B' and peek at other
resources

b) the url's get very long and for some reason I don't want to go into
here, I need to match the URLs style with some dynamic paths that
fetch resources from a db - there, I automatically take care of the
host name.

I couldn't find a example on how to expand/overwrite asset lookup (in
the same way I expanded template lookup). All I want is to add a
subfolder on the fly to the asset path and still use the same build
in asset service.

/Andreas Pardeike

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




Ce message et les pièces jointes sont confidentiels et réservés à l'usage 
exclusif de ses destinataires. Il peut également être protégé par le secret 
professionnel. Si vous recevez ce message par erreur, merci d'en avertir 
immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant 
être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra 
être recherchée quant au contenu de ce message. Bien que les meilleurs efforts 
soient faits pour maintenir cette transmission exempte de tout virus, 
l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne 
saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for 
the addressee; it may also be privileged. If you receive this e-mail in error, 
please notify the sender immediately and destroy it. As its integrity cannot be 
secured on the Internet, the Atos Origin group liability cannot be triggered 
for the message content. Although the sender endeavours to maintain a computer 
virus-free network, the sender does not warrant that this transmission is 
virus-free and will not be liable for any damages resulting from any virus 
transmitted.


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



Re: T5: Custom asset locator?

2008-03-28 Thread Andreas Pardeike

Thanks Christope, but it's not quite what I want. To illustrate
my problem, take a look at the request headers I want to process:

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_A.com

and

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_B.com

If I just create my own binding, the request urls would still contain
the real folder inside /assets and my requests would look like

GET /assets/SITE_A/i/test.gif HTTP/1.1
GET /assets/SITE_B/i/test.gif HTTP/1.1

which I rather not want.

/Andreas

On 28 mar 2008, at 15.10, Cordenier Christophe wrote:

Hello

I'm not sure this can help, this is just an idea,
but maybe it would be easier to create a new type of binding Factory  
upon the AssetBinding factory to add dynamic datas.


Best regards,
Christophe.

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 14:58
À : Tapestry users
Objet : T5: Custom asset locator?

Hi everyone,

First: many many thanks to the list for all the valuable info I
get from it (either as passive reading or answers to my questions!)

My problem: I want to expand the virtual /assets mapping because
in the app I am writing, I use the current host name to run different
sites/layouts.

So I want to implement that

Host: www.SITE_A.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_A/i/test.gif

and

Host: www.SITE_B.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_B/i/test.gif

instead of the default way to do it by using

img src=${asset:classpath:/CURRENTSITE/i/test.gif} /
or @Path(classpath:${host}/i/test.gif)

and have it dynamically expand to the same paths. The motivation  
behind

this is that

a) users at SITE_A could replace the url with 'SITE_B' and peek at  
other

   resources

b) the url's get very long and for some reason I don't want to go into
   here, I need to match the URLs style with some dynamic paths that
   fetch resources from a db - there, I automatically take care of the
   host name.

I couldn't find a example on how to expand/overwrite asset lookup (in
the same way I expanded template lookup). All I want is to add a
subfolder on the fly to the asset path and still use the same build
in asset service.

/Andreas Pardeike

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




Ce message et les pièces jointes sont confidentiels et réservés à  
l'usage exclusif de ses destinataires. Il peut également être  
protégé par le secret professionnel. Si vous recevez ce message par  
erreur, merci d'en avertir immédiatement l'expéditeur et de le  
détruire. L'intégrité du message ne pouvant être assurée sur  
Internet, la responsabilité du groupe Atos Origin ne pourra être  
recherchée quant au contenu de ce message. Bien que les meilleurs  
efforts soient faits pour maintenir cette transmission exempte de  
tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa  
responsabilité ne saurait être recherchée pour tout dommage  
résultant d'un virus transmis.


This e-mail and the documents attached are confidential and intended  
solely for the addressee; it may also be privileged. If you receive  
this e-mail in error, please notify the sender immediately and  
destroy it. As its integrity cannot be secured on the Internet, the  
Atos Origin group liability cannot be triggered for the message  
content. Although the sender endeavours to maintain a computer virus- 
free network, the sender does not warrant that this transmission is  
virus-free and will not be liable for any damages resulting from any  
virus transmitted.



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




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



RE: T5: Custom asset locator?

2008-03-28 Thread Cordenier Christophe
And what about a custom AssetDispatcher ?

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 15:22
À : Tapestry users
Objet : Re: T5: Custom asset locator?

Thanks Christope, but it's not quite what I want. To illustrate
my problem, take a look at the request headers I want to process:

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_A.com

and

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_B.com

If I just create my own binding, the request urls would still contain
the real folder inside /assets and my requests would look like

GET /assets/SITE_A/i/test.gif HTTP/1.1
GET /assets/SITE_B/i/test.gif HTTP/1.1

which I rather not want.

/Andreas

On 28 mar 2008, at 15.10, Cordenier Christophe wrote:
 Hello

 I'm not sure this can help, this is just an idea,
 but maybe it would be easier to create a new type of binding Factory
 upon the AssetBinding factory to add dynamic datas.

 Best regards,
 Christophe.

 -Message d'origine-
 De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
 Envoyé : vendredi 28 mars 2008 14:58
 À : Tapestry users
 Objet : T5: Custom asset locator?

 Hi everyone,

 First: many many thanks to the list for all the valuable info I
 get from it (either as passive reading or answers to my questions!)

 My problem: I want to expand the virtual /assets mapping because
 in the app I am writing, I use the current host name to run different
 sites/layouts.

 So I want to implement that

 Host: www.SITE_A.com
 img src=${asset:classpath:/i/test.gif} /
 points to SITE_A/i/test.gif

 and

 Host: www.SITE_B.com
 img src=${asset:classpath:/i/test.gif} /
 points to SITE_B/i/test.gif

 instead of the default way to do it by using

 img src=${asset:classpath:/CURRENTSITE/i/test.gif} /
 or @Path(classpath:${host}/i/test.gif)

 and have it dynamically expand to the same paths. The motivation
 behind
 this is that

 a) users at SITE_A could replace the url with 'SITE_B' and peek at
 other
resources

 b) the url's get very long and for some reason I don't want to go into
here, I need to match the URLs style with some dynamic paths that
fetch resources from a db - there, I automatically take care of the
host name.

 I couldn't find a example on how to expand/overwrite asset lookup (in
 the same way I expanded template lookup). All I want is to add a
 subfolder on the fly to the asset path and still use the same build
 in asset service.

 /Andreas Pardeike

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




 Ce message et les pièces jointes sont confidentiels et réservés à
 l'usage exclusif de ses destinataires. Il peut également être
 protégé par le secret professionnel. Si vous recevez ce message par
 erreur, merci d'en avertir immédiatement l'expéditeur et de le
 détruire. L'intégrité du message ne pouvant être assurée sur
 Internet, la responsabilité du groupe Atos Origin ne pourra être
 recherchée quant au contenu de ce message. Bien que les meilleurs
 efforts soient faits pour maintenir cette transmission exempte de
 tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa
 responsabilité ne saurait être recherchée pour tout dommage
 résultant d'un virus transmis.

 This e-mail and the documents attached are confidential and intended
 solely for the addressee; it may also be privileged. If you receive
 this e-mail in error, please notify the sender immediately and
 destroy it. As its integrity cannot be secured on the Internet, the
 Atos Origin group liability cannot be triggered for the message
 content. Although the sender endeavours to maintain a computer virus-
 free network, the sender does not warrant that this transmission is
 virus-free and will not be liable for any damages resulting from any
 virus transmitted.


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



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




Ce message et les pièces jointes sont confidentiels et réservés à l'usage 
exclusif de ses destinataires. Il peut également être protégé par le secret 
professionnel. Si vous recevez ce message par erreur, merci d'en avertir 
immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant 
être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra 
être recherchée quant au contenu de ce message. Bien que les meilleurs efforts 
soient faits pour maintenir cette transmission exempte de tout virus, 
l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne 
saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely

Re: T5: Custom asset locator?

2008-03-28 Thread Andreas Pardeike

Yes, I think that would work. Only problem there is that I still
want to have all benefits of caching that the build-in services
deliver. And I can't see how to just *modify* the asset path
inside the dispatcher and pass it on to Tapestry...

/Andreas

On 28 mar 2008, at 15.36, Cordenier Christophe wrote:


And what about a custom AssetDispatcher ?

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 15:22
À : Tapestry users
Objet : Re: T5: Custom asset locator?

Thanks Christope, but it's not quite what I want. To illustrate
my problem, take a look at the request headers I want to process:

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_A.com

and

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_B.com

If I just create my own binding, the request urls would still contain
the real folder inside /assets and my requests would look like

GET /assets/SITE_A/i/test.gif HTTP/1.1
GET /assets/SITE_B/i/test.gif HTTP/1.1

which I rather not want.

/Andreas

On 28 mar 2008, at 15.10, Cordenier Christophe wrote:

Hello

I'm not sure this can help, this is just an idea,
but maybe it would be easier to create a new type of binding Factory
upon the AssetBinding factory to add dynamic datas.

Best regards,
Christophe.

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 14:58
À : Tapestry users
Objet : T5: Custom asset locator?

Hi everyone,

First: many many thanks to the list for all the valuable info I
get from it (either as passive reading or answers to my questions!)

My problem: I want to expand the virtual /assets mapping because
in the app I am writing, I use the current host name to run different
sites/layouts.

So I want to implement that

Host: www.SITE_A.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_A/i/test.gif

and

Host: www.SITE_B.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_B/i/test.gif

instead of the default way to do it by using

img src=${asset:classpath:/CURRENTSITE/i/test.gif} /
or @Path(classpath:${host}/i/test.gif)

and have it dynamically expand to the same paths. The motivation
behind
this is that

a) users at SITE_A could replace the url with 'SITE_B' and peek at
other
  resources

b) the url's get very long and for some reason I don't want to go  
into

  here, I need to match the URLs style with some dynamic paths that
  fetch resources from a db - there, I automatically take care of the
  host name.

I couldn't find a example on how to expand/overwrite asset lookup (in
the same way I expanded template lookup). All I want is to add a
subfolder on the fly to the asset path and still use the same build
in asset service.

/Andreas Pardeike


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



RE: T5: Custom asset locator?

2008-03-28 Thread Cordenier Christophe
Maybe you can wrap the Request Tapestry object in a RequestFilter and then just 
modify the getPath() in the case of an asset URL.
Thereafter, You can use RequestGlobals service to put your wrapped object into 
the pipeline.

By doing this, you won't have to develop or hack the AssetDispatcher.

But there is still a caveat from my point of view,
I think that by doing this, we have to duplicate asset files in the differents 
directories, and then there will be no asset validation during rendering phase 
for the site dependent assets.

Sorry for my poor english, I hope this is understandable :)

Christophe

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 15:52
À : Tapestry users
Objet : Re: T5: Custom asset locator?

Yes, I think that would work. Only problem there is that I still
want to have all benefits of caching that the build-in services
deliver. And I can't see how to just *modify* the asset path
inside the dispatcher and pass it on to Tapestry...

/Andreas

On 28 mar 2008, at 15.36, Cordenier Christophe wrote:

 And what about a custom AssetDispatcher ?

 -Message d'origine-
 De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
 Envoyé : vendredi 28 mars 2008 15:22
 À : Tapestry users
 Objet : Re: T5: Custom asset locator?

 Thanks Christope, but it's not quite what I want. To illustrate
 my problem, take a look at the request headers I want to process:

 GET /assets/i/test.gif HTTP/1.1
 Host: www.SITE_A.com

 and

 GET /assets/i/test.gif HTTP/1.1
 Host: www.SITE_B.com

 If I just create my own binding, the request urls would still contain
 the real folder inside /assets and my requests would look like

 GET /assets/SITE_A/i/test.gif HTTP/1.1
 GET /assets/SITE_B/i/test.gif HTTP/1.1

 which I rather not want.

 /Andreas

 On 28 mar 2008, at 15.10, Cordenier Christophe wrote:
 Hello

 I'm not sure this can help, this is just an idea,
 but maybe it would be easier to create a new type of binding Factory
 upon the AssetBinding factory to add dynamic datas.

 Best regards,
 Christophe.

 -Message d'origine-
 De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
 Envoyé : vendredi 28 mars 2008 14:58
 À : Tapestry users
 Objet : T5: Custom asset locator?

 Hi everyone,

 First: many many thanks to the list for all the valuable info I
 get from it (either as passive reading or answers to my questions!)

 My problem: I want to expand the virtual /assets mapping because
 in the app I am writing, I use the current host name to run different
 sites/layouts.

 So I want to implement that

 Host: www.SITE_A.com
 img src=${asset:classpath:/i/test.gif} /
 points to SITE_A/i/test.gif

 and

 Host: www.SITE_B.com
 img src=${asset:classpath:/i/test.gif} /
 points to SITE_B/i/test.gif

 instead of the default way to do it by using

 img src=${asset:classpath:/CURRENTSITE/i/test.gif} /
 or @Path(classpath:${host}/i/test.gif)

 and have it dynamically expand to the same paths. The motivation
 behind
 this is that

 a) users at SITE_A could replace the url with 'SITE_B' and peek at
 other
   resources

 b) the url's get very long and for some reason I don't want to go
 into
   here, I need to match the URLs style with some dynamic paths that
   fetch resources from a db - there, I automatically take care of the
   host name.

 I couldn't find a example on how to expand/overwrite asset lookup (in
 the same way I expanded template lookup). All I want is to add a
 subfolder on the fly to the asset path and still use the same build
 in asset service.

 /Andreas Pardeike

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




Ce message et les pièces jointes sont confidentiels et réservés à l'usage 
exclusif de ses destinataires. Il peut également être protégé par le secret 
professionnel. Si vous recevez ce message par erreur, merci d'en avertir 
immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant 
être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra 
être recherchée quant au contenu de ce message. Bien que les meilleurs efforts 
soient faits pour maintenir cette transmission exempte de tout virus, 
l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne 
saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for 
the addressee; it may also be privileged. If you receive this e-mail in error, 
please notify the sender immediately and destroy it. As its integrity cannot be 
secured on the Internet, the Atos Origin group liability cannot be triggered 
for the message content. Although the sender endeavours to maintain a computer 
virus-free network, the sender does not warrant that this transmission is 
virus-free and will not be liable for any damages resulting from any virus 
transmitted

Re: T5: Custom asset locator?

2008-03-28 Thread Robert Zeigler

Shooting from the hip here, but...
One way of going about this would be to contribute a RequestFilter,  
rather than a Dispatcher.

RequestFilters get to pass on whatever request they want.
So you could wrap the request with a customized request that modifies  
the result of getPath() based on which host is being run.

Something like:

public class DynamicAssetRequestFilter implements RequestFilter {
   private final SymbolSource _source;
   public DynamicAssetRequestFilter(final SymbolSource source) {
_source=source;
   }

   public boolean service(Request request, Response response,  
RequestHandler handler) {
 if  
(request.getPath().startsWith(TapestryConstants.ASSET_PATH_PREFIX)) {

return handler.service(new 
DynamicAssetRequest(request),response);
 }
 return handler.service(request,response);
   }
  class DynamicAssetRequest implements Request {
  private final Request _request;
  private final String _path;

  DynamicAssetRequest(final Request request) {
  _request = request;
  String path = getPath();
   String host = source.valueForSymbol(host);
   _path = //process the path as appropriate to put host in  
where you need it



  }
  //implement the Request interface by calling through to the  
wrapped request

  ...
  //override getPath.
  public String getPath() {
 return _path;
  }
  }

}

On Mar 28, 2008, at 3/289:52 AM , Andreas Pardeike wrote:

Yes, I think that would work. Only problem there is that I still
want to have all benefits of caching that the build-in services
deliver. And I can't see how to just *modify* the asset path
inside the dispatcher and pass it on to Tapestry...

/Andreas

On 28 mar 2008, at 15.36, Cordenier Christophe wrote:


And what about a custom AssetDispatcher ?

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 15:22
À : Tapestry users
Objet : Re: T5: Custom asset locator?

Thanks Christope, but it's not quite what I want. To illustrate
my problem, take a look at the request headers I want to process:

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_A.com

and

GET /assets/i/test.gif HTTP/1.1
Host: www.SITE_B.com

If I just create my own binding, the request urls would still contain
the real folder inside /assets and my requests would look like

GET /assets/SITE_A/i/test.gif HTTP/1.1
GET /assets/SITE_B/i/test.gif HTTP/1.1

which I rather not want.

/Andreas

On 28 mar 2008, at 15.10, Cordenier Christophe wrote:

Hello

I'm not sure this can help, this is just an idea,
but maybe it would be easier to create a new type of binding Factory
upon the AssetBinding factory to add dynamic datas.

Best regards,
Christophe.

-Message d'origine-
De : Andreas Pardeike [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 28 mars 2008 14:58
À : Tapestry users
Objet : T5: Custom asset locator?

Hi everyone,

First: many many thanks to the list for all the valuable info I
get from it (either as passive reading or answers to my questions!)

My problem: I want to expand the virtual /assets mapping because
in the app I am writing, I use the current host name to run  
different

sites/layouts.

So I want to implement that

Host: www.SITE_A.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_A/i/test.gif

and

Host: www.SITE_B.com
img src=${asset:classpath:/i/test.gif} /
points to SITE_B/i/test.gif

instead of the default way to do it by using

img src=${asset:classpath:/CURRENTSITE/i/test.gif} /
or @Path(classpath:${host}/i/test.gif)

and have it dynamically expand to the same paths. The motivation
behind
this is that

a) users at SITE_A could replace the url with 'SITE_B' and peek at
other
 resources

b) the url's get very long and for some reason I don't want to go  
into

 here, I need to match the URLs style with some dynamic paths that
 fetch resources from a db - there, I automatically take care of the
 host name.

I couldn't find a example on how to expand/overwrite asset lookup  
(in

the same way I expanded template lookup). All I want is to add a
subfolder on the fly to the asset path and still use the same build
in asset service.

/Andreas Pardeike


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



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



Re: T5: Custom asset locator?

2008-03-28 Thread Andreas Pardeike

Robert ,

Just coded that and it (sort of) works. The problem is, as Chris has
mentioned, that T5 complains about the assets being not present.

And when I dodge this by simply creating my own prefix, lets say
'/host_assets/' and fall back to not using assets at all, then my
servlet container will handle the request and it will look at the
original request and fail to find the file.

So I have a feeling that I need to implement the strategy in two
parts: the one that modifies the request AND and custom lookup for
an assets.

OR, I use a third strategy: my app is divided in content that
is semi-static (in form of t5-templates with their own assets) and
content that is database driven. The later is already working fine
and there I simply use the fact that a T5 page has context that
I can use to create fake URLs (.../t5page/context/path/here.gif).

The only thing is, that I would love to use the build in asset
caching and not reinvent the wheel. With the database, Cayenne does
it automatically for me...

Is there a simple way to serve files from either a folder at the
classpath or from the web context *including* caching? Either from
a T5 page or from a dispatcher.

/Andreas


On 28 mar 2008, at 17.51, Robert Zeigler wrote:


Shooting from the hip here, but...
One way of going about this would be to contribute a RequestFilter,  
rather than a Dispatcher.

RequestFilters get to pass on whatever request they want.
So you could wrap the request with a customized request that  
modifies the result of getPath() based on which host is being run.

Something like:

public class DynamicAssetRequestFilter implements RequestFilter {
  private final SymbolSource _source;
  public DynamicAssetRequestFilter(final SymbolSource source) {
   _source=source;
  }

  public boolean service(Request request, Response response,  
RequestHandler handler) {
if  
(request.getPath().startsWith(TapestryConstants.ASSET_PATH_PREFIX)) {

return handler.service(new 
DynamicAssetRequest(request),response);
}
return handler.service(request,response);
  }
 class DynamicAssetRequest implements Request {
 private final Request _request;
 private final String _path;

 DynamicAssetRequest(final Request request) {
 _request = request;
 String path = getPath();
  String host = source.valueForSymbol(host);
  _path = //process the path as appropriate to put host in  
where you need it



 }
 //implement the Request interface by calling through to the  
wrapped request

 ...
 //override getPath.
 public String getPath() {
return _path;
 }
 }

}


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



Re: T5: Custom asset locator?

2008-03-28 Thread Robert Zeigler
Question: is the crux of the matter pretty urls, or is the cruz of  
the matter security?
If the crux is pretty urls, then we should think about this some  
more... trying to map a single url onto multiple resources, and cache  
all of those resources seems pretty tricky.
If, on the other hand, you just need to make sure that site_a users  
don't have access to site_b's assets, then maybe this isn't the best  
approach?
For instance, you could use a dispatcher to verify that the user in  
question has access to the asset in question.
For example, you could use the AssetProtectionDispatcher* that I wrote  
awhile back, and contribute your own AssetPathAuthorizer which looks  
at the asset path, and the current user, and determines if the user  
has access to the asset.


Then you're not beating your head over trying to map a single url to  
multiple assets, and you're using the built-in caching, and site b's  
users aren't peaking at site a's assets.


If you also want pretty urls to boot... I'll have to mull over it a  
bit when I have a bit more time.


Cheers,

Robert

* This is available from www.tapestrycomponents.com (I don't remember  
what version is in there at the moment). The most current version is  
0.0.9, dep on T5.0.11, and is available from the maven repo at:

www.saiwai-solutions.com/maven


On Mar 28, 2008, at 3/2812:08 PM , Andreas Pardeike wrote:

Robert ,

Just coded that and it (sort of) works. The problem is, as Chris has
mentioned, that T5 complains about the assets being not present.

And when I dodge this by simply creating my own prefix, lets say
'/host_assets/' and fall back to not using assets at all, then my
servlet container will handle the request and it will look at the
original request and fail to find the file.

So I have a feeling that I need to implement the strategy in two
parts: the one that modifies the request AND and custom lookup for
an assets.

OR, I use a third strategy: my app is divided in content that
is semi-static (in form of t5-templates with their own assets) and
content that is database driven. The later is already working fine
and there I simply use the fact that a T5 page has context that
I can use to create fake URLs (.../t5page/context/path/here.gif).

The only thing is, that I would love to use the build in asset
caching and not reinvent the wheel. With the database, Cayenne does
it automatically for me...

Is there a simple way to serve files from either a folder at the
classpath or from the web context *including* caching? Either from
a T5 page or from a dispatcher.

/Andreas


On 28 mar 2008, at 17.51, Robert Zeigler wrote:


Shooting from the hip here, but...
One way of going about this would be to contribute a RequestFilter,  
rather than a Dispatcher.

RequestFilters get to pass on whatever request they want.
So you could wrap the request with a customized request that  
modifies the result of getPath() based on which host is being run.

Something like:

public class DynamicAssetRequestFilter implements RequestFilter {
 private final SymbolSource _source;
 public DynamicAssetRequestFilter(final SymbolSource source) {
  _source=source;
 }

 public boolean service(Request request, Response response,  
RequestHandler handler) {
   if  
(request.getPath().startsWith(TapestryConstants.ASSET_PATH_PREFIX)) {

return handler.service(new 
DynamicAssetRequest(request),response);
   }
   return handler.service(request,response);
 }
class DynamicAssetRequest implements Request {
private final Request _request;
private final String _path;

DynamicAssetRequest(final Request request) {
_request = request;
String path = getPath();
 String host = source.valueForSymbol(host);
 _path = //process the path as appropriate to put host in  
where you need it



}
//implement the Request interface by calling through to the  
wrapped request

...
//override getPath.
public String getPath() {
   return _path;
}
}

}


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



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