. Checkpoint for the Rhino JavaScript engine integration:

- Additions to the Alfresco JavaScript data-model
. JUnit test for each entry point into Rhino and the ScriptService
  - tests for various API calls on the Scriptable Node object
. More javadoc clean-up in templating and script services

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2726 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-04-28 10:56:48 +00:00
parent fff0a5d49c
commit 2b251c922b
8 changed files with 422 additions and 76 deletions

View File

@@ -19,6 +19,8 @@ package org.alfresco.service.cmr.repository;
import java.io.Writer;
import java.util.Map;
import org.alfresco.service.namespace.QName;
/**
* Script Service.
* <p>
@@ -53,13 +55,15 @@ public interface ScriptService
* Process a script against the supplied data model.
*
* @param scriptRef Script NodeRef location
* @param contentProp QName of the property on the node that contains the content, null can
* be passed to indicate the default property of 'cm:content'
* @param model Object model to process script against
*
* @return output of the script (may be null or any valid wrapped JavaScript object)
*
* @throws ScriptException
*/
public Object executeScript(NodeRef scriptRef, Map<String, Object> model)
public Object executeScript(NodeRef scriptRef, QName contentProp, Map<String, Object> model)
throws ScriptException;
/**

View File

@@ -18,8 +18,8 @@ package org.alfresco.service.cmr.repository;
/**
* Interface contract for the conversion of file name to a fully qualified icon image path for use by
* the templating engine.
*
* templating and scripting engines executing within the repository context.
* <p>
* Generally this contract will be implemented by classes that have access to say the webserver
* context which can be used to generate an icon image for a specific filename.
*

View File

@@ -450,27 +450,30 @@ public final class QName implements QNamePattern, Serializable, Cloneable
throw new IllegalArgumentException("str parameter is mandatory");
}
if (str.charAt(0) != NAMESPACE_BEGIN && str.indexOf(NAMESPACE_PREFIX) != -1)
if (str.charAt(0) != NAMESPACE_BEGIN)
{
// get the prefix and resolve to the uri
int end = str.indexOf(NAMESPACE_PREFIX);
String prefix = str.substring(0, end);
String localName = str.substring(end + 1);
String uri = prefixResolver.getNamespaceURI(prefix);
if (uri != null)
if (str.indexOf(NAMESPACE_PREFIX) != -1)
{
result = new StringBuilder(64).append(NAMESPACE_BEGIN).append(uri).append(NAMESPACE_END).append(
localName).toString();
// get the prefix and resolve to the uri
int end = str.indexOf(NAMESPACE_PREFIX);
String prefix = str.substring(0, end);
String localName = str.substring(end + 1);
String uri = prefixResolver.getNamespaceURI(prefix);
if (uri != null)
{
result = new StringBuilder(64).append(NAMESPACE_BEGIN).append(uri).append(NAMESPACE_END)
.append(localName).toString();
}
}
else
{
// there's no namespace so prefix with Alfresco's Content Model
result = new StringBuilder(64).append(NAMESPACE_BEGIN).append(NamespaceService.CONTENT_MODEL_1_0_URI)
.append(NAMESPACE_END).append(str).toString();
}
}
else if (str.charAt(0) != NAMESPACE_BEGIN)
{
// there's no namespace so prefix with Alfresco's Content Model
result = new StringBuilder(64).append(NAMESPACE_BEGIN).append(NamespaceService.CONTENT_MODEL_1_0_URI)
.append(NAMESPACE_END).append(str).toString();
}
return result;
}
}