*/
public String invoke(SnippetInstanceTO snippet) throws IOException {
if (!test(snippet))
return null;
SnippetDefinition defn = snippet.getDefinition();
if (XMLUtils.hasValue(mode)
&& !"view".equalsIgnoreCase(mode)
&& !defn.getModes().contains(mode)) {
snippet.setStatus(SnippetInvoker.UNSUPPORTED_MODE);
return null;
}
String uri = defn.getUri(mode, action);
if (uri == null) {
snippet.setStatus(SnippetInvoker.UNSUPPORTED_MODE);
return null;
}
String namespace = snippet.getNamespace();
Map extraEnvironment = new HashMap();
extraEnvironment.put(SNIPPET_ID, snippet.getSnippetID());
extraEnvironment.put(SNIPPET_VERSION, snippet.getSnippetVersion());
extraEnvironment.put(PERSISTED_TEXT, snippet.getPersistedText());
extraEnvironment.put(RESOURCES, defn.getResources());
extraEnvironment.put(HTMLPreprocessor.REPLACEMENTS_PARAM, Collections
.singletonMap("$$$_", namespace));
for (int i = 0; i < PROPAGATE_TO_ENV.length; i++)
extraEnvironment.put(PROPAGATE_TO_ENV[i], parentParameters
.get(PROPAGATE_TO_ENV[i]));
StringBuffer queryString = new StringBuffer(this.queryString);
addNamespacedParameters(parentParameters, namespace, queryString);
if (defn.shouldParsePersistedText())
addParsedParameters(snippet.getPersistedText(), queryString);
StringBuffer fullUri = new StringBuffer();
fullUri.append(WebServer.urlEncodePath(prefix)).append("/").append(uri);
HTMLUtils.appendQuery(fullUri, queryString.toString());