cancel
Showing results for 
Search instead for 
Did you mean: 

Download & Template Servlet: Redirect?

ironman77
Champ in-the-making
Champ in-the-making
I'm using the download and the template servlet with a set of customized freemarker templates to provide customized xml to my application.

If i have a invalid ticket or the user isn't authorized to access the document, a automatic redirect to the login page is performed. So there is no way to catch this error automatic besides parsing the servlet response.

Why isn't the http status set to for example 401 - this could be caught by my application easily. As a side node: If i try to access a not existing alfresco node, a http 500 status is set.

Is there a way to change the redirect behavior? The guest download template seems to operate like i described it in the previous paragraph.

Is there a way to set the character encoding which is used for the output of the freemarker templates? This seems to be always latin 1 (ISO-8859-1). The mimetype could be set via a get parameter, why not the character set?
3 REPLIES 3

kevinr
Star Contributor
Star Contributor
If i have a invalid ticket or the user isn't authorized to access the document, a automatic redirect to the login page is performed. So there is no way to catch this error automatic besides parsing the servlet response.

Why isn't the http status set to for example 401 - this could be caught by my application easily. As a side node: If i try to access a not existing alfresco node, a http 500 status is set.

Mainly because that was the mostly useful approach for our web-client app. It would be easy to make that change to the servlet (probably via a url argument). Please raise it in JIRA.

Is there a way to change the redirect behavior? The guest download template seems to operate like i described it in the previous paragraph.

The Guest Template Servlet should behave in the same way as it just calls the base template servlet but as the Guest user.

Is there a way to set the character encoding which is used for the output of the freemarker templates? This seems to be always latin 1 (ISO-8859-1). The mimetype could be set via a get parameter, why not the character set?

The charset can be set as part of the mimetype value i.e.  mimetype=text/html;charset=utf-8  however there was a bug in some of the template code that meant the charset was getting ignored in some cases. It should be fixed in 2.1.

Thanks,

Kevin

davidc
Star Contributor
Star Contributor
An alternative approach is to wrap your freemarker template in a web script http://wiki.alfresco.com/wiki/Web_Scripts.  You then have full control over the http status response codes.

ironman77
Champ in-the-making
Champ in-the-making
Thanks for the reply. Using Web Scripts seems to be the best solution which overs additional features.

But first i have to upgrade to Alfresco 2.1, because Web Scripts are obviously a 2.1 only feature.