- Added a new ‘catch all’ FormatReader that populates a requestbody script variable when no other FormatReaders are configured to handle a given request type. This was added to help the processing of posts from Orbeon XForms.

- Modified AbstractWebScript.execute() so that request-type specific script parameters (e.g. json, feed) are only available to those scripts that declare a type specific suffix, e.g. *.post.json.js, *.put.atomfeed.js. All non request type specific JS scripts will see requestbody (or formData if the request was multipart form data).This is so that scripts relying on requestBody being available at the moment don’t later get broken if we later map their request types to new FormatReaders.
- Moved getExecuteScript from DeclarativeWebScript into AbstractWebScript and made other subclasses use it, therefore using consistent path resolution rules across all web scripts.
- Removed FormatReader.createTemplateParameters() – Dave said this is not needed and the scripts themselves should copy over script parameters that are required by the templates.
- Renamed *.post.js and *.put.js expecting JSON input to *.post.json.js and *.put.json.js
- Extensive manual testing of share
- Added unit tests
  - Ensure requestbody available to *.post.jst and *.put.js for unmapped request types
  - Ensure json variable available to *.json.post.js and *.json.put.js scripts handling application/json requests
  - Ensure entry variable available to *.atom.post.js and *. atom.put.js scripts handling application/atom;type=entry requests
  - Ensure error raised for bogus script with extension corresponding to format with no FormatReader


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11034 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2008-09-26 12:01:05 +00:00
parent 631c94c899
commit 660dc69222
36 changed files with 5 additions and 36 deletions

View File

@@ -53,9 +53,6 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.util.TempFileProvider;
import org.alfresco.web.scripts.AbstractWebScript;
import org.alfresco.web.scripts.Cache;
import org.alfresco.web.scripts.Container;
import org.alfresco.web.scripts.Description;
import org.alfresco.web.scripts.ScriptContent;
import org.alfresco.web.scripts.Status;
import org.alfresco.web.scripts.WebScriptException;
import org.alfresco.web.scripts.WebScriptRequest;
@@ -86,10 +83,6 @@ public class StreamContent extends AbstractWebScript
protected ContentService contentService;
protected MimetypeService mimetypeService;
// Script Context
private String basePath;
private ScriptContent executeScript;
/** Cached file modified date */
private Date resouceFileModifiedDate;
@@ -125,20 +118,6 @@ public class StreamContent extends AbstractWebScript
this.contentService = contentService;
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.AbstractWebScript#init(org.alfresco.web.scripts.WebScriptRegistry)
*/
@Override
public void init(Container container, Description description)
{
super.init(container, description);
// Test for "execute" script
basePath = getDescription().getId();
String scriptPath = basePath + ".js";
executeScript = container.getScriptProcessor().findScript(scriptPath);
}
/**
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/
@@ -161,16 +140,17 @@ public class StreamContent extends AbstractWebScript
model.put("cache", cache);
// execute script if it exists
ScriptDetails executeScript = getExecuteScript(req.getContentType());
if (executeScript != null)
{
if (logger.isDebugEnabled())
logger.debug("Executing script " + executeScript.getPathDescription());
logger.debug("Executing script " + executeScript.getContent().getPathDescription());
Map<String, Object> scriptModel = createScriptParameters(req, res, model);
// add return model allowing script to add items to template model
Map<String, Object> returnModel = new HashMap<String, Object>(8, 1.0f);
scriptModel.put("model", returnModel);
executeScript(executeScript, scriptModel);
executeScript(executeScript.getContent(), scriptModel);
mergeScriptModelIntoTemplateModel(returnModel, model);
}
@@ -317,7 +297,7 @@ public class StreamContent extends AbstractWebScript
final protected void renderFormatTemplate(String format, Map<String, Object> model, Writer writer)
{
format = (format == null) ? "" : format;
String templatePath = basePath + "." + format + ".ftl";
String templatePath = getDescription().getId() + "." + format + ".ftl";
if (logger.isDebugEnabled())
logger.debug("Rendering template '" + templatePath + "'");