Web Scripts:

- support url extension for specifying required response format
- update scriptUrl method to handle various forms of specifying format on url
- refactor web script request hierarchy; remove copy & paste
- add reset web script registry to web script "Test Server"

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5803 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-05-29 17:34:36 +00:00
parent a484e6737f
commit b2a11b9832
16 changed files with 497 additions and 432 deletions

View File

@@ -26,6 +26,8 @@ package org.alfresco.web.scripts;
import java.util.List;
import org.alfresco.web.scripts.WebScriptDescription.FormatStyle;
import freemarker.template.TemplateBooleanModel;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
@@ -73,15 +75,23 @@ public final class ScriptUrlMethod implements TemplateMethodModelEx
{
prefixServiceUrl = ((TemplateBooleanModel)args.get(1)).getAsBoolean();
}
if (arg0 instanceof TemplateScalarModel)
{
String arg = ((TemplateScalarModel)arg0).getAsString();
String url = prefixServiceUrl ? req.getServicePath() : "";
url += arg;
url += (arg.length() != 0) ? "&" : "";
url += "guest=" + (req.isGuest() ? "true" : "");
url += (req.getFormat().length() != 0) ? "&format=" + req.getFormat() : "";
result = res.encodeScriptUrl(url);
StringBuffer buf = new StringBuffer(128);
buf.append(prefixServiceUrl ? req.getServicePath() : "");
buf.append(arg);
buf.append(arg.length() != 0 ? "&" : "");
buf.append("guest=" + (req.isGuest() ? "true" : ""));
if (req.getFormatStyle() == FormatStyle.argument)
{
buf.append("&format=");
buf.append(req.getFormat());
}
result = res.encodeScriptUrl(buf.toString());
}
}