org.alfresco.service.cmr.model.FileFolderService
diff --git a/config/alfresco/public-services-security-context.xml b/config/alfresco/public-services-security-context.xml
index c1165c8a98..853fb2caba 100644
--- a/config/alfresco/public-services-security-context.xml
+++ b/config/alfresco/public-services-security-context.xml
@@ -671,8 +671,16 @@
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/alfresco/script-services-context.xml b/config/alfresco/script-services-context.xml
new file mode 100644
index 0000000000..464564d7de
--- /dev/null
+++ b/config/alfresco/script-services-context.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/repo/template/TemplateServiceImpl.java b/source/java/org/alfresco/repo/template/TemplateServiceImpl.java
index 1dcd768708..7ef9eefe5b 100644
--- a/source/java/org/alfresco/repo/template/TemplateServiceImpl.java
+++ b/source/java/org/alfresco/repo/template/TemplateServiceImpl.java
@@ -128,7 +128,7 @@ public class TemplateServiceImpl implements TemplateService, ApplicationContextA
}
public void processTemplateString(String engine, String template, Object model, Writer out)
- throws TemplateException
+ throws TemplateException
{
try
{
@@ -146,15 +146,13 @@ public class TemplateServiceImpl implements TemplateService, ApplicationContextA
}
}
-
public String processTemplateString(String engine, String template, Object model)
- throws TemplateException
+ throws TemplateException
{
Writer out = new StringWriter(1024);
processTemplateString(engine, template, model, out);
return out.toString();
}
-
/**
diff --git a/source/java/org/alfresco/service/cmr/repository/ScriptException.java b/source/java/org/alfresco/service/cmr/repository/ScriptException.java
new file mode 100644
index 0000000000..111c9d181b
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/repository/ScriptException.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+package org.alfresco.service.cmr.repository;
+
+import org.alfresco.error.AlfrescoRuntimeException;
+
+/**
+ * @author Kevin Roast
+ */
+public class ScriptException extends AlfrescoRuntimeException
+{
+ /**
+ * @param msgId
+ */
+ public ScriptException(String msgId)
+ {
+ super(msgId);
+ }
+
+ /**
+ * @param msgId
+ * @param cause
+ */
+ public ScriptException(String msgId, Throwable cause)
+ {
+ super(msgId, cause);
+ }
+
+ /**
+ * @param msgId
+ * @param params
+ */
+ public ScriptException(String msgId, Object[] params)
+ {
+ super(msgId, params);
+ }
+
+ /**
+ * @param msgId
+ * @param msgParams
+ * @param cause
+ */
+ public ScriptException(String msgId, Object[] msgParams, Throwable cause)
+ {
+ super(msgId, msgParams, cause);
+ }
+}
diff --git a/source/java/org/alfresco/service/cmr/repository/ScriptService.java b/source/java/org/alfresco/service/cmr/repository/ScriptService.java
new file mode 100644
index 0000000000..0586120787
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/repository/ScriptService.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+package org.alfresco.service.cmr.repository;
+
+import java.io.Writer;
+import java.util.Map;
+
+/**
+ * Script Service.
+ *
+ * Provides an interface to services for executing the JavaScript engine against a script file
+ * against a Java object based scripting data model.
+ *
+ * The template file can either be in the repository (passed as NodeRef string) or on the classpath.
+ * Also a script String can be passed directly to the service via the executeScriptString() methods.
+ * Java objects are passed into the scripting engine and methods can be accessed directly from the script.
+ *
+ * A script is executed within a single transaction, any modifications to nodes or properties that fail
+ * and cause a rollback will rollback the entire script transaction.
+ *
+ * @author Kevin Roast
+ */
+public interface ScriptService
+{
+ /**
+ * Process a script against the supplied data model.
+ *
+ * @param scriptClasspath Script location as qualified classpath name
+ * @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(String scriptClasspath, Map model)
+ throws ScriptException;
+
+ /**
+ * Process a script against the supplied data model.
+ *
+ * @param scriptRef Script NodeRef location
+ * @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 model)
+ throws ScriptException;
+
+ /**
+ * Process a script against the supplied data model.
+ *
+ * @param script Script content as a String.
+ * @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 executeScriptString(String script, Map model)
+ throws ScriptException;
+}
diff --git a/source/java/org/alfresco/service/cmr/repository/TemplateNode.java b/source/java/org/alfresco/service/cmr/repository/TemplateNode.java
index b8a0d3c58f..9341562d0b 100644
--- a/source/java/org/alfresco/service/cmr/repository/TemplateNode.java
+++ b/source/java/org/alfresco/service/cmr/repository/TemplateNode.java
@@ -91,8 +91,7 @@ public final class TemplateNode implements Serializable
private Long size = null;
private TemplateImageResolver imageResolver = null;
private TemplateNode parent = null;
-
- private ChildAssociationRef primaryParentAssoc;
+ private ChildAssociationRef primaryParentAssoc = null;
/**
@@ -494,8 +493,7 @@ public final class TemplateNode implements Serializable
}
/**
- *
- * @return the primary parent association so we can get at the association QName and the association type QName.
+ * @return the primary parent association so we can access the association QName and association type QName.
*/
public ChildAssociationRef getPrimaryParentAssoc()
{
diff --git a/source/java/org/alfresco/service/cmr/repository/TemplateService.java b/source/java/org/alfresco/service/cmr/repository/TemplateService.java
index e1ee46e7db..ff278cd529 100644
--- a/source/java/org/alfresco/service/cmr/repository/TemplateService.java
+++ b/source/java/org/alfresco/service/cmr/repository/TemplateService.java
@@ -25,8 +25,10 @@ import java.io.Writer;
* and data model.
*
* The service provides a configured list of available template engines. The template file
- * can either be in the repository (passed as NodeRef string) or on the classpath. The data
- * model is specified to the template engine. The FreeMarker template engine is used by default.
+ * can either be in the repository (passed as NodeRef string) or on the classpath. Also a template
+ * can be passed directly as a String using the processTemplateString() methods.
+ *
+ * The data model is specified to the template engine. The FreeMarker template engine is used by default.
*
* @author Kevin Roast
*/
@@ -67,7 +69,7 @@ public interface TemplateService
* @throws TemplateException
*/
public String processTemplateString(String engine, String template, Object model)
- throws TemplateException;
+ throws TemplateException;
/**
* Process a given template, provided as a string, against the supplied data model and report the
@@ -81,7 +83,7 @@ public interface TemplateService
* @throws TemplateException
*/
public void processTemplateString(String engine, String template, Object model, Writer out)
- throws TemplateException;
+ throws TemplateException;
/**
* Return a TemplateProcessor instance for the specified engine name.