Merged V2.1 to V2.0

6435: AR-1644 Web Scripts do not provide any control over caching
   6469: Replaced EUPL licence with standard license header
   6526: AR-1685 Error creating workflow with no document associated
   6565: Fix for issue with file Upload in main web-client portlet for JBoss/Liferay portal integration.
   6578: AR-1620: Upgraded One-Jar to 0.96-RC4


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6581 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-08-20 15:46:59 +00:00
parent 4ffc28f0bf
commit 4ba65b9950
16 changed files with 449 additions and 41 deletions

View File

@@ -93,14 +93,16 @@ public class DeclarativeWebScript extends AbstractWebScript
throw new WebScriptException("Web Script format '" + format + "' is not registered");
}
// construct data model for template
// construct model for script / template
WebScriptStatus status = new WebScriptStatus();
Map<String, Object> model = executeImpl(req, status);
WebScriptCache cache = new WebScriptCache(getDescription().getRequiredCache());
Map<String, Object> model = executeImpl(req, status, cache);
if (model == null)
{
model = new HashMap<String, Object>(7, 1.0f);
}
model.put("status", status);
model.put("cache", cache);
// execute script if it exists
if (executeScript != null)
@@ -122,7 +124,7 @@ public class DeclarativeWebScript extends AbstractWebScript
// is a redirect to a status specific template required?
if (status.getRedirect())
{
sendStatus(req, res, status, format, templateModel);
sendStatus(req, res, status, cache, format, templateModel);
}
else
{
@@ -135,6 +137,9 @@ public class DeclarativeWebScript extends AbstractWebScript
res.setStatus(statusCode);
}
// apply cache
res.setCache(cache);
String callback = req.getJSONCallback();
if (format.equals(WebScriptResponse.JSON_FORMAT) && callback != null)
{
@@ -178,10 +183,12 @@ public class DeclarativeWebScript extends AbstractWebScript
status.setCode(statusCode);
status.setMessage(e.getMessage());
status.setException(e);
WebScriptCache cache = new WebScriptCache();
cache.setNeverCache(true);
Map<String, Object> customModel = new HashMap<String, Object>();
customModel.put("status", status);
Map<String, Object> templateModel = createTemplateModel(req, res, customModel);
sendStatus(req, res, status, format, templateModel);
sendStatus(req, res, status, cache, format, templateModel);
}
}
@@ -207,6 +214,7 @@ public class DeclarativeWebScript extends AbstractWebScript
* Execute custom Java logic
*
* @param req Web Script request
* @param status Web Script status
* @return custom service model
*/
protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status)
@@ -214,6 +222,20 @@ public class DeclarativeWebScript extends AbstractWebScript
return null;
}
/**
* Execute custom Java logic
*
* @param req Web Script request
* @param status Web Script status
* @param cache Web Script cache
* @return custom service model
*/
protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status, WebScriptCache cache)
{
// NOTE: Redirect to those web scripts implemented before cache support
return executeImpl(req, status);
}
/**
* Render a template (of given format) to the Web Script Response
*